How to select a parent ("WebHome") document only with checkboxes in documentTree

Initial situation:

documenTree has an option “checkboxes” (combined with links=“false”) to allow multiple selections of tree elements.

A typical application in my environment is the generation of a list of documents to be revised.

These can be processed e.g. by Javascript routines get_json, get_selected within jstree (see below)

But if you want to select the “WebHome” document only:

  • A selection of the node will select all children elements
  • A multiple single select of all children elements will automatically select the node.

From a point of “tree view”: Conceptually, this is perfectly fine.

But the problem remains: How to select “WebHome” only?

A suggestion for improvement:

If the “WebHome” document is listed as an leaf item (HTML li element) additionally the
additional function wil be provided.

To remain downward compatible, an additional parameter should be introduced (e.g. showWebHome)

Any suggestion for a different way to achieve this is of course welcome.
Thanks
Norbert

Additional note: conceptional javascript

 function showMyTree () {
   require(["jquery"], function($) {
    // get all:   
    //     var v = $("#selectedTreeDocuments .xtree").jstree(true).get_json("#",{flat:true});
    // get selected only:
     var v = $("#selectedTreeDocuments .xtree").jstree(true).get_selected("full",true);
    // more - see: https://www.jstree.com/docs/
     var result = "";
       function lister (item,index) {
          if(item.state.selected) {
            result = result + item.id + "    (" + item.text+")\n\n";
          };
        };
    // v.forEach(lister);
    // debug:  alert(result);
    // debug:  console.log(v);
   });
 };

Selecting only the parent node is not easy out of the box using the documentTree macro but it can be done with a bit of scripting. Check the document tree from the Export administration section. If you right click on a tree node you get a context menu with two options: select children and unselect children. See xwiki-platform/exporter.js at master · xwiki/xwiki-platform · GitHub for how this is implemented.