Open tulinkry opened 7 years ago
I spent some non-trivial amount of time going through, debugging and modifying the JavaScript code in searchable-option-list
(SOL) only to find out that the problem actually comes into existence already in the JSP code in menu.jspf
:
<select tabindex="8" class="q" id="project"
name="project" multiple="multiple" size="<%=
Math.min(15, projectsSize) %>"><%
SortedSet<String> pRequested = cfg.getRequestedProjects();
for (Group group : ph.getGroups()) {
Set<Project> groupProjects = ph.getAllGrouped(group);
if (groupProjects.size() > 0) {
%><optgroup label="<%= group.getName() %>"><%
for (Project p : groupProjects) {
if (!p.isIndexed()) {
continue;
}
// TODO below "selected" has no effect if one refreshes the page
// with F5
%><option value="<%= p.getName() %>"<%
if (pRequested.contains(p.getName())) {
%> selected="selected"<%
}
This will result in multiple options
tags with selected
attribute if a project is in multiple groups. The "SOL" builds the sol-option
stuff based on the select form contents in _detectDataFromOriginalElement()
.
The bottom of the problem is that there is 1-1 relationship between the project items in the pull down menu (sol-option
) and the rectangle objects (sol-selected-display-item
). In addition to that, clicking the small x
in the rectangle (sol-quick-delete
) to remove the project triggers the form submission ($('#sbox').submit()
) which initiates a search.
If the above JSP code is modified to remove a project from the pRequested
set after its <option>
element was generated (so that at most one group will have the option selected
), this works reasonably well. There is little quirk, though: once all projects are selected, the rectangles will contain the project twice (for simplicity I am assuming a setup where one project is listed in 2 groups). Once one of them is deselected, the submit is triggered and now only one of them will remain thanks to the modified JSP code. Deselecting the last one will remove it and trigger the search again and they are both gone for good. This is not a problem when selecting the whole groups (by clicking on the group labels in the pull down menu) because only one group can be selected like that, at least this is what the current code does.
The alternative would be to rework the JavaScript SOL code to provide deduplication of the rectangle objects and introduce 1-N mapping between the rectangle and the options so that when clicking on the x
both (multiple) options would be deselected. Not sure this is worth the trouble. What do you think @tulinkry ?
The alternative would be to rework the JavaScript SOL code to provide deduplication of the rectangle objects and introduce 1-N mapping between the rectangle and the options so that when clicking on the
x
both (multiple) options would be deselected. Not sure this is worth the trouble. What do you think @tulinkry ?
I think this is not a big change, at least for me, I can have a look sometime. Let's continue with the "temporary" fix in the JSP code.
The downsides of the JS mods are speed and further divergence from official SOL.
po 18. 2. 2019 11:16 odesílatel Kryštof Tulinger notifications@github.com napsal:
The alternative would be to rework the JavaScript SOL code to provide deduplication of the rectangle objects and introduce 1-N mapping between the rectangle and the options so that when clicking on the x both (multiple) options would be deselected. Not sure this is worth the trouble. What do you think @tulinkry https://github.com/tulinkry ?
I think this is not a big change, at least for me, I can have a look sometime. Let's continue with the "temporary" fix in the JSP code.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/oracle/opengrok/issues/1576#issuecomment-464671708, or mute the thread https://github.com/notifications/unsubscribe-auth/ACzGDOmGDSaeBhKXpZQLSK8TG0hQF6Rzks5vOn1qgaJpZM4NQ9vk .
Using single project in multiple groups; when adding this project in the project picker from both groups then this project is listed twice on the right side next to the project picker.
Note: this is just the ui bug