Skip to content

Commit 2988386

Browse files
idodeclareVladimir Kotal
authored andcommitted
Fix bug introduced with 5cac8be re hidden selections
1 parent 671b797 commit 2988386

File tree

2 files changed

+71
-43
lines changed

2 files changed

+71
-43
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/web/Scripts.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public String toHtml() {
110110
putjs("jquery-ui", "js/jquery-ui-1.12.1-custom", 11);
111111
putjs("jquery-tablesorter", "js/jquery-tablesorter-2.26.6", 12);
112112
putjs("tablesorter-parsers", "js/tablesorter-parsers-0.0.2", 13, true);
113-
putjs("searchable-option-list", "js/searchable-option-list-2.0.10", 14);
113+
putjs("searchable-option-list", "js/searchable-option-list-2.0.11", 14);
114114
putjs("utils", "js/utils-0.0.34", 15, true);
115115
putjs("repos", "js/repos-0.0.2", 20, true);
116116
putjs("diff", "js/diff-0.0.4", 20, true);

opengrok-web/src/main/webapp/js/searchable-option-list-2.0.10.js renamed to opengrok-web/src/main/webapp/js/searchable-option-list-2.0.11.js

Lines changed: 70 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,70 +1044,98 @@
10441044
},
10451045

10461046
_addSelectionDisplayItem: function ($changedItem) {
1047-
var solOptionItem = $changedItem.data('sol-item'),
1048-
$existingDisplayItem = solOptionItem.displaySelectionItem,
1049-
$displayItemText;
1050-
10511047
this.numSelected = 1 + this.numSelected;
10521048

10531049
if (this.config.maxShow !== 0 && this.numSelected > this.config.maxShow) {
10541050
if (this.valMap == null) {
10551051
this._setXItemsSelected();
10561052
}
10571053
} else {
1058-
/*
1059-
* Modified for OpenGrok in 2016, 2019.
1060-
*/
1061-
var label = solOptionItem.label;
1062-
if ($changedItem.data('messages-available')) {
1063-
label += ' <span class="';
1064-
label += 'note-' + $changedItem.data('messages-level');
1065-
label += ' important-note important-note-rounded" ';
1066-
label += 'title="Some message is present for this project.';
1067-
label += ' Find more info in the project list.">!</span>'
1068-
}
1054+
this._buildSelectionDisplayItem($changedItem);
1055+
}
1056+
},
10691057

1070-
$displayItemText = $('<span class="sol-selected-display-item-text" />').html(label);
1071-
$existingDisplayItem = $('<div class="sol-selected-display-item"/>')
1072-
.append($displayItemText)
1073-
.attr('title', solOptionItem.tooltip)
1074-
.data('label', solOptionItem.label)
1075-
.appendTo(this.$showSelectionContainer)
1076-
.dblclick(function () { // Modified for OpenGrok in 2017.
1077-
$changedItem.dblclick();
1078-
});
1058+
_buildSelectionDisplayItem: function ($changedItem) {
1059+
var solOptionItem = $changedItem.data('sol-item'),
1060+
$existingDisplayItem,
1061+
$displayItemText;
10791062

1080-
// show remove button on display items if not disabled and null selection allowed
1081-
if ((this.config.multiple || this.config.allowNullSelection) && !$changedItem.prop('disabled')) {
1082-
$('<span class="sol-quick-delete"/>')
1083-
.html(this.config.texts.quickDelete)
1084-
.click(function () { // deselect the project and refresh the search
1085-
$changedItem
1086-
.prop('checked', false)
1087-
.trigger('change');
1088-
/*
1089-
* Modified for OpenGrok in 2017.
1090-
*/
1091-
if (isOnSearchPage()) {
1092-
$('#sbox').submit();
1093-
}
1094-
})
1095-
.prependTo($existingDisplayItem);
1096-
}
1063+
/*
1064+
* Modified for OpenGrok in 2016, 2019.
1065+
*/
1066+
var label = solOptionItem.label;
1067+
if ($changedItem.data('messages-available')) {
1068+
label += ' <span class="';
1069+
label += 'note-' + $changedItem.data('messages-level');
1070+
label += ' important-note important-note-rounded" ';
1071+
label += 'title="Some message is present for this project.';
1072+
label += ' Find more info in the project list.">!</span>'
1073+
}
10971074

1098-
solOptionItem.displaySelectionItem = $existingDisplayItem;
1075+
$displayItemText = $('<span class="sol-selected-display-item-text" />').html(label);
1076+
$existingDisplayItem = $('<div class="sol-selected-display-item"/>')
1077+
.append($displayItemText)
1078+
.attr('title', solOptionItem.tooltip)
1079+
.data('label', solOptionItem.label)
1080+
.appendTo(this.$showSelectionContainer)
1081+
.dblclick(function () { // Modified for OpenGrok in 2017.
1082+
$changedItem.dblclick();
1083+
});
1084+
1085+
// show remove button on display items if not disabled and null selection allowed
1086+
if ((this.config.multiple || this.config.allowNullSelection) && !$changedItem.prop('disabled')) {
1087+
$('<span class="sol-quick-delete"/>')
1088+
.html(this.config.texts.quickDelete)
1089+
.click(function () { // deselect the project and refresh the search
1090+
$changedItem
1091+
.prop('checked', false)
1092+
.trigger('change');
1093+
/*
1094+
* Modified for OpenGrok in 2017.
1095+
*/
1096+
if (isOnSearchPage()) {
1097+
$('#sbox').submit();
1098+
}
1099+
})
1100+
.prependTo($existingDisplayItem);
10991101
}
1102+
1103+
solOptionItem.displaySelectionItem = $existingDisplayItem;
11001104
},
11011105

11021106
_removeSelectionDisplayItem: function ($changedItem) {
11031107
var solOptionItem = $changedItem.data('sol-item'),
11041108
$myDisplayItem = solOptionItem.displaySelectionItem;
11051109

1110+
var wasExceeding = this.config.maxShow !== 0 && this.numSelected > this.config.maxShow;
11061111
this.numSelected = this.numSelected - 1;
11071112

11081113
if ($myDisplayItem) {
11091114
$myDisplayItem.remove();
11101115
solOptionItem.displaySelectionItem = undefined;
1116+
1117+
/*
1118+
* N.b. for bulk mode, wasExceeding handling is off since only
1119+
* Clear or Invert-Selection would cause this function to be
1120+
* called. For Clear, there won't be any selected items at the
1121+
* end, so wasExceeding is irrelevant. For Invert-Selection,
1122+
* checked options are unchecked first -- i.e. we go to zero
1123+
* this.numSelected first -- so normal _addSelectionDisplayItem
1124+
* takes care of things.
1125+
*/
1126+
1127+
if (wasExceeding && this.valMap == null) {
1128+
var self = this;
1129+
this.$selectionContainer
1130+
.find('.sol-option input[type="checkbox"]:not([disabled]):checked')
1131+
.each(function (index, item) {
1132+
var $currentOptionItem = $(item);
1133+
if ($currentOptionItem.data('sol-item').displaySelectionItem == null) {
1134+
self._buildSelectionDisplayItem($currentOptionItem);
1135+
return false;
1136+
}
1137+
});
1138+
}
11111139
}
11121140
if (this.valMap == null) {
11131141
this._setXItemsSelected();

0 commit comments

Comments
 (0)