Fix bug 69037

This commit is contained in:
Julia.Radzhabova
2025-05-13 23:38:46 +03:00
parent 31e9e3afa8
commit 5a72ed2c62
5 changed files with 74 additions and 64 deletions

View File

@ -341,7 +341,7 @@ DE.ApplicationController = new(function(){
var type = obj.type,
props = obj.pr,
specProps = (type == Asc.c_oAscContentControlSpecificType.ComboBox) ? props.get_ComboBoxPr() : props.get_DropDownListPr(),
isForm = !!props.get_FormPr();
formProps = props.get_FormPr();
var menuContainer = DE.ApplicationView.getMenuForm();
@ -373,24 +373,26 @@ DE.ApplicationController = new(function(){
if (specProps) {
var k = 0;
if (isForm){ // for dropdown and combobox form control always add placeholder item
var text = props.get_PlaceholderText();
$listControlMenu.append('<li><a tabindex="-1" type="menuitem" style="opacity: 0.6" value="0">' +
((text.trim()!=='') ? text : me.txtEmpty) +
'</a></li>');
listControlItems.push('');
}
var count = specProps.get_ItemsCount();
if (formProps){
if (!formProps.get_Required() || count<1) { // for required or empty dropdown/combobox form control always add placeholder item
var text = props.get_PlaceholderText();
$listControlMenu.append('<li><a tabindex="-1" type="menuitem" style="opacity: 0.6" value="0">' +
((text.trim()!=='') ? text : me.txtEmpty) +
'</a></li>');
listControlItems.push('');
}
}
k = listControlItems.length;
for (var i=0; i<count; i++) {
if (specProps.get_ItemValue(i)!=='' || !isForm) {
if (specProps.get_ItemValue(i)!=='' || !formProps) {
$listControlMenu.append('<li><a tabindex="-1" type="menuitem" value="' + (i+k) + '">' +
common.utils.htmlEncode(specProps.get_ItemDisplayText(i)) +
'</a></li>');
listControlItems.push(specProps.get_ItemValue(i));
}
}
if (!isForm && listControlItems.length<1) {
if (!formProps && listControlItems.length<1) {
$listControlMenu.append('<li><a tabindex="-1" type="menuitem" value="0">' +
me.txtEmpty +
'</a></li>');

View File

@ -1372,7 +1372,7 @@ define([
var type = obj.type,
props = obj.pr,
specProps = (type == Asc.c_oAscContentControlSpecificType.ComboBox) ? props.get_ComboBoxPr() : props.get_DropDownListPr(),
isForm = !!props.get_FormPr(),
formProps = props.get_FormPr(),
menu = this.listControlMenu,
menuContainer = menu ? this.boxSdk.find(Common.Utils.String.format('#menu-container-{0}', menu.id)) : null,
me = this;
@ -1409,21 +1409,23 @@ define([
});
}
if (specProps) {
if (isForm){ // for dropdown and combobox form control always add placeholder item
var text = props.get_PlaceholderText();
menu.addItem(new Common.UI.MenuItem({
caption : (text.trim()!=='') ? text : this.txtEmpty,
value : '',
template : _.template([
'<a id="<%= id %>" tabindex="-1" type="menuitem" style="<% if (options.value=="") { %> opacity: 0.6 <% } %>">',
'<%= Common.Utils.String.htmlEncode(caption) %>',
'</a>'
].join(''))
}));
}
var count = specProps.get_ItemsCount();
if (formProps){
if (!formProps.get_Required() || count<1) { // for required or empty dropdown/combobox form control always add placeholder item
var text = props.get_PlaceholderText();
menu.addItem(new Common.UI.MenuItem({
caption : (text.trim()!=='') ? text : this.txtEmpty,
value : '',
template : _.template([
'<a id="<%= id %>" tabindex="-1" type="menuitem" style="<% if (options.value=="") { %> opacity: 0.6 <% } %>">',
'<%= Common.Utils.String.htmlEncode(caption) %>',
'</a>'
].join(''))
}));
}
}
for (var i=0; i<count; i++) {
(specProps.get_ItemValue(i)!=='' || !isForm) && menu.addItem(new Common.UI.MenuItem({
(specProps.get_ItemValue(i)!=='' || !formProps) && menu.addItem(new Common.UI.MenuItem({
caption : specProps.get_ItemDisplayText(i),
value : specProps.get_ItemValue(i),
template : _.template([
@ -1433,7 +1435,7 @@ define([
].join(''))
}));
}
if (!isForm && menu.items.length<1) {
if (!formProps && menu.items.length<1) {
menu.addItem(new Common.UI.MenuItem({
caption : this.txtEmpty,
value : -1

View File

@ -1108,7 +1108,7 @@ define([], function () {
var type = obj.type,
props = obj.pr,
specProps = (type == Asc.c_oAscContentControlSpecificType.ComboBox) ? props.get_ComboBoxPr() : props.get_DropDownListPr(),
isForm = !!props.get_FormPr(),
formProps = props.get_FormPr(),
cmpEl = this.documentHolder.cmpEl,
menu = this.listControlMenu,
menuContainer = menu ? cmpEl.find(Common.Utils.String.format('#menu-container-{0}', menu.id)) : null,
@ -1146,21 +1146,23 @@ define([], function () {
});
}
if (specProps) {
if (isForm){ // for dropdown and combobox form control always add placeholder item
var text = props.get_PlaceholderText();
menu.addItem(new Common.UI.MenuItem({
caption : (text.trim()!=='') ? text : this.documentHolder.txtEmpty,
value : '',
template : _.template([
'<a id="<%= id %>" tabindex="-1" type="menuitem" style="<% if (options.value=="") { %> opacity: 0.6 <% } %>">',
'<%= Common.Utils.String.htmlEncode(caption) %>',
'</a>'
].join(''))
}));
}
var count = specProps.get_ItemsCount();
if (formProps){
if (!formProps.get_Required() || count<1) {// for required or empty dropdown/combobox form control always add placeholder item
var text = props.get_PlaceholderText();
menu.addItem(new Common.UI.MenuItem({
caption : (text.trim()!=='') ? text : this.documentHolder.txtEmpty,
value : '',
template : _.template([
'<a id="<%= id %>" tabindex="-1" type="menuitem" style="<% if (options.value=="") { %> opacity: 0.6 <% } %>">',
'<%= Common.Utils.String.htmlEncode(caption) %>',
'</a>'
].join(''))
}));
}
}
for (var i=0; i<count; i++) {
(specProps.get_ItemValue(i)!=='' || !isForm) && menu.addItem(new Common.UI.MenuItem({
(specProps.get_ItemValue(i)!=='' || !formProps) && menu.addItem(new Common.UI.MenuItem({
caption : specProps.get_ItemDisplayText(i),
value : specProps.get_ItemValue(i),
template : _.template([
@ -1170,7 +1172,7 @@ define([], function () {
].join(''))
}));
}
if (!isForm && menu.items.length<1) {
if (!formProps && menu.items.length<1) {
menu.addItem(new Common.UI.MenuItem({
caption : this.documentHolder.txtEmpty,
value : -1

View File

@ -33,7 +33,7 @@ class DropdownListController extends Component {
this.internalId = this.propsObj.get_InternalId();
this.isComboBox = this.type === Asc.c_oAscContentControlSpecificType.ComboBox;
this.specProps = this.isComboBox ? this.propsObj.get_ComboBoxPr() : this.propsObj.get_DropDownListPr();
this.isForm = !!this.propsObj.get_FormPr();
this.formProps = this.propsObj.get_FormPr();
this.listItems = [];
this.curValue = api.asc_GetContentControlListCurrentValue(this.internalId);
@ -65,17 +65,19 @@ class DropdownListController extends Component {
const { t } = this.props;
const count = this.specProps.get_ItemsCount();
if(this.isForm) {
let text = this.propsObj.get_PlaceholderText();
if(this.formProps) {
if (!this.formProps.get_Required() || count<1) {// for required or empty dropdown/combobox form control always add placeholder item
let text = this.propsObj.get_PlaceholderText();
this.listItems.push({
caption: text.trim() !== '' ? text : t('Edit.textEmpty'),
value: ''
});
this.listItems.push({
caption: text.trim() !== '' ? text : t('Edit.textEmpty'),
value: ''
});
}
}
for (let i = 0; i < count; i++) {
if(this.specProps.get_ItemValue(i) || !this.isForm) {
if(this.specProps.get_ItemValue(i) || !this.formProps) {
this.listItems.push({
caption: this.specProps.get_ItemDisplayText(i),
value: this.specProps.get_ItemValue(i)
@ -83,7 +85,7 @@ class DropdownListController extends Component {
}
}
if (!this.isForm && this.listItems.length < 1) {
if (!this.formProps && this.listItems.length < 1) {
this.listItems.push({
caption: t('Edit.textEmpty'),
value: -1

View File

@ -1723,7 +1723,7 @@ define([], function () {
var type = obj.type,
props = obj.pr,
specProps = (type == Asc.c_oAscContentControlSpecificType.ComboBox) ? props.get_ComboBoxPr() : props.get_DropDownListPr(),
isForm = !!props.get_FormPr(),
formProps = props.get_FormPr(),
cmpEl = this.documentHolder.cmpEl,
menu = this.listControlMenu,
menuContainer = menu ? cmpEl.find(Common.Utils.String.format('#menu-container-{0}', menu.id)) : null,
@ -1761,21 +1761,23 @@ define([], function () {
});
}
if (specProps) {
if (isForm){ // for dropdown and combobox form control always add placeholder item
var text = props.get_PlaceholderText();
menu.addItem(new Common.UI.MenuItem({
caption : (text.trim()!=='') ? text : this.documentHolder.txtEmpty,
value : '',
template : _.template([
'<a id="<%= id %>" tabindex="-1" type="menuitem" style="<% if (options.value=="") { %> opacity: 0.6 <% } %>">',
'<%= Common.Utils.String.htmlEncode(caption) %>',
'</a>'
].join(''))
}));
}
var count = specProps.get_ItemsCount();
if (formProps){
if (!formProps.get_Required() || count<1) {// for required or empty dropdown/combobox form control always add placeholder item
var text = props.get_PlaceholderText();
menu.addItem(new Common.UI.MenuItem({
caption : (text.trim()!=='') ? text : this.documentHolder.txtEmpty,
value : '',
template : _.template([
'<a id="<%= id %>" tabindex="-1" type="menuitem" style="<% if (options.value=="") { %> opacity: 0.6 <% } %>">',
'<%= Common.Utils.String.htmlEncode(caption) %>',
'</a>'
].join(''))
}));
}
}
for (var i=0; i<count; i++) {
(specProps.get_ItemValue(i)!=='' || !isForm) && menu.addItem(new Common.UI.MenuItem({
(specProps.get_ItemValue(i)!=='' || !formProps) && menu.addItem(new Common.UI.MenuItem({
caption : specProps.get_ItemDisplayText(i),
value : specProps.get_ItemValue(i),
template : _.template([
@ -1785,7 +1787,7 @@ define([], function () {
].join(''))
}));
}
if (!isForm && menu.items.length<1) {
if (!formProps && menu.items.length<1) {
menu.addItem(new Common.UI.MenuItem({
caption : this.documentHolder.txtEmpty,
value : -1