Skip to content

[5.x] Fix navigation edit form state issues #11732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion resources/js/components/fieldtypes/grid/Row.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export default {
},
meta: {
type: Object,
required: true
required: true,
default: () => ({})
},
name: {
type: String,
Expand Down
3 changes: 2 additions & 1 deletion resources/js/components/fieldtypes/replicator/Set.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ export default {
},
meta: {
type: Object,
required: true
required: true,
default: () => ({})
},
index: {
type: Number,
Expand Down
15 changes: 12 additions & 3 deletions resources/js/components/navigation/View.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@

<page-editor
v-if="editingPage"
:publishContainer="editingPage.editorId"
:persist-state="true"
:site="site"
:id="editingPage.page.id"
:entry="editingPage.page.entry"
Expand All @@ -152,6 +154,8 @@
<page-editor
v-if="creatingPage"
creating
:publishContainer="creatingPage.editorId"
:persist-state="true"
:site="site"
:blueprint="blueprint"
:handle="handle"
Expand Down Expand Up @@ -339,7 +343,7 @@ export default {
},

editPage(page, vm, store) {
this.editingPage = { page, vm, store };
this.editingPage = { page, vm, store, editorId: `tree-page-${page.id}` };
},

updatePage(values) {
Expand All @@ -362,7 +366,12 @@ export default {
},

openPageCreator() {
this.creatingPage = { info: null };
const uniqueId = uniqid();
this.creatingPage = {
info: null,
uniqueId: uniqueId,
editorId: `tree-page-${uniqueId}`
};
},

closePageCreator() {
Expand All @@ -371,7 +380,7 @@ export default {

pageCreated(values) {
const page = {
id: uniqid(),
id: this.creatingPage.uniqueId,
title: values.title,
url: values.url,
children: []
Expand Down
15 changes: 9 additions & 6 deletions resources/js/components/publish/Container.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default {
},

props: {
persistState: { type: Boolean, default: false },
reference: {
type: String
},
Expand Down Expand Up @@ -58,12 +59,16 @@ export default {
},

created() {
this.registerVuexModule();
if (!this.$store.hasModule(['publish', this.name])) {
this.registerVuexModule();
}
this.$events.$emit('publish-container-created', this);
},

destroyed() {
this.removeVuexModule();
if (!this.persistState) {
this.removeVuexModule();
}
this.clearDirtyState();
this.$events.$emit('publish-container-destroyed', this);
},
Expand All @@ -77,8 +82,6 @@ export default {
methods: {

registerVuexModule() {
const vm = this;

const initial = {
blueprint: _.clone(this.blueprint),
values: _.clone(this.values),
Expand Down Expand Up @@ -205,14 +208,12 @@ export default {
actions: {
setFieldValue(context, payload) {
context.commit('setFieldValue', payload);
vm.emitUpdatedEvent(context.state.values);
},
setFieldMeta(context, payload) {
context.commit('setFieldMeta', payload);
},
setValues(context, payload) {
context.commit('setValues', payload);
vm.emitUpdatedEvent(context.state.values);
},
setExtraValues(context, payload) {
context.commit('setExtraValues', payload);
Expand Down Expand Up @@ -257,13 +258,15 @@ export default {
handle, value,
user: Statamic.user.id
});
this.emitUpdatedEvent(this.$store.state.publish[this.name].values);
},

setFieldMeta(handle, value) {
this.$store.dispatch(`publish/${this.name}/setFieldMeta`, {
handle, value,
user: Statamic.user.id
});
this.$emit('meta-updated', this.$store.state.publish[this.name].meta);
},

dirty() {
Expand Down
4 changes: 3 additions & 1 deletion resources/js/components/structures/PageEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<publish-container
ref="container"
:name="publishContainer"
:persist-state="persistState"
:blueprint="adjustedBlueprint"
:values="values"
:extra-values="extraValues"
Expand Down Expand Up @@ -83,6 +84,8 @@ export default {
],

props: {
publishContainer: { type: String, required: true },
persistState: Boolean,
id: String,
entry: String,
site: String,
Expand All @@ -109,7 +112,6 @@ export default {
errors: {},
validating: false,
saveKeyBinding: null,
publishContainer: 'tree-page'
}
},

Expand Down