Beautiful Open-Source Form Builder
7953e better form editor (#580)
Julien Nahum5dcd4ff8cb8f
diff --git a/client/components/open/forms/OpenForm.vue b/client/components/open/forms/OpenForm.vueindex 069e1f4fb..eaeb290c0 100644--- a/client/components/open/forms/OpenForm.vue+++ b/client/components/open/forms/OpenForm.vue@@ -551,7 +551,7 @@ export default {handleDragDropped(data) {if (data.added) {const targetIndex = this.getTargetFieldIndex(data.added.newIndex)- this.workingFormStore.addBlock(data.added.element, targetIndex)+ this.workingFormStore.addBlock(data.added.element, targetIndex, false)}if (data.moved) {const oldTargetIndex = this.getTargetFieldIndex(data.moved.oldIndex)diff --git a/client/stores/working_form.js b/client/stores/working_form.jsindex 80df4bed8..d334e45aa 100644--- a/client/stores/working_form.js+++ b/client/stores/working_form.js@@ -87,7 +87,7 @@ export const useWorkingFormStore = defineStore("working_form", {return data},- addBlock(type, index = null) {+ addBlock(type, index = null, openSettings = true) {this.blockForm.type = typethis.blockForm.name = blocksTypes[type].default_block_nameconst newBlock = this.prefillDefault(this.blockForm.data())@@ -117,15 +117,39 @@ export const useWorkingFormStore = defineStore("working_form", {const newFields = clonedeep(this.content.properties)newFields.push(newBlock)this.content.properties = newFields- this.openSettingsForField(- this.content.properties.length - 1,- )+ if (openSettings) {+ this.openSettingsForField(+ this.content.properties.length - 1,+ )+ }} else {const fieldIndex = typeof index === "number" ? index : this.selectedFieldIndex + 1const newFields = clonedeep(this.content.properties)newFields.splice(fieldIndex, 0, newBlock)this.content.properties = newFields- this.openSettingsForField(fieldIndex)+ if (openSettings) {+ this.openSettingsForField(fieldIndex)+ }+ }+ },+ removeField(field) {+ this.internalRemoveField(field)+ },+ internalRemoveField(field) {+ const index = this.objectToIndex(field)++ if (index !== -1) {+ useAlert().success('Ctrl + Z to undo',10000,{+ title: 'Field removed',+ actions: [{+ label: 'Undo',+ icon:"i-material-symbols-undo",+ click: () => {+ this.undo()+ }+ }]+ })+ this.content.properties.splice(index, 1)}},removeField(field) {