@mindful-web/marko-web-search 1.0.0
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.
- package/.eslintignore +1 -0
- package/LICENSE +21 -0
- package/browser/.eslintrc.js +1 -0
- package/browser/index.js +9 -0
- package/browser/sort-select.vue +37 -0
- package/browser/toggle-filter-button.vue +69 -0
- package/browser/toggle-filters-button.vue +87 -0
- package/components/build-href.marko +14 -0
- package/components/build-href.marko.js +46 -0
- package/components/filters/content-types.marko +12 -0
- package/components/filters/content-types.marko.js +40 -0
- package/components/filters/filter-block.marko +66 -0
- package/components/filters/filter-block.marko.js +151 -0
- package/components/filters/filter-container.marko +29 -0
- package/components/filters/filter-container.marko.js +85 -0
- package/components/filters/load-website-sections.js +69 -0
- package/components/filters/marko.json +36 -0
- package/components/filters/selected/index.marko +51 -0
- package/components/filters/selected/index.marko.js +113 -0
- package/components/filters/selected/item.marko +27 -0
- package/components/filters/selected/item.marko.js +101 -0
- package/components/filters/selected/marko.json +8 -0
- package/components/filters/website-sections-by-alias.marko +46 -0
- package/components/filters/website-sections-by-alias.marko.js +139 -0
- package/components/filters/website-sections.marko +42 -0
- package/components/filters/website-sections.marko.js +123 -0
- package/components/form/index.marko +23 -0
- package/components/form/index.marko.js +79 -0
- package/components/form/input.marko +8 -0
- package/components/form/input.marko.js +30 -0
- package/components/form/marko.json +10 -0
- package/components/links/link.marko +14 -0
- package/components/links/link.marko.js +47 -0
- package/components/links/marko.json +17 -0
- package/components/links/next-page.marko +25 -0
- package/components/links/next-page.marko.js +59 -0
- package/components/links/previous-page.marko +25 -0
- package/components/links/previous-page.marko.js +59 -0
- package/components/links/reset-filter.marko +24 -0
- package/components/links/reset-filter.marko.js +55 -0
- package/components/links/set-filter-value.marko +45 -0
- package/components/links/set-filter-value.marko.js +86 -0
- package/components/marko.json +25 -0
- package/components/pagination-controls.marko +42 -0
- package/components/pagination-controls.marko.js +108 -0
- package/components/query-child-sections.marko +24 -0
- package/components/query-child-sections.marko.js +60 -0
- package/components/query.marko +30 -0
- package/components/query.marko.js +67 -0
- package/components/sort-by/index.marko +25 -0
- package/components/sort-by/index.marko.js +72 -0
- package/components/sort-by/marko.json +5 -0
- package/config/index.js +84 -0
- package/config/param.js +69 -0
- package/config/query-params.js +101 -0
- package/index.js +113 -0
- package/loaders/search.js +108 -0
- package/marko.json +6 -0
- package/middleware.js +9 -0
- package/package.json +32 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const gql = require('graphql-tag');
|
|
2
|
+
const { websiteSections } = require('@mindful-web/web-common/block-loaders');
|
|
3
|
+
|
|
4
|
+
const selectedQueryFragment = gql`
|
|
5
|
+
fragment MarkoWebSearchSeletedWebsiteSectionFragment on WebsiteSection {
|
|
6
|
+
id
|
|
7
|
+
name
|
|
8
|
+
alias
|
|
9
|
+
isRoot
|
|
10
|
+
hierarchy {
|
|
11
|
+
id
|
|
12
|
+
name
|
|
13
|
+
alias
|
|
14
|
+
}
|
|
15
|
+
children(input: { pagination: { limit: 100 }, sort: { field: name, order: asc } }) {
|
|
16
|
+
edges {
|
|
17
|
+
node {
|
|
18
|
+
id
|
|
19
|
+
name
|
|
20
|
+
alias
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
const queryFragment = gql`
|
|
28
|
+
fragment MarkoWebSearchWebsiteSectionFragment on WebsiteSection {
|
|
29
|
+
id
|
|
30
|
+
name
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
module.exports = async ({ $markoWebSearch: search, apolloMindfulWebCMS } = {}) => {
|
|
35
|
+
const { assignedToWebsiteSectionIds: selectedIds } = search.input;
|
|
36
|
+
const { assignedToWebsiteSectionIds: configuredIds } = search.config;
|
|
37
|
+
|
|
38
|
+
// for now, only handle one selected section.
|
|
39
|
+
const selectedId = selectedIds && selectedIds.length ? selectedIds[0] : null;
|
|
40
|
+
|
|
41
|
+
const [selectedSection, configuredSections] = await Promise.all([
|
|
42
|
+
(async () => {
|
|
43
|
+
if (!selectedIds || !selectedIds.length) return null;
|
|
44
|
+
const { nodes } = await websiteSections(apolloMindfulWebCMS, {
|
|
45
|
+
includeIds: [selectedId],
|
|
46
|
+
limit: 1,
|
|
47
|
+
queryFragment: selectedQueryFragment,
|
|
48
|
+
});
|
|
49
|
+
const [node] = nodes;
|
|
50
|
+
node.hierarchyMap = node.hierarchy.reduce((map, section) => {
|
|
51
|
+
map.set(section.id, true);
|
|
52
|
+
return map;
|
|
53
|
+
}, new Map());
|
|
54
|
+
return node;
|
|
55
|
+
})(),
|
|
56
|
+
|
|
57
|
+
(async () => {
|
|
58
|
+
if (!configuredIds || !configuredIds.length) return [];
|
|
59
|
+
const { nodes } = await websiteSections(apolloMindfulWebCMS, {
|
|
60
|
+
includeIds: configuredIds,
|
|
61
|
+
limit: configuredIds.length,
|
|
62
|
+
sort: { field: 'name', order: 'asc' },
|
|
63
|
+
queryFragment,
|
|
64
|
+
});
|
|
65
|
+
return nodes;
|
|
66
|
+
})(),
|
|
67
|
+
]);
|
|
68
|
+
return { selectedSection, configuredSections };
|
|
69
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"taglib-imports": [
|
|
3
|
+
"./selected/marko.json"
|
|
4
|
+
],
|
|
5
|
+
"<marko-web-search-content-types-filter>": {
|
|
6
|
+
"template": "./content-types.marko"
|
|
7
|
+
},
|
|
8
|
+
"<marko-web-search-filter-block>": {
|
|
9
|
+
"template": "./filter-block.marko",
|
|
10
|
+
"<title>": {},
|
|
11
|
+
"<item>": {
|
|
12
|
+
"<element>": {},
|
|
13
|
+
"@id-path": "string",
|
|
14
|
+
"@label-path": "string"
|
|
15
|
+
},
|
|
16
|
+
"<reset>": {
|
|
17
|
+
"@show": "boolean",
|
|
18
|
+
"@label": "string"
|
|
19
|
+
},
|
|
20
|
+
"@filter-key": "string",
|
|
21
|
+
"@items": "array",
|
|
22
|
+
"@modifiers": "array"
|
|
23
|
+
},
|
|
24
|
+
"<marko-web-search-filter-container>": {
|
|
25
|
+
"template": "./filter-container.marko",
|
|
26
|
+
"<title>": {
|
|
27
|
+
"@value": "string"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"<marko-web-search-website-sections-filter>": {
|
|
31
|
+
"template": "./website-sections.marko"
|
|
32
|
+
},
|
|
33
|
+
"<marko-web-search-website-sections-by-alias-filter>": {
|
|
34
|
+
"template": "./website-sections-by-alias.marko"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import gql from "graphql-tag";
|
|
2
|
+
import { get, getAsArray, getAsObject } from "@mindful-web/object-path";
|
|
3
|
+
import { isFunction } from '@mindful-web/utils';
|
|
4
|
+
|
|
5
|
+
$ const { $markoWebSearch: search, i18n } = out.global;
|
|
6
|
+
$ const blockName = "marko-web-search-selected-filters";
|
|
7
|
+
$ const { contentTypes, assignedToWebsiteSectionIds } = search.input;
|
|
8
|
+
$ const { contentTypeObjectMap } = search.config;
|
|
9
|
+
$ const i18nIsFunction = isFunction(i18n);
|
|
10
|
+
$ const typePrefix = i18nIsFunction ? i18n("Type") : "Type";
|
|
11
|
+
$ const sectionPrefix = i18nIsFunction? i18n("Section") : "Section";
|
|
12
|
+
|
|
13
|
+
$ const queryFragment = gql`
|
|
14
|
+
fragment MarkoWebSearchSelectedWebsiteSectionFragment on WebsiteSection {
|
|
15
|
+
id
|
|
16
|
+
fullName
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
$ const hasFilters = !search.isDefaultInputValueFor("contentTypes") || assignedToWebsiteSectionIds.length;
|
|
21
|
+
|
|
22
|
+
<if(hasFilters)>
|
|
23
|
+
<marko-web-block name=blockName>
|
|
24
|
+
<if(!search.isDefaultInputValueFor("contentTypes"))>
|
|
25
|
+
<for|contentTypeId| of=contentTypes>
|
|
26
|
+
$ const contentType = contentTypeObjectMap.get(contentTypeId);
|
|
27
|
+
$ const typeLabel = i18nIsFunction? i18n(contentType.label) : contentType.label;
|
|
28
|
+
<marko-web-search-selected-filter
|
|
29
|
+
prefix=typePrefix
|
|
30
|
+
filter-key="contentTypes"
|
|
31
|
+
label=typeLabel
|
|
32
|
+
/>
|
|
33
|
+
</for>
|
|
34
|
+
</if>
|
|
35
|
+
<if(assignedToWebsiteSectionIds.length)>
|
|
36
|
+
<marko-web-query-website-sections|{ nodes }|
|
|
37
|
+
include-ids=assignedToWebsiteSectionIds
|
|
38
|
+
limit=assignedToWebsiteSectionIds.length
|
|
39
|
+
query-fragment=queryFragment
|
|
40
|
+
>
|
|
41
|
+
<for|section| of=nodes>
|
|
42
|
+
<marko-web-search-selected-filter
|
|
43
|
+
prefix=sectionPrefix
|
|
44
|
+
filter-key="assignedToWebsiteSectionIds"
|
|
45
|
+
label=section.fullName
|
|
46
|
+
/>
|
|
47
|
+
</for>
|
|
48
|
+
</marko-web-query-website-sections>
|
|
49
|
+
</if>
|
|
50
|
+
</marko-web-block>
|
|
51
|
+
</if>
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Compiled using marko@4.20.2 - DO NOT EDIT
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.0.0/components/filters/selected/index.marko",
|
|
6
|
+
marko_component = require("./index.marko"),
|
|
7
|
+
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
|
+
module_gql = require("graphql-tag"),
|
|
9
|
+
gql = module_gql.default || module_gql,
|
|
10
|
+
module_objectPath_module = require("@mindful-web/object-path"),
|
|
11
|
+
objectPath_module = module_objectPath_module.default || module_objectPath_module,
|
|
12
|
+
get = module_objectPath_module.get,
|
|
13
|
+
getAsArray = module_objectPath_module.getAsArray,
|
|
14
|
+
getAsObject = module_objectPath_module.getAsObject,
|
|
15
|
+
module_utils_module = require("@mindful-web/utils"),
|
|
16
|
+
utils_module = module_utils_module.default || module_utils_module,
|
|
17
|
+
isFunction = module_utils_module.isFunction,
|
|
18
|
+
marko_forOf = require("marko/dist/runtime/helpers/for-of"),
|
|
19
|
+
marko_web_search_selected_filter_template = require("./item.marko"),
|
|
20
|
+
marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
|
|
21
|
+
marko_web_search_selected_filter_tag = marko_loadTag(marko_web_search_selected_filter_template),
|
|
22
|
+
marko_web_query_website_sections_template = require("@mindful-web/marko-core/components/queries/website-sections.marko"),
|
|
23
|
+
marko_web_query_website_sections_tag = marko_loadTag(marko_web_query_website_sections_template),
|
|
24
|
+
marko_web_block_template = require("@mindful-web/marko-web/components/element/block.marko"),
|
|
25
|
+
marko_web_block_tag = marko_loadTag(marko_web_block_template);
|
|
26
|
+
|
|
27
|
+
function render(input, out, __component, component, state) {
|
|
28
|
+
var data = input;
|
|
29
|
+
|
|
30
|
+
const { $markoWebSearch: search, i18n } = out.global;
|
|
31
|
+
|
|
32
|
+
const blockName = "marko-web-search-selected-filters";
|
|
33
|
+
|
|
34
|
+
const { contentTypes, assignedToWebsiteSectionIds } = search.input;
|
|
35
|
+
|
|
36
|
+
const { contentTypeObjectMap } = search.config;
|
|
37
|
+
|
|
38
|
+
const i18nIsFunction = isFunction(i18n);
|
|
39
|
+
|
|
40
|
+
const typePrefix = i18nIsFunction ? i18n("Type") : "Type";
|
|
41
|
+
|
|
42
|
+
const sectionPrefix = i18nIsFunction? i18n("Section") : "Section";
|
|
43
|
+
|
|
44
|
+
const queryFragment = gql`
|
|
45
|
+
fragment MarkoWebSearchSelectedWebsiteSectionFragment on WebsiteSection {
|
|
46
|
+
id
|
|
47
|
+
fullName
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
const hasFilters = !search.isDefaultInputValueFor("contentTypes") || assignedToWebsiteSectionIds.length;
|
|
52
|
+
|
|
53
|
+
if (hasFilters) {
|
|
54
|
+
marko_web_block_tag({
|
|
55
|
+
name: blockName,
|
|
56
|
+
tag: "div",
|
|
57
|
+
renderBody: function(out) {
|
|
58
|
+
if (!search.isDefaultInputValueFor("contentTypes")) {
|
|
59
|
+
var $for$0 = 0;
|
|
60
|
+
|
|
61
|
+
marko_forOf(contentTypes, function(contentTypeId) {
|
|
62
|
+
const contentType = contentTypeObjectMap.get(contentTypeId);
|
|
63
|
+
|
|
64
|
+
const typeLabel = i18nIsFunction? i18n(contentType.label) : contentType.label;
|
|
65
|
+
|
|
66
|
+
var $keyScope$0 = "[" + (($for$0++) + "]");
|
|
67
|
+
|
|
68
|
+
marko_web_search_selected_filter_tag({
|
|
69
|
+
prefix: typePrefix,
|
|
70
|
+
filterKey: "contentTypes",
|
|
71
|
+
label: typeLabel
|
|
72
|
+
}, out, __component, "1" + $keyScope$0);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (assignedToWebsiteSectionIds.length) {
|
|
77
|
+
marko_web_query_website_sections_tag({
|
|
78
|
+
includeIds: assignedToWebsiteSectionIds,
|
|
79
|
+
limit: assignedToWebsiteSectionIds.length,
|
|
80
|
+
queryFragment: queryFragment,
|
|
81
|
+
renderBody: function(out, { nodes }) {
|
|
82
|
+
var $for$1 = 0;
|
|
83
|
+
|
|
84
|
+
marko_forOf(nodes, function(section) {
|
|
85
|
+
var $keyScope$1 = "[" + (($for$1++) + "]");
|
|
86
|
+
|
|
87
|
+
marko_web_search_selected_filter_tag({
|
|
88
|
+
prefix: sectionPrefix,
|
|
89
|
+
filterKey: "assignedToWebsiteSectionIds",
|
|
90
|
+
label: section.fullName
|
|
91
|
+
}, out, __component, "3" + $keyScope$1);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}, out, __component, "2");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}, out, __component, "0");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
marko_template._ = marko_renderer(render, {
|
|
102
|
+
e_: marko_componentType
|
|
103
|
+
}, marko_component);
|
|
104
|
+
|
|
105
|
+
marko_template.meta = {
|
|
106
|
+
id: "/@mindful-web/marko-web-search$1.0.0/components/filters/selected/index.marko",
|
|
107
|
+
component: "./index.marko",
|
|
108
|
+
tags: [
|
|
109
|
+
"./item.marko",
|
|
110
|
+
"@mindful-web/marko-core/components/queries/website-sections.marko",
|
|
111
|
+
"@mindful-web/marko-web/components/element/block.marko"
|
|
112
|
+
]
|
|
113
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { get } from "@mindful-web/object-path";
|
|
2
|
+
|
|
3
|
+
$ const { $markoWebSearch: search } = out.global;
|
|
4
|
+
$ const blockName = "marko-web-search-selected-filter";
|
|
5
|
+
$ const { prefix } = input;
|
|
6
|
+
$ const path = get(search, "config.rootAlias");
|
|
7
|
+
|
|
8
|
+
<marko-web-block name=blockName>
|
|
9
|
+
<marko-web-element block-name=blockName name="label">
|
|
10
|
+
<if(prefix)>
|
|
11
|
+
${input.prefix}: ${input.label}
|
|
12
|
+
</if>
|
|
13
|
+
<else>
|
|
14
|
+
${input.label}
|
|
15
|
+
</else>
|
|
16
|
+
</marko-web-element>
|
|
17
|
+
<if(input.filterKey === "assignedToWebsiteSectionIds" && path !== "search")>
|
|
18
|
+
<marko-web-search-reset-filter-link name=input.filterKey path=path class=`${blockName}__reset`>
|
|
19
|
+
<marko-web-icon name="x" modifiers=[blockName] />
|
|
20
|
+
</marko-web-search-reset-filter-link>
|
|
21
|
+
</if>
|
|
22
|
+
<else>
|
|
23
|
+
<marko-web-search-reset-filter-link name=input.filterKey class=`${blockName}__reset`>
|
|
24
|
+
<marko-web-icon name="x" modifiers=[blockName] />
|
|
25
|
+
</marko-web-search-reset-filter-link>
|
|
26
|
+
</else>
|
|
27
|
+
</marko-web-block>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Compiled using marko@4.20.2 - DO NOT EDIT
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.0.0/components/filters/selected/item.marko",
|
|
6
|
+
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
|
+
module_objectPath_module = require("@mindful-web/object-path"),
|
|
8
|
+
objectPath_module = module_objectPath_module.default || module_objectPath_module,
|
|
9
|
+
get = module_objectPath_module.get,
|
|
10
|
+
helpers_escape_xml = require("marko/dist/runtime/html/helpers/escape-xml"),
|
|
11
|
+
marko_escapeXml = helpers_escape_xml.x,
|
|
12
|
+
marko_web_element_template = require("@mindful-web/marko-web/components/element/index.marko"),
|
|
13
|
+
marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
|
|
14
|
+
marko_web_element_tag = marko_loadTag(marko_web_element_template),
|
|
15
|
+
marko_web_icon_template = require("@mindful-web/marko-web-icons/components/icon.marko"),
|
|
16
|
+
marko_web_icon_tag = marko_loadTag(marko_web_icon_template),
|
|
17
|
+
marko_web_search_reset_filter_link_template = require("../../links/reset-filter.marko"),
|
|
18
|
+
marko_web_search_reset_filter_link_tag = marko_loadTag(marko_web_search_reset_filter_link_template),
|
|
19
|
+
marko_web_block_template = require("@mindful-web/marko-web/components/element/block.marko"),
|
|
20
|
+
marko_web_block_tag = marko_loadTag(marko_web_block_template);
|
|
21
|
+
|
|
22
|
+
function render(input, out, __component, component, state) {
|
|
23
|
+
var data = input;
|
|
24
|
+
|
|
25
|
+
const { $markoWebSearch: search } = out.global;
|
|
26
|
+
|
|
27
|
+
const blockName = "marko-web-search-selected-filter";
|
|
28
|
+
|
|
29
|
+
const { prefix } = input;
|
|
30
|
+
|
|
31
|
+
const path = get(search, "config.rootAlias");
|
|
32
|
+
|
|
33
|
+
marko_web_block_tag({
|
|
34
|
+
name: blockName,
|
|
35
|
+
tag: "div",
|
|
36
|
+
renderBody: function(out) {
|
|
37
|
+
marko_web_element_tag({
|
|
38
|
+
name: "label",
|
|
39
|
+
tag: "div",
|
|
40
|
+
blockName: blockName,
|
|
41
|
+
renderBody: function(out) {
|
|
42
|
+
if (prefix) {
|
|
43
|
+
out.w(marko_escapeXml(input.prefix) +
|
|
44
|
+
": " +
|
|
45
|
+
marko_escapeXml(input.label));
|
|
46
|
+
} else {
|
|
47
|
+
out.w(marko_escapeXml(input.label));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}, out, __component, "1");
|
|
51
|
+
|
|
52
|
+
if ((input.filterKey === "assignedToWebsiteSectionIds") && (path !== "search")) {
|
|
53
|
+
marko_web_search_reset_filter_link_tag({
|
|
54
|
+
name: input.filterKey,
|
|
55
|
+
path: path,
|
|
56
|
+
class: blockName + "__reset",
|
|
57
|
+
renderBody: function(out) {
|
|
58
|
+
marko_web_icon_tag({
|
|
59
|
+
blockName: "marko-web-icon",
|
|
60
|
+
tag: "span",
|
|
61
|
+
name: "x",
|
|
62
|
+
modifiers: [
|
|
63
|
+
blockName
|
|
64
|
+
]
|
|
65
|
+
}, out, __component, "3");
|
|
66
|
+
}
|
|
67
|
+
}, out, __component, "2");
|
|
68
|
+
} else {
|
|
69
|
+
marko_web_search_reset_filter_link_tag({
|
|
70
|
+
name: input.filterKey,
|
|
71
|
+
class: blockName + "__reset",
|
|
72
|
+
renderBody: function(out) {
|
|
73
|
+
marko_web_icon_tag({
|
|
74
|
+
blockName: "marko-web-icon",
|
|
75
|
+
tag: "span",
|
|
76
|
+
name: "x",
|
|
77
|
+
modifiers: [
|
|
78
|
+
blockName
|
|
79
|
+
]
|
|
80
|
+
}, out, __component, "5");
|
|
81
|
+
}
|
|
82
|
+
}, out, __component, "4");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}, out, __component, "0");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
marko_template._ = marko_renderer(render, {
|
|
89
|
+
d_: true,
|
|
90
|
+
e_: marko_componentType
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
marko_template.meta = {
|
|
94
|
+
id: "/@mindful-web/marko-web-search$1.0.0/components/filters/selected/item.marko",
|
|
95
|
+
tags: [
|
|
96
|
+
"@mindful-web/marko-web/components/element/index.marko",
|
|
97
|
+
"@mindful-web/marko-web-icons/components/icon.marko",
|
|
98
|
+
"../../links/reset-filter.marko",
|
|
99
|
+
"@mindful-web/marko-web/components/element/block.marko"
|
|
100
|
+
]
|
|
101
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { getAsArray } from "@mindful-web/object-path";
|
|
2
|
+
import { isFunction } from '@mindful-web/utils';
|
|
3
|
+
import loadWebsiteSections from "./load-website-sections";
|
|
4
|
+
|
|
5
|
+
$ const { $markoWebSearch, apollo, i18n } = out.global;
|
|
6
|
+
$ const filterKey = "assignedToWebsiteSectionIds";
|
|
7
|
+
$ const title = isFunction(i18n) ? i18n("Website Sections") : "Website Sections";
|
|
8
|
+
|
|
9
|
+
<marko-web-resolve|{ resolved }| promise=loadWebsiteSections({
|
|
10
|
+
$markoWebSearch,
|
|
11
|
+
apolloMindfulWebCMS: apollo,
|
|
12
|
+
})>
|
|
13
|
+
$ const { selectedSection, configuredSections } = resolved;
|
|
14
|
+
<marko-web-search-filter-block filter-key=filterKey items=configuredSections>
|
|
15
|
+
<@title value=title />
|
|
16
|
+
<@item|{ node, blockName }|>
|
|
17
|
+
<if(selectedSection && selectedSection.hierarchyMap.has(node.id))>
|
|
18
|
+
$ // loop through hierarchy to create "breadcrumb" links
|
|
19
|
+
$ const { hierarchy } = selectedSection;
|
|
20
|
+
<marko-web-element block-name=blockName name="item" modifiers=["breadcrumbs"]>
|
|
21
|
+
<for|section| of=hierarchy>
|
|
22
|
+
<marko-web-search-set-filter-value-link path=section.alias name=filterKey value=section.id reset-class=`${blockName}__clear-item`>
|
|
23
|
+
${section.name}
|
|
24
|
+
</marko-web-search-set-filter-value-link>
|
|
25
|
+
</for>
|
|
26
|
+
</marko-web-element>
|
|
27
|
+
|
|
28
|
+
$ // then display children
|
|
29
|
+
$ const children = getAsArray(selectedSection, "children.edges").map(edge => edge.node);
|
|
30
|
+
<marko-web-search-filter-block filter-key=filterKey items=children modifiers=["children"]>
|
|
31
|
+
<@item|{ node: child, blockName }|>
|
|
32
|
+
<marko-web-search-set-filter-value-link path=child.alias name=filterKey reset-class=`${blockName}__clear-item`>
|
|
33
|
+
${child.name}
|
|
34
|
+
</marko-web-search-set-filter-value-link>
|
|
35
|
+
</@item>
|
|
36
|
+
</marko-web-search-filter-block>
|
|
37
|
+
</if>
|
|
38
|
+
<else>
|
|
39
|
+
$ // display the "normal" section
|
|
40
|
+
<marko-web-search-set-filter-value-link path=node.alias name=filterKey>
|
|
41
|
+
${node.name}
|
|
42
|
+
</marko-web-search-set-filter-value-link>
|
|
43
|
+
</else>
|
|
44
|
+
</@item>
|
|
45
|
+
</marko-web-search-filter-block>
|
|
46
|
+
</marko-web-resolve>
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// Compiled using marko@4.20.2 - DO NOT EDIT
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.0.0/components/filters/website-sections-by-alias.marko",
|
|
6
|
+
marko_component = require("./website-sections-by-alias.marko"),
|
|
7
|
+
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
|
+
module_objectPath_module = require("@mindful-web/object-path"),
|
|
9
|
+
objectPath_module = module_objectPath_module.default || module_objectPath_module,
|
|
10
|
+
getAsArray = module_objectPath_module.getAsArray,
|
|
11
|
+
module_utils_module = require("@mindful-web/utils"),
|
|
12
|
+
utils_module = module_utils_module.default || module_utils_module,
|
|
13
|
+
isFunction = module_utils_module.isFunction,
|
|
14
|
+
module_loadWebsiteSections = require("./load-website-sections"),
|
|
15
|
+
loadWebsiteSections = module_loadWebsiteSections.default || module_loadWebsiteSections,
|
|
16
|
+
marko_forOf = require("marko/dist/runtime/helpers/for-of"),
|
|
17
|
+
helpers_escape_xml = require("marko/dist/runtime/html/helpers/escape-xml"),
|
|
18
|
+
marko_escapeXml = helpers_escape_xml.x,
|
|
19
|
+
marko_web_search_set_filter_value_link_template = require("../links/set-filter-value.marko"),
|
|
20
|
+
marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
|
|
21
|
+
marko_web_search_set_filter_value_link_tag = marko_loadTag(marko_web_search_set_filter_value_link_template),
|
|
22
|
+
marko_web_element_template = require("@mindful-web/marko-web/components/element/index.marko"),
|
|
23
|
+
marko_web_element_tag = marko_loadTag(marko_web_element_template),
|
|
24
|
+
marko_web_search_filter_block_template = require("./filter-block.marko"),
|
|
25
|
+
marko_web_search_filter_block_tag = marko_loadTag(marko_web_search_filter_block_template),
|
|
26
|
+
marko_web_resolve_template = require("@mindful-web/marko-core/components/resolve.marko"),
|
|
27
|
+
marko_web_resolve_tag = marko_loadTag(marko_web_resolve_template);
|
|
28
|
+
|
|
29
|
+
function render(input, out, __component, component, state) {
|
|
30
|
+
var data = input;
|
|
31
|
+
|
|
32
|
+
const { $markoWebSearch, apollo, i18n } = out.global;
|
|
33
|
+
|
|
34
|
+
const filterKey = "assignedToWebsiteSectionIds";
|
|
35
|
+
|
|
36
|
+
const title = isFunction(i18n) ? i18n("Website Sections") : "Website Sections";
|
|
37
|
+
|
|
38
|
+
marko_web_resolve_tag({
|
|
39
|
+
promise: loadWebsiteSections({
|
|
40
|
+
$markoWebSearch: $markoWebSearch,
|
|
41
|
+
apolloMindfulWebCMS: apollo
|
|
42
|
+
}),
|
|
43
|
+
renderBody: function(out, { resolved }) {
|
|
44
|
+
const { selectedSection, configuredSections } = resolved;
|
|
45
|
+
|
|
46
|
+
marko_web_search_filter_block_tag({
|
|
47
|
+
filterKey: filterKey,
|
|
48
|
+
items: configuredSections,
|
|
49
|
+
title: {
|
|
50
|
+
value: title
|
|
51
|
+
},
|
|
52
|
+
item: {
|
|
53
|
+
renderBody: function(out, { node, blockName }) {
|
|
54
|
+
if (selectedSection && selectedSection.hierarchyMap.has(node.id)) {
|
|
55
|
+
// loop through hierarchy to create "breadcrumb" links
|
|
56
|
+
|
|
57
|
+
const { hierarchy } = selectedSection;
|
|
58
|
+
|
|
59
|
+
marko_web_element_tag({
|
|
60
|
+
name: "item",
|
|
61
|
+
tag: "div",
|
|
62
|
+
blockName: blockName,
|
|
63
|
+
modifiers: [
|
|
64
|
+
"breadcrumbs"
|
|
65
|
+
],
|
|
66
|
+
renderBody: function(out) {
|
|
67
|
+
var $for$0 = 0;
|
|
68
|
+
|
|
69
|
+
marko_forOf(hierarchy, function(section) {
|
|
70
|
+
var $keyScope$0 = "[" + (($for$0++) + "]");
|
|
71
|
+
|
|
72
|
+
marko_web_search_set_filter_value_link_tag({
|
|
73
|
+
path: section.alias,
|
|
74
|
+
name: filterKey,
|
|
75
|
+
value: section.id,
|
|
76
|
+
resetClass: blockName + "__clear-item",
|
|
77
|
+
renderBody: function(out) {
|
|
78
|
+
out.w(marko_escapeXml(section.name));
|
|
79
|
+
}
|
|
80
|
+
}, out, __component, "5" + $keyScope$0);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}, out, __component, "4");
|
|
84
|
+
|
|
85
|
+
// then display children
|
|
86
|
+
|
|
87
|
+
const children = getAsArray(selectedSection, "children.edges").map(edge => edge.node);
|
|
88
|
+
|
|
89
|
+
marko_web_search_filter_block_tag({
|
|
90
|
+
filterKey: filterKey,
|
|
91
|
+
items: children,
|
|
92
|
+
modifiers: [
|
|
93
|
+
"children"
|
|
94
|
+
],
|
|
95
|
+
item: {
|
|
96
|
+
renderBody: function(out, { node: child, blockName }) {
|
|
97
|
+
marko_web_search_set_filter_value_link_tag({
|
|
98
|
+
path: child.alias,
|
|
99
|
+
name: filterKey,
|
|
100
|
+
resetClass: blockName + "__clear-item",
|
|
101
|
+
renderBody: function(out) {
|
|
102
|
+
out.w(marko_escapeXml(child.name));
|
|
103
|
+
}
|
|
104
|
+
}, out, __component, "8");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}, out, __component, "6");
|
|
108
|
+
} else {
|
|
109
|
+
// display the "normal" section
|
|
110
|
+
|
|
111
|
+
marko_web_search_set_filter_value_link_tag({
|
|
112
|
+
path: node.alias,
|
|
113
|
+
name: filterKey,
|
|
114
|
+
renderBody: function(out) {
|
|
115
|
+
out.w(marko_escapeXml(node.name));
|
|
116
|
+
}
|
|
117
|
+
}, out, __component, "9");
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}, out, __component, "1");
|
|
122
|
+
}
|
|
123
|
+
}, out, __component, "0");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
marko_template._ = marko_renderer(render, {
|
|
127
|
+
e_: marko_componentType
|
|
128
|
+
}, marko_component);
|
|
129
|
+
|
|
130
|
+
marko_template.meta = {
|
|
131
|
+
id: "/@mindful-web/marko-web-search$1.0.0/components/filters/website-sections-by-alias.marko",
|
|
132
|
+
component: "./website-sections-by-alias.marko",
|
|
133
|
+
tags: [
|
|
134
|
+
"../links/set-filter-value.marko",
|
|
135
|
+
"@mindful-web/marko-web/components/element/index.marko",
|
|
136
|
+
"./filter-block.marko",
|
|
137
|
+
"@mindful-web/marko-core/components/resolve.marko"
|
|
138
|
+
]
|
|
139
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getAsArray } from "@mindful-web/object-path";
|
|
2
|
+
import { isFunction } from '@mindful-web/utils';
|
|
3
|
+
import loadWebsiteSections from "./load-website-sections";
|
|
4
|
+
|
|
5
|
+
$ const { $markoWebSearch, apollo, i18n } = out.global;
|
|
6
|
+
$ const filterKey = "assignedToWebsiteSectionIds";
|
|
7
|
+
$ const title = isFunction(i18n) ? i18n("Website Sections") : "Website Sections";
|
|
8
|
+
|
|
9
|
+
<marko-web-resolve|{ resolved }| promise=loadWebsiteSections({
|
|
10
|
+
$markoWebSearch,
|
|
11
|
+
apolloMindfulWebCMS: apollo,
|
|
12
|
+
})>
|
|
13
|
+
$ const { selectedSection, configuredSections } = resolved;
|
|
14
|
+
<marko-web-search-filter-block filter-key=filterKey items=configuredSections>
|
|
15
|
+
<@title value=title />
|
|
16
|
+
<@item|{ node, blockName }|>
|
|
17
|
+
<if(selectedSection && selectedSection.hierarchyMap.has(node.id))>
|
|
18
|
+
<!-- loop through hierarchy to create "breadcrumb" links -->
|
|
19
|
+
$ const { hierarchy } = selectedSection;
|
|
20
|
+
<marko-web-element block-name=blockName name="item" modifiers=["breadcrumbs"]>
|
|
21
|
+
<for|section| of=hierarchy>
|
|
22
|
+
<marko-web-search-set-filter-value-link name=filterKey value=section.id reset-class=`${blockName}__clear-item`>
|
|
23
|
+
${section.name}
|
|
24
|
+
</marko-web-search-set-filter-value-link>
|
|
25
|
+
</for>
|
|
26
|
+
</marko-web-element>
|
|
27
|
+
|
|
28
|
+
<!-- then display children -->
|
|
29
|
+
$ const children = getAsArray(selectedSection, "children.edges").map(edge => edge.node);
|
|
30
|
+
<marko-web-search-filter-block filter-key=filterKey items=children modifiers=["children"]>
|
|
31
|
+
<@item label-path="name" />
|
|
32
|
+
</marko-web-search-filter-block>
|
|
33
|
+
</if>
|
|
34
|
+
<else>
|
|
35
|
+
<!-- display the "normal" section -->
|
|
36
|
+
<marko-web-search-set-filter-value-link name=filterKey value=node.id>
|
|
37
|
+
${node.name}
|
|
38
|
+
</marko-web-search-set-filter-value-link>
|
|
39
|
+
</else>
|
|
40
|
+
</@item>
|
|
41
|
+
</marko-web-search-filter-block>
|
|
42
|
+
</marko-web-resolve>
|