accrete 0.0.103__py3-none-any.whl → 0.0.105__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.
- accrete/contrib/ui/__init__.py +6 -29
- accrete/contrib/ui/context.py +26 -294
- accrete/contrib/ui/filter.py +316 -324
- accrete/contrib/ui/middleware.py +44 -0
- accrete/contrib/ui/models.py +3 -0
- accrete/contrib/ui/static/bulma/README.md +4 -2
- accrete/contrib/ui/static/bulma/bulma.css +21551 -0
- accrete/contrib/ui/static/bulma/bulma.css.map +1 -0
- accrete/contrib/ui/static/bulma/bulma.scss +1 -1
- accrete/contrib/ui/static/bulma/css/bulma.css +1988 -2874
- accrete/contrib/ui/static/bulma/css/bulma.css.map +1 -1
- accrete/contrib/ui/static/bulma/css/bulma.min.css +2 -2
- accrete/contrib/ui/static/bulma/css/versions/bulma-no-dark-mode.css +19648 -0
- accrete/contrib/ui/static/bulma/css/versions/bulma-no-dark-mode.css.map +1 -0
- accrete/contrib/ui/static/bulma/css/versions/bulma-no-dark-mode.min.css +2 -2
- accrete/contrib/ui/static/bulma/css/versions/bulma-no-helpers-prefixed.css +11136 -0
- accrete/contrib/ui/static/bulma/css/versions/bulma-no-helpers-prefixed.css.map +1 -0
- accrete/contrib/ui/static/bulma/css/versions/bulma-no-helpers-prefixed.min.css +2 -2
- accrete/contrib/ui/static/bulma/css/versions/bulma-no-helpers.css +11136 -0
- accrete/contrib/ui/static/bulma/css/versions/bulma-no-helpers.css.map +1 -0
- accrete/contrib/ui/static/bulma/css/versions/bulma-no-helpers.min.css +2 -2
- accrete/contrib/ui/static/bulma/css/versions/bulma-prefixed.min.css +21550 -2
- accrete/contrib/ui/static/bulma/css/versions/bulma-prefixed.min.css.map +1 -1
- accrete/contrib/ui/static/bulma/css/versions/bulma-prefixed.min.min.css +3 -0
- accrete/contrib/ui/static/bulma/package.json +12 -11
- accrete/contrib/ui/static/bulma/sass/base/animations.css +15 -0
- accrete/contrib/ui/static/bulma/sass/base/animations.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/base/generic.css +196 -0
- accrete/contrib/ui/static/bulma/sass/base/generic.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/base/minireset.css +82 -0
- accrete/contrib/ui/static/bulma/sass/base/minireset.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/base/skeleton.css +113 -0
- accrete/contrib/ui/static/bulma/sass/base/skeleton.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/base/skeleton.scss +0 -12
- accrete/contrib/ui/static/bulma/sass/components/breadcrumb.css +108 -0
- accrete/contrib/ui/static/bulma/sass/components/breadcrumb.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/components/card.css +130 -0
- accrete/contrib/ui/static/bulma/sass/components/card.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/components/dropdown.css +119 -0
- accrete/contrib/ui/static/bulma/sass/components/dropdown.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/components/menu.css +119 -0
- accrete/contrib/ui/static/bulma/sass/components/menu.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/components/message.css +191 -0
- accrete/contrib/ui/static/bulma/sass/components/message.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/components/modal.css +194 -0
- accrete/contrib/ui/static/bulma/sass/components/modal.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/components/navbar.css +768 -0
- accrete/contrib/ui/static/bulma/sass/components/navbar.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/components/navbar.scss +41 -30
- accrete/contrib/ui/static/bulma/sass/components/pagination.css +302 -0
- accrete/contrib/ui/static/bulma/sass/components/pagination.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/components/panel.css +224 -0
- accrete/contrib/ui/static/bulma/sass/components/panel.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/components/panel.scss +2 -2
- accrete/contrib/ui/static/bulma/sass/components/tabs.css +192 -0
- accrete/contrib/ui/static/bulma/sass/components/tabs.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/elements/block.css +17 -0
- accrete/contrib/ui/static/bulma/sass/elements/block.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/elements/box.css +43 -0
- accrete/contrib/ui/static/bulma/sass/elements/box.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/elements/button.css +685 -0
- accrete/contrib/ui/static/bulma/sass/elements/button.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/elements/button.scss +9 -2
- accrete/contrib/ui/static/bulma/sass/elements/content.css +208 -0
- accrete/contrib/ui/static/bulma/sass/elements/content.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/elements/content.scss +8 -2
- accrete/contrib/ui/static/bulma/sass/elements/delete.css +60 -0
- accrete/contrib/ui/static/bulma/sass/elements/delete.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/elements/icon.css +51 -0
- accrete/contrib/ui/static/bulma/sass/elements/icon.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/elements/image.css +253 -0
- accrete/contrib/ui/static/bulma/sass/elements/image.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/elements/loader.css +14 -0
- accrete/contrib/ui/static/bulma/sass/elements/loader.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/elements/notification.css +213 -0
- accrete/contrib/ui/static/bulma/sass/elements/notification.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/elements/progress.css +119 -0
- accrete/contrib/ui/static/bulma/sass/elements/progress.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/elements/table.css +294 -0
- accrete/contrib/ui/static/bulma/sass/elements/table.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/elements/tag.css +252 -0
- accrete/contrib/ui/static/bulma/sass/elements/tag.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/elements/title.css +131 -0
- accrete/contrib/ui/static/bulma/sass/elements/title.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/form/checkbox-radio.css +72 -0
- accrete/contrib/ui/static/bulma/sass/form/checkbox-radio.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/form/checkbox-radio.scss +7 -3
- accrete/contrib/ui/static/bulma/sass/form/file.css +374 -0
- accrete/contrib/ui/static/bulma/sass/form/file.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/form/input-textarea.css +284 -0
- accrete/contrib/ui/static/bulma/sass/form/input-textarea.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/form/input-textarea.scss +0 -10
- accrete/contrib/ui/static/bulma/sass/form/select.css +347 -0
- accrete/contrib/ui/static/bulma/sass/form/select.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/form/select.scss +1 -0
- accrete/contrib/ui/static/bulma/sass/form/shared.css +48 -0
- accrete/contrib/ui/static/bulma/sass/form/shared.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/form/shared.scss +5 -1
- accrete/contrib/ui/static/bulma/sass/form/tools.css +356 -0
- accrete/contrib/ui/static/bulma/sass/form/tools.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/form/tools.scss +23 -12
- accrete/contrib/ui/static/bulma/sass/grid/columns-v2.css +1635 -0
- accrete/contrib/ui/static/bulma/sass/grid/columns-v2.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/grid/columns.css +1652 -0
- accrete/contrib/ui/static/bulma/sass/grid/columns.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/grid/columns.scss +109 -25
- accrete/contrib/ui/static/bulma/sass/grid/grid.css +3011 -0
- accrete/contrib/ui/static/bulma/sass/grid/grid.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/grid/grid.scss +3 -3
- accrete/contrib/ui/static/bulma/sass/helpers/aspect-ratio.css +61 -0
- accrete/contrib/ui/static/bulma/sass/helpers/aspect-ratio.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/helpers/border.css +17 -0
- accrete/contrib/ui/static/bulma/sass/helpers/border.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/helpers/color.css +5582 -0
- accrete/contrib/ui/static/bulma/sass/helpers/color.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/helpers/color.scss +166 -186
- accrete/contrib/ui/static/bulma/sass/helpers/flexbox.css +217 -0
- accrete/contrib/ui/static/bulma/sass/helpers/flexbox.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/helpers/float.css +37 -0
- accrete/contrib/ui/static/bulma/sass/helpers/float.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/helpers/gap.css +209 -0
- accrete/contrib/ui/static/bulma/sass/helpers/gap.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/helpers/other.css +34 -0
- accrete/contrib/ui/static/bulma/sass/helpers/other.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/helpers/overflow.css +65 -0
- accrete/contrib/ui/static/bulma/sass/helpers/overflow.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/helpers/position.css +45 -0
- accrete/contrib/ui/static/bulma/sass/helpers/position.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/helpers/spacing.css +489 -0
- accrete/contrib/ui/static/bulma/sass/helpers/spacing.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/helpers/typography.css +423 -0
- accrete/contrib/ui/static/bulma/sass/helpers/typography.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/helpers/visibility.css +485 -0
- accrete/contrib/ui/static/bulma/sass/helpers/visibility.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/layout/container.scss +16 -8
- accrete/contrib/ui/static/bulma/sass/layout/footer.css +9 -0
- accrete/contrib/ui/static/bulma/sass/layout/footer.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/layout/hero.css +534 -0
- accrete/contrib/ui/static/bulma/sass/layout/hero.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/layout/level.css +102 -0
- accrete/contrib/ui/static/bulma/sass/layout/level.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/layout/media.css +90 -0
- accrete/contrib/ui/static/bulma/sass/layout/media.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/layout/section.css +23 -0
- accrete/contrib/ui/static/bulma/sass/layout/section.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/layout/section.scss +4 -0
- accrete/contrib/ui/static/bulma/sass/themes/dark.css +3 -0
- accrete/contrib/ui/static/bulma/sass/themes/dark.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/themes/light.css +3 -0
- accrete/contrib/ui/static/bulma/sass/themes/light.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/themes/light.scss +1 -0
- accrete/contrib/ui/static/bulma/sass/themes/setup.css +3 -0
- accrete/contrib/ui/static/bulma/sass/themes/setup.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/utilities/controls.css +13 -0
- accrete/contrib/ui/static/bulma/sass/utilities/controls.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/utilities/css-variables.css +3 -0
- accrete/contrib/ui/static/bulma/sass/utilities/css-variables.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/utilities/css-variables.scss +3 -2
- accrete/contrib/ui/static/bulma/sass/utilities/derived-variables.css +3 -0
- accrete/contrib/ui/static/bulma/sass/utilities/derived-variables.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/utilities/extends.css +13 -0
- accrete/contrib/ui/static/bulma/sass/utilities/extends.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/utilities/functions.scss +2 -2
- accrete/contrib/ui/static/bulma/sass/utilities/initial-variables.css +3 -0
- accrete/contrib/ui/static/bulma/sass/utilities/initial-variables.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/utilities/initial-variables.scss +4 -4
- accrete/contrib/ui/static/bulma/sass/utilities/mixins.css +3 -0
- accrete/contrib/ui/static/bulma/sass/utilities/mixins.css.map +1 -0
- accrete/contrib/ui/static/bulma/sass/utilities/mixins.scss +1 -1
- accrete/contrib/ui/static/bulma/versions/bulma-no-dark-mode.css +19648 -0
- accrete/contrib/ui/static/bulma/versions/bulma-no-dark-mode.css.map +1 -0
- accrete/contrib/ui/static/bulma/versions/bulma-no-dark-mode.scss +2 -1
- accrete/contrib/ui/static/bulma/versions/bulma-no-helpers-prefixed.css +11136 -0
- accrete/contrib/ui/static/bulma/versions/bulma-no-helpers-prefixed.css.map +1 -0
- accrete/contrib/ui/static/bulma/versions/bulma-no-helpers-prefixed.scss +1 -1
- accrete/contrib/ui/static/bulma/versions/bulma-no-helpers.css +11136 -0
- accrete/contrib/ui/static/bulma/versions/bulma-no-helpers.css.map +1 -0
- accrete/contrib/ui/static/bulma/versions/bulma-no-helpers.scss +1 -1
- accrete/contrib/ui/static/bulma/versions/bulma-prefixed.css +21551 -0
- accrete/contrib/ui/static/bulma/versions/bulma-prefixed.css.map +1 -0
- accrete/contrib/ui/static/bulma/versions/bulma-prefixed.scss +1 -1
- accrete/contrib/ui/static/css/accrete.css +20757 -19997
- accrete/contrib/ui/static/css/accrete.css.map +1 -1
- accrete/contrib/ui/static/css/accrete.scss +185 -462
- accrete/contrib/ui/static/js/filter.js +97 -679
- accrete/contrib/ui/static/js/htmx.min.js +1 -1
- accrete/contrib/ui/templates/django/forms/widgets/date.html +5 -9
- accrete/contrib/ui/templates/django/forms/widgets/select.html +7 -5
- accrete/contrib/ui/templates/ui/content_right.html +7 -0
- accrete/contrib/ui/templates/ui/filter/filter.html +27 -0
- accrete/contrib/ui/templates/ui/filter/query_input.html +31 -0
- accrete/contrib/ui/templates/ui/filter/query_operator.html +11 -0
- accrete/contrib/ui/templates/ui/filter/query_params.html +106 -0
- accrete/contrib/ui/templates/ui/filter/query_tags.html +26 -0
- accrete/contrib/ui/templates/ui/layout.html +162 -233
- accrete/contrib/ui/templates/ui/list.html +39 -28
- accrete/contrib/ui/templates/ui/list_update.html +3 -0
- accrete/contrib/ui/templates/ui/message.html +13 -0
- accrete/contrib/ui/templates/ui/{partials/modal.html → modal.html} +9 -5
- accrete/contrib/ui/templates/ui/oob.html +3 -0
- accrete/contrib/ui/templates/ui/table.html +67 -71
- accrete/contrib/ui/templates/ui/table_row_update.html +14 -0
- accrete/contrib/ui/templates/ui/widgets/model_search_select.html +2 -2
- accrete/contrib/ui/templates/ui/widgets/model_search_select_multi.html +25 -14
- accrete/contrib/ui/templates/ui/widgets/model_search_select_options.html +1 -1
- accrete/contrib/ui/templatetags/{accrete_ui.py → ui.py} +68 -56
- accrete/contrib/ui/urls.py +3 -1
- accrete/contrib/ui/views.py +33 -3
- accrete/contrib/ui/widgets/__init__.py +1 -0
- accrete/contrib/ui/{forms/widgets.py → widgets/search_select.py} +7 -2
- accrete/contrib/user/templates/user/login.html +71 -23
- accrete/forms.py +0 -2
- accrete/managers.py +4 -4
- accrete/middleware.py +43 -66
- accrete/models.py +7 -1
- accrete/storage.py +4 -1
- accrete/tenant.py +9 -4
- accrete/utils/__init__.py +2 -0
- accrete/utils/models.py +9 -1
- accrete/utils/views.py +36 -20
- accrete/views.py +9 -5
- {accrete-0.0.103.dist-info → accrete-0.0.105.dist-info}/METADATA +2 -2
- accrete-0.0.105.dist-info/RECORD +370 -0
- {accrete-0.0.103.dist-info → accrete-0.0.105.dist-info}/WHEEL +1 -1
- accrete/contrib/ui/components/__init__.py +0 -1
- accrete/contrib/ui/components/search_select.py +0 -18
- accrete/contrib/ui/elements.py +0 -95
- accrete/contrib/ui/forms/__init__.py +0 -0
- accrete/contrib/ui/static/bulma/css/versions/bulma-no-dark-mode.min.css.map +0 -1
- accrete/contrib/ui/static/bulma/css/versions/bulma-no-helpers-prefixed.min.css.map +0 -1
- accrete/contrib/ui/static/bulma/css/versions/bulma-no-helpers.min.css.map +0 -1
- accrete/contrib/ui/static/bulma/sass/grid/columns-v2.scss +0 -957
- accrete/contrib/ui/static/js/ui.js +0 -30
- accrete/contrib/ui/templates/ui/dashboard.html +0 -7
- accrete/contrib/ui/templates/ui/detail.html +0 -19
- accrete/contrib/ui/templates/ui/form.html +0 -21
- accrete/contrib/ui/templates/ui/partials/filter.html +0 -146
- accrete/contrib/ui/templates/ui/partials/form_errors.html +0 -34
- accrete/contrib/ui/templates/ui/partials/header.html +0 -123
- accrete/contrib/ui/templates/ui/partials/modal_form.html +0 -46
- accrete/contrib/ui/templates/ui/partials/onchange_form.html +0 -1
- accrete/contrib/ui/templates/ui/partials/pagination_detail.html +0 -23
- accrete/contrib/ui/templates/ui/partials/pagination_list.html +0 -28
- accrete/contrib/ui/templates/ui/partials/table_field.html +0 -16
- accrete/contrib/ui/templates/ui/partials/table_field_float.html +0 -1
- accrete/contrib/ui/templates/ui/partials/table_field_monetary.html +0 -4
- accrete/contrib/ui/templates/ui/partials/table_field_string.html +0 -1
- accrete/contrib/ui/templates/ui/widgets/model_search_select_multi_selected_options.html +0 -3
- accrete/contrib/ui/templates/ui/widgets/model_search_select_multi_tags.html +0 -6
- accrete-0.0.103.dist-info/RECORD +0 -241
- {accrete-0.0.103.dist-info → accrete-0.0.105.dist-info}/licenses/LICENSE +0 -0
@@ -1,696 +1,114 @@
|
|
1
|
-
document.
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
}
|
1
|
+
document.addEventListener('alpine:init', () => {
|
2
|
+
Alpine.data('filter', () => ({
|
3
|
+
|
4
|
+
showParams: false,
|
5
|
+
|
6
|
+
closeParams() {
|
7
|
+
this.$el.active = false;
|
8
|
+
this.showParams = false;
|
9
|
+
},
|
10
|
+
|
11
|
+
applyQuery(queryString = null) {
|
12
|
+
const url = new URL(window.location);
|
13
|
+
const queryApply = this.$refs.queryApply;
|
14
|
+
const queryApplyEvent = new Event('click');
|
15
|
+
const query = queryString || JSON.stringify(this.buildJsonQueryFromHtml());
|
16
|
+
url.searchParams.set('q', query);
|
17
|
+
queryApply.setAttribute('hx-get', url.toString());
|
18
|
+
htmx.process(queryApply);
|
19
|
+
queryApply.dispatchEvent(queryApplyEvent);
|
20
|
+
this.$refs.filterInput.focus()
|
21
|
+
if (this.$refs.filterInput.nodeName === 'INPUT') {
|
22
|
+
this.$refs.filterInput.select();
|
23
|
+
}
|
24
|
+
},
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
operator = item
|
29
|
-
}
|
30
|
-
else if (isObject(item)) {
|
31
|
-
operator = queryGroup.firstElementChild && operator || null;
|
32
|
-
for (let term in item) {
|
33
|
-
queryGroup.appendChild(createQueryTag(term, operator, item[term]));
|
34
|
-
operator = '&';
|
26
|
+
addTag() {
|
27
|
+
if (this.$refs.filterInput.nodeName === 'INPUT' && !this.$refs.filterInput.reportValidity()) {
|
28
|
+
return
|
35
29
|
}
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
30
|
+
const jsonQuery = this.buildJsonQueryFromHtml();
|
31
|
+
const value = this.cleanValue(
|
32
|
+
this.$refs.filterInput.value,
|
33
|
+
this.$refs.filterInput.getAttribute('data-type')
|
40
34
|
);
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
}
|
35
|
+
jsonQuery.push({
|
36
|
+
[this.$refs.filterLookup.value]: value}
|
37
|
+
);
|
38
|
+
const jsonQueryString = JSON.stringify(jsonQuery);
|
39
|
+
this.applyQuery(jsonQueryString);
|
40
|
+
},
|
47
41
|
|
48
|
-
|
49
|
-
|
50
|
-
|
42
|
+
removeTag() {
|
43
|
+
this.$el.parentElement.parentElement.setAttribute(
|
44
|
+
'data-remove-from-query', 'true'
|
45
|
+
);
|
46
|
+
this.applyQuery();
|
47
|
+
},
|
48
|
+
|
49
|
+
groupTag() {
|
50
|
+
this.$el.parentElement.parentElement.setAttribute(
|
51
|
+
'data-group-tag', 'true'
|
52
|
+
);
|
53
|
+
this.applyQuery();
|
54
|
+
},
|
51
55
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
for (let tag of queryTags.children) {
|
60
|
-
if (tag.classList.contains('query-tag-operator')) {
|
61
|
-
const operator = tag.firstElementChild.value
|
62
|
-
if (operator !== '&') {query.push(operator);}
|
63
|
-
}
|
64
|
-
else if (tag.classList.contains('query-group-operator')) {
|
65
|
-
const operator = tag.firstElementChild.firstElementChild.value;
|
66
|
-
if (operator !== '&') {query.push(operator);}
|
67
|
-
}
|
68
|
-
else if (tag.classList.contains('query-group')) {
|
69
|
-
query.push(buildJsonQueryFromHtml(tag))
|
70
|
-
}
|
71
|
-
else if (tag.classList.contains('query-tag-container')) {
|
72
|
-
if (tag.firstElementChild.classList.contains('query-tag-operator')) {
|
73
|
-
const operator = tag.firstElementChild.firstElementChild.value
|
74
|
-
if (operator !== '&') {query.push(operator);}
|
56
|
+
buildJsonQueryFromHtml(tagGroup=null) {
|
57
|
+
const queryTags = (
|
58
|
+
tagGroup || this.$refs.queryTags
|
59
|
+
);
|
60
|
+
let query = []
|
61
|
+
if (!queryTags) {
|
62
|
+
return query
|
75
63
|
}
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
'
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
value = true
|
64
|
+
for (let tag of queryTags.children) {
|
65
|
+
if (tag.hasAttribute('data-remove-from-query')) {
|
66
|
+
continue
|
67
|
+
}
|
68
|
+
if (tag.classList.contains('query-group-container')) {
|
69
|
+
const operator = tag.querySelector('.query-operator').firstElementChild.firstElementChild.value;
|
70
|
+
const queryGroup = this.buildJsonQueryFromHtml(tag.querySelector('.query-group'))
|
71
|
+
if (queryGroup.length === 0) {
|
72
|
+
continue
|
86
73
|
}
|
87
|
-
|
88
|
-
|
74
|
+
if (query.length === 0) {
|
75
|
+
query = this.buildJsonQueryFromHtml(tag.querySelector('.query-group'));
|
76
|
+
}
|
77
|
+
else {
|
78
|
+
query.push(operator);
|
79
|
+
query.push(this.buildJsonQueryFromHtml(tag.querySelector('.query-group')));
|
89
80
|
}
|
90
81
|
}
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
const queryInput = document.getElementById('query-input');
|
107
|
-
const query = queryParam.getAttribute('id');
|
108
|
-
const dataType = queryParam.getAttribute('data-type');
|
109
|
-
const queryLabel = getCompleteQueryText(queryParam);
|
110
|
-
const step = queryParam.getAttribute('data-step') || null;
|
111
|
-
const inputControl = document.getElementById('query-input-control');
|
112
|
-
const selectControl = document.getElementById('query-input-select-control');
|
113
|
-
queryInput.setAttribute('data-param', query);
|
114
|
-
queryInput.setAttribute('data-text', queryLabel);
|
115
|
-
if (dataType === 'selection') {
|
116
|
-
const selectInput = document.getElementById('query-input-select');
|
117
|
-
const options = queryParam.querySelector('.param-options');
|
118
|
-
selectInput.innerHTML = options.innerHTML
|
119
|
-
selectControl.classList.remove('is-hidden');
|
120
|
-
inputControl.classList.add('is-hidden');
|
121
|
-
selectInput.setAttribute('data-param', query);
|
122
|
-
selectInput.setAttribute('data-text', queryLabel);
|
123
|
-
return
|
124
|
-
}
|
125
|
-
selectControl.classList.add('is-hidden');
|
126
|
-
inputControl.classList.remove('is-hidden');
|
127
|
-
queryInput.setAttribute('type', dataType);
|
128
|
-
if (step) {queryInput.step = step;}
|
129
|
-
queryInput.select()
|
130
|
-
}
|
131
|
-
|
132
|
-
function inputConfirm() {
|
133
|
-
if (this.event.key === 'Enter') {
|
134
|
-
applyInput();
|
135
|
-
}
|
136
|
-
}
|
137
|
-
|
138
|
-
function applyInput() {
|
139
|
-
const input = getActiveInput();
|
140
|
-
if (!input.reportValidity()) {
|
141
|
-
return
|
142
|
-
}
|
143
|
-
const edit = document.querySelector('.selected-query-edit');
|
144
|
-
const tag = document.querySelector('.selected-query-tag');
|
145
|
-
let group = (
|
146
|
-
document.querySelector('.selected-query-group')
|
147
|
-
|| document.getElementById('query-tags').firstElementChild
|
148
|
-
);
|
149
|
-
if (!group) {
|
150
|
-
group = document.getElementById('query-tags').appendChild(createQueryGroup());
|
151
|
-
}
|
152
|
-
if (edit) {
|
153
|
-
editQueryTag(edit.closest('.query-tag-container'));
|
154
|
-
}
|
155
|
-
else if (tag) {
|
156
|
-
const container = tag.closest('.query-tag-container');
|
157
|
-
const previous = container.previousElementSibling;
|
158
|
-
if (previous) {
|
159
|
-
appendToTag(container);
|
160
|
-
}
|
161
|
-
else {
|
162
|
-
appendAfterTag(container);
|
163
|
-
}
|
164
|
-
}
|
165
|
-
else {
|
166
|
-
const operator = (
|
167
|
-
group.childElementCount
|
168
|
-
&& document.getElementById('query-operation-select').value
|
169
|
-
|| null
|
170
|
-
);
|
171
|
-
group.appendChild(createQueryTag(
|
172
|
-
input.getAttribute('data-param'),
|
173
|
-
operator,
|
174
|
-
input.value
|
175
|
-
));
|
176
|
-
}
|
177
|
-
fetchQuery();
|
178
|
-
resetInput();
|
179
|
-
input.scrollIntoView();
|
180
|
-
}
|
181
|
-
|
182
|
-
function editQueryTag(queryTagContainer) {
|
183
|
-
const input = getActiveInput();
|
184
|
-
const param = input.getAttribute('data-param');
|
185
|
-
const operator = (
|
186
|
-
queryTagContainer.previousElementSibling
|
187
|
-
&& document.getElementById('query-operation-select').value
|
188
|
-
|| null
|
189
|
-
);
|
190
|
-
const queryTag = createQueryTag(param, operator, input.value);
|
191
|
-
queryTagContainer.replaceWith(queryTag);
|
192
|
-
}
|
193
|
-
|
194
|
-
function appendToTag(queryTagContainer) {
|
195
|
-
const input = getActiveInput();
|
196
|
-
const operator = (
|
197
|
-
queryTagContainer.firstElementChild.classList.contains('query-tag-operator')
|
198
|
-
&& queryTagContainer.firstElementChild.firstElementChild.value
|
199
|
-
|| '&'
|
200
|
-
);
|
201
|
-
const operatorSelect = createOperatorSelect(operator);
|
202
|
-
const queryGroup = createQueryGroup();
|
203
|
-
queryTagContainer.after(operatorSelect);
|
204
|
-
if (queryTagContainer.firstElementChild.classList.contains('query-tag-operator')) {
|
205
|
-
queryTagContainer.firstElementChild.remove();
|
206
|
-
}
|
207
|
-
operatorSelect.after(queryGroup);
|
208
|
-
|
209
|
-
queryGroup.appendChild(queryTagContainer);
|
210
|
-
queryGroup.appendChild(createQueryTag(
|
211
|
-
input.getAttribute('data-param'),
|
212
|
-
document.getElementById('query-operation-select').value,
|
213
|
-
input.value)
|
214
|
-
);
|
215
|
-
|
216
|
-
}
|
217
|
-
|
218
|
-
function appendAfterTag(queryTagContainer) {
|
219
|
-
const input = getActiveInput();
|
220
|
-
const operator = document.getElementById('query-operation-select').value;
|
221
|
-
const tag = createQueryTag(
|
222
|
-
input.getAttribute('data-param'), operator, input.value
|
223
|
-
);
|
224
|
-
queryTagContainer.after(tag);
|
225
|
-
}
|
226
|
-
|
227
|
-
function resetInput() {
|
228
|
-
const input = document.getElementById('query-input');
|
229
|
-
const queryParam = getParamElement(input.getAttribute('data-default-term'))
|
230
|
-
if (!queryParam) {
|
231
|
-
return
|
232
|
-
}
|
233
|
-
const queryLabel = getCompleteQueryText(queryParam);
|
234
|
-
const queryNotificationLabel = document.getElementById('query-label');
|
235
|
-
queryNotificationLabel.innerText = queryLabel;
|
236
|
-
setInputType(queryParam);
|
237
|
-
const queryInput = getActiveInput();
|
238
|
-
queryInput.value = null;
|
239
|
-
}
|
240
|
-
|
241
|
-
function fetchQuery(queryString=null) {
|
242
|
-
const queryApply = document.getElementById('query-apply');
|
243
|
-
const queryApplyEvent = new Event('click');
|
244
|
-
const url = new URL(window.location)
|
245
|
-
url.searchParams.set('q', queryString ?? queryStringFromJsonQuery());
|
246
|
-
queryApply.setAttribute('hx-get', url.toString());
|
247
|
-
htmx.process(queryApply);
|
248
|
-
queryApply.dispatchEvent(queryApplyEvent);
|
249
|
-
toggleFilterModalButton();
|
250
|
-
}
|
251
|
-
|
252
|
-
function toggleFilterModalButton() {
|
253
|
-
const button = document.getElementById('modal-filter-button');
|
254
|
-
const query = document.getElementById('query-tags');
|
255
|
-
if (query.firstElementChild && query.firstElementChild.childElementCount) {
|
256
|
-
button.classList.add('is-active');
|
257
|
-
}
|
258
|
-
else {
|
259
|
-
button.classList.remove('is-active');
|
260
|
-
}
|
261
|
-
}
|
262
|
-
|
263
|
-
function checkSelectedFields() {
|
264
|
-
const table = document.getElementById('content-table');
|
265
|
-
if (!table) {
|
266
|
-
return
|
267
|
-
}
|
268
|
-
const header = table.querySelectorAll('th')
|
269
|
-
document.getElementById(
|
270
|
-
'field-path-checkboxes'
|
271
|
-
).querySelectorAll(
|
272
|
-
'input:checked'
|
273
|
-
).forEach((el) => {el.checked = ''});
|
274
|
-
header.forEach((th) => {
|
275
|
-
const name = th.getAttribute('data-name');
|
276
|
-
if (name) {
|
277
|
-
document.getElementById(
|
278
|
-
'field-path-checkboxes'
|
279
|
-
).querySelector(`input[name=${name}]`
|
280
|
-
).checked = 'checked';
|
281
|
-
}
|
282
|
-
})
|
283
|
-
}
|
284
|
-
|
285
|
-
//-----------------------------------------------------------------------------
|
286
|
-
// Events
|
287
|
-
//-----------------------------------------------------------------------------
|
288
|
-
|
289
|
-
function showHide() {
|
290
|
-
const target = this.event.target;
|
291
|
-
const queryInput = document.getElementById('query-input-fieldset');
|
292
|
-
if (!queryInput) {
|
293
|
-
return;
|
294
|
-
}
|
295
|
-
const queryParamDropDown = document.getElementById('query-params-dropdown');
|
296
|
-
const operation = document.getElementById('query-operation');
|
297
|
-
if (queryInput.contains(target)
|
298
|
-
|| queryParamDropDown.contains(target)
|
299
|
-
|| operation.contains(target)
|
300
|
-
) {
|
301
|
-
queryParamDropDown.classList.remove('is-hidden');
|
302
|
-
return
|
303
|
-
}
|
304
|
-
queryParamDropDown.classList.add('is-hidden');
|
305
|
-
}
|
306
|
-
|
307
|
-
function showFilterModal() {
|
308
|
-
const filterModal = document.getElementById('filter-modal');
|
309
|
-
const modalContent = document.getElementById('modal-content');
|
310
|
-
modalContent.appendChild(document.getElementById('query-block'));
|
311
|
-
filterModal.classList.add('is-active');
|
312
|
-
}
|
313
|
-
|
314
|
-
function hideFilterModal() {
|
315
|
-
const filterModal = document.getElementById('filter-modal');
|
316
|
-
const panel = document.getElementById('filter-panel');
|
317
|
-
panel.appendChild(document.getElementById('query-block'));
|
318
|
-
filterModal.classList.remove('is-active');
|
319
|
-
}
|
320
|
-
|
321
|
-
function toggleParams() {
|
322
|
-
const target = this.event.target
|
323
|
-
const nextSibling = target.nextElementSibling;
|
324
|
-
if (!nextSibling) {
|
325
|
-
return
|
326
|
-
}
|
327
|
-
if (nextSibling.classList.contains('query-params')) {
|
328
|
-
nextSibling.classList.toggle('is-hidden');
|
329
|
-
}
|
330
|
-
if (nextSibling.classList.contains('param-options')) {
|
331
|
-
setQueryParam(nextSibling.parentElement);
|
332
|
-
}
|
333
|
-
}
|
334
|
-
|
335
|
-
function deleteQueryTag(event) {
|
336
|
-
const tagContainer = event.currentTarget.closest('.query-tag-container');
|
337
|
-
const previousTagContainer = tagContainer.previousElementSibling;
|
338
|
-
const nextTagContainer = tagContainer.nextElementSibling;
|
339
|
-
const queryGroup = tagContainer.parentElement;
|
340
|
-
|
341
|
-
if (
|
342
|
-
previousTagContainer
|
343
|
-
&& nextTagContainer
|
344
|
-
&& tagContainer.firstElementChild.classList.contains('query-tag-operator')
|
345
|
-
) {
|
346
|
-
if (nextTagContainer.childElementCount === 1) {
|
347
|
-
nextTagContainer.prepend(tagContainer.firstElementChild)
|
348
|
-
}
|
349
|
-
}
|
350
|
-
tagContainer.remove();
|
351
|
-
if (
|
352
|
-
!previousTagContainer
|
353
|
-
&& nextTagContainer
|
354
|
-
&& nextTagContainer.firstElementChild.classList.contains('query-tag-operator')
|
355
|
-
) {
|
356
|
-
nextTagContainer.firstElementChild.remove();
|
357
|
-
}
|
358
|
-
if (!queryGroup.childElementCount) {
|
359
|
-
queryGroup.previousElementSibling && queryGroup.previousElementSibling.remove();
|
360
|
-
queryGroup.remove();
|
361
|
-
}
|
362
|
-
else if (
|
363
|
-
queryGroup.firstElementChild
|
364
|
-
&& queryGroup.firstElementChild.classList.contains('query-group-operator')
|
365
|
-
) {
|
366
|
-
if (!isFirstQueryGroup(queryGroup)) {
|
367
|
-
queryGroup.previousElementSibling && queryGroup.previousElementSibling.remove();
|
368
|
-
while (queryGroup.childElementCount) {
|
369
|
-
queryGroup.after(queryGroup.lastElementChild);
|
370
|
-
}
|
371
|
-
queryGroup.remove();
|
372
|
-
}
|
373
|
-
else {
|
374
|
-
queryGroup.firstElementChild.remove();
|
375
|
-
const subQueryGroup = queryGroup.firstElementChild;
|
376
|
-
while (subQueryGroup.childElementCount) {
|
377
|
-
subQueryGroup.before(subQueryGroup.firstElementChild);
|
378
|
-
}
|
379
|
-
subQueryGroup.remove();
|
380
|
-
}
|
381
|
-
}
|
382
|
-
fetchQuery();
|
383
|
-
}
|
384
|
-
|
385
|
-
function setSelectedTag(event) {
|
386
|
-
event.stopPropagation();
|
387
|
-
const toDeactivate = event.currentTarget.classList.contains(
|
388
|
-
'selected-query-tag'
|
389
|
-
);
|
390
|
-
unselectAll();
|
391
|
-
if (!toDeactivate) {
|
392
|
-
event.currentTarget.classList.add('selected-query-tag');
|
393
|
-
}
|
394
|
-
}
|
395
|
-
|
396
|
-
function setSelectedQueryGroup(event) {
|
397
|
-
event.stopPropagation();
|
398
|
-
const toDeactivate = event.currentTarget.classList.contains(
|
399
|
-
'selected-query-group-selector'
|
400
|
-
);
|
401
|
-
unselectAll();
|
402
|
-
if (!toDeactivate) {
|
403
|
-
event.currentTarget.classList.add('selected-query-group-selector');
|
404
|
-
const parent = event.currentTarget.closest('.query-group-operator');
|
405
|
-
parent.nextElementSibling.classList.add('selected-query-group');
|
406
|
-
}
|
407
|
-
}
|
408
|
-
|
409
|
-
function selectForEdit(event) {
|
410
|
-
event.stopPropagation();
|
411
|
-
const toDeactivate = event.currentTarget.classList.contains(
|
412
|
-
'selected-query-edit'
|
413
|
-
);
|
414
|
-
unselectAll();
|
415
|
-
if (toDeactivate) {
|
416
|
-
return
|
417
|
-
}
|
418
|
-
const tag = event.currentTarget.closest('.query-tag');
|
419
|
-
event.currentTarget.classList.add('selected-query-edit');
|
420
|
-
setQueryParam(getParamElement(
|
421
|
-
tag.getAttribute('data-param'),
|
422
|
-
tag.getAttribute('data-value')
|
423
|
-
));
|
424
|
-
const input = getActiveInput();
|
425
|
-
input.value = tag.getAttribute('data-value')
|
426
|
-
if (input.type === 'select-one') {
|
427
|
-
return;
|
428
|
-
}
|
429
|
-
input.select()
|
430
|
-
}
|
431
|
-
|
432
|
-
function unselectAll() {
|
433
|
-
unselectAllQueryGroups();
|
434
|
-
unselectAllQueryTags();
|
435
|
-
unselectAllQueryEdits();
|
436
|
-
}
|
437
|
-
|
438
|
-
function unselectAllQueryTags() {
|
439
|
-
document.querySelectorAll('.selected-query-tag').forEach(
|
440
|
-
(tag) => {
|
441
|
-
tag.classList.remove('selected-query-tag')
|
442
|
-
}
|
443
|
-
);
|
444
|
-
}
|
445
|
-
|
446
|
-
function unselectAllQueryGroups() {
|
447
|
-
document.querySelectorAll(
|
448
|
-
'.selected-query-group, .selected-query-group-selector'
|
449
|
-
).forEach(
|
450
|
-
(tag) => {
|
451
|
-
tag.classList.remove(
|
452
|
-
'selected-query-group', 'selected-query-group-selector'
|
453
|
-
)
|
454
|
-
}
|
455
|
-
);
|
456
|
-
}
|
457
|
-
|
458
|
-
function unselectAllQueryEdits() {
|
459
|
-
document.querySelectorAll('.selected-query-edit').forEach(
|
460
|
-
(tag) => {tag.classList.remove('selected-query-edit')}
|
461
|
-
);
|
462
|
-
}
|
463
|
-
|
464
|
-
function changeOperator(event) {
|
465
|
-
fetchQuery();
|
466
|
-
}
|
467
|
-
|
468
|
-
function filterFieldPaths() {
|
469
|
-
const value = document.getElementById('field-path-search-input').value.toString().toLowerCase();
|
470
|
-
const checkBoxes = document.getElementById('field-path-checkboxes');
|
471
|
-
if (!value) {
|
472
|
-
checkBoxes.querySelectorAll(':scope * input').forEach(
|
473
|
-
(el) => {
|
474
|
-
el.parentElement.classList.remove('is-hidden')
|
475
|
-
});
|
476
|
-
return
|
477
|
-
}
|
478
|
-
const pathsToShow = checkBoxes.querySelectorAll(`:scope * input[data-label*=${value}]`);
|
479
|
-
const pathsToHide = checkBoxes.querySelectorAll(`:scope * input:not([data-label*=${value}])`);
|
480
|
-
pathsToShow.forEach((el) => {el.parentElement.classList.remove('is-hidden')});
|
481
|
-
pathsToHide.forEach((el) => {el.parentElement.classList.add('is-hidden')})
|
482
|
-
}
|
483
|
-
|
484
|
-
function changeFieldSelection() {
|
485
|
-
const fieldPathApply = document.getElementById('field-path-apply');
|
486
|
-
const fieldPathApplyEvent = new Event('click');
|
487
|
-
const url = new URL(window.location);
|
488
|
-
const fieldPaths = document.getElementById('field-path-checkboxes');
|
489
|
-
const selected = fieldPaths.querySelectorAll('input:checked');
|
490
|
-
let fields = [];
|
491
|
-
selected.forEach((input) => {
|
492
|
-
fields.push(input.name);
|
493
|
-
})
|
494
|
-
url.searchParams.set('fields', JSON.stringify(fields));
|
495
|
-
fieldPathApply.setAttribute('hx-get', url.toString());
|
496
|
-
htmx.process(fieldPathApply);
|
497
|
-
fieldPathApply.dispatchEvent(fieldPathApplyEvent);
|
498
|
-
}
|
499
|
-
|
500
|
-
function resetFieldPaths() {
|
501
|
-
const fieldPathApply = document.getElementById('field-path-apply');
|
502
|
-
const fieldPathApplyEvent = new Event('click');
|
503
|
-
const url = new URL(window.location)
|
504
|
-
url.searchParams.delete('fields');
|
505
|
-
fieldPathApply.setAttribute('hx-get', url.toString());
|
506
|
-
htmx.process(fieldPathApply);
|
507
|
-
fieldPathApply.dispatchEvent(fieldPathApplyEvent);
|
508
|
-
}
|
509
|
-
|
510
|
-
//-----------------------------------------------------------------------------
|
511
|
-
// Elements
|
512
|
-
//-----------------------------------------------------------------------------
|
513
|
-
|
514
|
-
function createQueryGroup(operator=null) {
|
515
|
-
const queryGroup = document.createElement('div');
|
516
|
-
queryGroup.classList.add('query-group');
|
517
|
-
return queryGroup
|
518
|
-
}
|
519
|
-
|
520
|
-
function createQueryTag(term, operator, value=null) {
|
521
|
-
let displayValue;
|
522
|
-
const element = getParamElement(term, value);
|
523
|
-
const dataType = element.getAttribute('data-type');
|
524
|
-
const text = getCompleteQueryText(element);
|
525
|
-
if (dataType === 'selection') {
|
526
|
-
const option = element.querySelector(
|
527
|
-
`.param-options > option[value="${value}"]`
|
528
|
-
);
|
529
|
-
displayValue = option.textContent;
|
530
|
-
}
|
531
|
-
else {
|
532
|
-
displayValue = value;
|
533
|
-
}
|
534
|
-
return createTag(text, term, value, displayValue, operator);
|
535
|
-
}
|
536
|
-
|
537
|
-
function createTag(text, param, value, displayValue, operator) {
|
538
|
-
const tagContainer = document.createElement('div');
|
539
|
-
const tag = document.createElement('div');
|
540
|
-
const tagEditDiv = document.createElement('div');
|
541
|
-
const tagEditIcon = document.createElement('div');
|
542
|
-
const tagText = document.createElement('span');
|
543
|
-
const tagDeleteDiv = document.createElement('div');
|
544
|
-
const tagDeleteButton = document.createElement('button');
|
545
|
-
tagEditDiv.classList.add('query-tag-edit')
|
546
|
-
tagEditDiv.addEventListener('click', selectForEdit);
|
547
|
-
tagEditDiv.appendChild(tagEditIcon);
|
548
|
-
tagEditIcon.classList.add('icon-edit', 'query-tag-edit-icon');
|
549
|
-
tagText.classList.add('query-tag-text', 'is-size-7', 'is-unselectable');
|
550
|
-
tagText.innerText = text.concat(displayValue && `: ${displayValue}` || '');
|
551
|
-
tagDeleteDiv.classList.add('query-tag-delete')
|
552
|
-
tagDeleteButton.classList.add('delete', 'mx-1');
|
553
|
-
tagDeleteDiv.appendChild(tagDeleteButton);
|
554
|
-
tagDeleteButton.addEventListener('click', deleteQueryTag);
|
555
|
-
tag.addEventListener('click', setSelectedTag);
|
556
|
-
tag.classList.add('query-tag');
|
557
|
-
tag.tabIndex = -1;
|
558
|
-
tag.setAttribute('data-param', param.replace('filter-id-', ''));
|
559
|
-
tag.setAttribute('data-value', value);
|
560
|
-
tag.appendChild(tagEditDiv);
|
561
|
-
tag.appendChild(tagText);
|
562
|
-
tag.appendChild(tagDeleteDiv);
|
563
|
-
if (operator && operator !== '&') {
|
564
|
-
tagContainer.appendChild(createOperatorDiv(operator));
|
565
|
-
}
|
566
|
-
tagContainer.appendChild(tag);
|
567
|
-
tagContainer.classList.add('query-tag-container');
|
568
|
-
return tagContainer
|
569
|
-
}
|
570
|
-
|
571
|
-
function createOperatorDiv(operator) {
|
572
|
-
const operatorContainer = document.createElement('div');
|
573
|
-
const operatorDiv = document.createElement('div');
|
574
|
-
operatorContainer.classList.add('query-tag-operator');
|
575
|
-
operatorDiv.innerText = getOperatorLabel(operator);
|
576
|
-
operatorDiv.value = operator;
|
577
|
-
operatorDiv.setAttribute('value', operator);
|
578
|
-
operatorContainer.appendChild(operatorDiv);
|
579
|
-
return operatorContainer
|
580
|
-
}
|
581
|
-
|
582
|
-
function createOperatorSelect(operator) {
|
583
|
-
const selectContainer = document.createElement('div');
|
584
|
-
const selectDiv = document.createElement('div');
|
585
|
-
const select = document.createElement('select');
|
586
|
-
const andOption = document.createElement('option');
|
587
|
-
const orOption = document.createElement('option');
|
588
|
-
const xorOption = document.createElement('option');
|
589
|
-
const groupSelectorDiv = document.createElement('div');
|
590
|
-
const groupSelector = document.createElement('button');
|
591
|
-
groupSelectorDiv.classList.add('query-group-selector');
|
592
|
-
groupSelector.classList.add('icon-select');
|
593
|
-
groupSelectorDiv.appendChild(groupSelector);
|
594
|
-
andOption.value = '&';
|
595
|
-
andOption.innerText = getOperatorLabel('&');
|
596
|
-
orOption.innerText = getOperatorLabel('|');
|
597
|
-
xorOption.innerText = getOperatorLabel('^');
|
598
|
-
orOption.value = '|';
|
599
|
-
xorOption.value = '^';
|
600
|
-
if (operator === '&') {andOption.setAttribute('selected', '')}
|
601
|
-
else if (operator === '|') {orOption.setAttribute('selected', '')}
|
602
|
-
else if (operator === '^') {xorOption.setAttribute('selected', '')}
|
603
|
-
select.appendChild(andOption);
|
604
|
-
select.appendChild(orOption);
|
605
|
-
select.addEventListener('change', changeOperator);
|
606
|
-
selectDiv.classList.add('select')
|
607
|
-
selectDiv.appendChild(select);
|
608
|
-
if (operator === '^') {select.appendChild(xorOption);}
|
609
|
-
selectContainer.classList.add(
|
610
|
-
'query-group-operator', 'is-size-7', 'mr-1', 'mb-1'
|
611
|
-
);
|
612
|
-
selectContainer.appendChild(selectDiv);
|
613
|
-
selectContainer.appendChild(groupSelectorDiv);
|
614
|
-
groupSelector.addEventListener('click', setSelectedQueryGroup);
|
615
|
-
return selectContainer
|
616
|
-
}
|
617
|
-
|
618
|
-
//-----------------------------------------------------------------------------
|
619
|
-
// Helper
|
620
|
-
//-----------------------------------------------------------------------------
|
82
|
+
else if (tag.classList.contains('query-tag-container')) {
|
83
|
+
if (query.length > 0) {
|
84
|
+
const operator = tag.querySelector('.query-operator');
|
85
|
+
query.push(operator.firstElementChild.firstElementChild.value);
|
86
|
+
}
|
87
|
+
const key = tag.getAttribute('data-lookup');
|
88
|
+
let value = tag.getAttribute('data-value');
|
89
|
+
let dataType = tag.getAttribute('data-type');
|
90
|
+
value = this.cleanValue(value, dataType);
|
91
|
+
if (tag.hasAttribute('data-group-tag')) {
|
92
|
+
query.push([{[key]: value}]);
|
93
|
+
}
|
94
|
+
else {
|
95
|
+
query.push({[key]: value});
|
96
|
+
}
|
621
97
|
|
622
|
-
function normalizeQueryString(queryString=null, left=null) {
|
623
|
-
queryString = queryString || JSON.parse(
|
624
|
-
new URL(window.location.href).searchParams.get('q') || '[]'
|
625
|
-
);
|
626
|
-
let normalizedQueryString = []
|
627
|
-
for (let item of queryString) {
|
628
|
-
if (isString(item)) {
|
629
|
-
normalizedQueryString.push(item)
|
630
|
-
left = item
|
631
|
-
}
|
632
|
-
else if (isObject(item)) {
|
633
|
-
for (let k in item) {
|
634
|
-
if (left && !isString(left)) {
|
635
|
-
normalizedQueryString.push('&')
|
636
98
|
}
|
637
|
-
normalizedQueryString.push({[k]: item[k]})
|
638
|
-
left = item
|
639
|
-
}
|
640
|
-
}
|
641
|
-
else if (isArray(item)) {
|
642
|
-
if (left && !isString(left)) {
|
643
|
-
normalizedQueryString.push('&')
|
644
99
|
}
|
645
|
-
|
646
|
-
|
647
|
-
}
|
648
|
-
}
|
649
|
-
return normalizedQueryString
|
650
|
-
}
|
651
|
-
|
652
|
-
function getOperatorLabel(operator) {
|
653
|
-
const queryTags = document.getElementById('query-tags');
|
654
|
-
if (operator === '&') {
|
655
|
-
return queryTags.getAttribute('data-and-label')
|
656
|
-
}
|
657
|
-
else if (operator === '|') {
|
658
|
-
return queryTags.getAttribute('data-or-label')
|
659
|
-
}
|
660
|
-
else if (operator === '^') {
|
661
|
-
return queryTags.getAttribute('data-xor-label')
|
662
|
-
}
|
663
|
-
}
|
664
|
-
|
665
|
-
function getParamElement(param, value=null){
|
666
|
-
const filterId = `filter-id-${param.replace('filter-id-', '')}`
|
667
|
-
return document.getElementById(filterId)
|
668
|
-
}
|
669
|
-
|
670
|
-
function getCompleteQueryText(paramElement) {
|
671
|
-
let names = getQueryTextParts(paramElement);
|
672
|
-
return names.join(' \u2192 ')
|
673
|
-
}
|
100
|
+
return query
|
101
|
+
},
|
674
102
|
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
return names.reverse()
|
684
|
-
}
|
103
|
+
cleanValue(value, dataType) {
|
104
|
+
if (dataType === 'bool') {
|
105
|
+
value = value.toLowerCase() === 'true'
|
106
|
+
}
|
107
|
+
return value
|
108
|
+
},
|
109
|
+
}))
|
110
|
+
})
|
685
111
|
|
686
|
-
function getActiveInput() {
|
687
|
-
const input = document.getElementById('query-input');
|
688
|
-
return (
|
689
|
-
input.parentElement.classList.contains('is-hidden')
|
690
|
-
&& document.getElementById('query-input-select')
|
691
|
-
|| input
|
692
|
-
)
|
693
|
-
}
|
694
112
|
|
695
113
|
function isObject(item) {
|
696
114
|
return Object.prototype.toString.apply(item) === '[object Object]'
|