c2cgeoportal-admin 2.5.0.100__py3-none-any.whl → 2.9rc44__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. c2cgeoportal_admin/__init__.py +44 -14
  2. c2cgeoportal_admin/lib/__init__.py +0 -0
  3. c2cgeoportal_admin/lib/lingva_extractor.py +77 -0
  4. c2cgeoportal_admin/lib/ogcserver_synchronizer.py +410 -0
  5. c2cgeoportal_admin/py.typed +0 -0
  6. c2cgeoportal_admin/routes.py +30 -11
  7. c2cgeoportal_admin/schemas/dimensions.py +17 -11
  8. c2cgeoportal_admin/schemas/functionalities.py +60 -22
  9. c2cgeoportal_admin/schemas/interfaces.py +27 -19
  10. c2cgeoportal_admin/schemas/metadata.py +122 -48
  11. c2cgeoportal_admin/schemas/restriction_areas.py +26 -20
  12. c2cgeoportal_admin/schemas/roles.py +13 -7
  13. c2cgeoportal_admin/schemas/treegroup.py +90 -20
  14. c2cgeoportal_admin/schemas/treeitem.py +3 -4
  15. c2cgeoportal_admin/static/layertree.css +26 -4
  16. c2cgeoportal_admin/static/navbar.css +59 -36
  17. c2cgeoportal_admin/static/theme.css +51 -11
  18. c2cgeoportal_admin/subscribers.py +3 -3
  19. c2cgeoportal_admin/templates/404.jinja2 +41 -2
  20. c2cgeoportal_admin/templates/edit.jinja2 +23 -0
  21. c2cgeoportal_admin/templates/home.jinja2 +23 -0
  22. c2cgeoportal_admin/templates/index.jinja2 +23 -0
  23. c2cgeoportal_admin/templates/layertree.jinja2 +55 -11
  24. c2cgeoportal_admin/templates/layout.jinja2 +23 -0
  25. c2cgeoportal_admin/templates/navigation_navbar.jinja2 +56 -0
  26. c2cgeoportal_admin/templates/ogcserver_synchronize.jinja2 +90 -0
  27. c2cgeoportal_admin/templates/widgets/child.pt +35 -3
  28. c2cgeoportal_admin/templates/widgets/children.pt +121 -92
  29. c2cgeoportal_admin/templates/widgets/dimension.pt +23 -0
  30. c2cgeoportal_admin/templates/widgets/dimensions.pt +23 -0
  31. c2cgeoportal_admin/templates/widgets/functionality_fields.pt +51 -0
  32. c2cgeoportal_admin/templates/widgets/layer_fields.pt +23 -0
  33. c2cgeoportal_admin/templates/widgets/layer_group_fields.pt +23 -0
  34. c2cgeoportal_admin/templates/widgets/layer_v1_fields.pt +23 -0
  35. c2cgeoportal_admin/templates/widgets/metadata.pt +30 -1
  36. c2cgeoportal_admin/templates/widgets/metadatas.pt +23 -0
  37. c2cgeoportal_admin/templates/widgets/ogcserver_fields.pt +23 -0
  38. c2cgeoportal_admin/templates/widgets/restriction_area_fields.pt +25 -9
  39. c2cgeoportal_admin/templates/widgets/role_fields.pt +52 -25
  40. c2cgeoportal_admin/templates/widgets/theme_fields.pt +23 -0
  41. c2cgeoportal_admin/templates/widgets/user_fields.pt +23 -0
  42. c2cgeoportal_admin/views/__init__.py +29 -0
  43. c2cgeoportal_admin/views/dimension_layers.py +14 -9
  44. c2cgeoportal_admin/views/functionalities.py +52 -18
  45. c2cgeoportal_admin/views/home.py +5 -5
  46. c2cgeoportal_admin/views/interfaces.py +29 -21
  47. c2cgeoportal_admin/views/layer_groups.py +36 -25
  48. c2cgeoportal_admin/views/layers.py +17 -13
  49. c2cgeoportal_admin/views/layers_cog.py +135 -0
  50. c2cgeoportal_admin/views/layers_vectortiles.py +62 -27
  51. c2cgeoportal_admin/views/layers_wms.py +61 -36
  52. c2cgeoportal_admin/views/layers_wmts.py +54 -32
  53. c2cgeoportal_admin/views/layertree.py +37 -28
  54. c2cgeoportal_admin/views/logged_views.py +83 -0
  55. c2cgeoportal_admin/views/logs.py +91 -0
  56. c2cgeoportal_admin/views/oauth2_clients.py +96 -0
  57. c2cgeoportal_admin/views/ogc_servers.py +192 -21
  58. c2cgeoportal_admin/views/restriction_areas.py +78 -25
  59. c2cgeoportal_admin/views/roles.py +88 -25
  60. c2cgeoportal_admin/views/themes.py +47 -35
  61. c2cgeoportal_admin/views/themes_ordering.py +44 -24
  62. c2cgeoportal_admin/views/treeitems.py +21 -17
  63. c2cgeoportal_admin/views/users.py +46 -26
  64. c2cgeoportal_admin/widgets.py +79 -28
  65. {c2cgeoportal_admin-2.5.0.100.dist-info → c2cgeoportal_admin-2.9rc44.dist-info}/METADATA +15 -13
  66. c2cgeoportal_admin-2.9rc44.dist-info/RECORD +97 -0
  67. {c2cgeoportal_admin-2.5.0.100.dist-info → c2cgeoportal_admin-2.9rc44.dist-info}/WHEEL +1 -1
  68. c2cgeoportal_admin-2.9rc44.dist-info/entry_points.txt +5 -0
  69. tests/__init__.py +36 -27
  70. tests/conftest.py +23 -24
  71. tests/test_edit_url.py +16 -19
  72. tests/test_functionalities.py +52 -14
  73. tests/test_home.py +0 -1
  74. tests/test_interface.py +35 -12
  75. tests/test_layer_groups.py +58 -32
  76. tests/test_layers_cog.py +243 -0
  77. tests/test_layers_vectortiles.py +46 -30
  78. tests/test_layers_wms.py +77 -82
  79. tests/test_layers_wmts.py +51 -30
  80. tests/test_layertree.py +107 -101
  81. tests/test_learn.py +1 -1
  82. tests/test_left_menu.py +0 -1
  83. tests/test_lingva_extractor_config.py +64 -0
  84. tests/test_logs.py +102 -0
  85. tests/test_main.py +4 -2
  86. tests/test_metadatas.py +79 -71
  87. tests/test_oauth2_clients.py +186 -0
  88. tests/test_ogc_servers.py +110 -28
  89. tests/test_restriction_areas.py +109 -20
  90. tests/test_role.py +142 -82
  91. tests/test_themes.py +75 -41
  92. tests/test_themes_ordering.py +1 -2
  93. tests/test_treegroup.py +2 -2
  94. tests/test_user.py +72 -70
  95. tests/themes_ordering.py +1 -2
  96. c2cgeoportal_admin/templates/navigation_vertical.jinja2 +0 -10
  97. c2cgeoportal_admin-2.5.0.100.dist-info/RECORD +0 -84
  98. c2cgeoportal_admin-2.5.0.100.dist-info/entry_points.txt +0 -3
  99. {c2cgeoportal_admin-2.5.0.100.dist-info → c2cgeoportal_admin-2.9rc44.dist-info}/top_level.txt +0 -0
