From dc333f77d5d5119eaf61f280e62cc233552edd56 Mon Sep 17 00:00:00 2001 From: sboursen-scinote Date: Wed, 8 Feb 2023 18:19:55 +0100 Subject: [PATCH] Update the Selector when a user is selected/deselected [SCI-7625] --- .../javascripts/sitewide/dropdown_selector.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/assets/javascripts/sitewide/dropdown_selector.js b/app/assets/javascripts/sitewide/dropdown_selector.js index ba7eefb6f..1ff4bf572 100644 --- a/app/assets/javascripts/sitewide/dropdown_selector.js +++ b/app/assets/javascripts/sitewide/dropdown_selector.js @@ -708,6 +708,7 @@ var dropdownSelector = (function() { } else { // Or delete specific one deleteValue(selector, container, tagLabel.data('ds-tag-id'), tagLabel.data('ds-tag-group')); + removeOptionFromSelector(selector, tagLabel.data('ds-tag-id')); } }, 350); } @@ -871,6 +872,19 @@ var dropdownSelector = (function() { return result; } + function appendOptionToSelector(selector, value) { + $(selector).append( + `` + ); + } + + function removeOptionFromSelector(selector, id) { + $(selector).find(`option[value="${id}"]`).remove(); + } + // //////////////////// // Public functions /// // //////////////////// @@ -987,6 +1001,7 @@ var dropdownSelector = (function() { currentData = getCurrentData($(selector).next()); currentData.push(value); setData($(selector), currentData, skip_event); + appendOptionToSelector(selector, value); return this; },