diff --git a/components/FormBuilderCanvas.vue b/components/FormBuilderCanvas.vue
index d6a0bb2..b3daeb1 100644
--- a/components/FormBuilderCanvas.vue
+++ b/components/FormBuilderCanvas.vue
@@ -64,16 +64,23 @@
+
@@ -101,6 +108,32 @@
+
+
+
+
+
+
+
+
Delete Component
+
+ Are you sure you want to delete this component? This action cannot be undone and will permanently remove the component from your form.
+
+
+
+
+
+
+
+ Cancel
+
+
+
+ Delete
+
+
+
+
@@ -115,7 +148,7 @@ const props = defineProps({
}
});
-const emit = defineEmits(['select-component', 'move-component', 'delete-component', 'update-component', 'optimize-layout', 'select-nested-component', 'insert-component-at-index']);
+const emit = defineEmits(['select-component', 'move-component', 'delete-component', 'update-component', 'optimize-layout', 'select-nested-component', 'insert-component-at-index', 'duplicate-component']);
const selectedComponentId = ref(null);
const resizeMode = ref(false);
@@ -123,6 +156,10 @@ const resizing = ref(false);
const initialWidth = ref(0);
const initialX = ref(0);
+// Delete modal state
+const showDeleteConfirmModal = ref(false);
+const componentToDelete = ref(null);
+
// Watch for changes in formComponents
watch(() => props.formComponents, (newComponents) => {
// If the currently selected component is no longer in the list, deselect it
@@ -155,13 +192,35 @@ const selectComponent = (component) => {
emit('select-component', componentCopy);
};
-// Handle component deletion
-const deleteComponent = (id) => {
- if (selectedComponentId.value === id) {
- selectedComponentId.value = null;
- resizeMode.value = false;
+// Handle component duplication
+const duplicateComponent = (component) => {
+ emit('duplicate-component', component);
+};
+
+// Show delete confirmation modal
+const showDeleteModal = (id) => {
+ componentToDelete.value = id;
+ showDeleteConfirmModal.value = true;
+};
+
+// Cancel delete operation
+const cancelDelete = () => {
+ showDeleteConfirmModal.value = false;
+ componentToDelete.value = null;
+};
+
+// Confirm delete operation
+const confirmDelete = () => {
+ if (componentToDelete.value) {
+ const id = componentToDelete.value;
+ if (selectedComponentId.value === id) {
+ selectedComponentId.value = null;
+ resizeMode.value = false;
+ }
+ emit('delete-component', id);
}
- emit('delete-component', id);
+ showDeleteConfirmModal.value = false;
+ componentToDelete.value = null;
};
// Handle nested component selection from sections
diff --git a/components/FormBuilderFieldSettingsModal.vue b/components/FormBuilderFieldSettingsModal.vue
index 2533b5b..2fc94fd 100644
--- a/components/FormBuilderFieldSettingsModal.vue
+++ b/components/FormBuilderFieldSettingsModal.vue
@@ -2918,7 +2918,7 @@ if (this.element.querySelector('.file-upload')) {
@@ -2937,6 +2937,32 @@ if (this.element.querySelector('.file-upload')) {
+
+
+
+
+
+
+
Reset to Default Settings
+
+ Are you sure you want to reset this component to its default settings? This action will overwrite all current configuration and cannot be undone.
+
+
+
+
+
+
+
+ Cancel
+
+
+
+ Reset to Default
+
+
+
+
+