Coverage for gws-app/gws/base/client/__init__.py: 100%

1 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-05 13:35 +0200

1"""Browser client configuration and bundles. 

2 

3The client object describes the browser client of the application or a 

4project: a list of UI elements, identified by tags such as ``Toolbar.Print`` 

5or ``Sidebar.Layers``, and a dict of client options. Both are sent to the 

6browser as client props. Elements can have access rules, so different users can 

7see different elements. 

8 

9The application has a default client, which is used by projects without a 

10client configuration. A project client inherits the 

11application options (merged with its own) and the application elements. A 

12project can replace the element list with ``elements``, or modify the inherited 

13one with ``addElements`` (placed ``before`` or ``after`` an existing tag, or 

14appended) and ``removeElements``. 

15 

16Submodules: 

17 

18- ``core``: the client ``Object``, the ``Element`` node and their configs and props. 

19- ``bundles``: serves the JavaScript and CSS bundles built by the JS bundler 

20 (``app/js/helpers/builder.js``), with the UI strings for the client locale 

21 and the CSS for the requested theme. 

22 

23Example:: 

24 

25 client { 

26 elements [ 

27 { tag "Sidebar.Layers" } 

28 { tag "Toolbar.Print" access "allow user, deny all" } 

29 ] 

30 options { 

31 sidebarActiveTab "Sidebar.Layers" 

32 sidebarVisible true 

33 } 

34 } 

35 

36 projects [ 

37 { 

38 uid "project_1" 

39 client.addElements [ 

40 { tag "Sidebar.Edit" after "Sidebar.Layers" } 

41 ] 

42 client.removeElements [ 

43 { tag "Toolbar.Print" } 

44 ] 

45 } 

46 ] 

47""" 

48 

49from .core import Object, Props, Config