From 088afbb39675fa8a9c2b0ffdaa227967a7a2f29f Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 12 Mar 2025 19:56:21 +0300 Subject: [PATCH] [PDF] Add settings for combobox/listbox fields --- .../main/app/template/FormSettings.template | 35 +++++++----- apps/pdfeditor/main/app/view/FormSettings.js | 57 ++++++++++++++++++- apps/pdfeditor/main/locale/en.json | 2 + 3 files changed, 77 insertions(+), 17 deletions(-) diff --git a/apps/pdfeditor/main/app/template/FormSettings.template b/apps/pdfeditor/main/app/template/FormSettings.template index 1bd9f8b7f5..68a8ad8f9e 100644 --- a/apps/pdfeditor/main/app/template/FormSettings.template +++ b/apps/pdfeditor/main/app/template/FormSettings.template @@ -18,17 +18,17 @@ - + - + - + @@ -36,16 +36,31 @@
- - + - + + + + + + + + +
+
+
+
+
+
+
+
+
@@ -53,19 +68,11 @@
- - - - - -
-
-
diff --git a/apps/pdfeditor/main/app/view/FormSettings.js b/apps/pdfeditor/main/app/view/FormSettings.js index 9ecacd20b7..729835649b 100644 --- a/apps/pdfeditor/main/app/view/FormSettings.js +++ b/apps/pdfeditor/main/app/view/FormSettings.js @@ -85,7 +85,8 @@ define([ scope: this })); this.PlaceholderSettings = el.find('.form-placeholder'); - this.ListOnlySettings = el.find('.form-list'); + this.ListSettings = el.find('.form-list-common'); + this.ListboxOnlySettings = el.find('.form-list'); this.AutofitSettings = el.find('.form-autofit'); this.TextSettings = el.find('.form-text'); this.ComboSettings = el.find('.form-combo'); @@ -277,6 +278,18 @@ define([ dataHintOffset: 'small' }); this.chCustomText.on('change', this.onChCustomText.bind(this)); + this.lockedControls.push(this.chCustomText); + + // dropdown list + this.chMultisel = new Common.UI.CheckBox({ + el: $markup.findById('#form-chb-multisel'), + labelText: this.textMultisel, + dataHint: '1', + dataHintDirection: 'left', + dataHintOffset: 'small' + }); + this.chMultisel.on('change', this.onChMultisel.bind(this)); + this.lockedControls.push(this.chMultisel); // combobox & dropdown list this.txtNewValue = new Common.UI.InputField({ @@ -360,6 +373,16 @@ define([ this.btnListDown.on('click', _.bind(this.onMoveItem, this, false)); this.lockedControls.push(this.btnListDown); + this.chCommit = new Common.UI.CheckBox({ + el: $markup.findById('#form-chb-commit'), + labelText: this.textCommit, + dataHint: '1', + dataHintDirection: 'left', + dataHintOffset: 'small' + }); + this.chCommit.on('change', this.onChCommit.bind(this)); + this.lockedControls.push(this.chCommit); + this.UpdateThemeColors(); }, @@ -547,6 +570,20 @@ define([ } }, + onChMultisel: function(field, newValue, oldValue, eOpts){ + if (this.api && !this._noApply) { + this.api.SetListboxFieldMultiSelect(field.getValue()=='checked'); + this.fireEvent('editcomplete', this); + } + }, + + onChCommit: function(field, newValue, oldValue, eOpts){ + if (this.api && !this._noApply) { + this.api.SetListFieldCommitOnSelChange(field.getValue()=='checked'); + this.fireEvent('editcomplete', this); + } + }, + onChMaxCharsChanged: function(field, newValue, oldValue, eOpts){ var checked = (field.getValue()=='checked'); if (this.api && !this._noApply) { @@ -735,7 +772,14 @@ define([ this.chCustomText.setValue(!!val, true); this._state.CustomText=val; } - this.chCustomText.setDisabled(this._state.DisabledControls); + } + + if (type == AscPDF.FIELD_TYPES.listbox && specProps) { + val = specProps.asc_getMultipleSelection(); + if ( this._state.Multisel!==val ) { + this.chMultisel.setValue(!!val, true); + this._state.Multisel=val; + } } //for list controls @@ -766,6 +810,12 @@ define([ this.btnListAdd.setDisabled(true); this._state.listValue = this._state.listIndex = undefined; } + + val = specProps.asc_getCommitOnSelChange(); + if ( this._state.Commit!==val ) { + this.chCommit.setValue(!!val, true); + this._state.Commit=val; + } } this.disableListButtons(); } @@ -891,9 +941,10 @@ define([ isListbox = type === AscPDF.FIELD_TYPES.listbox; this.PlaceholderSettings.toggleClass('hidden', !(isCombobox || isText)); this.AutofitSettings.toggleClass('hidden', !(isCombobox || isText)); - this.ListOnlySettings.toggleClass('hidden', !(isCombobox || isListbox)); + this.ListSettings.toggleClass('hidden', !(isCombobox || isListbox)); this.TextSettings.toggleClass('hidden', !isText); this.ComboSettings.toggleClass('hidden', !isCombobox); + this.ListboxOnlySettings.toggleClass('hidden', !isListbox); } }, PDFE.Views.FormSettings || {})); diff --git a/apps/pdfeditor/main/locale/en.json b/apps/pdfeditor/main/locale/en.json index c6907c0d2c..8e86891e01 100644 --- a/apps/pdfeditor/main/locale/en.json +++ b/apps/pdfeditor/main/locale/en.json @@ -1407,6 +1407,8 @@ "PDFE.Views.FormSettings.textCustomText": "Allow custom text", "PDFE.Views.FormSettings.textMaxChars": "Characters limit", "PDFE.Views.FormSettings.textComb": "Comb of characters", + "PDFE.Views.FormSettings.textCommit": "Commit selected value immediately", + "PDFE.Views.FormSettings.textMultisel": "Multiple selection", "PDFE.Views.FormsTab.capBtnCheckBox": "Checkbox", "PDFE.Views.FormsTab.capBtnComboBox": "Combo Box", "PDFE.Views.FormsTab.capBtnDownloadForm": "Download As PDF",