Beautiful Open-Source Form Builder
Enhance FormEditorPreview component to support absolute property indexing
Julien Nahumb195eb0f323c
diff --git a/.cursor/commands/documentation-change-mode.md b/.cursor/commands/documentation-change-mode.mdnew file mode 100644index 000000000..d9cedd037--- /dev/null+++ b/.cursor/commands/documentation-change-mode.md@@ -0,0 +1,29 @@+# change-documentation: Change Documentation Mode++### General++When I say "enter change documentation mode" or "document changes", analyze the recent changes in the codebase and generate a comprehensive markdown document directly in the chat. The document should be a "techincal spec" document of changes to be done (as we'll use it in the context of another project where this change doesn't exist yet). Document should include:++1. A sort summary of the changes detected + rationale. Don't mention commit, mention them as changes to be done as the AI thay will apply the change doens't have context of this current project+2. Explanations of each file modified with before/after code snippets+3. Clear checklist of changes+4. Finish with a clear instruction (1 sentence enough) prompting the AI in the other project to apply similar changes 1 by 1 in current project right now (so that we can copy and paste the whole block without change). Also explain that to find file they can: search by name or if doesn't work search by some code (variables, html etc) to find similar files which may have different name. Because in anothe project file names may be slightly different.++### Mode parameteres++If I specify "for commit X" or "since commit X", focus on changes from that specific commit or range. Use git diff in command line to get the diff. For instance `git --no-pager show HEAD` or `git --no-pager show [commit-id]`.++If I specify "for current changes", analyze uncommitted changes in the working directory.++If I specify "for file X", focus only on changes to that specific file.s++### Code changes++For each changed function or code block, keep it as short as possible but include:++- The file path+- The function/block name+- Before and after code snippets+- Very short explanation of what changed and why++VERY Important: for change-documentation mode, do not execute any commands or create files - just provide the RAW markdown code (escaped within a code block ```) for the doc directly in the chat.diff --git a/client/components/open/forms/components/form-components/FormEditorPreview.vue b/client/components/open/forms/components/form-components/FormEditorPreview.vueindex 570aa7096..36d6b57ed 100644--- a/client/components/open/forms/components/form-components/FormEditorPreview.vue+++ b/client/components/open/forms/components/form-components/FormEditorPreview.vue@@ -221,19 +221,39 @@ function isValidIndex(index) {return typeof index === 'number' && index >= 0 && index < total}+// Helper to get the absolute property index from a visible page index in focused mode+function getAbsoluteIndexFromVisiblePage(visiblePageIndex) {+ const struct = workingFormStore.structureService+ if (!struct || typeof struct.getPageFields !== 'function') return visiblePageIndex++ const pageFields = struct.getPageFields(visiblePageIndex)+ if (!pageFields || pageFields.length === 0) return visiblePageIndex++ const field = pageFields[0]+ const properties = workingFormStore.content?.properties || []+ const absoluteIndex = properties.findIndex(p => p?.nf_id === field?.nf_id)++ return absoluteIndex >= 0 ? absoluteIndex : visiblePageIndex+}+// Sync selected field with current page in focused mode while editingwatch(() => currentSlideIndex.value, (newIndex) => {try {- if (isFocusedEditing.value && isValidIndex(newIndex) && workingFormStore.selectedFieldIndex !== newIndex) {- // Skip if the field at this index is hidden- const field = workingFormStore.content?.properties?.[newIndex]- const struct = workingFormStore.structureService- if (field && struct && typeof struct.isFieldHidden === 'function' && struct.isFieldHidden(field)) {- return- }- // Update the selected field to follow the currently focused slide- workingFormStore.setEditingField(newIndex)+ if (!isFocusedEditing.value) return++ // Convert visible page index to absolute property index+ const absoluteIndex = getAbsoluteIndexFromVisiblePage(newIndex)++ if (!isValidIndex(absoluteIndex) || workingFormStore.selectedFieldIndex === absoluteIndex) return++ // Skip if the field at this index is hidden+ const field = workingFormStore.content?.properties?.[absoluteIndex]+ const struct = workingFormStore.structureService+ if (field && struct && typeof struct.isFieldHidden === 'function' && struct.isFieldHidden(field)) {+ return}+ // Update the selected field to follow the currently focused slide+ workingFormStore.setEditingField(absoluteIndex)} catch (e) {console.error(e)}@@ -261,7 +281,8 @@ watch(() => workingFormStore.selectedFieldIndex, (newIndex) => {function handleAddBlock() {try {workingFormStore.activeTab = 'build'- workingFormStore.openAddFieldSidebar(currentSlideIndex.value)+ const absoluteIndex = getAbsoluteIndexFromVisiblePage(currentSlideIndex.value)+ workingFormStore.openAddFieldSidebar(absoluteIndex)} catch (e) {console.error(e)}@@ -270,7 +291,8 @@ function handleAddBlock() {function handleEditCurrent() {try {workingFormStore.activeTab = 'build'- workingFormStore.openSettingsForField(currentSlideIndex.value, true)+ const absoluteIndex = getAbsoluteIndexFromVisiblePage(currentSlideIndex.value)+ workingFormStore.openSettingsForField(absoluteIndex, true)} catch (e) {console.error(e)}@@ -296,12 +318,12 @@ const moreMenuItems = computed(() => ([]))function handleDuplicateCurrent() {- const index = currentSlideIndex.value+ const index = getAbsoluteIndexFromVisiblePage(currentSlideIndex.value)workingFormStore.duplicateField(index)}function handleDeleteCurrent() {- const index = currentSlideIndex.value+ const index = getAbsoluteIndexFromVisiblePage(currentSlideIndex.value)workingFormStore.removeField(index)}</script>