Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: form layout/drag and drop designer - container/control visibility by expression #3713

Closed
1 task done
josemvm opened this issue Jun 5, 2023 · 6 comments
Closed
1 task done
Labels
expression question stale This ticket might be closed soon

Comments

@josemvm
Copy link
Collaborator

josemvm commented Jun 5, 2023

What is the question?

i'm trying to control container visibility by expression like @lizmap_user = 'jose' or @lizmap_user_groups = 'dafaj'
but the contaneir is always visible for all users or groups

imagem

thanks for your help

Versions

Versions :

  • Lizmap Web Client : 3.6.4
  • Lizmap plugin : 3.14.0
  • QGIS Desktop : 3.22.16
  • QGIS Server : 3.22.16
  • Py-QGIS-Server : not used
  • QGIS Server plugin atlasprint : 3.3.2
  • QGIS Server plugin lizmap_server : 2.7.1
  • QGIS Server plugin wfsOutputExtension : 1.7.1

Check Lizmap plugin

  • I have done the step just before in the Lizmap QGIS desktop plugin before opening this ticket. Otherwise, my ticket is not considered valid and might get closed.

QGIS server version, only if the section above doesn't mention the QGIS Server version

No response

Operating system

Ubuntu 20.04

Browsers

Firefox

Browsers version

lasted

Relevant log output

No response

@josemvm
Copy link
Collaborator Author

josemvm commented Jun 5, 2023

#2535 ?

@Gustry
Copy link
Member

Gustry commented Jun 5, 2023

@lizmap_user_groups = 'dafaj'

This will never work for sure, because it's an array, not a string. You can look the variable help for it.

Then for string, this must be checked.
You can still check QGIS server logs when opening the form, you will see if the expression is evaluated correctly and if yes, with which parameters were used

@josemvm
Copy link
Collaborator Author

josemvm commented Jun 5, 2023

i'm trying to use login field ("login" = 'jose') to control de visibility using this script as usual for me https://docs.lizmap.com/current/en/publish/customization/javascript.html#send-current-login-user-id
but with this way the container remains always invisible for all users


i'm trying too with a cod_divisao_serv field which has a relation reference widget type (the best pratice for my propose)
imagem
like "cod_divisao_serv" = 9
imagem
the container is always invisible!

@josemvm
Copy link
Collaborator Author

josemvm commented Jun 5, 2023

the form needs a interaction, a choice make by the user on one field, it doesn´t assume loaded values like @lizmap_user , "login" = 'jose' or "cod_divisao_serv" = 9

am i right?

@josemvm
Copy link
Collaborator Author

josemvm commented Jun 5, 2023

from qgis server logs, i can detect that there are 3 moments:

  • when the user open the form
14:51:25 INFO Server[54807]: **_EXPRESSIONS_**:{"jforms_view_edition-group9":" \"tipo\"  =  'RQI' "}
14:51:25 INFO Server[54807]: **_FEATURE_**:{"type":"Feature","geometry":null,"properties":{"tipo":""}}
14:51:25 INFO Server[54807]: FORM_SCOPE:true
14:51:25 INFO Server[54807]: LAYER:p_cabimentos
14:51:25 INFO Server[54807]: MAP:/var/www/html/lizmap_web_client/lizmap/install/ma/gestaoCabimentos.qgs
14:51:25 INFO Server[54807]: REQUEST:Evaluate
14:51:25 INFO Server[54807]: SERVICE:EXPRESSION
14:51:25 INFO Lizmap[54807]: Request headers provided
14:51:25 INFO Lizmap[54807]: No lizmap user groups in request headers
14:51:25 INFO Lizmap[54807]: Request headers provided
14:51:25 INFO Lizmap[54807]: No lizmap user login in request headers
14:51:25 INFO Lizmap[54807]: **_Sending JSON response_** : {'status': 'success', 'results': [{'jforms_view_edition-group9': 0}], 'errors': [{'jforms_view_edition-group9': ' "tipo"  =  \'RQI\' '}], 'features': 0}
  • when the user write or choice a value on the field include into the expression
