From 04dbc2b42f64693362923352329c078803a7048b Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 17 Jun 2021 19:42:52 +0300 Subject: [PATCH] [DE] Add autofit, multiline, fixed size settings for forms --- .../main/app/template/FormSettings.template | 12 +++- .../main/app/view/FormSettings.js | 69 ++++++++++++++++--- apps/documenteditor/main/locale/en.json | 2 + 3 files changed, 73 insertions(+), 10 deletions(-) diff --git a/apps/documenteditor/main/app/template/FormSettings.template b/apps/documenteditor/main/app/template/FormSettings.template index 529b09571..f064b6eea 100644 --- a/apps/documenteditor/main/app/template/FormSettings.template +++ b/apps/documenteditor/main/app/template/FormSettings.template @@ -34,7 +34,7 @@
- +
@@ -62,6 +62,16 @@
+ + +
+ + + + +
+ +
diff --git a/apps/documenteditor/main/app/view/FormSettings.js b/apps/documenteditor/main/app/view/FormSettings.js index 177dc9ffb..8875b7f1a 100644 --- a/apps/documenteditor/main/app/view/FormSettings.js +++ b/apps/documenteditor/main/app/view/FormSettings.js @@ -98,6 +98,7 @@ define([ this.ListOnlySettings = el.find('.form-list'); this.ImageOnlySettings = el.find('.form-image'); this.ConnectedSettings = el.find('.form-connected'); + this.NotImageSettings = el.find('.form-not-image'); }, createDelayedElements: function() { @@ -189,6 +190,20 @@ define([ this.spnWidth.on('change', this.onWidthChange.bind(this)); this.spnWidth.on('inputleave', function(){ me.fireEvent('editcomplete', me);}); + this.chAutofit = new Common.UI.CheckBox({ + el: $markup.findById('#form-chb-autofit'), + labelText: this.textAutofit + }); + this.chAutofit.on('change', this.onChAutofit.bind(this)); + this.lockedControls.push(this.chAutofit); + + this.chMulti = new Common.UI.CheckBox({ + el: $markup.findById('#form-chb-multiline'), + labelText: this.textMulti + }); + this.chMulti.on('change', this.onChMulti.bind(this)); + this.lockedControls.push(this.chMulti); + this.chRequired = new Common.UI.CheckBox({ el: $markup.findById('#form-chb-required'), labelText: this.textRequired @@ -459,18 +474,37 @@ define([ } }, - onChFixed: function(field, newValue, oldValue, eOpts){ + onChAutofit: function(field, newValue, oldValue, eOpts){ var checked = (field.getValue()=='checked'); if (this.api && !this._noApply) { var props = this._originalProps || new AscCommon.CContentControlPr(); var formTextPr = this._originalTextFormProps || new AscCommon.CSdtTextFormPr(); - formTextPr.put_FixedSize(checked); + formTextPr.put_AutoFit(checked); props.put_TextFormPr(formTextPr); this.api.asc_SetContentControlProperties(props, this.internalId); this.fireEvent('editcomplete', this); } }, + onChMulti: function(field, newValue, oldValue, eOpts){ + var checked = (field.getValue()=='checked'); + if (this.api && !this._noApply) { + var props = this._originalProps || new AscCommon.CContentControlPr(); + var formTextPr = this._originalTextFormProps || new AscCommon.CSdtTextFormPr(); + formTextPr.put_MultiLine(checked); + props.put_TextFormPr(formTextPr); + this.api.asc_SetContentControlProperties(props, this.internalId); + this.fireEvent('editcomplete', this); + } + }, + + onChFixed: function(field, newValue, oldValue, eOpts){ + if (this.api && !this._noApply) { + this.api.asc_SetFixedForm(this.internalId, field.getValue()=='checked'); + this.fireEvent('editcomplete', this); + } + }, + onGroupKeyChanged: function(combo, record) { if (this.api && !this._noApply) { var props = this._originalProps || new AscCommon.CContentControlPr(); @@ -746,6 +780,14 @@ define([ this.labelFormName.text(ischeckbox ? this.textCheckbox : this.textRadiobox); } + + if (type !== Asc.c_oAscContentControlSpecificType.Picture) { + val = formPr.get_Fixed(); + if ( this._state.Fixed!==val ) { + this.chFixed.setValue(!!val, true); + this._state.Fixed=val; + } + } } var formTextPr = props.get_TextFormPr(); @@ -758,12 +800,18 @@ define([ this.chComb.setValue(!!val, true); this._state.Comb=val; } - // - // val = formTextPr.get_FixedSize(); - // if ( this._state.Fixed!==val ) { - // this.chFixed.setValue(!!val, true); - // this._state.Fixed=val; - // } + + val = formTextPr.get_MultiLine(); + if ( this._state.Multi!==val ) { + this.chMulti.setValue(!!val, true); + this._state.Multi=val; + } + + val = formTextPr.get_AutoFit(); + if ( this._state.AutoFit!==val ) { + this.chAutofit.setValue(!!val, true); + this._state.AutoFit=val; + } this.btnColor.setDisabled(!val); @@ -917,6 +965,7 @@ define([ var value = (checkboxOnly || radioboxOnly); this.PlaceholderSettings.toggleClass('hidden', value); this.CheckOnlySettings.toggleClass('hidden', !value); + this.NotImageSettings.toggleClass('hidden', imageOnly); }, onSelectItem: function(listView, itemView, record) { @@ -968,7 +1017,9 @@ define([ textDisconnect: 'Disconnect', textNoBorder: 'No border', textFixed: 'Fixed size field', - textRequired: 'Required' + textRequired: 'Required', + textAutofit: 'AutoFit', + textMulti: 'Multiline field' }, DE.Views.FormSettings || {})); }); \ No newline at end of file diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index d6a5bcb78..10b25300b 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -1768,6 +1768,8 @@ "DE.Views.FormSettings.textUnlock": "Unlock", "DE.Views.FormSettings.textValue": "Value Options", "DE.Views.FormSettings.textWidth": "Cell width", + "DE.Views.FormSettings.textAutofit": "AutoFit", + "DE.Views.FormSettings.textMulti": "Multiline field", "DE.Views.FormsTab.capBtnCheckBox": "Checkbox", "DE.Views.FormsTab.capBtnComboBox": "Combo Box", "DE.Views.FormsTab.capBtnDropDown": "Dropdown",