diff --git a/CHANGELOG b/CHANGELOG index 3bcf0dd9ebc3284f743ededdead3f161969dd75b..0bd5d1a1ca3a48efe9e24bafb4e576dbd2d813f8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,13 @@ django-ucamlookup changelog ============================= +3.0.2 - 30/04/2019 +------------------ + +- Replaced a feature that was removed in 3.0.0: namely that if a user or group is currently +selected in the control, it's filtered out of the dropdown results and thus can't be selected +twice. + 3.0.1 - 30/04/2019 ------------------ diff --git a/ucamlookup/templates/ucamlookup_groups.html b/ucamlookup/templates/ucamlookup_groups.html index fe220891c9e165862d2123c58c32bbbfc442cc19..28b145e1f58cca1fadb600e6833e161019b2beaa 100644 --- a/ucamlookup/templates/ucamlookup_groups.html +++ b/ucamlookup/templates/ucamlookup_groups.html @@ -34,8 +34,13 @@ processResults: function (data) { if (data.searchId_g != searchId_g) return; + // create the set of current selections + var groupids = new Set($select.select2('data').map(function(item) {return item.id})); + // filter out any results that are currently selected return { - results: $.map(data.groups, function(group) { + results: data.groups.filter(function(group) { + return ! groupids.has(group.groupid) + }).map(function(group) { return create_data(group.groupid, group.title) }) }; diff --git a/ucamlookup/templates/ucamlookup_users.html b/ucamlookup/templates/ucamlookup_users.html index 4b6a5d0ed39685635f2905ba00c4196c81e5ce18..31a80fcfad0c3910b06624b374309267e66b2c1b 100644 --- a/ucamlookup/templates/ucamlookup_users.html +++ b/ucamlookup/templates/ucamlookup_users.html @@ -34,8 +34,13 @@ processResults: function (data) { if (data.searchId_u != searchId_u) return; + // create the set of current selections + var crsids = new Set($select.select2('data').map(function(item) {return item.id})); + // filter out any results that are currently selected return { - results: $.map(data.persons, function(person) { + results: data.persons.filter(function(person) { + return ! crsids.has(person.crsid) + }).map(function(person) { return create_data(person.crsid, person.visibleName) }) };