diff --git a/resources/js/components/blueprints/Section.vue b/resources/js/components/blueprints/Section.vue index b8385486ab1..59f95fe09a4 100644 --- a/resources/js/components/blueprints/Section.vue +++ b/resources/js/components/blueprints/Section.vue @@ -54,7 +54,18 @@ class="font-mono text-sm" v-model="editingSection.handle" @input="handleSyncedWithDisplay = false" - /> + > + + @@ -219,15 +230,15 @@ export default { }, }, - created() { - // This logic isn't ideal, but it was better than passing along a 'isNew' boolean and having - // to deal with stripping it out and making it not new, etc. Good enough for a quick win. - if (!this.section.handle || this.section.handle == 'new_section' || this.section.handle == 'new_set') { - this.handleSyncedWithDisplay = true; - } - }, - methods: { + regenerateHandle() { + if (!this.editingSection) { + return; + } + + this.editingSection.handle = snake_case(this.editingSection.display); + }, + fieldLinked(field) { this.section.fields.push(field); this.$toast.success(__('Field added')); @@ -250,6 +261,7 @@ export default { }, edit() { + this.handleSyncedWithDisplay = !this.section.handle || ['new_section', 'new_set'].includes(this.section.handle); this.editingSection = { display: this.section.display, handle: this.section.handle, diff --git a/resources/js/components/blueprints/Tab.vue b/resources/js/components/blueprints/Tab.vue index 0224caf3842..d867d7f1ffd 100644 --- a/resources/js/components/blueprints/Tab.vue +++ b/resources/js/components/blueprints/Tab.vue @@ -32,7 +32,18 @@ - + + + @@ -103,14 +114,6 @@ export default { }; }, - created() { - // This logic isn't ideal, but it was better than passing along a 'isNew' boolean and having - // to deal with stripping it out and making it not new, etc. Good enough for a quick win. - if (!this.handle || this.handle == 'new_tab' || this.handle == 'new_set_group') { - this.handleSyncedWithDisplay = true; - } - }, - computed: { isActive() { return this.currentTab === this.tab._id; @@ -149,7 +152,16 @@ export default { }, methods: { + regenerateHandle() { + this.handle = snake_case(this.display); + }, + edit() { + this.display = this.tab.display; + this.handle = this.tab.handle; + this.instructions = this.tab.instructions; + this.icon = this.tab.icon; + this.handleSyncedWithDisplay = !this.tab.handle || ['new_tab', 'new_set_group'].includes(this.tab.handle); this.editing = true; },