g3w-admin-qplotly 0.0.1__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 (139) hide show
  1. g3w_admin_qplotly-0.0.1.dist-info/METADATA +52 -0
  2. g3w_admin_qplotly-0.0.1.dist-info/RECORD +139 -0
  3. g3w_admin_qplotly-0.0.1.dist-info/WHEEL +5 -0
  4. g3w_admin_qplotly-0.0.1.dist-info/licenses/LICENSE +373 -0
  5. g3w_admin_qplotly-0.0.1.dist-info/top_level.txt +1 -0
  6. qplotly/__init__.py +1 -0
  7. qplotly/admin.py +34 -0
  8. qplotly/api/__init__.py +0 -0
  9. qplotly/api/plots/__init__.py +0 -0
  10. qplotly/api/plots/views.py +211 -0
  11. qplotly/api/widgets/__init__.py +0 -0
  12. qplotly/api/widgets/permissions.py +79 -0
  13. qplotly/api/widgets/serializers.py +109 -0
  14. qplotly/api/widgets/views.py +287 -0
  15. qplotly/apiurls.py +132 -0
  16. qplotly/apps.py +11 -0
  17. qplotly/locale/bg/LC_MESSAGES/django.mo +0 -0
  18. qplotly/locale/bg/LC_MESSAGES/django.po +162 -0
  19. qplotly/locale/de/LC_MESSAGES/django.mo +0 -0
  20. qplotly/locale/de/LC_MESSAGES/django.po +126 -0
  21. qplotly/locale/de/LC_MESSAGES/djangojs.mo +0 -0
  22. qplotly/locale/de/LC_MESSAGES/djangojs.po +221 -0
  23. qplotly/locale/es/LC_MESSAGES/django.mo +0 -0
  24. qplotly/locale/es/LC_MESSAGES/django.po +151 -0
  25. qplotly/locale/es/LC_MESSAGES/djangojs.mo +0 -0
  26. qplotly/locale/es/LC_MESSAGES/djangojs.po +232 -0
  27. qplotly/locale/fi/LC_MESSAGES/django.mo +0 -0
  28. qplotly/locale/fi/LC_MESSAGES/django.po +126 -0
  29. qplotly/locale/fi/LC_MESSAGES/djangojs.mo +0 -0
  30. qplotly/locale/fi/LC_MESSAGES/djangojs.po +222 -0
  31. qplotly/locale/fr/LC_MESSAGES/django.mo +0 -0
  32. qplotly/locale/fr/LC_MESSAGES/django.po +160 -0
  33. qplotly/locale/fr/LC_MESSAGES/djangojs.mo +0 -0
  34. qplotly/locale/fr/LC_MESSAGES/djangojs.po +222 -0
  35. qplotly/locale/it/LC_MESSAGES/django.mo +0 -0
  36. qplotly/locale/it/LC_MESSAGES/django.po +163 -0
  37. qplotly/locale/it/LC_MESSAGES/djangojs.mo +0 -0
  38. qplotly/locale/it/LC_MESSAGES/djangojs.po +220 -0
  39. qplotly/locale/pl/LC_MESSAGES/django.mo +0 -0
  40. qplotly/locale/pl/LC_MESSAGES/django.po +129 -0
  41. qplotly/locale/pl/LC_MESSAGES/djangojs.mo +0 -0
  42. qplotly/locale/pl/LC_MESSAGES/djangojs.po +217 -0
  43. qplotly/locale/pt/LC_MESSAGES/django.mo +0 -0
  44. qplotly/locale/pt/LC_MESSAGES/django.po +160 -0
  45. qplotly/locale/ro/LC_MESSAGES/django.mo +0 -0
  46. qplotly/locale/ro/LC_MESSAGES/django.po +128 -0
  47. qplotly/locale/ro/LC_MESSAGES/djangojs.mo +0 -0
  48. qplotly/locale/ro/LC_MESSAGES/djangojs.po +222 -0
  49. qplotly/locale/se/LC_MESSAGES/django.mo +0 -0
  50. qplotly/locale/se/LC_MESSAGES/django.po +126 -0
  51. qplotly/locale/se/LC_MESSAGES/djangojs.mo +0 -0
  52. qplotly/locale/se/LC_MESSAGES/djangojs.po +222 -0
  53. qplotly/migrations/0001_initial.py +26 -0
  54. qplotly/migrations/0002_qplotlywidget_type.py +18 -0
  55. qplotly/migrations/0003_auto_20200925_0838.py +18 -0
  56. qplotly/migrations/0004_auto_20200925_1535.py +25 -0
  57. qplotly/migrations/0005_qplotlywidget_show_on_start_client.py +18 -0
  58. qplotly/migrations/0006_alter_qplotlywidget_options_qplotlywidget_order.py +23 -0
  59. qplotly/migrations/0007_alter_qplotlywidget_options_and_more.py +22 -0
  60. qplotly/migrations/0008_alter_qplotlywidget_order.py +18 -0
  61. qplotly/migrations/0009_qplotlywidget_show_in_sidebar.py +18 -0
  62. qplotly/migrations/0010_remove_qplotlywidget_show_in_sidebar_and_more.py +22 -0
  63. qplotly/migrations/0011_rename_show_poistion_qplotlywidget_show_position.py +18 -0
  64. qplotly/migrations/0012_qplotlywidgetrelation_qplotlywidget_related_widgets.py +34 -0
  65. qplotly/migrations/0013_alter_qplotlywidgetrelation_source_and_more.py +24 -0
  66. qplotly/migrations/0014_alter_qplotlywidgetrelation_source_and_more.py +24 -0
  67. qplotly/migrations/0015_qplotlywidgetrelation_project.py +34 -0
  68. qplotly/migrations/0016_remove_qplotlywidget_project.py +17 -0
  69. qplotly/migrations/__init__.py +0 -0
  70. qplotly/models.py +142 -0
  71. qplotly/receivers.py +356 -0
  72. qplotly/requirements.txt +1 -0
  73. qplotly/server_filters/__init__.py +1 -0
  74. qplotly/server_filters/relations.py +32 -0
  75. qplotly/static/qplotly/icons/2dhistogram.svg +2048 -0
  76. qplotly/static/qplotly/icons/barplot.svg +2048 -0
  77. qplotly/static/qplotly/icons/boxplot.svg +2048 -0
  78. qplotly/static/qplotly/icons/contour.svg +2056 -0
  79. qplotly/static/qplotly/icons/histogram.svg +2048 -0
  80. qplotly/static/qplotly/icons/pie.svg +2048 -0
  81. qplotly/static/qplotly/icons/polar.svg +2055 -0
  82. qplotly/static/qplotly/icons/scatterplot.svg +2048 -0
  83. qplotly/static/qplotly/icons/scatterternary.svg +2055 -0
  84. qplotly/static/qplotly/icons/violin.svg +2878 -0
  85. qplotly/static/qplotly/js/data-widget-qplotlyWidgetList.js +373 -0
  86. qplotly/static/qplotly/js/i18n/bg.js +19 -0
  87. qplotly/static/qplotly/js/i18n/de.js +19 -0
  88. qplotly/static/qplotly/js/i18n/en.js +19 -0
  89. qplotly/static/qplotly/js/i18n/fi.js +19 -0
  90. qplotly/static/qplotly/js/i18n/fr.js +19 -0
  91. qplotly/static/qplotly/js/i18n/index.js +19 -0
  92. qplotly/static/qplotly/js/i18n/it.js +19 -0
  93. qplotly/static/qplotly/js/i18n/ro.js +19 -0
  94. qplotly/static/qplotly/js/i18n/se.js +19 -0
  95. qplotly/static/qplotly/js/i18n/uk.js +19 -0
  96. qplotly/static/qplotly/js/plugin.js +927 -0
  97. qplotly/static/qplotly/js/sidebar.js +373 -0
  98. qplotly/static/qplotly/js/widget.js +9 -0
  99. qplotly/static/qplotly/plotly-1.52.2.min.js +7 -0
  100. qplotly/static/qplotly/polyfill.min.js +3 -0
  101. qplotly/templates/qplotly/include/plot_type_icon.html +52 -0
  102. qplotly/templates/qplotly/layer_action.html +13 -0
  103. qplotly/templates/qplotly/plots_list_order.html +68 -0
  104. qplotly/templates/qplotly/plots_list_order_action.html +14 -0
  105. qplotly/templatetags/__init__.py +0 -0
  106. qplotly/templatetags/qplotly_tags.py +28 -0
  107. qplotly/urls.py +52 -0
  108. qplotly/utils/__init__.py +13 -0
  109. qplotly/utils/models.py +86 -0
  110. qplotly/utils/qplotly_factory.py +699 -0
  111. qplotly/utils/qplotly_settings.py +37 -0
  112. qplotly/vendor/DataPlotly/__init__.py +0 -0
  113. qplotly/vendor/DataPlotly/core/__init__.py +0 -0
  114. qplotly/vendor/DataPlotly/core/plot_factory.py +843 -0
  115. qplotly/vendor/DataPlotly/core/plot_settings.py +322 -0
  116. qplotly/vendor/DataPlotly/core/plot_types/__init__.py +20 -0
  117. qplotly/vendor/DataPlotly/core/plot_types/bar_plot.py +83 -0
  118. qplotly/vendor/DataPlotly/core/plot_types/box.py +56 -0
  119. qplotly/vendor/DataPlotly/core/plot_types/contour.py +43 -0
  120. qplotly/vendor/DataPlotly/core/plot_types/histogram.py +66 -0
  121. qplotly/vendor/DataPlotly/core/plot_types/histogram2d.py +39 -0
  122. qplotly/vendor/DataPlotly/core/plot_types/icons/2dhistogram.svg +2048 -0
  123. qplotly/vendor/DataPlotly/core/plot_types/icons/barplot.svg +2048 -0
  124. qplotly/vendor/DataPlotly/core/plot_types/icons/boxplot.svg +2048 -0
  125. qplotly/vendor/DataPlotly/core/plot_types/icons/contour.svg +2056 -0
  126. qplotly/vendor/DataPlotly/core/plot_types/icons/histogram.svg +2048 -0
  127. qplotly/vendor/DataPlotly/core/plot_types/icons/pie.svg +2048 -0
  128. qplotly/vendor/DataPlotly/core/plot_types/icons/polar.svg +2055 -0
  129. qplotly/vendor/DataPlotly/core/plot_types/icons/scatterplot.svg +2048 -0
  130. qplotly/vendor/DataPlotly/core/plot_types/icons/scatterternary.svg +2055 -0
  131. qplotly/vendor/DataPlotly/core/plot_types/icons/violin.svg +2878 -0
  132. qplotly/vendor/DataPlotly/core/plot_types/pie.py +60 -0
  133. qplotly/vendor/DataPlotly/core/plot_types/plot_type.py +170 -0
  134. qplotly/vendor/DataPlotly/core/plot_types/polar.py +63 -0
  135. qplotly/vendor/DataPlotly/core/plot_types/scatter.py +74 -0
  136. qplotly/vendor/DataPlotly/core/plot_types/ternary.py +129 -0
  137. qplotly/vendor/DataPlotly/core/plot_types/violin.py +62 -0
  138. qplotly/vendor/__init__.py +0 -0
  139. qplotly/views.py +148 -0
