Merge pull request #1934 from ONLYOFFICE/fix/addTextForm

[DE] Set placeholder when add email/phone forms
This commit is contained in:
Julia Radzhabova 2022-09-01 21:16:11 +03:00 committed by GitHub
commit f9bd914de6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View file

@ -182,14 +182,19 @@ define([
} else if (type == 'combobox' || type == 'dropdown')
this.api.asc_AddContentControlList(type == 'combobox', oPr, oFormPr);
else if (type == 'text') {
var props = new AscCommon.CContentControlPr();
oPr = new AscCommon.CSdtTextFormPr();
if (options) {
if (options.reg)
oPr.put_RegExpFormat(options.reg);
else if (options.mask)
oPr.put_MaskFormat(options.mask);
if (options.placeholder)
props.put_PlaceholderText(options.placeholder);
}
this.api.asc_AddContentControlTextForm(oPr, oFormPr);
props.put_TextFormPr(oPr);
props.put_FormPr(oFormPr);
this.api.asc_AddContentControlTextForm(props);
} else if (type == 'complex') {
this.api.asc_AddComplexForm();
}

View file

@ -2040,8 +2040,11 @@ define([
else if (item.value.indexOf('combobox')>=0 || item.value.indexOf('dropdown')>=0)
this.api.asc_AddContentControlList(item.value.indexOf('combobox')>=0, oPr, oFormPr);
else if (item.value == 'new-field') {
var props = new AscCommon.CContentControlPr();
oPr = new AscCommon.CSdtTextFormPr();
this.api.asc_AddContentControlTextForm(oPr, oFormPr);
props.put_TextFormPr(oPr);
props.put_FormPr(oFormPr);
this.api.asc_AddContentControlTextForm(props);
}
Common.component.Analytics.trackEvent('ToolBar', 'Add Content Control');

View file

@ -106,10 +106,10 @@ define([
me.fireEvent('forms:insert', ['complex']);
});
this.btnEmailField && this.btnEmailField.on('click', function (b, e) {
me.fireEvent('forms:insert', ['text', {reg: "\\S+@\\S+\\.\\S+"}]);
me.fireEvent('forms:insert', ['text', {reg: "\\S+@\\S+\\.\\S+", placeholder: 'user_name@email.com'}]);
});
this.btnPhoneField && this.btnPhoneField.on('click', function (b, e) {
me.fireEvent('forms:insert', ['text', {mask: "(999)999-9999"}]);
me.fireEvent('forms:insert', ['text', {mask: "(999)999-9999", placeholder: '(999)999-9999'}]);
});
this.btnViewForm && this.btnViewForm.on('click', function (b, e) {
me.fireEvent('forms:mode', [b.pressed]);