|
32 | 32 | <Input ref="title" :model-value="display" @update:model-value="fieldUpdated('display', $event)" /> |
33 | 33 | </Field> |
34 | 34 | <Field :label="__('Handle')" class="form-group field-w-100"> |
35 | | - <Input class="font-mono" :model-value="handle" @update:model-value="fieldUpdated('handle', $event)" /> |
| 35 | + <Input class="font-mono" :model-value="handle" @update:model-value="fieldUpdated('handle', $event)"> |
| 36 | + <template #append> |
| 37 | + <Button |
| 38 | + icon="sync" |
| 39 | + size="sm" |
| 40 | + variant="ghost" |
| 41 | + :aria-label="__('Regenerate from: :field', { field: __('Title') })" |
| 42 | + @click="regenerateHandle" |
| 43 | + v-tooltip="__('Regenerate from: :field', { field: __('Title') })" |
| 44 | + /> |
| 45 | + </template> |
| 46 | + </Input> |
36 | 47 | </Field> |
37 | 48 | <Field v-if="showInstructions" :label="__('Instructions')" class="form-group field-w-100"> |
38 | 49 | <Input :model-value="instructions" @update:model-value="fieldUpdated('instructions', $event)" /> |
@@ -103,14 +114,6 @@ export default { |
103 | 114 | }; |
104 | 115 | }, |
105 | 116 |
|
106 | | - created() { |
107 | | - // This logic isn't ideal, but it was better than passing along a 'isNew' boolean and having |
108 | | - // to deal with stripping it out and making it not new, etc. Good enough for a quick win. |
109 | | - if (!this.handle || this.handle == 'new_tab' || this.handle == 'new_set_group') { |
110 | | - this.handleSyncedWithDisplay = true; |
111 | | - } |
112 | | - }, |
113 | | -
|
114 | 117 | computed: { |
115 | 118 | isActive() { |
116 | 119 | return this.currentTab === this.tab._id; |
@@ -149,7 +152,16 @@ export default { |
149 | 152 | }, |
150 | 153 |
|
151 | 154 | methods: { |
| 155 | + regenerateHandle() { |
| 156 | + this.handle = snake_case(this.display); |
| 157 | + }, |
| 158 | +
|
152 | 159 | edit() { |
| 160 | + this.display = this.tab.display; |
| 161 | + this.handle = this.tab.handle; |
| 162 | + this.instructions = this.tab.instructions; |
| 163 | + this.icon = this.tab.icon; |
| 164 | + this.handleSyncedWithDisplay = !this.tab.handle || ['new_tab', 'new_set_group'].includes(this.tab.handle); |
153 | 165 | this.editing = true; |
154 | 166 | }, |
155 | 167 |
|
|
0 commit comments