FlowingCode / OrgChartAddon

Organizational Chart Vaadin Add-on
https://www.flowingcode.com/en/open-source/
Apache License 2.0
18 stars 4 forks source link

Nodes aren't collapsable vertically #52

Closed Charlie28000 closed 2 years ago

Charlie28000 commented 3 years ago

Expectation: All nodes, except one "last" node, can be / are collapsed - like seen in the JQuery library https://dabeng.github.io/OrgChart/toggle-sibs-resp.html or when using https://addonsv14.flowingcode.com/orgchart "Bottom to Top"

Observation: One node in every "layer" remains uncollapsable (when not using Bottom to Top, but setChartExpandCollapse), thus collapsing nodes vertically is not possible. Additionally this prevents uncollapsing nodes when setCollapsedNodes is used. When a node with child nodes is collapsed horizontally, its child nodes disappear and can't be uncollapsed again. Furthermore, the collapse / uncollapse arrows don't show up using below setup, which makes it hard for the user to determine which nodes are collapsable / collapsed.

Code:

    int i = 1;
    OrgChartItem root;
    OrgChart orgChart;

    public MyOrgChart() {
        root = new OrgChartItem(i++, "root", "root");
        addChildren();
        orgChart = new OrgChart(root);
        String nodeTemplate = "<div class='title'>${item.title}</div>" + "<div class='middle content'>${item.name}</div>" + "${item.data.content?`<div class='custom content'>${item.data.content}</div>`:''}";
        orgChart.setNodeTemplate("item", TemplateLiteralRewriter.rewriteFunction(nodeTemplate));
        orgChart.addClassName("orgChart");
        orgChart.setChartTitle("Showcase Organigramm");
        orgChart.setChartExpandCollapse(true);
        // orgChart.setCollapsedNodes();    
    }

    public void addChildren() { 
        List<OrgChartItem> childrenItems = new ArrayList<>();

        OrgChartItem child1 = new OrgChartItem(i++, "child1", "child1");
        child1.setData("content", "child1");
        childrenItems.add(child1);

        OrgChartItem child2 = new OrgChartItem(i++, "child2", "child2");
        child2.setData("content", "child2");

        OrgChartItem subChild21 = new OrgChartItem(i++, "subChild21", "subChild21");
        subChild21.setData("content", "subChild21");

        OrgChartItem subChild22 = new OrgChartItem(i++, "subChild22", "subChild22");
        subChild22.setData("content", "subChild22");

        child2.setChildren(Arrays.asList(subChild21, subChild22));

        childrenItems.add(child2);

        root.setChildren(childrenItems);
    }
paodb commented 3 years ago

Hi @Charlie28000, did you do this test on the latest released version of the add-on (version 4.2.1)? I did a test with your example and I cannot replicate what you report. The indicators for the nodes are visible and I can collapse all that is possible to collapse. I attach a gif with my test:

org_chart

paodb commented 2 years ago

Hi @Charlie28000. Can you tell us if this still an issue for you? Thanks.