3liz / lizmap-documentation

Full documentation for Lizmap Web Client and Lizmap Plugin
20 stars 40 forks source link

[Bug]: Collapse gruop js does not work in Lizmap-web-client v3.7.2 #248

Closed NvBgm closed 9 months ago

NvBgm commented 9 months ago

What is the bug?

Collapse a group in the legend.

lizMap.events.on({
    uicreated: function(e) {
        $('#group-test td a.expander').click();
    }
});

When a add this js script to "\media\js\testmap\" or in the default "\media\js\default" map both does not work anymore.

Themes/JavaScript enable on the repositories.

Steps to reproduce the issue

Add js script from example in lizmap v3.7.2 doc.

Versions, safeguards, check summary etc

Versions :

List of safeguards :
* Mode : normal * Allow parent folder : yes * Number of parent : 2 folder(s) * Prevent other drive : yes * Prevent PG service : yes * Prevent PG Auth DB : yes * Force PG user&pass : yes * Prevent ECW : yes

Check Lizmap plugin

Operating system

Window 11

Browsers

Chrome

Browsers version

Chrome Versie 120.0.6099.227 (Officiële build) (64-bits)

Relevant log output

No response

Gustry commented 9 months ago

I guess you mean this link ? https://docs.lizmap.com/current/fr/publish/customization/javascript.html

Indeed, it needs an update.

nboisteault commented 9 months ago

@Gustry I'm not even sure we should keep this example. Should we communicate on the Activate first map theme on startup instead?

rldhont commented 9 months ago

Here is the new way

lizMap.events.on({
    uicreated: function(e) {
        for (const treeItem of lizMap.mainLizmap.state.layerTree.findTreeLayersAndGroups()) {
            if (treeItem.type != 'group') {
                continue;
            }
            if (treeItem.name != 'test') {
                continue;
            }
            treeItem.expanded = true;
        }
    }
});
NvBgm commented 9 months ago

Can i collapse several groups using commas ??

Gustry commented 9 months ago

@NvBgm Does using a QGIS theme not enough for your needs ?

josemvm commented 9 months ago

@rldhont how can i unchek a group? like above i'm trying with treeItem.checked = false; but it doesn't work