Skip to content

Commit b578888

Browse files
committed
Bug #14661
Fix the bug. The d&d handling was based upon the .jstree-draggable class. But since the refactoring within the fix of the bug 14478, the <span> with this CSS class didn't receive anymore the mouse event but its <a> parent because this one had a class attribute set. Without the class attribute in the <a> parent, the <span> element succeed to receive any mouse click down event on it. Nevertheless, in order the d&d mechanism works on publications, it was needed to move the id attribute from the <a> element to the <span class=".jstree-draggable> element because this publication identifier is fetched from this id on the dragged HTML node. So, the click event handler of the <a> node required to be refined to take into account of this (because the id attribute was also fetched to figure out the identifier of the publication to redirect the user to.
1 parent ae0fa70 commit b578888

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

kmelia/kmelia-war/src/main/java/org/silverpeas/components/kmelia/servlets/renderers/PublicationsRenderer.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -557,11 +557,11 @@ void renderPublicationDefaultFragment(KmeliaPublication aPub,
557557

558558
writer.write(SCRIPT_START);
559559
writer.write("whenSilverpeasReady(function() {" +
560-
" document.querySelectorAll('a.pub-link').forEach(function(a) {\n" +
560+
" document.querySelectorAll('.publication-name a').forEach(function(a) {\n" +
561561
" a.addEventListener('click', function(e) {\n" +
562562
" e.preventDefault();\n" +
563563
" e.stopPropagation();\n" +
564-
" const pubId = this.getAttribute('id').trim().slice(4);\n" +
564+
" const pubId = this.querySelector('span.jstree-draggable').getAttribute('id').trim().slice(4);\n" +
565565
" publicationGoTo(pubId);\n" +
566566
" });" +
567567
" });" +
@@ -666,10 +666,9 @@ private static void renderPublicationLink(PublicationDetail pub, String name, Wr
666666
PublicationFragmentSettings fragmentSettings) throws IOException {
667667
writer.write("<div class=\"");
668668
writer.write(fragmentSettings.getPubColor());
669-
writer.write("\"><a href=\"#\" class=\"pub-link\" id=\"pub-" + pub.getPK().getId());
670-
writer.write("\"><span class=\"" + fragmentSettings.getHighlightClass() + "\">");
669+
writer.write("\"><a href=\"#\"><span class=\"" + fragmentSettings.getHighlightClass() + "\">");
671670
if (fragmentSettings.isDraggable()) {
672-
writer.write("<span class=\"jstree-draggable\">");
671+
writer.write("<span class=\"jstree-draggable\" id=\"pub-" + pub.getPK().getId() + "\">");
673672
writer.write(name);
674673
writer.write(END_SPAN);
675674
} else {

kmelia/kmelia-war/src/main/webapp/kmelia/jsp/treeview.jsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@
920920
'nodes' : [{id : $(this).attr('id'), text : $(this).text()}]
921921
},
922922
'<div id="jstree-dnd" class="jstree-default"><i class="jstree-icon jstree-er"></i>' +
923-
$(this).text() + '</div>');
923+
$(this).text().escapeHTML() + '</div>');
924924
});
925925
926926
window.__spTreeviewDndContext = {

0 commit comments

Comments
 (0)