Skip to content

Commit

Permalink
Fixing a regression about silverpeas-user-group-list.js behavior intr…
Browse files Browse the repository at this point in the history
…oduced when the rule that the technical hidden inputs containing ids ordered like it is shown on UI has been implemented.
  • Loading branch information
SilverYoCha committed Jul 11, 2019
1 parent 06e8c39 commit 83fea5a
Showing 1 changed file with 9 additions and 2 deletions.
Expand Up @@ -230,12 +230,17 @@
item.name = item.getFullName();
item.score = score;
};
var __isUserId = function(id) {
return id.startsWith("user-")
};
var __normalizeId = function(id) {
return id.replace(/[^0-9]/g, '');
};
var __updateIdContainers = function(id, allValues) {
allValues = typeof allValues === 'string' ? [allValues] : allValues;
var isAdd = Array.isArray(allValues);
var idContainer = id.startsWith("user-") ?
var isUserId = __isUserId(id);
var idContainer = isUserId ?
userGroupSelectInstance.context.currentUserIds :
userGroupSelectInstance.context.currentGroupIds;
if (isAdd) {
Expand All @@ -247,7 +252,9 @@
return;
}
idContainer.removeAll();
allValues.forEach(function(anId) {
allValues.filter(function(anId) {
return isUserId ? __isUserId(anId) : !__isUserId(anId);
}).forEach(function(anId) {
idContainer.addElement(__normalizeId(anId));
});
} else {
Expand Down

0 comments on commit 83fea5a

Please sign in to comment.