@@ -1,3 +1,26 @@
1
+ {#
2
+ # The MIT License (MIT)
3
+ #
4
+ # Copyright (c) Camptocamp SA
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ # this software and associated documentation files (the "Software"), to deal in
8
+ # the Software without restriction, including without limitation the rights to
9
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ # the Software, and to permit persons to whom the Software is furnished to do so,
11
+ # subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #}
23
+
1
24
  {% extends "layout.jinja2" %}
2
25
 
3
26
  {% block extra_links %}
@@ -14,15 +37,26 @@
14
37
  {% block content %}
15
38
  <div id="layertree" class="container-fluid">
16
39
  <div id="toolbar">
17
- <div class="btn-group">
18
- {% if limit_exceeded %}
19
- <button id="layertree-expand" type="button" class="btn btn-default"><span class="glyphicon glyphicon-chevron-down"></span> {{_("Expand all")}}</button>
20
- {% endif %}
21
- <button id="layertree-collapse" type="button" class="btn btn-default"><span class="glyphicon glyphicon-chevron-up"></span> {{_("Collapse all")}}</button>
22
- </div>
23
- <div class="btn-group">
24
- <a id="layertree-ordering" class="btn btn-default" href="{{request.route_url('layertree_ordering')}}"><span class="glyphicon glyphicon-sort"></span> {{_("Edit themes order")}}</a>
25
- </div>
40
+ <form class="form-inline">
41
+ <div class="form-group">
42
+ <label for="interface">{{ _("Interface") }}</label>
43
+ <select class="form-control" id="interface">
44
+ <option value="all">{{ _("All") }}</option>
45
+ {% for interface in interfaces %}
46
+ <option>{{ interface.name }}</option>
47
+ {% endfor %}
48
+ </select>
49
+ </div>
50
+ <div class="btn-group">
51
+ {% if limit_exceeded %}
52
+ <button id="layertree-expand" type="button" class="btn btn-default"><span class="glyphicon glyphicon-chevron-down"></span> {{_("Expand all")}}</button>
53
+ {% endif %}
54
+ <button id="layertree-collapse" type="button" class="btn btn-default"><span class="glyphicon glyphicon-chevron-up"></span> {{_("Collapse all")}}</button>
55
+ </div>
56
+ <div class="btn-group">
57
+ <a id="layertree-ordering" class="btn btn-default" href="{{request.route_url('layertree_ordering')}}"><span class="glyphicon glyphicon-sort"></span> {{_("Edit themes order")}}</a>
58
+ </div>
59
+ </form>
26
60
  </div>
27
61
 
28
62
  <div id="tree"></div>
@@ -33,8 +67,14 @@
33
67
  core: {
34
68
  data: function(node, callback) {
35
69
  var url = "{{ request.route_url('layertree_children') }}";
70
+ let separator = '?';
36
71
  if (node.id != '#') {
37
72
  url += "?group_id=" + node.data.id + "&path=" + node.id;
73
+ separator = '&';
74
+ }
75
+ const interface = $('#interface')[0].value;
76
+ if (interface != 'all') {
77
+ url += separator + "interface=" + interface;
38
78
  }
39
79
  $.ajax({ url: url })
40
80
  .done(function(data) {
@@ -163,8 +203,7 @@
163
203
  type: $(this).data('method'),
164
204
  success: function(data) {
165
205
  if (this.type == 'DELETE') {
166
- //$grid.bootstrapTable('refresh');
167
- $jstree.jstree(true).delete_node(node_id);
206
+ $jstree.jstree(true).refresh();
168
207
  } else {
169
208
  window.location = data.redirect;
170
209
  }
@@ -204,6 +243,11 @@
204
243
  $('.jstree-grid-wrapper').height($(window).height() - $('nav').height() - $('#toolbar').height() - 50);
205
244
  $('.jstree-grid-wrapper').width('100%');
206
245
  });
246
+
247
+ const interfaceField = $('#interface');
248
+ interfaceField.on('change', function(e) {
249
+ $jstree.jstree(true).refresh();
250
+ });
207
251
  });
208
252
  </script>
209
253
 
@@ -1,3 +1,26 @@
1
+ {#
2
+ # The MIT License (MIT)
3
+ #
4
+ # Copyright (c) Camptocamp SA
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ # this software and associated documentation files (the "Software"), to deal in
8
+ # the Software without restriction, including without limitation the rights to
9
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ # the Software, and to permit persons to whom the Software is furnished to do so,
11
+ # subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #}
23
+
1
24
  <!DOCTYPE html>
2
25
  <html lang="{{request.locale_name}}">
3
26
  <head>
@@ -1,3 +1,26 @@
1
+ {#
2
+ # The MIT License (MIT)
3
+ #
4
+ # Copyright (c) Camptocamp SA
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ # this software and associated documentation files (the "Software"), to deal in
8
+ # the Software without restriction, including without limitation the rights to
9
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ # the Software, and to permit persons to whom the Software is furnished to do so,
11
+ # subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #}
23
+
1
24
  <nav class="navbar navbar-default">
2
25
  <div class="container-fluid">
3
26
  <!-- Brand and toggle get grouped for better mobile display -->
@@ -23,6 +46,39 @@
23
46
  {% endfor %}
24
47
  </ul>
25
48
 
49
+ <button id="help-button" type="button" class="btn btn-default navbar-btn navbar-right">{{_("Show help")}}</button>
50
+ <script>
51
+ $(function() {
52
+ const key = 'adminShowHelp';
53
+
54
+ const getCurrentValue = function() {
55
+ // Get current value from localStorage
56
+ // True by default
57
+ return localStorage.getItem(key) !== 'false'
58
+ }
59
+
60
+ const apply = function(value) {
61
+ // Apply some value on UI
62
+ if (value) {
63
+ $("#help-button").addClass("active")
64
+ $(".help-block").removeClass("hidden")
65
+ } else {
66
+ $("#help-button").removeClass("active")
67
+ $(".help-block").addClass("hidden")
68
+ }
69
+ }
70
+
71
+ $("#help-button").click(function() {
72
+ // Toggle value in localStorage and apply on UI
73
+ localStorage.setItem(key, getCurrentValue() ? 'false' : 'true');
74
+ apply(getCurrentValue())
75
+ })
76
+
77
+ // Apply current value from localStorage on UI
78
+ apply(getCurrentValue())
79
+ });
80
+ </script>
81
+
26
82
  <ul class="nav navbar-nav navbar-right">
27
83
  <li id="language-dropdown" class="dropdown">
28
84
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{request.locale_name}} <span class="caret"></span></a>
@@ -0,0 +1,90 @@
1
+ {#
2
+ # The MIT License (MIT)
3
+ #
4
+ # Copyright (c) Camptocamp SA
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ # this software and associated documentation files (the "Software"), to deal in
8
+ # the Software without restriction, including without limitation the rights to
9
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ # the Software, and to permit persons to whom the Software is furnished to do so,
11
+ # subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #}
23
+
24
+ {% extends "layout.jinja2" %}
25
+
26
+ {% block content %}
27
+ <div class="container-fluid">
28
+
29
+ <div class="panel panel-default form-panel">
30
+ <div class="panel-heading">
31
+ Synchronization of OGC Server "{{ogcserver.name}}"
32
+ </div>
33
+
34
+ <div class="panel-body">
35
+ <h3>Check layers validity</h3>
36
+ <p>Download the WMS Capabilities and for each <code>LayerWMS</code> item in this OGC server:</p>
37
+ <ul>
38
+ <li>verify that all the layers specified in <code>layer</code> field exists on the remote server;</li>
39
+ <li>if <code>style</code> field is not empty, it will also verify that the corresponding <code>&lt;Style&gt;</code> element is available;</li>
40
+ <li>and finally populate <code>valid</code> and <code>invalid_reason</code> fields with the results.</li>
41
+ </ul>
42
+ <p>Note that <code>valid</code> and <code>invalid_reason</code> fields have no effect on the front office,
43
+ they are only populated for your information in this back office.</p>
44
+ <form method="POST" class="deform" id="form-check">
45
+ <button type="submit" name="check" class="btn btn-default">{{_("Check layers validity")}}</button>
46
+ </form>
47
+ <hr/>
48
+ <h3>Dry run synchronize</h3>
49
+ <p>Run the synchronization and display the report but do not commit changes to the database.<p>
50
+ <form method="POST" class="deform" id="form-dry-run">
51
+ <button type="submit" name="dry-run" class="btn btn-default">{{_("Dry run synchronize")}}</button>
52
+ </form>
53
+ <hr/>
54
+ <h3>Synchronize</h3>
55
+ <p>Download the WMS Capabilities and for each &lt;Layer>&gt; element:</p>
56
+ <ul>
57
+ <li>if the <code>&lt;Layer&gt;</code> element does not contains any other <code>&lt;Layer&gt;</code> element, it will create a <code>LayerWMS</code> object;</li>
58
+ <li>else if the Layer element is at top level, it will create a <code>Theme</code> object;</li>
59
+ <li>else it will create a <code>Group</code> object.</li>
60
+ </ul>
61
+ <form method="POST" class="deform" id="form-synchronize">
62
+ <div class="form-group">
63
+ <input type="checkbox" name="force-parents" id="force-parents-field">
64
+ <label for="force-parents-field" class="control-label">{{_("Force parents re-initialization.")}}</label>
65
+ </div>
66
+ <div class="form-group">
67
+ <input type="checkbox" name="force-ordering" id="force-ordering-field">
68
+ <label for="force-ordering-field" class="control-label">{{_("Force children sorting, current server at top and other servers at bottom.")}}</label>
69
+ </div>
70
+ <div class="form-group">
71
+ <input type="checkbox" name="clean" id="clean">
72
+ <label for="clean" class="control-label">{{_("Remove unexisting layers and empty groups.")}}</label>
73
+ </div>
74
+ <button type="submit" name="synchronize" class="btn btn-primary">{{_("Synchronize")}}</button>
75
+ </form>
76
+ </div>
77
+ </div>
78
+
79
+ {% if success %}
80
+ <div class="alert alert-success">
81
+ <div class="msg-lbl">OGC Server has been successfully synchronized.</div>
82
+ </div>
83
+ {% endif %}
84
+
85
+ {% if report %}
86
+ <pre>{{ report }}</pre>
87
+ {% endif %}
88
+
89
+ </div>
90
+ {% endblock content %}
@@ -1,11 +1,43 @@
1
+ <tal:comment replace="nothing">
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) Camptocamp SA
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ this software and associated documentation files (the "Software"), to deal in
8
+ the Software without restriction, including without limitation the rights to
9
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ the Software, and to permit persons to whom the Software is furnished to do so,
11
+ subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ </tal:comment>
23
+
1
24
  <tal:def tal:define="title title|field.title;
2
25
  description description|field.description;
3
26
  errormsg errormsg|field.errormsg;
4
- item_template item_template|field.widget.item_template"
27
+ item_template item_template|field.widget.item_template;
28
+ label_field label_field|field.widget.label_field;
29
+ icon_class icons_class|field.widget.icon_class(child);
30
+ edit_url edit_url|field.widget.edit_url(field.schema.bindings['request'], child)"
5
31
  i18n:domain="deform">
6
32
 
7
- <div class="deform-order-button ">
8
- <div class="well"><span class="glyphicon icon-${treeitem.item_type}"></span> ${treeitem.name}</div>
33
+ <div class="orderable-item">
34
+ <div class="well">
35
+ <span tal:condition="icon_class" class="glyphicon ${icon_class}"></span>
36
+ ${getattr(child, label_field)}
37
+ <a tal:condition="edit_url" href="${edit_url}">
38
+ <span class="glyphicon glyphicon-pencil"></span>
39
+ </a>
40
+ </div>
9
41
 
10
42
  ${field.start_mapping()}
11
43
  <div tal:repeat="child field.children"
@@ -1,3 +1,26 @@
1
+ <tal:comment replace="nothing">
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) Camptocamp SA
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ this software and associated documentation files (the "Software"), to deal in
8
+ the Software without restriction, including without limitation the rights to
9
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ the Software, and to permit persons to whom the Software is furnished to do so,
11
+ subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ </tal:comment>
23
+
1
24
  <?python import json ?>
2
25
  <div tal:define="item_tmpl item_template|field.widget.item_template;
3
26
  oid oid|field.oid;
@@ -9,6 +32,7 @@
9
32
  now_len len(subfields);
10
33
  orderable orderable|field.widget.orderable;
11
34
  orderable orderable and 1 or 0;
35
+ child_input_name child_input_name|field.widget.child_input_name;
12
36
  prototype field.widget.prototype(field);
13
37
  title title|field.title;"
14
38
  class="deform-seq item-${field.schema.name}"
@@ -30,17 +54,19 @@
30
54
  <input type="hidden" name="__start__"
31
55
  value="${field.name}:sequence"
32
56
  class="deform-proto"
33
- tal:attributes="prototype prototype"/>
57
+ tal:attributes="prototype prototype;
58
+ attributes|field.widget.attributes|{};"/>
34
59
 
35
60
  <div class="panel panel-default">
36
61
  <div class="panel-heading">${title}</div>
37
-
38
62
  <div class="panel-body">
63
+
39
64
  <div class="deform-seq-container"
40
65
  id="${oid}-orderable">
41
66
  <div tal:define="subfields [ x[1] for x in subfields ]"
42
67
  tal:repeat="subfield subfields"
43
- tal:replace="structure subfield.render_template(item_tmpl, parent=field)" />
68
+ tal:replace="structure subfield.render_template(item_tmpl,
69
+ parent=field)" />
44
70
  <span class="deform-insert-before"
45
71
  tal:attributes="
46
72
  min_len min_len;
@@ -48,97 +74,100 @@
48
74
  now_len now_len;
49
75
  orderable orderable;"></span>
50
76
  </div>
51
- </div>
52
77
 
53
- <div class="panel-footer" tal:condition="field.widget.add_subitem">
54
- <div class="magicsuggest"></div>
55
78
  </div>
56
- </div>
57
79
 
58
- <input type="hidden" name="__end__" value="${field.name}:sequence"/>
59
- <!-- /sequence -->
60
-
61
- <script type="text/javascript">
62
- deform.addCallback(
63
- '${field.oid}',
64
- function(oid) {
65
- oid_node = $('#'+ oid);
66
- deform.processSequenceButtons(oid_node, ${min_len},
67
- ${max_len}, ${now_len},
68
- ${orderable});
69
- oid_node.find('.deform-order-button').show();
70
-
71
- var ms = $('#'+ oid + ' .magicsuggest').magicSuggest({
72
- data: ${ structure: json.dumps(treeitems, indent=4, separators=(',', ': ')) },
73
- renderer: function(data) {
74
- return '<span class="glyphicon icon-' + data.item_type + '"></span> ' + data.name;
75
- },
76
- valueField: 'id',
77
- displayField: 'name',
78
- groupBy: 'group',
79
- allowFreeEntries: false,
80
- maxDropHeight: 500
81
- });
82
-
83
- $(ms).on('selectionchange', function(e, m) {
84
- this.getSelection().forEach(function(selecteditem) {
85
-
86
- // Search for the corresponding item in sequence
87
- var $el = $('#'+ oid).find('.deform-seq-item input[name="treeitem_id"][value="' + selecteditem.id + '"]');
88
-
89
- // If item is already sequence, flash it to the user
90
- if ($el.length > 0) {
91
- for (var i=0; i<3; i++) {
92
- $el.closest('.deform-seq-item').
93
- fadeOut(100).
94
- fadeIn(100)
95
- }
96
- }
97
- else {
98
- // Add item in sequence
99
- deform.appendSequenceItem('#'+ oid);
100
-
101
- // Set title and treeitem_id
102
- var $itemnode = $('#'+ oid).find('.deform-insert-before').last().prev();
103
- $itemnode.find('.well').html('<span class="glyphicon icon-' + selecteditem.item_type + '"></span> ' + selecteditem.name);
104
- $itemnode.find('input[name="treeitem_id"]').val(selecteditem.id);
105
- $itemnode.find('.deform-order-button').show();
106
- }
107
- });
108
- this.removeFromSelection(this.getSelection(), true);
109
- });
110
- }
111
- )
112
- <tal:block condition="orderable">
113
- $( "#${oid}-orderable" ).sortable({
114
- handle: ".deform-order-button, .panel-heading",
115
- containerSelector: "#${oid}-orderable",
116
- itemSelector: ".deform-seq-item",
117
- placeholder: '<span class="glyphicon glyphicon-arrow-right placeholder"></span>',
118
- onDragStart: function ($item, container, _super) {
119
- var offset = $item.offset(),
120
- pointer = container.rootGroup.pointer
121
-
122
- adjustment = {
123
- left: pointer.left - offset.left,
124
- top: pointer.top - offset.top
125
- }
126
-
127
- _super($item, container)
128
- },
129
- onDrag: function ($item, position) {
130
- $item.css({
131
- left: position.left - adjustment.left,
132
- top: position.top - adjustment.top
133
- })
134
- }});
135
-
136
- // Deform hide sequence .deform-order-button when has_multiple change to false,
137
- // but icon and title are inside .deform-order-button in our case.
138
- $('#deform').on('change', function(e) {
139
- $('#${oid} .deform-order-button').show();
140
- });
141
- </tal:block>
142
- </script>
80
+ <div class="panel-footer">
81
+ <div
82
+ class="magicsuggest"
83
+ tal:condition="field.widget.add_subitem"
84
+ ></div>
85
+
86
+ <script type="text/javascript">
87
+ deform.addCallback(
88
+ '${field.oid}',
89
+ function(oid) {
90
+ oid_node = $('#'+ oid);
91
+ deform.processSequenceButtons(oid_node, ${min_len},
92
+ ${max_len}, ${now_len},
93
+ ${orderable});
94
+
95
+ var ms = $('#'+ oid + ' .magicsuggest').magicSuggest({
96
+ data: ${ structure: json.dumps(candidates, indent=4, separators=(',', ': ')) },
97
+ renderer: function(data) {
98
+ return '<span class="glyphicon ' + data.icon_class + '"></span> ' + data.label;
99
+ },
100
+ valueField: 'id',
101
+ displayField: 'label',
102
+ groupBy: 'group',
103
+ allowFreeEntries: false,
104
+ maxDropHeight: 500
105
+ });
106
+
107
+ $(ms).on('selectionchange', function(e, m) {
108
+ this.getSelection().forEach(function(selecteditem) {
109
+
110
+ // Search for the corresponding item in sequence
111
+ var $el = $('#'+ oid).find('.deform-seq-item input[name="${child_input_name}"][value="' + selecteditem.id + '"]');
112
+
113
+ // If item is already sequence, flash it to the user
114
+ if ($el.length > 0) {
115
+ for (var i=0; i<3; i++) {
116
+ $el.closest('.deform-seq-item').
117
+ fadeOut(100).
118
+ fadeIn(100)
119
+ }
120
+ }
121
+ else {
122
+ // Add item in sequence
123
+ deform.appendSequenceItem('#'+ oid);
124
+
125
+ // Set title and treeitem_id
126
+ var $itemnode = $('#'+ oid).find('.deform-insert-before').last().prev();
127
+ $itemnode.find('.well').html(
128
+ '<span class="glyphicon ' + selecteditem.icon_class + '"></span> ' +
129
+ selecteditem.label +
130
+ ' <a href="' + selecteditem.edit_url + '">' +
131
+ '<span class="glyphicon glyphicon-pencil"></span>' +
132
+ '</a>'
133
+ );
134
+ $itemnode.find('input[name="${child_input_name}"]').val(selecteditem.id);
135
+ }
136
+ });
137
+ this.removeFromSelection(this.getSelection(), true);
138
+ });
139
+ }
140
+ )
141
+ <tal:block condition="orderable">
142
+ $( "#${oid}-orderable" ).sortable({
143
+ handle: ".deform-order-button, .panel-heading, .orderable-item",
144
+ containerSelector: "#${oid}-orderable",
145
+ itemSelector: ".deform-seq-item",
146
+ placeholder: '<span class="glyphicon glyphicon-arrow-right placeholder"></span>',
147
+ onDragStart: function ($item, container, _super) {
148
+ var offset = $item.offset(),
149
+ pointer = container.rootGroup.pointer
150
+
151
+ adjustment = {
152
+ left: pointer.left - offset.left,
153
+ top: pointer.top - offset.top
154
+ }
155
+
156
+ _super($item, container)
157
+ },
158
+ onDrag: function ($item, position) {
159
+ $item.css({
160
+ left: position.left - adjustment.left,
161
+ top: position.top - adjustment.top
162
+ })
163
+ }
164
+ });
165
+ </tal:block>
166
+ </script>
167
+
168
+ <input type="hidden" name="__end__" value="${field.name}:sequence"/>
169
+ <!-- /sequence -->
170
+ </div>
143
171
 
172
+ </div>
144
173
  </div>
@@ -1,3 +1,26 @@
1
+ <tal:comment replace="nothing">
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) Camptocamp SA
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ this software and associated documentation files (the "Software"), to deal in
8
+ the Software without restriction, including without limitation the rights to
9
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ the Software, and to permit persons to whom the Software is furnished to do so,
11
+ subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ </tal:comment>
23
+
1
24
  <tal:def tal:define="title title|field.title;
2
25
  name name|field.name;
3
26
  type type|field.type;
@@ -1,3 +1,26 @@
1
+ <tal:comment replace="nothing">
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) Camptocamp SA
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ this software and associated documentation files (the "Software"), to deal in
8
+ the Software without restriction, including without limitation the rights to
9
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ the Software, and to permit persons to whom the Software is furnished to do so,
11
+ subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ </tal:comment>
23
+
1
24
  <div class="item-dimensions">
2
25
  <tal metal:use-macro='load:sequence.pt'></tal>
3
26
  </div>