adjust autosave

This commit is contained in:
Pete Matsyburka committed 2026-10-23 10:02:32 +03:00
1 parent 87f6878eda
commit b99e5d1262
2 files changed
+20 -3

No files matched your search

+19 -2
View File
@@ -415,9 +415,9 @@
<a
:href="`/templates/${template.id}/form`"
:data-native-actions="template.submitters.length > 1 ? 'users' : null"
data-turbo="false"
data-turbo-prefetch="false"
class="flex items-center justify-center space-x-2"
@click.exact="isPreviewLoading = true"
@click.exact="onSaveAndPreviewClick"
>
<IconInnerShadowTop
v-if="isPreviewLoading"
@@ -2253,6 +2253,23 @@ export default {
this.insertField(field)
}
},
onSaveAndPreviewClick (event) {
this.isPreviewLoading = true
if (!this.autosave) {
event.preventDefault()
const dynamicDocumentRefs = this.documentRefs.filter((ref) => ref.isDynamic)
dynamicDocumentRefs.forEach((ref) => ref.update())
this.rebuildVariablesSchema({ disable: false })
Promise.all([this.save({ force: true }), ...dynamicDocumentRefs.map((ref) => ref.saveBody())]).then(() => {
window.Turbo.visit(`/templates/${this.template.id}/form`)
})
}
},
onBeforeUnload (event) {
if (this.hasUnsavedChanges) {
event.preventDefault()