@@ -0,0 +1,373 @@
1
+ /**
2
+ * @file ORIGINAL SOURCE: g3w-admin/qplotly/static/qplotly/js/widget.js@v3.9.
3
+ * @since g3w-admin@v3.10.0
4
+ */
5
+
6
+ const { SITE_PREFIX_URL, FRONTEND } = SETTINGS;
7
+
8
+ // TODO: we can safely remove this when ".magic-checkbox" will be deprecated
9
+ document.head.insertAdjacentHTML('beforeend', `<style>
10
+ .qplotly input[type="checkbox"] { accent-color: #1abc9c; width: 1.25em; aspect-ratio: 1; }
11
+ .qplotly :is(th, td) { padding: 8px; }
12
+ </style>`);
13
+
14
+ /**
15
+ * [data-widget-type="qplotlyWidgetList"]
16
+ */
17
+ export default async function qplotlyWidgetList($datatable, $item, refresh = false) {
18
+ try {
19
+
20
+ if (!SETTINGS.G3WADMIN_LOCAL_MORE_APPS.includes('qplotly')) {
21
+ return;
22
+ }
23
+
24
+ const url = $item.attr('data-qplotlywidget-list-url');
25
+ if (undefined === url) {
26
+ throw new Error('data-qplotlywidget-list-url is not defined');
27
+ }
28
+
29
+ const tr = $item.closest('tr');
30
+ const row = $datatable.row(tr);
31
+
32
+ if (!(!!refresh || !row.child.isShown())) {
33
+ row.child.hide();
34
+ return;
35
+ }
36
+
37
+ const res = await (await fetch(url)).json();
38
+
39
+ // Build plots table
40
+ const layer_pk = $item.attr('data-qplotlywidget-layer-pk');
41
+ const project_pk = $item.attr('data-qplotlywidget-project-pk');
42
+
43
+ const $div = $(/* html */`
44
+ <div class="qplotly" style="margin-left:40px;">
45
+ <!-- add new plot -->
46
+ <a href="#" class="btn btn-sm btn-default btn-add-new-plot"><i class="fa fa-plus-circle"></i> ${gettext('New qplotly widget')}</a>
47
+ <!-- saved plots -->
48
+ <p class="text-muted"><small>* ${gettext('Position options is valid for children layers of a relation')}</small></p>
49
+ <table style="width: 100%;">
50
+ <thead>
51
+ <tr>
52
+ <th style="width:180px;">${gettext('Actions')}</th>
53
+ <th>${gettext('Active at startup')}</th>
54
+ <th>${gettext('Position')}*</th>
55
+ <th>${gettext('Title')}</th>
56
+ <th>${gettext('Type')}</th>
57
+ <th>${gettext('Linked')}</th>
58
+ </tr>
59
+ </thead>
60
+ <tbody>
61
+ ${res.map(v => /* html */ `
62
+ <tr id="qplotlywidget-item-${v.pk}">
63
+ <td style="display: flex; flex-wrap: wrap; gap: 0 10px; font-size: 1.25em;">
64
+ <a
65
+ style="display:${v.rule_count > 0 ? 'none' : 'display'}"
66
+ href="#"
67
+ data-toggle="tooltip"
68
+ title="${gettext('Edit')}"
69
+ data-qplotlywidget-action-mode="update"
70
+ data-qplotlywidget-pk="${v.pk}"
71
+ data-qplotlywidget-layer-id="${layer_pk}"
72
+ >
73
+ <i class="fa fa-pencil"></i>
74
+ </a>
75
+ <a
76
+ href="#"
77
+ data-toggle="tooltip"
78
+ title="${gettext('Delete')}"
79
+ data-widget-type="deleteItem"
80
+ data-delete-url="/${SITE_PREFIX_URL}qplotly/api/widget/detail/${project_pk}/${v.pk}/"
81
+ data-item-selector="#qplotlywidget-item-${v.pk}"
82
+ data-delete-method="delete"
83
+ >
84
+ <i class="fa fa-trash" style="color:red;"></i>
85
+ </a>
86
+ <a
87
+ style="display:${v.rule_count > 0 ? 'none' : 'display'}"
88
+ href="/${SETTINGS.CURRENT_LANGUAGE_CODE}/${SITE_PREFIX_URL}${FRONTEND ? 'admin/' : ''}qplotly/download/xml/${v.pk}/"
89
+ data-toggle="tooltip"
90
+ title="${gettext('Download')}"
91
+ >
92
+ <i class="fa fa-download"></i>
93
+ </a>
94
+ <a
95
+ style="display:${v.rule_count > 0 ? 'none' : 'display'}"
96
+ href="#"
97
+ data-toggle="tooltip"
98
+ title="${gettext('Related widgets')}"
99
+ data-qplotlywidget-action-mode="related"
100
+ data-qplotlywidget-pk="${v.pk}"
101
+ data-qplotlywidget-layer-id="${layer_pk}"
102
+ >
103
+ <i class="fa fa-sitemap"></i>
104
+ </a>
105
+ </td>
106
+ <td>
107
+ <input
108
+ type="checkbox"
109
+ name="show_on_start_client"
110
+ value="1"
111
+ data-qplotlywidget-pk="${v.pk}"
112
+ ${v.show_on_start_client ? 'checked' : ''}
113
+ onchange="fetch('/${SETTINGS.CURRENT_LANGUAGE_CODE}/${SITE_PREFIX_URL}${FRONTEND ? 'admin/' : ''}qplotly/showonstartclient/${v.pk}/' + (event.target.checked ? '' : '?show=0')).catch(g3wadmin.widget.showError)"
114
+ />
115
+ </td>
116
+ <td>
117
+ <select
118
+ id = "'qplotly-show-position-'${v.pk}"
119
+ data-qplotlywidget-pk = "${v.pk}"
120
+ class = "form-control select2 "
121
+ onchange = "fetch('/${SETTINGS.CURRENT_LANGUAGE_CODE}/${SITE_PREFIX_URL}${FRONTEND ? 'admin/' : ''}qplotly/showposition/${v.pk}/', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ value: event.target.value }), }).catch(g3wadmin.widget.showError)"
122
+ >
123
+ <option value = "sidebarquery" ${'sidebarquery' === v.show_position ? 'selected' : ''}>Sidebar, Query</option>
124
+ <option value = "sidebar" ${'sidebar' === v.show_position ? 'selected' : ''}>Sidebar</option>
125
+ <option value = "query" ${'query' === v.show_position ? 'selected' : ''}>Query</option>
126
+ </select>
127
+ </td>
128
+ <td>${v.title}</td>
129
+ <td>${v.type}</td>
130
+ <td>
131
+ <input
132
+ type="checkbox"
133
+ name="linked"
134
+ value="1"
135
+ ${($.inArray(parseInt(layer_pk), v.layers) != -1) ? 'checked' : ''}
136
+ onchange="fetch('/${SETTINGS.CURRENT_LANGUAGE_CODE}/${SITE_PREFIX_URL}${FRONTEND ? 'admin/' : ''}qplotly/layer/${layer_pk}/widgets/link/${v.pk}/' + (event.target.checked ? '' : '?unlink=unlink')).catch(g3wadmin.widget.showError)"
137
+ />
138
+ </td>
139
+ </tr>`).join('')}
140
+ </tbody>
141
+ </table>
142
+ </div>
143
+ `);
144
+
145
+ // attach events
146
+
147
+ // shared: re-fetch free widget PKs and hide/show sitemap buttons accordingly
148
+ const refreshButtonsVisibility = async () => {
149
+ const notTargetPks = new Set(
150
+ (await fetch(`/${SITE_PREFIX_URL}qplotly/api/widget/free/${project_pk}/${layer_pk}/`).then(r => r.json())).map(String)
151
+ );
152
+ $div.find('[data-qplotlywidget-action-mode="related"]').each(function () {
153
+ const pk = $(this).attr('data-qplotlywidget-pk');
154
+ const isVisible = notTargetPks.has(pk);
155
+ $(this).toggle(isVisible);
156
+ $div.find(`input[name="show_on_start_client"][data-qplotlywidget-pk="${pk}"]`).toggle(isVisible);
157
+ $div.find(`select[data-qplotlywidget-pk="${pk}"]`).toggle(isVisible);
158
+ });
159
+ };
160
+
161
+ $div.on("click", ".btn-add-new-plot, [data-qplotlywidget-action-mode='update']", async function (e) {
162
+ if ($(this).is('.btn-add-new-plot') || $(this).is('[data-qplotlywidget-action-mode="update"]')) {
163
+ const PLOT = res.find(v => `${v.pk}` === $(this).attr("data-qplotlywidget-pk"));
164
+
165
+ const modal = ga.currentModal = g3wadmin.ui._buildModal({
166
+ modalTitle: gettext(PLOT ? 'Update widget' : 'New qplotly widget'),
167
+ modalBody: /* html */ `
168
+ <form action="/${SITE_PREFIX_URL}qplotly/api/widget/${PLOT?.pk ? `detail/${project_pk}/${PLOT?.pk}/` : `layer/${layer_pk}/`}" id="form-qplotlywidget-${layer_pk}" class="qplotly-new-widget-form">
169
+ <div class="qplotly-new-widget-shell">
170
+ <div class="form-errors"></div>
171
+ <input type="hidden" name="xml" value="" />
172
+
173
+ <div class="qplotly-intro">
174
+ <i class="fa fa-area-chart"></i>
175
+ <div>
176
+ <strong>${gettext(PLOT ? 'Update qplotly widget' : 'New qplotly widget')}</strong>
177
+ <span>${gettext('Upload a DataPlotly configuration XML file to build the chart widget for this layer.')}</span>
178
+ </div>
179
+ </div>
180
+
181
+ <div class="form-group qplotly-dropzone">
182
+ <label class="controls qq-upload-button-selector qplotly-dropzone-inner" for="load_xml_plot">
183
+ <input class="form-control qplotly-dropzone-input" id="load_xml_plot" accept=".xml" title="" name="xml_file" type="file" />
184
+ <i class="fa fa-upload" aria-hidden="true"></i>
185
+ <strong>${gettext('Click to browse or drop your .xml file')}</strong>
186
+ <span>${gettext('Only DataPlotly XML files are accepted')}</span>
187
+ </label>
188
+ <div id="xml_plot_filename" class="qplotly-filename" style="display: none;"></div>
189
+ </div>
190
+ </div>
191
+ </form>`,
192
+ });
193
+
194
+ modal.data.$evoker = $item;
195
+
196
+ const form = modal.$modal.find('form')[0];
197
+ const g3w_form = Object.assign(new ga.forms.form($(form)), {
198
+ successAction: e => { qplotlyWidgetList($datatable, $item, true); modal.hide(); },
199
+ errorAction: (xhr, msg) => {
200
+ form.querySelector('.form-errors').innerHTML = /* html */`
201
+ <h4 class="badge bg-red">${xhr.responseJSON.error.message}</h4>
202
+ ${(xhr.responseJSON.error.data.non_field_errors || []).map(e => `<p>${e}</p>`).join('')}
203
+ `;
204
+ }
205
+ });
206
+
207
+ $('input[name="xml"]').val(PLOT?.xml || '');
208
+
209
+ // read and set input[name="xml"] value
210
+ $(form).find('[name="xml_file"]').on('change', function (evt) {
211
+ const reader = new FileReader();
212
+ const file = evt.target.files[0];
213
+ const filename = file.name;
214
+ reader.onload = (evt) => {
215
+ const data = evt.target.result;
216
+ $('input[name="xml"]').val(data);
217
+ $('#xml_plot_filename').text(filename).show();
218
+ };
219
+ reader.readAsText(file);
220
+ });
221
+
222
+ modal.$modal.find('.modal-button-confirm').on('click', function (e) {
223
+ g3w_form.sendData(e, PLOT ? 'put' : 'post', JSON.stringify(Object.assign(g3w_form.getData('array'), { layers: [layer_pk] })), 'application/json; charset=UTF-8');
224
+ });
225
+
226
+ modal.show();
227
+
228
+ // init form
229
+ Object.entries(PLOT || {}).forEach(([k,v]) => modal.$modal.find('[name=' + k + ']').val(v)); // TODO: check if superflous
230
+ }
231
+ });
232
+
233
+ $div.on("click", "[data-qplotlywidget-action-mode='related']", async function (e) {
234
+ e.preventDefault();
235
+ const PLOT = res.find(v => `${v.pk}` === $(this).attr("data-qplotlywidget-pk"));
236
+ const relatedReadUrl = `/${SITE_PREFIX_URL}qplotly/api/widget/related/${PLOT.pk}/${PLOT.project}/`;
237
+ const relatedWriteUrl = `/${SITE_PREFIX_URL}qplotly/api/widget/related/${PLOT.pk}/`;
238
+
239
+ // widgets available as targets: fetched from dedicated API endpoint
240
+ const availableUrl = `/${SITE_PREFIX_URL}qplotly/api/widget/related/${PLOT.pk}/available/${PLOT.project}/`;
241
+ const fetchAvailable = () => fetch(availableUrl).then(r => r.json());
242
+
243
+ const buildTable = (relatedWidgets) => /* html */ `
244
+ <table class="table table-bordered table-condensed" style="width:100%">
245
+ <thead>
246
+ <tr>
247
+ <th style="width:20px;"></th>
248
+ <th>${gettext('Title')}</th>
249
+ <th>${gettext('Type')}</th>
250
+ <th></th>
251
+ </tr>
252
+ </thead>
253
+ <tbody>
254
+ ${relatedWidgets.length === 0
255
+ ? /* html */`<tr><td colspan="4" class="text-center text-muted">${gettext('No related widgets')}</td></tr>`
256
+ : relatedWidgets.map(w => /* html */`
257
+ <tr id="related-widget-row-${w.id}" data-related-pk="${w.id}">
258
+ <td class="drag-handle" style="cursor:grab; color:#aaa;"><i class="fa fa-bars"></i></td>
259
+ <td>${w.title || '-'}</td>
260
+ <td>${w.type || '-'}</td>
261
+ <td>
262
+ ${w.id !== PLOT.pk ? /* html */`
263
+ <a href="#" class="btn btn-xs btn-danger btn-remove-related" data-related-target-pk="${w.id}">
264
+ <i class="fa fa-trash"></i>
265
+ </a>` : ''}
266
+ </td>
267
+ </tr>`).join('')
268
+ }
269
+ </tbody>
270
+ </table>`;
271
+
272
+ // fetch current related widgets and available widgets in parallel
273
+ const [related, available] = await Promise.all([
274
+ fetch(relatedReadUrl).then(r => r.json()),
275
+ fetchAvailable(),
276
+ ]);
277
+
278
+ const buildSelect = (availableWidgets) =>
279
+ `<option value="">${gettext('Select a widget...')}</option>` +
280
+ availableWidgets.map(w => `<option value="${w.id}">${w.title || w.id} (${w.type || '-'})</option>`).join('');
281
+
282
+ await refreshButtonsVisibility();
283
+
284
+ const modal = ga.currentModal = g3wadmin.ui._buildModal({
285
+ modalTitle: gettext('Related widgets'),
286
+ confirmButton: false,
287
+ modalBody: /* html */`
288
+ <div id="related-widgets-container">
289
+ ${buildTable(related)}
290
+ </div>
291
+ <hr/>
292
+ <div style="display:flex; gap:8px; align-items:center; flex-wrap:wrap;">
293
+ <select class="form-control" id="related-widget-select" style="flex:1; min-width:150px;">
294
+ ${buildSelect(available)}
295
+ </select>
296
+ <button class="btn btn-primary btn-sm" id="btn-add-related">
297
+ <i class="fa fa-plus"></i> ${gettext('Add')}
298
+ </button>
299
+ </div>`,
300
+ });
301
+
302
+
303
+ const initSortable = () => {
304
+ const $container = modal.$modal.find('#related-widgets-container tbody');
305
+ $container.sortable({
306
+ handle: '.drag-handle',
307
+ axis: 'y',
308
+ update() {
309
+ const rows = modal.$modal.find('#related-widgets-container tbody tr[data-related-pk]');
310
+ rows.toArray().map((tr, i) =>
311
+ fetch(relatedWriteUrl, {
312
+ method: 'POST',
313
+ headers: { 'Content-Type': 'application/json' },
314
+ body: JSON.stringify({ target: parseInt($(tr).attr('data-related-pk')), project: parseInt(PLOT.project), order: i }),
315
+ })
316
+ )
317
+ },
318
+ });
319
+ };
320
+
321
+ const refreshSelect = async () => {
322
+ const freshAvailable = await fetchAvailable();
323
+ modal.$modal.find('#related-widget-select').html(buildSelect(freshAvailable));
324
+ };
325
+
326
+ const refreshTable = async () => {
327
+ const updated = await (await fetch(relatedReadUrl)).json();
328
+ modal.$modal.find('#related-widgets-container').html(buildTable(updated));
329
+ await refreshButtonsVisibility();
330
+ initSortable();
331
+ await refreshSelect();
332
+ };
333
+
334
+ modal.$modal.on('click', '.btn-remove-related', async function (e) {
335
+ e.preventDefault();
336
+ const targetPk = $(this).attr('data-related-target-pk');
337
+ try {
338
+ await fetch(`/${SITE_PREFIX_URL}qplotly/api/widget/related/${PLOT.pk}/${targetPk}/${PLOT.project}/`, { method: 'DELETE' });
339
+ await refreshTable();
340
+ } catch (err) {
341
+ g3wadmin.widget.showError(err.message);
342
+ }
343
+ });
344
+
345
+ modal.$modal.on('click', '#btn-add-related', async function (e) {
346
+ e.preventDefault();
347
+ const targetPk = modal.$modal.find('#related-widget-select').val();
348
+ if (!targetPk) return;
349
+ const nextOrder = modal.$modal.find('#related-widgets-container tbody tr[data-related-pk]').length;
350
+ try {
351
+ await fetch(relatedWriteUrl, {
352
+ method: 'POST',
353
+ headers: { 'Content-Type': 'application/json' },
354
+ body: JSON.stringify({ target: parseInt(targetPk), project: parseInt(PLOT.project), order: nextOrder }),
355
+ });
356
+ await refreshTable();
357
+ } catch (err) {
358
+ g3wadmin.widget.showError(err.message);
359
+ }
360
+ });
361
+
362
+ modal.$modal.on('shown.bs.modal', initSortable);
363
+ modal.show();
364
+ });
365
+
366
+ row.child($div).show();
367
+
368
+ await refreshButtonsVisibility();
369
+
370
+ } catch (e) {
371
+ g3wadmin.widget.showError(e.message);
372
+ }
373
+ }
@@ -0,0 +1,19 @@
1
+ export default {
2
+ title: 'Диаграми',
3
+ no_plots : 'Няма диаграма. Добавете поне една графика.',
4
+ no_data: "Няма налични данни",
5
+ tooltip: {
6
+ show_all_features_on_map: "Филтриране на графиките по геометрии, видими на картата",
7
+ filter_chart: "Филтриране на графики по избрани геометрии/записи"
8
+ },
9
+ filters: {
10
+ in_bbox: "Данните, филтрирани по геометрии, видими на картата",
11
+ filtertoken: "Данни, филтрирани по избрани геометрии/записи",
12
+ in_bbox_filtertoken: "Данните са филтрирани по избрани геометрии/записи и са видими на картата",
13
+ relation: {
14
+ in_bbox: "Данните, филтрирани по (родителски) геометрии, видими на картата",
15
+ filtertoken: "Данни, филтрирани по избрани (родителски) геометрии/записи",
16
+ in_bbox_filtertoken: "Данните са филтрирани по избрани (родителски) геометрии/записи и са видими на картата"
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ export default {
2
+ title: 'Diagramme',
3
+ no_plots : 'Kein Diagramm vorhanden. Mindestens ein Diagramm hinzufügen',
4
+ no_data: "Keine Daten verfügbar",
5
+ tooltip: {
6
+ show_all_features_on_map: "Alle Diagramme nach den auf der Karte sichtbaren Elementen filtern",
7
+ filter_chart: "Diagramme nach ausgewählten Elementen filtern"
8
+ },
9
+ filters: {
10
+ in_bbox: "Die im Diagramm angezeigten Daten sind nach den auf der Karte sichtbaren Geometrien gefiltert",
11
+ filtertoken: "Die im Diagramm angezeigten Daten sind nach den ausgewählten Elementen gefiltert",
12
+ in_bbox_filtertoken: "Die im Diagramm angezeigten Daten sind nach den ausgewählten und auf der Karte sichtbaren Geometrien/Datensätzen gefiltert",
13
+ relation: {
14
+ in_bbox: "Die im Diagramm angezeigten Daten sind nach den auf der Karte sichtbaren Referenzgeometrien (Eltern) gefiltert",
15
+ filtertoken: "Die im Diagramm angezeigten Daten sind nach den ausgewählten Referenzgeometrien/-datensätzen (Eltern) gefiltert.",
16
+ in_bbox_filtertoken: "Die im Diagramm angezeigten Daten sind nach den ausgewählten und auf der Karte sichtbaren Referenzgeometrien/-datensätzen (Eltern) gefiltert"
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ export default {
2
+ title: 'Charts',
3
+ no_plots : 'No chart. Add at least one plot',
4
+ no_data: "No Data available",
5
+ tooltip: {
6
+ show_all_features_on_map: "Filter plots by geometries visible on map",
7
+ filter_chart: "Filter plots by selected geometries/records"
8
+ },
9
+ filters: {
10
+ in_bbox: "Data filtered by geometries visible on map",
11
+ filtertoken: "Data filtered by selected geometries/records",
12
+ in_bbox_filtertoken: "Data filtered by selected geometries/records and visible on map",
13
+ relation: {
14
+ in_bbox: "Data filtered by (parents) geometries visible on map",
15
+ filtertoken: "Data filtered by selected (parents) geometries/records",
16
+ in_bbox_filtertoken: "Data filtered by selected (parents) geometries/records and visible on map"
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ export default {
2
+ title: 'Charts',
3
+ no_plots : 'No chart. Add at least one plot',
4
+ no_data: "No Data available",
5
+ tooltip: {
6
+ show_all_features_on_map: "Filter all plots according to the geometries visible on the map",
7
+ filter_chart: "Filter plots according to the selected geometries/records"
8
+ },
9
+ filters: {
10
+ in_bbox: "The data ​​shown in the plot are filtered according to the geometries visible on the map",
11
+ filtertoken: "The data ​​shown in the plot are filtered according to the selected geometries/records",
12
+ in_bbox_filtertoken: "The data ​​shown in the plot are filtered according to the geometries/records selected and visible on the map",
13
+ relation: {
14
+ in_bbox: "The data​​ shown in the plot are filtered according to the reference (parents) geometries visible on the map",
15
+ filtertoken: "The data ​​shown in the plot are filtered according to the reference (parents) selected geometries/records",
16
+ in_bbox_filtertoken: "The data ​​shown in the plot are filtered according to the reference (parents) geometries/records selected and visible on the map"
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ export default {
2
+ title: 'Graphiques',
3
+ no_plots : 'Pas de graphiques à montrer. Ajoutez au moins un graphique',
4
+ no_data: "Aucune donnée disponible",
5
+ tooltip: {
6
+ show_all_features_on_map: "Filtrer ce graphique en fonction des éléments visibles sur la carte",
7
+ filter_chart: "Filtrer tous les graphiques en fonction des éléments sélectionnés"
8
+ },
9
+ filters: {
10
+ in_bbox: "Les données présentées dans le graphique sont filtrées en fonction des géométries visibles sur la carte",
11
+ filtertoken: "Les données affichées dans le graphique sont filtrées en fonction des géométries/enregistrements sélectionnés",
12
+ in_bbox_filtertoken: "Les données présentées dans le graphique sont filtrées en fonction des géométries/enregistrements sélectionnés visibles sur la carte",
13
+ relation: {
14
+ in_bbox: "Les données présentées dans le graphique sont filtrées en fonction des géométries de référence (parents) visibles sur la carte",
15
+ filtertoken: "Les données affichées dans le graphique sont filtrées par les géométries/enregistrements de référence sélectionnés (parents)",
16
+ in_bbox_filtertoken: "Les données présentées dans le graphique sont filtrées en fonction des géométries/enregistrements de référence sélectionnés (parents) visibles sur la carte"
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ import it from './it.js';
2
+ import en from './en.js';
3
+ import fi from './fi.js';
4
+ import se from './se.js';
5
+ import fr from './fr.js';
6
+ import de from './de.js';
7
+ import ro from './ro.js';
8
+ import uk from './uk.js';
9
+
10
+ export default {
11
+ it,
12
+ en,
13
+ fi,
14
+ se,
15
+ fr,
16
+ de,
17
+ ro,
18
+ uk,
19
+ }
@@ -0,0 +1,19 @@
1
+ export default {
2
+ title: 'Grafici',
3
+ no_plots : 'Nessun grafico da mostrare. Aggiungi almeno un grafico',
4
+ no_data: "Nessun dato disponibile",
5
+ tooltip: {
6
+ show_all_features_on_map: "Filtra i grafici in base alle geometrie visibili sulla mappa",
7
+ filter_chart: "Filtra i grafici in base alle geometrie/record selezionati"
8
+ },
9
+ filters: {
10
+ in_bbox: "Dati filtrati in base alle geometrie visibili sulla mappa",
11
+ filtertoken: "Dati filtrati in base alle geometrie/record selezionati",
12
+ in_bbox_filtertoken: "Dati filtrati in base alle geometrie/record selezionati e visibili sulla mappa",
13
+ relation: {
14
+ in_bbox: "Dati filtrati in base alle geometrie (genitori) visibili sulla mappa",
15
+ filtertoken: "Dati filtrati in base alle geometrie/record (genitori) selezionati ",
16
+ in_bbox_filtertoken: "Dati filtrati in base alle geometrie/record (genitori) selezionati e visibili sulla mappa"
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ export default {
2
+ title: 'Grafice',
3
+ no_plots : 'Fără grafice. Adaugă unul',
4
+ no_data: "Nu avem date disponibile",
5
+ tooltip: {
6
+ show_all_features_on_map: "Filtrează toate graficele după geometriile vizibile în hartă",
7
+ filter_chart: "Filtrează graficele după entitățile selectate"
8
+ },
9
+ filters: {
10
+ in_bbox: "Datele ​​prezentate în grafic sunt filtrate după geometriile vizibile pe hartă",
11
+ filtertoken: "Datele ​​prezentate în grafic sunt filtrate după entitățile selectate",
12
+ in_bbox_filtertoken: "Datele ​​prezentate în grafic sunt filtrate după entitățile selectate și vizibile pe hartă",
13
+ relation: {
14
+ in_bbox: "Datele ​​ prezentate în grafic sunt filtrate după geometriile vizibile în hartă ale entităților relaționate de tip părinte",
15
+ filtertoken: "Datele ​​prezentate în grafic sunt filtrate după entitățile relaționate de tip părinte care sunt selectate",
16
+ in_bbox_filtertoken: "Datele ​​prezentate în grafic sunt filtrate după entitățile relaționate de tip părinte care sunt selectate și vizibile în hartă"
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ export default {
2
+ title: 'Charts',
3
+ no_plots : 'No chart. Add at least one plot',
4
+ no_data: "No Data available",
5
+ tooltip: {
6
+ show_all_features_on_map: "Filter all plots according to the geometries visible on the map",
7
+ filter_chart: "Filter plots according to the selected geometries/records"
8
+ },
9
+ filters: {
10
+ in_bbox: "The data ​​shown in the plot are filtered according to the geometries visible on the map",
11
+ filtertoken: "The data ​​shown in the plot are filtered according to the selected geometries/records",
12
+ in_bbox_filtertoken: "The data ​​shown in the plot are filtered according to the geometries/records selected and visible on the map",
13
+ relation: {
14
+ in_bbox: "The data​​ shown in the plot are filtered according to the reference (parents) geometries visible on the map",
15
+ filtertoken: "The data ​​shown in the plot are filtered according to the reference (parents) selected geometries/records",
16
+ in_bbox_filtertoken: "The data ​​shown in the plot are filtered according to the reference (parents) geometries/records selected and visible on the map"
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ export default {
2
+ title: 'Діаграми',
3
+ no_plots : 'Без діаграм. Додайте принаймні одну діаграму.',
4
+ no_data: "Дані не доступні",
5
+ tooltip: {
6
+ show_all_features_on_map: "Фільтрувати всі діаграми відповідно до видимих на мапі об'єктів",
7
+ filter_chart: "Фільтрувати діаграми відповідно до вибраних об'єктів/записів"
8
+ },
9
+ filters: {
10
+ in_bbox: "Діаграму відфільтровано відповідно до видимих на мапі об'єктів",
11
+ filtertoken: "Діаграму відфільтровано відповідно до вибраних об'єктів/записів",
12
+ in_bbox_filtertoken: "Діаграму відфільтровано відповідно до вибраних та видимих на мапі об'єктів/записів",
13
+ relation: {
14
+ in_bbox: "Діаграму відфільтровано відповідно до видимих на мапі опорних (батьківських) об'єктів",
15
+ filtertoken: "Діаграму відфільтровано відповідно до вибраних опорних (батьківських) об'єктів/записів",
16
+ in_bbox_filtertoken: "Діаграму відфільтровано відповідно до вибраних та видимих на мапі опорних (батьківських) об'єктів/записів"
17
+ }
18
+ }
19
+ }