Skip to content

Commit cdb2262

Browse files
author
Fernando Alvarez-Castellanos Rojo
authored
SAK-44609 Hiding Favorites site warning shown when user attempts to hide unfavorited site (sakaiproject#10597)
1 parent 865f149 commit cdb2262

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

user/user-tool-prefs/tool/src/webapp/js/manage-hidden-sites.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ $(function () {
127127
var confirmMsg = $.trim($('#reallyHideConfirm').text());
128128
var checkedHiddenSites = $('.site-hidden:checked');
129129

130-
if (clicked_button === 'hidden_sites_form:submit' && checkedHiddenSites.length > 0 && !confirm(confirmMsg)) {
130+
if (clicked_button === 'hidden_sites_form:submit' && checkedHiddenSites.length > 0 && wereFavoritesPreviously(checkedHiddenSites) && !confirm(confirmMsg)) {
131131
return false;
132132
}
133133

@@ -169,4 +169,15 @@ $(function () {
169169
}
170170
});
171171
});
172+
173+
function wereFavoritesPreviously(checkedSites) {
174+
let hasFavorites = 0;
175+
checkedSites.each(function() {
176+
if ($(this).parent().hasClass('favorite-site') && hiddenSites.indexOf($(this).data('site-id')) < 0) {
177+
hasFavorites++;
178+
return false;
179+
}
180+
});
181+
return hasFavorites > 0;
182+
}
172183
});

0 commit comments

Comments
 (0)