From fa803d0f4a2ea673f7743577f68dd3045abb539e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 20 May 2021 00:38:09 +0300 Subject: [PATCH] [DE] Add required option for form settings --- .../main/app/template/FormSettings.template | 12 ++++- .../main/app/view/FormSettings.js | 54 ++++++++++++++++++- apps/documenteditor/main/locale/en.json | 2 + 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/apps/documenteditor/main/app/template/FormSettings.template b/apps/documenteditor/main/app/template/FormSettings.template index c55e4e3cc..7e50265c4 100644 --- a/apps/documenteditor/main/app/template/FormSettings.template +++ b/apps/documenteditor/main/app/template/FormSettings.template @@ -34,6 +34,11 @@
+ + + + +
@@ -52,11 +57,16 @@ - +
+ + +
+ +
diff --git a/apps/documenteditor/main/app/view/FormSettings.js b/apps/documenteditor/main/app/view/FormSettings.js index 443f84bf2..b25566056 100644 --- a/apps/documenteditor/main/app/view/FormSettings.js +++ b/apps/documenteditor/main/app/view/FormSettings.js @@ -189,6 +189,20 @@ define([ this.spnWidth.on('change', this.onWidthChange.bind(this)); this.spnWidth.on('inputleave', function(){ me.fireEvent('editcomplete', me);}); + this.chRequired = new Common.UI.CheckBox({ + el: $markup.findById('#form-chb-required'), + labelText: this.textRequired + }); + this.chRequired.on('change', this.onChRequired.bind(this)); + this.lockedControls.push(this.chRequired); + + this.chFixed = new Common.UI.CheckBox({ + el: $markup.findById('#form-chb-fixed'), + labelText: this.textFixed + }); + this.chFixed.on('change', this.onChFixed.bind(this)); + this.lockedControls.push(this.chFixed); + // Radio props this.cmbGroupKey = new Common.UI.ComboBox({ el: $markup.findById('#form-combo-group-key'), @@ -432,6 +446,30 @@ define([ } }, + onChRequired: function(field, newValue, oldValue, eOpts){ + var checked = (field.getValue()=='checked'); + if (this.api && !this._noApply) { + var props = this._originalProps || new AscCommon.CContentControlPr(); + var formPr = this._originalFormProps || new AscCommon.CSdtFormPr(); + formPr.put_Required(checked); + props.put_FormPr(formPr); + this.api.asc_SetContentControlProperties(props, this.internalId); + this.fireEvent('editcomplete', this); + } + }, + + onChFixed: 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); + props.put_TextFormPr(formTextPr); + this.api.asc_SetContentControlProperties(props, this.internalId); + this.fireEvent('editcomplete', this); + } + }, + onGroupKeyChanged: function(combo, record) { if (this.api && !this._noApply) { var props = this._originalProps || new AscCommon.CContentControlPr(); @@ -679,6 +717,12 @@ define([ this._state.help=val; } + val = formPr.get_Required(); + if ( this._state.Required!==val ) { + this.chRequired.setValue(!!val, true); + this._state.Required=val; + } + if (type == Asc.c_oAscContentControlSpecificType.CheckBox && specProps) { val = specProps.get_GroupKey(); var ischeckbox = (typeof val !== 'string'); @@ -713,6 +757,12 @@ 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; + // } this.btnColor.setDisabled(!val); @@ -915,7 +965,9 @@ define([ textColor: 'Border color', textConnected: 'Fields connected', textDisconnect: 'Disconnect', - textNoBorder: 'No border' + textNoBorder: 'No border', + textFixed: 'Fixed size field', + textRequired: 'Required' }, 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 6476da0f4..b6e61cc97 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -1766,6 +1766,8 @@ "DE.Views.FormSettings.textUnlock": "Unlock", "DE.Views.FormSettings.textValue": "Value Options", "DE.Views.FormSettings.textWidth": "Cell width", + "DE.Views.FormSettings.textFixed": "Fixed size field", + "DE.Views.FormSettings.textRequired": "Required", "DE.Views.FormsTab.capBtnCheckBox": "Checkbox", "DE.Views.FormsTab.capBtnComboBox": "Combo Box", "DE.Views.FormsTab.capBtnDropDown": "Dropdown",