-
-
Notifications
You must be signed in to change notification settings - Fork 155
/
MultipleSelector.yaml
117 lines (109 loc) · 4.39 KB
/
MultipleSelector.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Copyright 2020-2022 Lowdefy, Inc
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
_ref:
path: templates/blocks/template.yaml.njk
vars:
block_type: MultipleSelector
value_type: any[]
category: input
schema: ../plugins/blocks/blocks-antd/src/blocks/MultipleSelector/schema.json
filePath: blocks/input/MultipleSelector.yaml
init_state_values:
__type_block.properties.options: object[]
__object_arr_block.properties.options:
- label: First
value: '1'
- label: Second
value: '2'
description_content: |
The `MultipleSelector` block is a drop down selector that allows a user to select multiple values from a set of options.
The options for the selector can be provides as either an array of primitive values (Strings, numbers, booleans or dates), or as an array of label-value pairs, where the label is a string, and the value can be of any type, including objects like dates and arrays.
> Other selector blocks are `ButtonSelector`, `CheckboxSelector`, `RadioSelector` and `Selector`.
examples:
- title: Listing options from database search
block:
id: example_selector
type: MultipleSelector
requests:
- id: example_search
type: MongoDBAggregation
connectionId: companies
properties:
pipeline:
- $search:
compound:
should:
- wildcard:
query:
_string.concat:
- '*'
- _state: search_input
- '*'
path: # field names to search in the companies collection
- _id
- company_name
allowAnalyzedField: true
- $addFields:
score:
$meta: searchScore
- $sort:
score: -1
- $limit: 50
- $project:
_id: 0
value: $_id
label:
$concat:
- $_id
- ' - '
- $ifNull:
- $company_name
- ''
properties:
placeholder: Search
options: # search request results will be used as options
_array.concat:
- _if_none:
- _state: example_options
- []
- _if_none:
- _request: example_search
- []
label:
disabled: true
events:
onChange: # selector onChange actions - triggered when the value of the selector changes
- id: set_state
type: SetState
params:
example_options:
_mql.aggregate:
on:
_array.concat:
- _state: example_options
- _request: example_search
pipeline:
- $match:
value:
$in:
_state: example_selector
onSearch: # selector onSearch actions - triggered when the user types in the search input
debounce:
ms: 500
try:
- id: set_state
type: SetState
params:
search_input:
_event: value
- id: perform_search
type: Request
params: example_search