Skip to content

Commit bf2c692

Browse files
authored
Merge pull request #2 from Weble/feature/ais-sort-by
added sort by builder element
2 parents d65a390 + 28cad1c commit bf2c692

10 files changed

Lines changed: 160 additions & 1 deletion

File tree

plugin/assets/algolia.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/assets/src/components/AlgoliaSearch.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
AisRefinementList,
1010
AisStats,
1111
AisSearchBox,
12+
AisSortBy,
1213
} from 'vue-instantsearch';
1314

1415
import {history as historyRouter} from 'instantsearch.js/es/lib/routers';
@@ -47,6 +48,7 @@ export default {
4748
AisCurrentRefinements,
4849
AisStats,
4950
AisSearchBox,
51+
AisSortBy,
5052
},
5153

5254
data() {
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"@import": "./element.php",
3+
"name": "algolia_sort",
4+
"title": "Sort Items",
5+
"group": "Algolia",
6+
"icon": "${url:svg/icon.svg}",
7+
"iconSmall": "${url:svg/iconSmall.svg}",
8+
"element": true,
9+
"width": 500,
10+
"templates": {
11+
"render": "./templates/template.php",
12+
"content": "./templates/content.php"
13+
},
14+
"fields": {
15+
"sorting_items": {
16+
"label": "List Item",
17+
"type": "content-items",
18+
"item": "algolia_sort_item"
19+
},
20+
"position": "${builder.position}",
21+
"position_left": "${builder.position_left}",
22+
"position_right": "${builder.position_right}",
23+
"position_top": "${builder.position_top}",
24+
"position_bottom": "${builder.position_bottom}",
25+
"position_z_index": "${builder.position_z_index}",
26+
"margin": "${builder.margin}",
27+
"margin_remove_top": "${builder.margin_remove_top}",
28+
"margin_remove_bottom": "${builder.margin_remove_bottom}",
29+
"maxwidth": "${builder.maxwidth}",
30+
"maxwidth_breakpoint": "${builder.maxwidth_breakpoint}",
31+
"block_align": "${builder.block_align}",
32+
"block_align_breakpoint": "${builder.block_align_breakpoint}",
33+
"block_align_fallback": "${builder.block_align_fallback}",
34+
"text_align": "${builder.text_align_justify}",
35+
"text_align_breakpoint": "${builder.text_align_breakpoint}",
36+
"text_align_fallback": "${builder.text_align_justify_fallback}",
37+
"animation": "${builder.animation}",
38+
"_parallax_button": "${builder._parallax_button}",
39+
"visibility": "${builder.visibility}",
40+
"name": "${builder.name}",
41+
"status": "${builder.status}",
42+
"id": "${builder.id}",
43+
"class": "${builder.cls}",
44+
"attributes": "${builder.attrs}",
45+
"css": {
46+
"label": "CSS",
47+
"description": "Enter your own custom CSS. The following selectors will be prefixed automatically for this element: <code>.el-element</code>, <code>.el-item</code>, <code>.el-title</code>, <code>.el-meta</code>, <code>.el-content</code>, <code>.el-image</code>, <code>.el-link</code>",
48+
"type": "editor",
49+
"editor": "code",
50+
"mode": "css",
51+
"attrs": {
52+
"debounce": 500
53+
}
54+
}
55+
},
56+
"fieldset": {
57+
"default": {
58+
"type": "tabs",
59+
"fields": [
60+
{
61+
"title": "Settings",
62+
"fields": [
63+
"sorting_items"
64+
]
65+
},
66+
"${builder.advanced}"
67+
]
68+
}
69+
}
70+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
4+
return [
5+
6+
'transforms' => [
7+
8+
'render' => function ($node) {
9+
10+
11+
12+
foreach ($node->children as $child) {
13+
$node->props['sorting_items'][] = [
14+
'value' => $child->props['item_value'],
15+
'label' => $child->props['item_label']
16+
];
17+
}
18+
19+
}
20+
21+
],
22+
23+
];
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

plugin/builder/algolia_sort/templates/content.php

Whitespace-only changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
$el = $this->el('div', $attrs);
3+
4+
$search = $this->el('ais-sort-by', [
5+
':items' => json_encode($props['sorting_items'])
6+
])
7+
?>
8+
9+
<?= $el($props, $attrs); ?>
10+
<?= $search($props); ?><?= $search->end(); ?>
11+
<?= $el->end(); ?>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"@import": "./element.php",
3+
"name": "algolia_sort_item",
4+
"title": "Item",
5+
"width": 500,
6+
"fields": {
7+
"item_value": {
8+
"label": "Title",
9+
"source": true
10+
},
11+
"item_label": {
12+
"label": "Title",
13+
"source": true
14+
},
15+
"status": "${builder.statusItem}",
16+
"source": "${builder.source}"
17+
},
18+
"fieldset": {
19+
"default": {
20+
"type": "tabs",
21+
"fields": [
22+
{
23+
"title": "Settings",
24+
"fields": [
25+
"item_value",
26+
"item_label"
27+
]
28+
},
29+
"${builder.advancedItem}"
30+
]
31+
}
32+
}
33+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
4+
return [
5+
6+
'transforms' => [
7+
8+
'render' => function ($node) {
9+
10+
}
11+
12+
],
13+
14+
];

0 commit comments

Comments
 (0)