jsdialog: show also empty listbox on desktop

Change-Id: Id08a242055c006c8166ec3effdc91919bac0a49d
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
This commit is contained in:
Szymon Kłos 2020-12-02 11:33:28 +01:00 committed by Szymon Kłos
parent a522f13dc8
commit 068884a762
2 changed files with 22 additions and 16 deletions

View file

@ -131,6 +131,12 @@
vertical-align: middle;
}
/* listbox */
.jsdialog.ui-listbox {
min-width: 100px;
}
/* Autofilter dropdown */
.autofilter.row {

View file

@ -1507,9 +1507,6 @@ L.Control.JSDialogBuilder = L.Control.extend({
},
_listboxControl: function(parentContainer, data, builder) {
if (!data.entries || data.entries.length === 0)
return false;
var title = data.text;
var selectedEntryIsString = false;
if (data.selectedEntries) {
@ -1518,26 +1515,29 @@ L.Control.JSDialogBuilder = L.Control.extend({
// pass
} else if (selectedEntryIsString)
title = builder._cleanText(data.selectedEntries[0]);
else
else if (data.entries && data.entries.length > data.selectedEntries[0])
title = data.entries[data.selectedEntries[0]];
}
title = builder._cleanText(title);
var listbox = L.DomUtil.create('select', builder.options.cssClass + ' ui-listbox ', parentContainer);
listbox.id = data.id;
for (var index in data.entries) {
var isSelected = false;
if ((data.selectedEntries && index == data.selectedEntries[0])
|| (data.selectedEntries && selectedEntryIsString && data.entries[index] === data.selectedEntries[0])
|| data.entries[index] == title) {
isSelected = true;
if (typeof(data.entries) === 'object') {
for (var index in data.entries) {
var isSelected = false;
if ((data.selectedEntries && index == data.selectedEntries[0])
|| (data.selectedEntries && selectedEntryIsString && data.entries[index] === data.selectedEntries[0])
|| data.entries[index] == title) {
isSelected = true;
}
var option = L.DomUtil.create('option', '', listbox);
option.value = index;
option.innerText = data.entries[index];
if (isSelected)
option.selected = 'true';
}
var option = L.DomUtil.create('option', '', listbox);
option.value = index;
option.innerText = data.entries[index];
if (isSelected)
option.selected = 'true';
}
return false;