From: Matthias Schmidt Date: Sun, 18 Aug 2019 08:21:42 +0000 (+0200) Subject: Allow removing initial excess items in static item list X-Git-Tag: 5.2.0_Beta_1~16^2~1^2~4 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f346e0236448cd83bc8d8f6db36a1c98a1b09e81;p=GitHub%2FWoltLab%2FWCF.git Allow removing initial excess items in static item list --- 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);