3liz / lizmap-web-client

Transfer a QGIS project on a server, Lizmap is providing the web interface to browse it
https://www.lizmap.com
Mozilla Public License 2.0
260 stars 143 forks source link

(SOLVED) collapse / expand the nodes in the tree legend #245

Closed vincent-petale closed 8 years ago

vincent-petale commented 8 years ago

Hi, first of all, many many thanks to 3Liz for this plugin which allows me to publish my info on the web, without developping, it's a pleasure to use !

I'm not keen on modifying the codes, but I have a question, by default all my groups appear expanded on the legend, but because I have a lot of items, I'd like to choose which one is expanded or not, is it possible ?

On the Qgis plugin, I of course noticed the different choices for grouping some items, which result is that a group appears unexpanded, but then the boxes are no longer clickables... EDIT : I found a file named "jquery.treeTable.js" in /www/lizmap/www/TreeTable/javascripts, but I'm not sure how to edit it...

My map is here, you may well understand by yourself http://petale07.org/annuaire

Many thanks for your answers (as you can read my english is not very good so french is also ok...) vincent

vincent-petale commented 8 years ago

OK, solved !

The layers in the map have an attribut "expandAll" by default , we need to change it in "collapseAll" : -open "map.js" in /www/lizmap/www/js/

all the groups in the legend will now appear collapsed at the opening of the map.

Moreover, if we want only one group (or subgroup) to stay expanded, we just need to to add this line after the block $('#layer-Name of the group').expand();

... hope it will be useful for other people.

nboisteault commented 8 years ago

It would be better not to modify map.js because you'll have to take care of it when you'll update lizmap web client. It is better to add some javascript this way : http://docs.3liz.com/fr/publisher_guide/advanced_lizmap_config.html#adding-your-own-javascript

vincent-petale commented 8 years ago

Bonjour, oui c'est effectivement une remarque pertinente...

Je veux bien faire la modif mais le lien que vous me donnez pointe sur l'aide de la version 2.12, et je suis en beta 3.0beta1

il n'y avait pas de dossier "js/default" dans le dossier "media" de mon projet, je les ai donc créés puis créé l'exemple "disableRightClick.js"

... mais cela ne change rien, mon clic droit est toujours actif

Avez-vous une idée ?

Merci

nboisteault commented 8 years ago

Ca fonctionne en 2.12 aussi. J'ai utilisé cette fonction sur ce site : http://etiage-dordogne.fr/ Le code injecté est ici : http://etiage-dordogne.fr/lizmap-web-client/lizmap/www/index.php/view/media/getMedia?repository=epidor&project=Epidor&path=media%2Fjs%2FEpidor%2Fextend.js

En espérant que ça vous aide.

mdouchin commented 8 years ago

Hi Have you activated the right in the admin panel ? See documentation: "you allow it, through the Lizmap admin interface, adding the privilege “Allow themes for this repository” in the form for the modification of the repository"

vincent-petale commented 8 years ago

Hi, yes I did.

@nboisteault : J'ai résolu le problème en créant un répertoire avec le nom de mon projet dans /js , et non dans /default

Merci encore pour votre aide et bonne suite

josemvm commented 8 years ago

hi,

i'm trying to collapse a group at startup with js function, something like this:

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

what's wrong with this? can somone help me please?

thanks in advance

nboisteault commented 8 years ago

Could you provide a link to your interface?

josemvm commented 8 years ago

hi @nboisteault,

yes, it's a temporary link for you. i need to close the "PO - Aglomerados Urbanos" group (subgroup), identified by PO___Aglomerados_Urbanos.

http://pdm-revisao.municipioarraiolos.pt user: test pass: test

nboisteault commented 8 years ago

It is : $('#group-PO___Aglomerados_Urbanos td a.expander').click()

josemvm commented 8 years ago

so easy... and so perfect!!! :+1:

thanks @nboisteault (Nicolas)

BorisLD commented 5 years ago

Hello,

I'm sorry if my english is not very good.

I'm not a specialist of javascript and developping. I have the same problem als @vincent-petale for the legend in Lizmap wich is expand. I want to collapse it.

For that, i follow your instructions and i go in the file named "map.js" in Lizmap file (in the prod document). I open this file and then, i found the function "function createSwitcher" on the line 2059. I try to add the line }).collapseAll(); But it does not work. Maybe i don't put this line at the good place... Can somebody tell me where i have to add this line in this file ? I send you a view of my file map.js with the line with the function createSwitcher.

Thanks for all. PS : you can answer in French, maybe it will be better for me :) jvs

pcav commented 5 years ago

Perhaps this example should be added to lizmap/install/qgis/media/js/montpellier/, as it seems to be a widely requested function.