14:52:13 INFO Server[54807]: **_EXPRESSIONS_**:{"jforms_view_edition-group9":" \"tipo\"  =  'RQI' "}
14:52:13 INFO Server[54807]: **_FEATURE_**:{"type":"Feature","geometry":null,"properties":{"tipo":"Empreitada"}}
14:52:13 INFO Server[54807]: FORM_SCOPE:true
14:52:13 INFO Server[54807]: LAYER:p_cabimentos
14:52:13 INFO Server[54807]: MAP:/var/www/html/lizmap_web_client/lizmap/install/ma/gestaoCabimentos.qgs
14:52:13 INFO Server[54807]: REQUEST:Evaluate
14:52:13 INFO Server[54807]: SERVICE:EXPRESSION
14:52:13 INFO Lizmap[54807]: Request headers provided
14:52:13 INFO Lizmap[54807]: No lizmap user groups in request headers
14:52:13 INFO Lizmap[54807]: Request headers provided
14:52:13 INFO Lizmap[54807]: No lizmap user login in request headers
14:52:13 INFO Lizmap[54807]: **_Sending JSON response_** : {'status': 'success', 'results': [{'jforms_view_edition-group9': 0}], 'errors': [{'jforms_view_edition-group9': ' "tipo"  =  \'RQI\' '}], 'features': 0}
  • when the qgis validate de value into the expression (0 or 1)
14:53:11 INFO Server[54807]: **_EXPRESSIONS_**:{"jforms_view_edition-group9":" \"tipo\"  =  'RQI' "}
14:53:11 INFO Server[54807]: **_FEATURE_**:{"type":"Feature","geometry":null,"properties":{"tipo":"RQI"}}
14:53:11 INFO Server[54807]: FORM_SCOPE:true
14:53:11 INFO Server[54807]: LAYER:p_cabimentos
14:53:11 INFO Server[54807]: MAP:/var/www/html/lizmap_web_client/lizmap/install/ma/gestaoCabimentos.qgs
14:53:11 INFO Server[54807]: REQUEST:Evaluate
14:53:11 INFO Server[54807]: SERVICE:EXPRESSION
14:53:11 INFO Lizmap[54807]: Request headers provided
14:53:11 INFO Lizmap[54807]: No lizmap user groups in request headers
14:53:11 INFO Lizmap[54807]: Request headers provided
14:53:11 INFO Lizmap[54807]: No lizmap user login in request headers
14:53:11 INFO Lizmap[54807]: **_Sending JSON response_** : {'status': 'success', 'results': [{'jforms_view_edition-group9': **_1_**}], 'errors': [{'jforms_view_edition-group9': ' "tipo"  =  \'RQI\' '}], 'features': 0}


without inteaction on the field included into the expression only the first moment happens

14:56:08 INFO Server[55003]: **_EXPRESSIONS_**:{"jforms_view_edition-group9":" \"cod_divisao_serv\"  = 9"}
14:56:08 INFO Server[55003]: **_FEATURE_**:{"type":"Feature","geometry":null,"properties":{"cod_divisao_serv":""}}
14:56:08 INFO Server[55003]: FORM_SCOPE:true
14:56:08 INFO Server[55003]: LAYER:p_cabimentos
14:56:08 INFO Server[55003]: MAP:/var/www/html/lizmap_web_client/lizmap/install/ma/gestaoCabimentos.qgs
14:56:08 INFO Server[55003]: REQUEST:Evaluate
14:56:08 INFO Server[55003]: SERVICE:EXPRESSION
14:56:08 INFO Lizmap[55003]: Request headers provided
14:56:08 INFO Lizmap[55003]: No lizmap user groups in request headers
14:56:08 INFO Lizmap[55003]: Request headers provided
14:56:08 INFO Lizmap[55003]: No lizmap user login in request headers
14:56:08 INFO Lizmap[55003]: **_Sending JSON response_** : {'status': 'success', 'results': [{'jforms_view_edition-group9': 0}], 'errors': [{'jforms_view_edition-group9': ' "cod_divisao_serv"  = 9'}], 'features': 0}

by this way the qgis server can't validate pre-populated fields or fields without interaction by the user
imagem


can i do something (any trick) to make it work from lizmap form?

many thanks

Copy link

Hiya!
This issue has gone quiet. 👻
We get a few questions in the bug tracker, we are currently slowly closing issues.
If we missed this issue or if you want to keep it open, please reply here.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request.
Thanks for being a part of the Lizmap community! 🦎

@github-actions github-actions bot added the stale This ticket might be closed soon label Feb 14, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expression question stale This ticket might be closed soon
Projects
None yet
Development

No branches or pull requests

2 participants