Merge pull request '[PDF forms] Add label for checkbox/radiobox' (#813) from fix/labeled-checkbox into hotfix/v9.2.0

This commit is contained in:
Julia Radzhabova
2025-10-29 15:33:45 +00:00
3 changed files with 45 additions and 0 deletions

View File

@ -39,6 +39,12 @@
<div id="form-txt-pholder"></div>
</td>
</tr>
<tr class="form-checkbox">
<td class="padding-small">
<label class="input-label"><%= scope.textLabel %></label>
<div id="form-txt-label"></div>
</td>
</tr>
<tr class="form-not-in-complex">
<td class="padding-small">
<label class="input-label"><%= scope.textTag %></label>

View File

@ -419,6 +419,25 @@ define([
setTimeout(function(){me.txtChoice._input && me.txtChoice._input.select();}, 1);
});
// checkbox props
this.txtLabel = new Common.UI.InputField({
el : $markup.findById('#form-txt-label'),
allowBlank : true,
validateOnChange: false,
validateOnBlur: false,
style : 'width: 100%;',
value : '',
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'small'
});
this.lockedControls.push(this.txtLabel);
this.txtLabel.on('changed:after', this.onLabelChanged.bind(this));
this.txtLabel.on('inputleave', function(){ me.fireEvent('editcomplete', me);});
this.txtLabel.cmpEl.on('focus', 'input.form-control', function() {
setTimeout(function(){me.txtLabel._input && me.txtLabel._input.select();}, 1);
});
// combobox & dropdown list
this.txtNewValue = new Common.UI.InputField({
el : $markup.findById('#form-txt-new-value'),
@ -1097,6 +1116,19 @@ define([
}
},
onLabelChanged: function(input, newValue, oldValue, e) {
if (this.api && !this._noApply && (newValue!==oldValue)) {
this._state.label = undefined;
var props = this._originalProps || new AscCommon.CContentControlPr();
var specProps = this._originalCheckProps || new AscCommon.CSdtCheckBoxPr();
specProps.put_Label(newValue);
props.put_CheckBoxPr(specProps);
this.api.asc_SetContentControlProperties(props, this.internalId);
if (!e.relatedTarget || (e.relatedTarget.localName != 'input' && e.relatedTarget.localName != 'textarea') || !/form-control/.test(e.relatedTarget.className))
this.fireEvent('editcomplete', this);
}
},
fillListProps: function() {
if (this.api && !this._noApply) {
var props = this._originalProps || new AscCommon.CContentControlPr();
@ -1469,6 +1501,12 @@ define([
this.chDefValue.setValue(!!val, true);
this._state.ChDefValue=val;
}
val = specProps.get_Label();
if (this._state.label !== val) {
this.txtLabel.setValue(val ? val : '');
this._state.label = val;
}
}
if (type !== Asc.c_oAscContentControlSpecificType.Picture && type !== Asc.c_oAscContentControlSpecificType.Signature) {

View File

@ -2854,6 +2854,7 @@
"DE.Views.FormSettings.textValue": "Value options",
"DE.Views.FormSettings.textWidth": "Cell width",
"DE.Views.FormSettings.textZipCodeUS": "US ZIP Code (e.g. 92663 or 92663-1234)",
"DE.Views.FormSettings.textLabel": "Label",
"DE.Views.FormsTab.capBtnCheckBox": "Checkbox",
"DE.Views.FormsTab.capBtnComboBox": "Combo Box",
"DE.Views.FormsTab.capBtnComplex": "Complex Field",