|
1 | 1 | <template> |
2 | 2 | <DefaultField |
3 | | - :field="field" |
| 3 | + :field="currentField" |
4 | 4 | :errors="errors" |
5 | 5 | :show-help-text="showHelpText" |
6 | 6 | :full-width-content="true" |
|
22 | 22 | :style="{minHeight: containerHeight}" |
23 | 23 | ref="editor" |
24 | 24 | @load="editorLoaded" |
25 | | - :locale=field.config.locale |
26 | | - :projectId=field.config.projectId |
27 | | - :templateId="field.value ? null : field.config.templateId" |
28 | | - :options=unProxy(field.config) |
| 25 | + :locale=currentField.config.locale |
| 26 | + :projectId=currentField.config.projectId |
| 27 | + :templateId="currentField.value ? null : currentField.config.templateId" |
| 28 | + :options=unProxy(currentField.config) |
| 29 | + :key=currentField.config.key |
29 | 30 | /> |
30 | 31 | </div> |
31 | 32 | </template> |
|
34 | 35 |
|
35 | 36 | <script> |
36 | 37 | import UnlayerEditor from './UnlayerEditor.vue'; |
37 | | - import { FormField, HandlesValidationErrors } from 'laravel-nova' |
| 38 | + import { DependentFormField, HandlesValidationErrors } from 'laravel-nova' |
38 | 39 |
|
39 | 40 | const defaultHeight = '700px'; |
40 | 41 |
|
41 | 42 | export default { |
42 | | - mixins: [FormField, HandlesValidationErrors], |
| 43 | + mixins: [DependentFormField, HandlesValidationErrors], |
43 | 44 |
|
44 | 45 | components: { |
45 | 46 | UnlayerEditor, |
|
49 | 50 |
|
50 | 51 | computed: { |
51 | 52 | containerHeight: function () { |
52 | | - return this.field.height || defaultHeight; |
| 53 | + return this.currentField.height || defaultHeight; |
53 | 54 | }, |
54 | 55 | }, |
55 | 56 |
|
56 | 57 | methods: { |
57 | 58 | /** Register listeners, load initial template, etc. */ |
58 | 59 | editorLoaded() { |
59 | | - if (this.field.value !== null) { |
60 | | - this.$refs.editor.loadDesign(this.unProxy(this.field.value)); |
| 60 | + if (this.currentField.value !== null) { |
| 61 | + this.$refs.editor.loadDesign(this.unProxy(this.currentField.value)); |
61 | 62 | } |
62 | 63 |
|
63 | 64 | /** @see https://docs.unlayer.com/docs/events */ |
64 | 65 | window.unlayer.addEventListener('design:loaded', this.handleDesignLoaded); |
65 | 66 | window.unlayer.addEventListener('design:updated', this.handleDesignUpdated); |
66 | 67 | window.unlayer.addEventListener('image:uploaded', this.handleImageUploaded); |
67 | 68 |
|
68 | | - this.loadPlugins(this.field.plugins); |
| 69 | + this.loadPlugins(this.currentField.plugins); |
69 | 70 | }, |
70 | 71 |
|
71 | 72 | /** |
|
97 | 98 | * @property {FormData} formData |
98 | 99 | */ |
99 | 100 | fill(formData) { |
100 | | - formData.append(this.field.attribute, JSON.stringify(this.design)); |
101 | | - formData.append(`${this.field.attribute}_html`, this.html); |
| 101 | + formData.append(this.currentField.attribute, JSON.stringify(this.design)); |
| 102 | + formData.append(`${this.currentField.attribute}_html`, this.html); |
102 | 103 | }, |
103 | 104 |
|
104 | 105 | /** |
|
111 | 112 | }); |
112 | 113 |
|
113 | 114 | Nova.$emit('unlayer:design:loaded', { |
114 | | - inputName: this.field.attribute, |
| 115 | + inputName: this.currentField.attribute, |
115 | 116 | payload: loadedDesign, |
116 | 117 | }); |
117 | 118 | }, |
|
177 | 178 | } |
178 | 179 |
|
179 | 180 | Nova.$emit('unlayer:design:updated', { |
180 | | - inputName: this.field.attribute, |
| 181 | + inputName: this.currentField.attribute, |
181 | 182 | payload: changeLog, |
182 | 183 | }); |
183 | 184 | }, |
|
187 | 188 | */ |
188 | 189 | handleImageUploaded(imageData) { |
189 | 190 | Nova.$emit('unlayer:image:uploaded', { |
190 | | - inputName: this.field.attribute, |
| 191 | + inputName: this.currentField.attribute, |
191 | 192 | payload: imageData, |
192 | 193 | }); |
193 | 194 | }, |
|
0 commit comments