From f346e0236448cd83bc8d8f6db36a1c98a1b09e81 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 18 Aug 2019 10:21:42 +0200 Subject: [PATCH] Allow removing initial excess items in static item list --- .../files/js/WoltLabSuite/Core/Ui/ItemList/Static.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList/Static.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList/Static.js index 9fb1c326f6..7c7ddc10a0 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList/Static.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList/Static.js @@ -116,13 +116,14 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'EventKey', 'Ui/Simple values = (data.values.length) ? data.values : values; if (Array.isArray(values)) { var value; + var forceRemoveIcon = !data.element.disabled; for (var i = 0, length = values.length; i < length; i++) { value = values[i]; if (typeof value === 'string') { value = { objectId: 0, value: value }; } - this._addItem(elementId, value); + this._addItem(elementId, value, forceRemoveIcon); } } }, @@ -384,10 +385,11 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'EventKey', 'Ui/Simple /** * Adds an item to the list. * - * @param {string} elementId input element id - * @param {object} value item value + * @param {string} elementId input element id + * @param {object} value item value + * @param {?boolean} forceRemoveIcon if `true`, the icon to remove the item will be added in every case */ - _addItem: function(elementId, value) { + _addItem: function(elementId, value, forceRemoveIcon) { var data = _data.get(elementId); var listItem = elCreate('li'); @@ -399,7 +401,7 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'EventKey', 'Ui/Simple content.textContent = value.value; listItem.appendChild(content); - if (!data.element.disabled) { + if (forceRemoveIcon || !data.element.disabled) { var button = elCreate('a'); button.className = 'icon icon16 fa-times'; button.addEventListener(WCF_CLICK_EVENT, _callbackRemoveItem); -- 2.20.1