Skip to content

Commit

Permalink
fix: Fix Navigation Form Target initialization - MEED-7906 - Meeds-io…
Browse files Browse the repository at this point in the history
…/meeds#2576 (#265)

Prior to this change, the Navigation with External Link wasn't
initialized correctly when opening the Form. In fact, it's all time set
to 'NEW_TAB' rather than retrieving the setting from stored value of
navigation. This change will initialize the value from retrieved
properties from store. In addition, this will simplify the
interpretation of switch button values by using `true-value` and
`false-value` rather than using a value based on Boolean value (default
behavior of a v-switch button).
  • Loading branch information
boubaker authored Dec 8, 2024
1 parent dee77d8 commit a2c061c
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@
</span>
<v-switch
v-model="nodeTarget"
true-value="SAME_TAB"
false-value="NEW_TAB"
class="mt-0 me-0" />
</div>
</template>
Expand All @@ -141,6 +143,8 @@
</span>
<v-switch
v-model="nodeTarget"
true-value="SAME_TAB"
false-value="NEW_TAB"
class="mt-0 me-0" />
</div>
</template>
Expand Down Expand Up @@ -275,7 +279,7 @@ export default {
displayNodeName: false,
elementType: 'PAGE',
allSites: true,
nodeTarget: true,
nodeTarget: 'SAME_TAB',
parentNavigationNodeUrl: '',
editMode: false,
nodeIcon: null,
Expand Down Expand Up @@ -353,6 +357,7 @@ export default {
if (this.editMode) {
this.nodeLabel = parentNavigationNode.label;
this.nodeId = parentNavigationNode.name;
this.nodeTarget = parentNavigationNode.target;
if (this.navigationNode?.pageKey) {
const pageRef = this.navigationNode.pageKey.ref ||`${ this.navigationNode.pageKey.site.typeName}::${ this.navigationNode.pageKey.site.name}::${this.navigationNode.pageKey.name}`;
this.$pageLayoutService.getPage(pageRef)
Expand Down Expand Up @@ -393,7 +398,7 @@ export default {
this.isScheduled = false;
this.displayNodeName = false;
this.elementType = 'PAGE';
this.nodeTarget = true;
this.nodeTarget = 'SAME_TAB';
this.disableNodeId = false;
this.editMode= false;
this.pageToEdit = null;
Expand Down Expand Up @@ -441,7 +446,7 @@ export default {
const pageRef = this.selectedPage?.pageRef;
pageData = {
'pageRef': pageRef,
'nodeTarget': this.nodeTarget ? 'SAME_TAB' : 'NEW_TAB',
'nodeTarget': this.nodeTarget,
'pageType': this.elementType
};
this.updateNode(pageData, pageRef, startScheduleDate, endScheduleDate, nodeLabels);
Expand All @@ -459,7 +464,7 @@ export default {
const pageRef = createdPage?.key?.ref || `${createdPage?.key.site.typeName}::${createdPage?.key.site.name}::${createdPage?.pageContext?.key.name}`;
pageData = {
'pageRef': pageRef,
'nodeTarget': this.nodeTarget ? 'NEW_TAB' : 'SAME_TAB',
'nodeTarget': this.nodeTarget,
'pageType': this.elementType,
'createdPage': createdPage,
};
Expand All @@ -479,7 +484,7 @@ export default {
const pageRef = this.selectedPage?.pageRef;
pageData = {
'pageRef': pageRef,
'nodeTarget': this.nodeTarget ? 'SAME_TAB' : 'NEW_TAB',
'nodeTarget': this.nodeTarget,
'pageType': this.elementType
};
this.createNode(previousNodeId, pageData, startScheduleDate, endScheduleDate, nodeLabels);
Expand All @@ -494,7 +499,7 @@ export default {
const pageRef = createdPage?.key?.ref || `${createdPage?.key.site.typeName}::${createdPage?.key.site.name}::${createdPage?.pageContext?.key.name}`;
pageData = {
'pageRef': pageRef,
'nodeTarget': this.nodeTarget ? 'SAME_TAB' : 'NEW_TAB',
'nodeTarget': this.nodeTarget,
'pageType': this.elementType,
'createdPage': createdPage,
};
Expand Down Expand Up @@ -536,7 +541,7 @@ export default {
.then(() => {
const pageData = {
'pageRef': pageRef,
'nodeTarget': this.nodeTarget ? 'SAME_TAB' : 'NEW_TAB',
'nodeTarget': this.nodeTarget,
'pageType': this.elementType
};
this.updateNode(pageData, pageRef, startScheduleDate, endScheduleDate, nodeLabels);
Expand Down

0 comments on commit a2c061c

Please sign in to comment.