-
-
Notifications
You must be signed in to change notification settings - Fork 541
/
PublishForm.vue
813 lines (699 loc) · 31.7 KB
/
PublishForm.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
<template>
<div>
<breadcrumb v-if="breadcrumbs" :url="breadcrumbs[1].url" :title="breadcrumbs[1].text" />
<div class="flex items-center mb-6">
<h1 class="flex-1">
<div class="flex items-center">
<span v-if="! isCreating" class="little-dot mr-2" :class="activeLocalization.status" v-tooltip="activeLocalization.status" />
<span v-html="$options.filters.striptags(title)" />
</div>
</h1>
<dropdown-list class="mr-4" v-if="canEditBlueprint">
<dropdown-item :text="__('Edit Blueprint')" :redirect="actions.editBlueprint" />
</dropdown-list>
<div class="pt-px text-2xs text-gray-600 flex mr-4" v-if="readOnly">
<svg-icon name="lock" class="w-4 mr-1 -mt-1" /> {{ __('Read Only') }}
</div>
<div class="hidden md:flex items-center">
<save-button-options
v-if="!readOnly"
:show-options="!revisionsEnabled && !isInline"
:button-class="saveButtonClass"
:preferences-prefix="preferencesPrefix"
>
<button
:class="saveButtonClass"
:disabled="!canSave"
@click.prevent="save"
v-text="saveText"
/>
</save-button-options>
<button
v-if="revisionsEnabled && !isCreating"
class="ml-4 btn-primary flex items-center"
:disabled="!canPublish"
@click="confirmingPublish = true">
<span>{{ __('Publish') }}…</span>
</button>
</div>
<slot name="action-buttons-right" />
</div>
<publish-container
v-if="fieldset"
ref="container"
:name="publishContainer"
:blueprint="fieldset"
:values="values"
:reference="initialReference"
:meta="meta"
:errors="errors"
:site="site"
:localized-fields="localizedFields"
:is-root="isRoot"
:track-dirty-state="trackDirtyState"
@updated="values = $event"
>
<live-preview
slot-scope="{ container, components, setFieldMeta }"
:name="publishContainer"
:url="livePreviewUrl"
:previewing="isPreviewing"
:targets="previewTargets"
:values="values"
:blueprint="fieldset.handle"
:reference="initialReference"
@opened-via-keyboard="openLivePreview"
@closed="closeLivePreview"
>
<div>
<component
v-for="component in components"
:key="component.id"
:is="component.name"
:container="container"
v-bind="component.props"
v-on="component.events"
/>
<transition name="live-preview-tabs-drop">
<publish-tabs
v-show="tabsVisible"
:read-only="readOnly"
:syncable="hasOrigin"
@updated="setFieldValue"
@meta-updated="setFieldMeta"
@synced="syncField"
@desynced="desyncField"
@focus="container.$emit('focus', $event)"
@blur="container.$emit('blur', $event)"
>
<template #actions="{ shouldShowSidebar }">
<div class="card p-0 mb-5">
<div v-if="collectionHasRoutes" :class="{ 'hi': !shouldShowSidebar }">
<div class="p-3 flex items-center space-x-2" v-if="showLivePreviewButton || showVisitUrlButton">
<button
class="flex items-center justify-center btn w-full"
v-if="showLivePreviewButton"
@click="openLivePreview">
<svg-icon name="light/synchronize" class="h-4 w-4 mr-2 shrink-0" />
<span>{{ __('Live Preview') }}</span>
</button>
<a
class="flex items-center justify-center btn w-full"
v-if="showVisitUrlButton"
:href="permalink"
target="_blank">
<svg-icon name="light/external-link" class="w-4 h-4 mr-2 shrink-0" />
<span>{{ __('Visit URL') }}</span>
</a>
</div>
</div>
<div
v-if="!revisionsEnabled"
class="flex items-center justify-between px-4 py-2"
:class="{ 'border-t': showLivePreviewButton || showVisitUrlButton }"
>
<label v-text="__('Published')" class="publish-field-label font-medium" />
<toggle-input :value="published" :read-only="!canManagePublishState" @input="setFieldValue('published', $event)" />
</div>
<div
v-if="revisionsEnabled && !isCreating"
class="p-4"
:class="{ 'border-t': showLivePreviewButton || showVisitUrlButton }"
>
<label class="publish-field-label font-medium mb-2" v-text="__('Revisions')"/>
<div class="mb-1 flex items-center" v-if="published">
<span class="text-green-600 w-6 text-center">✓</span>
<span class="text-2xs" v-text="__('Entry has a published version')"></span>
</div>
<div class="mb-1 flex items-center" v-else>
<span class="text-orange w-6 text-center">!</span>
<span class="text-2xs" v-text="__('Entry has not been published')"></span>
</div>
<div class="mb-1 flex items-center" v-if="!isWorkingCopy && published">
<span class="text-green-600 w-6 text-center">✓</span>
<span class="text-2xs" v-text="__('This is the published version')"></span>
</div>
<div class="mb-1 flex items-center" v-if="isDirty">
<span class="text-orange w-6 text-center">!</span>
<span class="text-2xs" v-text="__('Unsaved changes')"></span>
</div>
<button
class="flex items-center justify-center mt-4 btn-flat px-2 w-full"
v-if="!isCreating && revisionsEnabled"
@click="showRevisionHistory = true">
<svg-icon name="light/history" class="h-4 w-4 mr-2" />
<span>{{ __('View History') }}</span>
</button>
</div>
<div class="p-4 border-t" v-if="localizations.length > 1">
<label class="publish-field-label font-medium mb-2" v-text="__('Sites')" />
<div
v-for="option in localizations"
:key="option.handle"
class="text-sm flex items-center -mx-4 px-4 py-2 cursor-pointer"
:class="option.active ? 'bg-blue-100' : 'hover:bg-gray-200'"
@click="localizationSelected(option)"
>
<div class="flex-1 flex items-center" :class="{ 'line-through': !option.exists }">
<span class="little-dot mr-2" :class="{
'bg-green-600': option.published,
'bg-gray-500': !option.published,
'bg-red-500': !option.exists
}" />
{{ option.name }}
<loading-graphic
:size="14"
text=""
class="ml-2"
v-if="localizing && localizing.handle === option.handle" />
</div>
<div class="badge-sm bg-orange" v-if="option.origin" v-text="__('Origin')" />
<div class="badge-sm bg-blue" v-if="option.active" v-text="__('Active')" />
<div class="badge-sm bg-purple" v-if="option.root && !option.origin && !option.active" v-text="__('Root')" />
</div>
</div>
</div>
</template>
</publish-tabs>
</transition>
</div>
<template v-slot:buttons>
<button
v-if="!readOnly"
class="ml-4"
:class="{
'btn': revisionsEnabled,
'btn-primary': isCreating || !revisionsEnabled,
}"
:disabled="!canSave"
@click.prevent="save"
v-text="saveText">
</button>
<button
v-if="revisionsEnabled && !isCreating"
class="ml-4 btn-primary flex items-center"
:disabled="!canPublish"
@click="confirmingPublish = true">
<span v-text="__('Publish')" />
<svg-icon name="micro/chevron-down-xs" class="ml-2 w-2" />
</button>
</template>
</live-preview>
</publish-container>
<div class="md:hidden mt-6 flex items-center">
<button
v-if="!readOnly"
class="btn-lg"
:class="{
'btn-primary w-full': ! revisionsEnabled,
'btn w-1/2 mr-4': revisionsEnabled,
}"
:disabled="!canSave"
@click.prevent="save"
v-text="__(revisionsEnabled ? 'Save Changes' : 'Save')" />
<button
v-if="revisionsEnabled"
class="ml-2 btn btn-lg justify-center btn-primary flex items-center w-1/2"
:disabled="!canPublish"
@click="confirmingPublish = true">
<span v-text="__('Publish')" />
<svg-icon name="micro/chevron-down-xs" class="ml-2 w-2" />
</button>
</div>
<stack name="revision-history" v-if="showRevisionHistory" @closed="showRevisionHistory = false" :narrow="true">
<revision-history
slot-scope="{ close }"
:index-url="actions.revisions"
:restore-url="actions.restore"
:reference="initialReference"
@closed="close"
/>
</stack>
<publish-actions
v-if="confirmingPublish"
:actions="actions"
:published="published"
:collection="collectionHandle"
:reference="initialReference"
:publish-container="publishContainer"
:can-manage-publish-state="canManagePublishState"
@closed="confirmingPublish = false"
@saving="saving = true"
@saved="publishActionCompleted"
/>
<confirmation-modal
v-if="selectingOrigin"
:title="__('Create Localization')"
:buttonText="__('Create')"
@cancel="cancelLocalization()"
@confirm="createLocalization(localizing)"
>
<div class="publish-fields">
<div class="form-group publish-field field-w-full">
<label v-text="__('Origin')" />
<div class="help-block -mt-2" v-text="__('messages.entry_origin_instructions')"></div>
<select-input
v-model="selectedOrigin"
:options="originOptions"
:placeholder="false"
/>
</div>
</div>
</confirmation-modal>
</div>
</template>
<script>
import PublishActions from './PublishActions.vue';
import SaveButtonOptions from '../publish/SaveButtonOptions.vue';
import RevisionHistory from '../revision-history/History.vue';
import HasPreferences from '../data-list/HasPreferences';
import HasHiddenFields from '../publish/HasHiddenFields';
export default {
mixins: [
HasPreferences,
HasHiddenFields,
],
components: {
PublishActions,
SaveButtonOptions,
RevisionHistory,
},
props: {
publishContainer: String,
initialReference: String,
initialFieldset: Object,
initialValues: Object,
initialMeta: Object,
initialTitle: String,
initialLocalizations: Array,
initialLocalizedFields: Array,
originBehavior: String,
initialHasOrigin: Boolean,
initialOriginValues: Object,
initialOriginMeta: Object,
initialSite: String,
initialIsWorkingCopy: Boolean,
collectionHandle: String,
breadcrumbs: Array,
initialActions: Object,
method: String,
isCreating: Boolean,
isInline: Boolean,
initialReadOnly: Boolean,
initialIsRoot: Boolean,
initialPermalink: String,
revisionsEnabled: Boolean,
preloadedAssets: Array,
canEditBlueprint: Boolean,
canManagePublishState: Boolean,
createAnotherUrl: String,
listingUrl: String,
collectionHasRoutes: Boolean,
previewTargets: Array,
autosaveInterval: Number,
},
data() {
return {
actions: this.initialActions,
saving: false,
localizing: false,
trackDirtyState: true,
fieldset: this.initialFieldset,
title: this.initialTitle,
values: _.clone(this.initialValues),
meta: _.clone(this.initialMeta),
localizations: _.clone(this.initialLocalizations),
localizedFields: this.initialLocalizedFields,
hasOrigin: this.initialHasOrigin,
originValues: this.initialOriginValues || {},
originMeta: this.initialOriginMeta || {},
site: this.initialSite,
selectingOrigin: false,
selectedOrigin: null,
isWorkingCopy: this.initialIsWorkingCopy,
error: null,
errors: {},
isPreviewing: false,
tabsVisible: true,
state: 'new',
revisionMessage: null,
showRevisionHistory: false,
preferencesPrefix: `collections.${this.collectionHandle}`,
// Whether it was published the last time it was saved.
// Successful publish actions (if using revisions) or just saving (if not) will update this.
// The current published value is inside the "values" object, and also accessible as a computed.
initialPublished: this.initialValues.published,
confirmingPublish: false,
readOnly: this.initialReadOnly,
isRoot: this.initialIsRoot,
permalink: this.initialPermalink,
saveKeyBinding: null,
quickSaveKeyBinding: null,
quickSave: false,
isAutosave: false,
}
},
computed: {
hasErrors() {
return this.error || Object.keys(this.errors).length;
},
somethingIsLoading() {
return ! this.$progress.isComplete();
},
canSave() {
return !this.readOnly && !this.somethingIsLoading;
},
canPublish() {
if (!this.revisionsEnabled) return false;
if (this.readOnly || this.isCreating || this.somethingIsLoading || this.isDirty) return false;
return true;
},
published() {
return this.values.published;
},
livePreviewUrl() {
return _.findWhere(this.localizations, { active: true }).livePreviewUrl;
},
showLivePreviewButton() {
return !this.isCreating && this.isBase && this.livePreviewUrl;
},
showVisitUrlButton() {
return !!this.permalink;
},
isBase() {
return this.publishContainer === 'base';
},
isDirty() {
return this.$dirty.has(this.publishContainer);
},
activeLocalization() {
return _.findWhere(this.localizations, { active: true });
},
saveText() {
switch(true) {
case this.revisionsEnabled:
return __('Save Changes');
case this.isUnpublishing:
return __('Save & Unpublish');
case this.isDraft:
return __('Save Draft');
default:
return __('Save & Publish');
}
},
isUnpublishing() {
return this.initialPublished && ! this.published && ! this.isCreating;
},
isDraft() {
return ! this.published;
},
saveButtonClass() {
return {
'btn': this.revisionsEnabled,
'btn-primary': this.isCreating || ! this.revisionsEnabled,
};
},
afterSaveOption() {
return this.getPreference('after_save');
},
originOptions() {
return this.localizations
.filter(localization => localization.exists)
.map(localization => ({
value: localization.handle,
label: localization.name,
}));
},
},
watch: {
saving(saving) {
this.$progress.loading(`${this.publishContainer}-entry-publish-form`, saving);
}
},
methods: {
clearErrors() {
this.error = null;
this.errors = {};
},
save() {
if (! this.canSave) {
this.quickSave = false;
return;
}
this.saving = true;
this.clearErrors();
setTimeout(() => this.runBeforeSaveHook(), 151); // 150ms is the debounce time for fieldtype updates
},
runBeforeSaveHook() {
this.$refs.container.saving();
Statamic.$hooks.run('entry.saving', {
collection: this.collectionHandle,
values: this.values,
container: this.$refs.container,
storeName: this.publishContainer,
})
.then(this.performSaveRequest)
.catch(error => {
this.saving = false;
this.$toast.error(error || 'Something went wrong');
});
},
performSaveRequest() {
// Once the hook has completed, we need to make the actual request.
// We build the payload here because the before hook may have modified values.
const payload = { ...this.visibleValues, ...{
_blueprint: this.fieldset.handle,
_localized: this.localizedFields,
}};
this.$axios[this.method](this.actions.save, payload).then(response => {
this.saving = false;
this.title = response.data.data.title;
this.isWorkingCopy = true;
if (this.isBase) {
document.title = this.title + ' ‹ ' + this.breadcrumbs[1].text + ' ‹ ' + this.breadcrumbs[0].text + ' ‹ Statamic';
}
if (!this.revisionsEnabled) this.permalink = response.data.data.permalink;
if (!this.isCreating && !this.isAutosave) this.$toast.success(__('Saved'));
this.$refs.container.saved();
this.runAfterSaveHook(response);
}).catch(error => this.handleAxiosError(error));
},
runAfterSaveHook(response) {
// Once the save request has completed, we want to run the "after" hook.
// Devs can do what they need and we'll wait for them, but they can't cancel anything.
Statamic.$hooks
.run('entry.saved', {
collection: this.collectionHandle,
reference: this.initialReference,
response
})
.then(() => {
// If revisions are enabled, just emit event.
if (this.revisionsEnabled) {
this.$nextTick(() => this.$emit('saved', response));
return;
}
let nextAction = this.quickSave || this.isAutosave ? 'continue_editing' : this.afterSaveOption;
// If the user has opted to create another entry, redirect them to create page.
if (!this.isInline && nextAction === 'create_another') {
window.location = this.createAnotherUrl;
}
// If the user has opted to go to listing (default/null option), redirect them there.
else if (!this.isInline && nextAction === null) {
window.location = this.listingUrl;
}
// Otherwise, leave them on the edit form and emit an event. We need to wait until after
// the hooks are resolved because if this form is being shown in a stack, we only
// want to close it once everything's done.
else {
this.values = this.resetValuesFromResponse(response.data.data.values);
this.initialPublished = response.data.data.published;
this.activeLocalization.published = response.data.data.published;
this.activeLocalization.status = response.data.data.status;
this.$nextTick(() => this.$emit('saved', response));
}
this.quickSave = false;
this.isAutosave = false;
}).catch(e => console.error(e));
},
confirmPublish() {
if (this.canPublish) {
this.confirmingPublish = true;
}
},
handleAxiosError(e) {
this.saving = false;
if (e.response && e.response.status === 422) {
const { message, errors } = e.response.data;
this.error = message;
this.errors = errors;
this.$toast.error(message);
} else if (e.response) {
this.$toast.error(e.response.data.message);
} else {
this.$toast.error(e || 'Something went wrong');
}
},
localizationSelected(localization) {
if (localization.active) return;
if (this.isDirty) {
if (! confirm(__('Are you sure? Unsaved changes will be lost.'))) {
return;
}
}
this.$dirty.remove(this.publishContainer);
this.localizing = localization;
if (localization.exists) {
this.editLocalization(localization);
} else if (this.localizations.length > 2 && this.originBehavior === 'select') {
this.selectingOrigin = true;
} else {
this.createLocalization(localization);
}
if (this.isBase) {
window.history.replaceState({}, '', localization.url);
}
},
editLocalization(localization) {
return this.$axios.get(localization.url).then(response => {
clearTimeout(this.trackDirtyStateTimeout);
this.trackDirtyState = false;
const data = response.data;
this.values = data.values;
this.originValues = data.originValues;
this.originMeta = data.originMeta;
this.meta = data.meta;
this.localizations = data.localizations;
this.localizedFields = data.localizedFields;
this.hasOrigin = data.hasOrigin;
this.publishUrl = data.actions[this.action];
this.collection = data.collection;
this.title = data.editing ? data.values.title : this.title;
this.actions = data.actions;
this.fieldset = data.blueprint;
this.isRoot = data.isRoot;
this.permalink = data.permalink;
this.site = localization.handle;
this.localizing = false;
this.initialPublished = data.values.published;
this.trackDirtyStateTimeout = setTimeout(() => this.trackDirtyState = true, 300); // after any fieldtypes do a debounced update
})
},
createLocalization(localization) {
this.selectingOrigin = false;
if (this.isCreating) {
this.$nextTick(() => window.location = localization.url);
return;
}
const originLocalization = this.localizations.find(e => e.handle === this.selectedOrigin);
const url = originLocalization.url + '/localize';
this.$axios.post(url, { site: localization.handle }).then(response => {
this.editLocalization(response.data).then(() => {
this.$events.$emit('localization.created', { store: this.publishContainer });
if (this.originValues.published) {
this.setFieldValue('published', true);
}
});
});
},
cancelLocalization() {
this.selectingOrigin = false;
this.localizing = false;
},
localizationStatusText(localization) {
if (! localization.exists) return 'This entry does not exist for this site.';
return localization.published
? 'This entry exists in this site, and is published.'
: 'This entry exists in this site, but is not published.';
},
openLivePreview() {
this.tabsVisible = false;
this.$wait(200)
.then(() => {
this.isPreviewing = true;
return this.$wait(300);
})
.then(() => this.tabsVisible = true);
},
closeLivePreview() {
this.isPreviewing = false;
this.tabsVisible = true;
},
publishActionCompleted({ published, isWorkingCopy, response }) {
this.saving = false;
if (published !== undefined) {
this.$refs.container.setFieldValue('published', published);
this.initialPublished = published;
}
this.$refs.container.saved();
this.isWorkingCopy = isWorkingCopy;
this.confirmingPublish = false;
this.title = response.data.data.title;
this.activeLocalization.title = response.data.data.title;
this.activeLocalization.published = response.data.data.published;
this.activeLocalization.status = response.data.data.status;
this.permalink = response.data.data.permalink
this.$nextTick(() => this.$emit('saved', response));
},
setFieldValue(handle, value) {
if (this.hasOrigin) this.desyncField(handle);
this.$refs.container.setFieldValue(handle, value);
},
syncField(handle) {
if (! confirm('Are you sure? This field\'s value will be replaced by the value in the original entry.'))
return;
this.localizedFields = this.localizedFields.filter(field => field !== handle);
this.$refs.container.setFieldValue(handle, this.originValues[handle]);
// Update the meta for this field. For instance, a relationship field would have its data preloaded into it.
// If you sync the field, the preloaded data would be outdated and an ID would show instead of the titles.
this.meta[handle] = this.originMeta[handle];
},
desyncField(handle) {
if (!this.localizedFields.includes(handle))
this.localizedFields.push(handle);
this.$refs.container.dirty();
},
setAutosaveInterval() {
const interval = setInterval(() => {
if (!this.isDirty) return;
this.isAutosave = true;
this.save();
}, this.autosaveInterval);
this.$store.commit(`publish/${this.publishContainer}/setAutosaveInterval`, interval);
}
},
mounted() {
this.saveKeyBinding = this.$keys.bindGlobal(['mod+return'], e => {
e.preventDefault();
if (this.confirmingPublish) return;
this.save();
});
this.quickSaveKeyBinding = this.$keys.bindGlobal(['mod+s'], e => {
e.preventDefault();
if (this.confirmingPublish) return;
this.quickSave = true;
this.save();
});
this.$store.commit(`publish/${this.publishContainer}/setPreloadedAssets`, this.preloadedAssets);
if (typeof this.autosaveInterval === 'number') {
this.setAutosaveInterval();
}
},
created() {
window.history.replaceState({}, document.title, document.location.href.replace('created=true', ''));
this.selectedOrigin = this.originBehavior === 'active'
? this.localizations.find(l => l.active)?.handle
: this.localizations.find(l => l.root)?.handle;
},
unmounted() {
clearTimeout(this.trackDirtyStateTimeout);
},
beforeDestroy() {
this.$store.commit(`publish/${this.publishContainer}/clearAutosaveInterval`);
},
destroyed() {
this.saveKeyBinding.destroy();
this.quickSaveKeyBinding.destroy();
}
}
</script>