[DE] Refactoring form settings

This commit is contained in:
Julia Radzhabova 2020-09-30 10:33:38 +03:00
parent 16d9a78d8f
commit 3234492ccc
4 changed files with 182 additions and 106 deletions

View file

@ -167,12 +167,16 @@ define([
this._settings[Common.Utils.documentSettingsType.Signature].locked = value.get_Locked(); this._settings[Common.Utils.documentSettingsType.Signature].locked = value.get_Locked();
} }
if (control_props) { if (control_props && control_props.get_FormPr()) {
var spectype = control_props.get_SpecificType();
if (spectype==Asc.c_oAscContentControlSpecificType.CheckBox || spectype==Asc.c_oAscContentControlSpecificType.Picture ||
spectype==Asc.c_oAscContentControlSpecificType.ComboBox || spectype==Asc.c_oAscContentControlSpecificType.DropDownList || spectype==Asc.c_oAscContentControlSpecificType.None) {
settingsType = Common.Utils.documentSettingsType.Form; settingsType = Common.Utils.documentSettingsType.Form;
this._settings[settingsType].props = control_props; this._settings[settingsType].props = control_props;
this._settings[settingsType].locked = false; this._settings[settingsType].locked = false;
this._settings[settingsType].hidden = 0; this._settings[settingsType].hidden = 0;
} }
}
if ( this._settings[Common.Utils.documentSettingsType.Header].locked ) { // если находимся в locked header/footer, то считаем, что все элементы в нем тоже недоступны if ( this._settings[Common.Utils.documentSettingsType.Header].locked ) { // если находимся в locked header/footer, то считаем, что все элементы в нем тоже недоступны
for (i=0; i<this._settings.length; i++) { for (i=0; i<this._settings.length; i++) {

View file

@ -1,7 +1,7 @@
<table cols="1"> <table cols="1">
<tr> <tr>
<td> <td>
<label class="header" id="form-settings-name"><%= scope.textField %></label> <label class="header padding-small" id="form-settings-name"><%= scope.textField %></label>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -10,7 +10,7 @@
<div id="form-combo-key" style="width: 100%;"></div> <div id="form-combo-key" style="width: 100%;"></div>
</td> </td>
</tr> </tr>
<tr> <tr class="form-panel-textfield">
<td class="padding-small"> <td class="padding-small">
<label class="input-label"><%= scope.textPlaceholder %></label> <label class="input-label"><%= scope.textPlaceholder %></label>
<div id="form-txt-pholder"></div> <div id="form-txt-pholder"></div>
@ -19,24 +19,24 @@
<tr> <tr>
<td class="padding-large"> <td class="padding-large">
<label class="input-label"><%= scope.textTip %></label> <label class="input-label"><%= scope.textTip %></label>
<textarea id="form-txt-help" class="form-control" style="width: 100%; height: 90px;"></textarea> <div id="form-txt-help"></div>
</td> </td>
</tr> </tr>
<tr> <tr class="form-panel-textfield">
<td class="padding-small"> <td class="padding-small">
<div id="form-chb-max-chars" style="display: inline-block;margin-right: 10px;"></div> <div id="form-chb-max-chars" style="display: inline-block;margin-top: 4px;"></div>
<div id="form-spin-max-chars" style="display: inline-block;"></div> <div id="form-spin-max-chars" style="display: inline-block;float: right;"></div>
</td> </td>
</tr> </tr>
<tr> <tr class="form-panel-textfield">
<td class="padding-small"> <td class="padding-small">
<div id="form-chb-comb"></div> <div id="form-chb-comb"></div>
</td> </td>
</tr> </tr>
<tr> <tr class="form-panel-textfield">
<td class="padding-small" colspan="2"> <td class="padding-small" colspan="2">
<label class="input-label" style="margin-right: 10px;"><%= scope.textWidth %></label> <label class="input-label" style="margin-left: 22px;margin-top: 4px;"><%= scope.textWidth %></label>
<div id="form-spin-width" style=""></div> <div id="form-spin-width" style="display: inline-block; float: right;"></div>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -46,12 +46,13 @@
</tr> </tr>
<tr> <tr>
<td class="padding-small"> <td class="padding-small">
<div id="form-btn-delete" style="width:100%;"></div> <div id="form-btn-delete"></div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="padding-small"> <td class="padding-small">
<div id="form-btn-lock" style="width:100%;"></div> <div id="form-btn-lock"></div>
</td> </td>
</tr> </tr>
<tr class="finish-cell"></tr>
</table> </table>

View file

@ -307,7 +307,8 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template',
step: .1, step: .1,
width: 80, width: 80,
defaultUnit : "cm", defaultUnit : "cm",
value: '3 cm', value: 'Auto',
allowAuto: true,
maxValue: 55.88, maxValue: 55.88,
minValue: 0.1 minValue: 0.1
}); });
@ -522,7 +523,7 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template',
this.spnMaxChars.setValue(val && val>=0 ? val : 10); this.spnMaxChars.setValue(val && val>=0 ? val : 10);
val = formTextPr.get_Width(); val = formTextPr.get_Width();
this.spnWidth.setValue(val ? val : '', true); this.spnWidth.setValue(val!==0 && val!==undefined ? Common.Utils.Metric.fnRecalcFromMM(val * 25.4 / 20 / 72.0) : -1, true);
} }
} }
}, },
@ -607,8 +608,12 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template',
if (this.btnsCategory[5].isVisible()) { if (this.btnsCategory[5].isVisible()) {
var formTextPr = new AscCommon.CSdtTextFormPr(); var formTextPr = new AscCommon.CSdtTextFormPr();
if (this.spnWidth.getValue()) if (this.spnWidth.getValue()) {
formTextPr.put_Width(this.spnWidth.getNumberValue()); var value = this.spnWidth.getNumberValue();
formTextPr.put_Width(value<=0 ? 0 : parseInt(Common.Utils.Metric.fnRecalcToMM(value) * 72 * 20 / 25.4));
} else
formTextPr.put_Width(0);
if (this.placeholder && this.placeholder.changed) { if (this.placeholder && this.placeholder.changed) {
formTextPr.put_PlaceHolderSymbol(this.placeholder.code); formTextPr.put_PlaceHolderSymbol(this.placeholder.code);
formTextPr.put_PlaceHolderFont(this.placeholder.font); formTextPr.put_PlaceHolderFont(this.placeholder.font);
@ -618,7 +623,7 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template',
var checked = (this.chMaxChars.getValue()=='checked' || this.chComb.getValue()=='checked'); var checked = (this.chMaxChars.getValue()=='checked' || this.chComb.getValue()=='checked');
formTextPr.put_MaxCharacters(checked); formTextPr.put_MaxCharacters(checked);
if (checked) if (checked)
formTextPr.put_MaxCharacters(this.spnMaxChars.getNumberValue() || 12); formTextPr.put_MaxCharacters(this.spnMaxChars.getNumberValue() || 10);
props.put_TextFormPr(formTextPr); props.put_TextFormPr(formTextPr);
} }

View file

@ -45,6 +45,7 @@ define([
'backbone', 'backbone',
'common/main/lib/component/ComboBox', 'common/main/lib/component/ComboBox',
'common/main/lib/component/MetricSpinner', 'common/main/lib/component/MetricSpinner',
'common/main/lib/component/TextareaField',
'common/main/lib/component/CheckBox' 'common/main/lib/component/CheckBox'
], function (menuTemplate, $, _, Backbone) { ], function (menuTemplate, $, _, Backbone) {
'use strict'; 'use strict';
@ -71,7 +72,12 @@ define([
}; };
this.spinners = []; this.spinners = [];
this.lockedControls = []; this.lockedControls = [];
this.internalId = null;
this._locked = true; this._locked = true;
this._originalTextFormProps = null;
this._originalFormProps = null;
this._originalProps = null;
this._lockedControl = false;
this.render(); this.render();
}, },
@ -82,16 +88,12 @@ define([
scope: this scope: this
})); }));
this.FillColorContainer = $('#shape-panel-color-fill'); this.textFieldContainer = el.find('.form-panel-textfield');
this.FillImageContainer = $('#shape-panel-image-fill');
this.FillPatternContainer = $('#shape-panel-pattern-fill');
this.FillGradientContainer = $('#shape-panel-gradient-fill');
this.TransparencyContainer = $('#shape-panel-transparent-fill');
this.ShapeOnlySettings = $('.shape-only');
this.CanChangeType = $('.change-type');
}, },
createDelayedElements: function() { createDelayedElements: function() {
this._initSettings = false;
var $markup = this.$el || $(this.el); var $markup = this.$el || $(this.el);
var me = this; var me = this;
@ -102,14 +104,14 @@ define([
this.cmbKey = new Common.UI.ComboBox({ this.cmbKey = new Common.UI.ComboBox({
el: $markup.findById('#form-combo-key'), el: $markup.findById('#form-combo-key'),
cls: 'input-group-nr', cls: 'input-group-nr',
menuStyle: 'min-width: 85px;', menuStyle: 'min-width: 100%;',
editable: true, editable: true,
data: [], data: [],
disabled: this._locked disabled: this._locked
}); });
this.cmbKey.setValue(''); this.cmbKey.setValue('');
this.lockedControls.push(this.cmbKey); this.lockedControls.push(this.cmbKey);
this.cmbKey.on('selected', this.onKeySelect.bind(this)); this.cmbKey.on('selected', this.onKeyChanged.bind(this));
this.cmbKey.on('changed:after', this.onKeyChanged.bind(this)); this.cmbKey.on('changed:after', this.onKeyChanged.bind(this));
this.cmbKey.on('hide:after', this.onHideMenus.bind(this)); this.cmbKey.on('hide:after', this.onHideMenus.bind(this));
@ -123,14 +125,16 @@ define([
}); });
this.lockedControls.push(this.txtPlaceholder); this.lockedControls.push(this.txtPlaceholder);
this.txtPlaceholder.on('changed:after', this.onPlaceholderChanged.bind(this)); this.txtPlaceholder.on('changed:after', this.onPlaceholderChanged.bind(this));
this.txtPlaceholder.on('inputleave', function(){ me.fireEvent('editcomplete', me);});
this.textareaHelp = $markup.findById('#form-txt-help'); this.textareaHelp = new Common.UI.TextareaField({
this.textareaHelp.keydown(function (event) { el : $markup.findById('#form-txt-help'),
if (event.keyCode == Common.UI.Keys.RETURN) { style : 'width: 100%; height: 90px;',
event.stopPropagation(); value : ''
}
me.isHelpChanged = true;
}); });
this.lockedControls.push(this.textareaHelp);
this.textareaHelp.on('changed:after', this.onHelpChanged.bind(this));
this.textareaHelp.on('inputleave', function(){ me.fireEvent('editcomplete', me);});
this.chMaxChars = new Common.UI.CheckBox({ this.chMaxChars = new Common.UI.CheckBox({
el: $markup.findById('#form-chb-max-chars'), el: $markup.findById('#form-chb-max-chars'),
@ -142,7 +146,7 @@ define([
this.spnMaxChars = new Common.UI.MetricSpinner({ this.spnMaxChars = new Common.UI.MetricSpinner({
el: $markup.findById('#form-spin-max-chars'), el: $markup.findById('#form-spin-max-chars'),
step: 1, step: 1,
width: 53, width: 48,
defaultUnit : "", defaultUnit : "",
value: '10', value: '10',
maxValue: 1000000, maxValue: 1000000,
@ -162,9 +166,10 @@ define([
this.spnWidth = new Common.UI.MetricSpinner({ this.spnWidth = new Common.UI.MetricSpinner({
el: $markup.findById('#form-spin-width'), el: $markup.findById('#form-spin-width'),
step: .1, step: .1,
width: 80, width: 64,
defaultUnit : "cm", defaultUnit : "cm",
value: '3 cm', value: 'Auto',
allowAuto: true,
maxValue: 55.88, maxValue: 55.88,
minValue: 0.1 minValue: 0.1
}); });
@ -177,7 +182,7 @@ define([
cls : 'btn-toolbar', cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-remove-duplicates', iconCls : 'toolbar__icon btn-remove-duplicates',
caption : this.textDelete, caption : this.textDelete,
style : 'width: 100%;text-align: left;' style : 'text-align: left;'
}); });
this.btnRemForm.on('click', _.bind(function(btn){ this.btnRemForm.on('click', _.bind(function(btn){
this.api.asc_RemoveContentControlWrapper(this._state.id); this.api.asc_RemoveContentControlWrapper(this._state.id);
@ -189,10 +194,14 @@ define([
cls : 'btn-toolbar', cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-remove-duplicates', iconCls : 'toolbar__icon btn-remove-duplicates',
caption : this.textLock, caption : this.textLock,
style : 'width: 100%;text-align: left;' style : 'text-align: left;'
}); });
this.btnLockForm.on('click', _.bind(function(btn){ this.btnLockForm.on('click', _.bind(function(btn){
if (this.api && !this._noApply) {
var props = this._originalProps || new AscCommon.CContentControlPr();
props.put_Lock(!this._lockedControl ? Asc.c_oAscSdtLockType.SdtContentLocked : Asc.c_oAscSdtLockType.Unlocked);
this.api.asc_SetContentControlProperties(props, this.internalId);
}
}, this)); }, this));
this.lockedControls.push(this.btnLockForm); this.lockedControls.push(this.btnLockForm);
@ -207,74 +216,101 @@ define([
return this; return this;
}, },
onKeySelect: function(combo, record) {
if (this.api)
this.api.put_PrLineSpacing(record.value, record.defaultValue);
this.numLineHeight.setDefaultUnit(this._arrLineRule[record.value].defaultUnit);
this.numLineHeight.setMinValue(this._arrLineRule[record.value].minValue);
this.numLineHeight.setStep(this._arrLineRule[record.value].step);
this.fireEvent('editcomplete', this);
},
onKeyChanged: function(combo, record) { onKeyChanged: function(combo, record) {
if (me._changedProps) { if (this.api && !this._noApply) {
me._changedProps.put_XAlign(undefined); var props = this._originalProps || new AscCommon.CContentControlPr();
me._changedProps.put_X(Common.Utils.Metric.fnRecalcToMM(Common.Utils.String.parseFloat(record.value))); var formPr = this._originalFormProps || new AscCommon.CSdtFormPr();
} formPr.put_Key(record.value);
props.put_FormPr(formPr);
this.api.asc_SetContentControlProperties(props, this.internalId);
this.fireEvent('editcomplete', this); this.fireEvent('editcomplete', this);
}
}, },
onPlaceholderChanged: function(input, newValue, oldValue, e) { onPlaceholderChanged: function(input, newValue, oldValue, e) {
var val = parseInt(me.txtFieldNum.getValue()); if (this.api && !this._noApply) {
if (val !== parseInt(oldValue)) { var props = this._originalProps || new AscCommon.CContentControlPr();
me.api.asc_PreviewMailMergeResult(val-1); props.put_PlaceholderText(newValue);
me.fireEvent('editcomplete', me); this.api.asc_SetContentControlProperties(props, this.internalId);
this.fireEvent('editcomplete', this);
}
},
onHelpChanged: function(input, newValue, oldValue, e) {
if (this.api && !this._noApply) {
var props = this._originalProps || new AscCommon.CContentControlPr();
var formPr = this._originalFormProps || new AscCommon.CSdtFormPr();
formPr.put_HelpText(newValue);
props.put_FormPr(formPr);
this.api.asc_SetContentControlProperties(props, this.internalId);
this.fireEvent('editcomplete', this);
} }
}, },
onChMaxCharsChanged: function(field, newValue, oldValue, eOpts){ onChMaxCharsChanged: function(field, newValue, oldValue, eOpts){
this.spnMaxChars.setDisabled(field.getValue()!='checked'); this.spnMaxChars.setDisabled(field.getValue()!='checked');
if (this.api && !this._noApply) {
var props = this._originalProps || new AscCommon.CContentControlPr();
var formTextPr = this._originalTextFormProps || new AscCommon.CSdtTextFormPr();
var checked = (field.getValue()=='checked' || this.chComb.getValue()=='checked');
formTextPr.put_MaxCharacters(checked ? (this.spnMaxChars.getNumberValue() || 10) : checked);
props.put_TextFormPr(formTextPr);
this.api.asc_SetContentControlProperties(props, this.internalId);
this.fireEvent('editcomplete', this);
}
}, },
onMaxCharsChange: function(field, newValue, oldValue, eOpts){ onMaxCharsChange: function(field, newValue, oldValue, eOpts){
if ( this.cmbLineRule.getRawValue() === '' ) if (this.api && !this._noApply) {
return; var props = this._originalProps || new AscCommon.CContentControlPr();
var type = c_paragraphLinerule.LINERULE_AUTO; var formTextPr = this._originalTextFormProps || new AscCommon.CSdtTextFormPr();
if (this.api) var checked = (this.chMaxChars.getValue()=='checked' || this.chComb.getValue()=='checked');
this.api.put_PrLineSpacing(this.cmbLineRule.getValue(), (this.cmbLineRule.getValue()==c_paragraphLinerule.LINERULE_AUTO) ? field.getNumberValue() : Common.Utils.Metric.fnRecalcToMM(field.getNumberValue())); formTextPr.put_MaxCharacters(checked ? (field.getNumberValue() || 10) : checked);
props.put_TextFormPr(formTextPr);
this.api.asc_SetContentControlProperties(props, this.internalId);
this.fireEvent('editcomplete', this);
}
}, },
onChCombChanged: function(field, newValue, oldValue, eOpts){ onChCombChanged: function(field, newValue, oldValue, eOpts){
var checked = (field.getValue()=='checked'); var checked = (field.getValue()=='checked');
if (checked) { if (checked) {
this.chMaxChars.setValue(true); this.chMaxChars.setValue(true, true);
this.spnMaxChars.setDisabled(false);
} }
this.spnWidth.setDisabled(!checked); this.spnWidth.setDisabled(!checked);
if (this.api) if (this.api && !this._noApply) {
this.api.put_AddSpaceBetweenPrg((field.getValue()=='checked')); var props = this._originalProps || new AscCommon.CContentControlPr();
var formTextPr = this._originalTextFormProps || new AscCommon.CSdtTextFormPr();
formTextPr.put_Comb(checked);
if (checked) {
formTextPr.put_MaxCharacters(this.spnMaxChars.getNumberValue() || 10);
if (this.spnWidth.getValue()) {
var value = this.spnWidth.getNumberValue();
formTextPr.put_Width(value<=0 ? 0 : parseInt(Common.Utils.Metric.fnRecalcToMM(value) * 72 * 20 / 25.4));
} else
formTextPr.put_Width(0);
}
props.put_TextFormPr(formTextPr);
this.api.asc_SetContentControlProperties(props, this.internalId);
this.fireEvent('editcomplete', this); this.fireEvent('editcomplete', this);
},
onNumSpacingBeforeChange: function(field, newValue, oldValue, eOpts){
if (this.api) {
var num = field.getNumberValue();
this._state.LineSpacingBefore = (num<0) ? -1 : Common.Utils.Metric.fnRecalcToMM(num);
this.api.put_LineSpacingBeforeAfter(0, this._state.LineSpacingBefore);
} }
}, },
onNumSpacingAfterChange: function(field, newValue, oldValue, eOpts){ onWidthChange: function(field, newValue, oldValue, eOpts){
if (this.api){ if (this.api && !this._noApply) {
var num = field.getNumberValue(); var props = this._originalProps || new AscCommon.CContentControlPr();
this._state.LineSpacingAfter = (num<0) ? -1 : Common.Utils.Metric.fnRecalcToMM(num); var formTextPr = this._originalTextFormProps || new AscCommon.CSdtTextFormPr();
this.api.put_LineSpacingBeforeAfter(1, this._state.LineSpacingAfter); if (this.spnWidth.getValue()) {
} var value = this.spnWidth.getNumberValue();
}, formTextPr.put_Width(value<=0 ? 0 : parseInt(Common.Utils.Metric.fnRecalcToMM(value) * 72 * 20 / 25.4));
} else
formTextPr.put_Width(0);
onAddIntervalChange: function(field, newValue, oldValue, eOpts){ props.put_TextFormPr(formTextPr);
if (this.api) this.api.asc_SetContentControlProperties(props, this.internalId);
this.api.put_AddSpaceBetweenPrg((field.getValue()=='checked'));
this.fireEvent('editcomplete', this); this.fireEvent('editcomplete', this);
}
}, },
ChangeSettings: function(props) { ChangeSettings: function(props) {
@ -284,12 +320,25 @@ define([
this.disableControls(this._locked); this.disableControls(this._locked);
if (props) { if (props) {
this._originalProps = props;
this._noApply = true;
this.internalId = props.get_InternalId();
var val = props.get_PlaceholderText(); var val = props.get_PlaceholderText();
if (this._state.placeholder !== val) {
this.txtPlaceholder.setValue(val ? val : ''); this.txtPlaceholder.setValue(val ? val : '');
this._state.placeholder = val;
}
val = props.get_Lock(); val = props.get_Lock();
(val===undefined) && (val = Asc.c_oAscSdtLockType.Unlocked); (val===undefined) && (val = Asc.c_oAscSdtLockType.Unlocked);
// this.btnLock.setValue(val==Asc.c_oAscSdtLockType.SdtContentLocked || val==Asc.c_oAscSdtLockType.SdtLocked || val==Asc.c_oAscSdtLockType.ContentLocked); if (this._lockedControl !== val) {
this._lockedControl = (val==Asc.c_oAscSdtLockType.SdtContentLocked || val==Asc.c_oAscSdtLockType.SdtLocked || val==Asc.c_oAscSdtLockType.ContentLocked);
this.btnLockForm.setCaption(this._lockedControl ? this.textUnlock : this.textLock);
this.btnRemForm.setDisabled(this._lockedControl || this._locked);
}
var type = props.get_SpecificType(); var type = props.get_SpecificType();
var specProps; var specProps;
@ -298,6 +347,7 @@ define([
this.labelFormName.text(type == Asc.c_oAscContentControlSpecificType.ComboBox ? this.textCombobox : this.textDropDown); this.labelFormName.text(type == Asc.c_oAscContentControlSpecificType.ComboBox ? this.textCombobox : this.textDropDown);
specProps = (type == Asc.c_oAscContentControlSpecificType.ComboBox) ? props.get_ComboBoxPr() : props.get_DropDownListPr(); specProps = (type == Asc.c_oAscContentControlSpecificType.ComboBox) ? props.get_ComboBoxPr() : props.get_DropDownListPr();
if (specProps) { if (specProps) {
this._originalListProps = specProps;
var count = specProps.get_ItemsCount(); var count = specProps.get_ItemsCount();
var arr = []; var arr = [];
for (var i=0; i<count; i++) { for (var i=0; i<count; i++) {
@ -309,10 +359,9 @@ define([
this.list.store.reset(arr); this.list.store.reset(arr);
} }
this.disableListButtons(); this.disableListButtons();
} } else if (type == Asc.c_oAscContentControlSpecificType.CheckBox) {
if (type == Asc.c_oAscContentControlSpecificType.CheckBox) {
specProps = props.get_CheckBoxPr(); specProps = props.get_CheckBoxPr();
this._originalCheckProps = specProps;
} }
this.type = type; this.type = type;
@ -320,24 +369,37 @@ define([
// form settings // form settings
var formPr = props.get_FormPr(); var formPr = props.get_FormPr();
if (formPr) { if (formPr) {
this._originalFormProps = formPr;
val = formPr.get_Key(); val = formPr.get_Key();
if (this._state.key!==val) {
this.cmbKey.setValue(val ? val : ''); this.cmbKey.setValue(val ? val : '');
this._state.key = val;
}
val = formPr.get_HelpText(); val = formPr.get_HelpText();
this.textareaHelp.val(val ? val : ''); if (this._state.help!==val) {
this.textareaHelp.setValue(val ? val : '');
this._state.help=val;
}
var hidden = true; var hidden = true;
if (type == Asc.c_oAscContentControlSpecificType.CheckBox && specProps) { if (type == Asc.c_oAscContentControlSpecificType.CheckBox && specProps) {
val = specProps.get_GroupKey(); val = specProps.get_GroupKey();
if (this._state.groupkey!==val) {
this.txtGroupKey.setValue(val ? val : ''); this.txtGroupKey.setValue(val ? val : '');
this._state.groupkey=val;
}
hidden = (typeof val !== 'string'); hidden = (typeof val !== 'string');
this.labelFormName.text(hidden ? this.textCheckBox : this.textRadiobox); this.labelFormName.text(hidden ? this.textCheckbox : this.textRadiobox);
} }
this.$el.find('.group-key').toggleClass('hidden', hidden); this.$el.find('.group-key').toggleClass('hidden', hidden);
} }
var formTextPr = props.get_TextFormPr(); var formTextPr = props.get_TextFormPr();
if (formTextPr) { if (formTextPr) {
this._originalTextFormProps = formTextPr;
this.labelFormName.text(this.textField); this.labelFormName.text(this.textField);
val = formTextPr.get_Comb(); val = formTextPr.get_Comb();
if ( this._state.Comb!==val ) { if ( this._state.Comb!==val ) {
@ -347,19 +409,17 @@ define([
this.spnWidth.setDisabled(!val); this.spnWidth.setDisabled(!val);
val = formTextPr.get_Width(); val = formTextPr.get_Width();
if ( Math.abs(this._state.Width-val)>0.1) { if ( (val===undefined || this._state.Width===undefined)&&(this._state.Width!==val) || Math.abs(this._state.Width-val)>0.1) {
this.spnWidth.setValue(val ? val : '', true); this.spnWidth.setValue(val!==0 && val!==undefined ? Common.Utils.Metric.fnRecalcFromMM(val * 25.4 / 20 / 72.0) : -1, true);
this._state.Width=val; this._state.Width=val;
} }
val = formTextPr.get_MaxCharacters(); val = formTextPr.get_MaxCharacters();
if ( Math.abs(this._state.MaxChars-val)>0.1) { this.chMaxChars.setValue(val && val>=0);
this.chMaxChars.setValue(val && val>=0, true);
this.spnMaxChars.setDisabled(!val || val<0); this.spnMaxChars.setDisabled(!val || val<0);
this.spnMaxChars.setValue(val && val>=0 ? val : 10, true); this.spnMaxChars.setValue(val && val>=0 ? val : 10);
this._state.MaxChars=val;
}
} }
this._noApply = false;
} }
}, },
@ -387,8 +447,8 @@ define([
_.each(this.lockedControls, function(item) { _.each(this.lockedControls, function(item) {
item.setDisabled(disable); item.setDisabled(disable);
}); });
this.textTip.toggleClass('disabled', disable);
} }
this.btnRemForm.setDisabled(this._lockedControl || disable);
}, },
hideTextOnlySettings: function(value) { hideTextOnlySettings: function(value) {
@ -406,7 +466,13 @@ define([
textComb: 'Comb of characters', textComb: 'Comb of characters',
textWidth: 'Width', textWidth: 'Width',
textDelete: 'Delete', textDelete: 'Delete',
textLock: 'Lock' textLock: 'Lock',
textUnlock: 'Unlock',
textRadiobox: 'Radio button',
textCheckbox: 'Checkbox',
textCombobox: 'Combo box',
textDropDown: 'Dropdown',
textImage: 'Image'
}, DE.Views.FormSettings || {})); }, DE.Views.FormSettings || {}));
}); });