alchemy-form 0.1.3 → 0.1.6
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/CHANGELOG.md +24 -0
- package/assets/stylesheets/form/alchemy_field_array.scss +4 -0
- package/assets/stylesheets/form/alchemy_toggle.scss +2 -0
- package/assets/stylesheets/form/query_builder.scss +185 -0
- package/config/routes.js +8 -0
- package/controller/form_api_controller.js +51 -2
- package/element/00_form_base.js +37 -1
- package/element/20_query_builder_base.js +82 -0
- package/element/alchemy_field.js +65 -15
- package/element/alchemy_field_schema.js +45 -11
- package/element/alchemy_form.js +1 -12
- package/element/alchemy_select.js +68 -13
- package/element/alchemy_select_item.js +42 -1
- package/element/alchemy_table.js +123 -21
- package/element/query_builder.js +90 -0
- package/element/query_builder_entry.js +388 -0
- package/element/query_builder_group.js +221 -0
- package/element/query_builder_value.js +435 -0
- package/helper/form_actions/00_form_action.js +328 -0
- package/helper/form_actions/url_action.js +69 -0
- package/helper/query_builder_variable_definition/00_variable_definition.js +351 -0
- package/helper/query_builder_variable_definition/boolean_variable_definition.js +24 -0
- package/helper/query_builder_variable_definition/number_variable_definition.js +106 -0
- package/helper/query_builder_variable_definition/string_variable_definition.js +46 -0
- package/helper/widgets/alchemy_field_widget.js +48 -1
- package/helper/widgets/alchemy_form_widget.js +17 -2
- package/helper_field/query_builder_assignment.js +11 -0
- package/helper_field/query_builder_field.js +91 -0
- package/helper_field/query_builder_value.js +56 -0
- package/package.json +2 -2
- package/view/form/elements/alchemy_field_array.hwk +3 -1
- package/view/form/elements/alchemy_field_array_entry.hwk +3 -1
- package/view/form/elements/alchemy_field_schema.hwk +2 -4
- package/view/form/elements/alchemy_select_item.hwk +6 -1
- package/view/form/elements/query_builder.hwk +1 -0
- package/view/form/elements/query_builder_entry.hwk +33 -0
- package/view/form/elements/query_builder_group.hwk +64 -0
- package/view/form/elements/query_builder_value.hwk +10 -0
- package/view/form/inputs/edit/query_builder.hwk +5 -0
- package/view/form/inputs/edit/query_builder_assignment.hwk +6 -0
- package/view/form/inputs/edit/query_builder_value.hwk +11 -0
- package/view/form/select/qb_item.hwk +7 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ValueType
|
|
3
|
+
*
|
|
4
|
+
* @constructor
|
|
5
|
+
*
|
|
6
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
7
|
+
* @since 0.1.6
|
|
8
|
+
* @version 0.1.6
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} config
|
|
11
|
+
*/
|
|
12
|
+
const VariableDefinition = Function.inherits('Alchemy.Base', 'Alchemy.QueryBuilder.VariableDefinition', function VariableDefinition(config) {
|
|
13
|
+
this.applyConfig(config);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Make this an abtract class
|
|
18
|
+
*/
|
|
19
|
+
VariableDefinition.makeAbstractClass();
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* This class starts a new group
|
|
23
|
+
*/
|
|
24
|
+
VariableDefinition.startNewGroup('qb_variable_definitions');
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The machine-readable name of the variable
|
|
28
|
+
*
|
|
29
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
30
|
+
* @since 0.1.6
|
|
31
|
+
* @version 0.1.6
|
|
32
|
+
*/
|
|
33
|
+
VariableDefinition.setProperty('name');
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The human-readable title of the variable
|
|
37
|
+
*
|
|
38
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
39
|
+
* @since 0.1.6
|
|
40
|
+
* @version 0.1.6
|
|
41
|
+
*/
|
|
42
|
+
VariableDefinition.setProperty('title');
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The description of the variable
|
|
46
|
+
*
|
|
47
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
48
|
+
* @since 0.1.6
|
|
49
|
+
* @version 0.1.6
|
|
50
|
+
*/
|
|
51
|
+
VariableDefinition.setProperty('description');
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Is this variable readonly? (Mainly used for assignments)
|
|
55
|
+
*
|
|
56
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
57
|
+
* @since 0.1.6
|
|
58
|
+
* @version 0.1.6
|
|
59
|
+
*/
|
|
60
|
+
VariableDefinition.setProperty('readonly', false);
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The flags of this variable
|
|
64
|
+
*
|
|
65
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
66
|
+
* @since 0.1.6
|
|
67
|
+
* @version 0.1.6
|
|
68
|
+
*/
|
|
69
|
+
VariableDefinition.setProperty('flags');
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get the type_name from the constructor
|
|
73
|
+
*
|
|
74
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
75
|
+
* @since 0.1.6
|
|
76
|
+
* @version 0.1.6
|
|
77
|
+
*/
|
|
78
|
+
VariableDefinition.setProperty(function type_name() {
|
|
79
|
+
return this.constructor.type_name;
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The `id` property just refers to the `name`
|
|
84
|
+
*
|
|
85
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
86
|
+
* @since 0.1.6
|
|
87
|
+
* @version 0.1.6
|
|
88
|
+
*/
|
|
89
|
+
VariableDefinition.setProperty(function id() {
|
|
90
|
+
return this.name;
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Make sure this definition has operators
|
|
95
|
+
*
|
|
96
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
97
|
+
* @since 0.1.6
|
|
98
|
+
* @version 0.1.6
|
|
99
|
+
*/
|
|
100
|
+
VariableDefinition.constitute(function prepareOperators() {
|
|
101
|
+
this.logical_operators = {};
|
|
102
|
+
this.assignment_operators = {};
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Create the correct variable definition
|
|
107
|
+
*
|
|
108
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
109
|
+
* @since 0.1.6
|
|
110
|
+
* @version 0.1.6
|
|
111
|
+
*/
|
|
112
|
+
VariableDefinition.setStatic(function cast(entry) {
|
|
113
|
+
|
|
114
|
+
if (!entry) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (entry instanceof VariableDefinition) {
|
|
119
|
+
return entry;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!entry.type) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
let constructor = VariableDefinition.getMember(entry.type);
|
|
127
|
+
|
|
128
|
+
if (!constructor) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
let result = new constructor(entry);
|
|
133
|
+
|
|
134
|
+
return result;
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Add a logical operator
|
|
139
|
+
*
|
|
140
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
141
|
+
* @since 0.1.6
|
|
142
|
+
* @version 0.1.6
|
|
143
|
+
*
|
|
144
|
+
* @param {String} name
|
|
145
|
+
* @param {Object} config
|
|
146
|
+
*/
|
|
147
|
+
VariableDefinition.setStatic(function addLogicalOperator(name, config) {
|
|
148
|
+
|
|
149
|
+
if (typeof config == 'string') {
|
|
150
|
+
config = {
|
|
151
|
+
title : config
|
|
152
|
+
};
|
|
153
|
+
} else if (!config) {
|
|
154
|
+
config = {};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if(!config.title) {
|
|
158
|
+
config.title = name.titleize();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
config.id = name;
|
|
162
|
+
|
|
163
|
+
this.constitute(function _addOperator() {
|
|
164
|
+
this.logical_operators[name] = config;
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Add an assignment operator
|
|
170
|
+
*
|
|
171
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
172
|
+
* @since 0.1.6
|
|
173
|
+
* @version 0.1.6
|
|
174
|
+
*
|
|
175
|
+
* @param {String} name
|
|
176
|
+
* @param {Object} config
|
|
177
|
+
*/
|
|
178
|
+
VariableDefinition.setStatic(function addAssignmentOperator(name, config) {
|
|
179
|
+
|
|
180
|
+
if (typeof config == 'string') {
|
|
181
|
+
config = {
|
|
182
|
+
title : config
|
|
183
|
+
};
|
|
184
|
+
} else if (!config) {
|
|
185
|
+
config = {};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if(!config.title) {
|
|
189
|
+
config.title = name.titleize();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
config.id = name;
|
|
193
|
+
|
|
194
|
+
this.constitute(function _addOperator() {
|
|
195
|
+
this.assignment_operators[name] = config;
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Apply configuration
|
|
201
|
+
*
|
|
202
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
203
|
+
* @since 0.1.6
|
|
204
|
+
* @version 0.1.6
|
|
205
|
+
*/
|
|
206
|
+
VariableDefinition.setMethod(function applyConfig(config) {
|
|
207
|
+
|
|
208
|
+
if (!config) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (config.name != null) {
|
|
213
|
+
this.name = config.name;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (config.title != null) {
|
|
217
|
+
this.title = config.title;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (config.description != null) {
|
|
221
|
+
this.description = config.description;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Return an simple object for JSON-ifying
|
|
227
|
+
*
|
|
228
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
229
|
+
* @since 0.1.6
|
|
230
|
+
* @version 0.1.6
|
|
231
|
+
*
|
|
232
|
+
* @return {Object}
|
|
233
|
+
*/
|
|
234
|
+
VariableDefinition.setMethod(function toJSON() {
|
|
235
|
+
return {
|
|
236
|
+
name : this.name,
|
|
237
|
+
title : this.title,
|
|
238
|
+
description : this.description,
|
|
239
|
+
type : this.type_name,
|
|
240
|
+
};
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Return an object for json-drying this object
|
|
245
|
+
*
|
|
246
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
247
|
+
* @since 0.1.6
|
|
248
|
+
* @version 0.1.6
|
|
249
|
+
*
|
|
250
|
+
* @return {Object}
|
|
251
|
+
*/
|
|
252
|
+
VariableDefinition.setMethod(function toDry() {
|
|
253
|
+
return {
|
|
254
|
+
value : this.toJSON(),
|
|
255
|
+
};
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* unDry an object
|
|
260
|
+
*
|
|
261
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
262
|
+
* @since 0.1.6
|
|
263
|
+
* @version 0.1.6
|
|
264
|
+
*
|
|
265
|
+
* @return {VariableDefinition}
|
|
266
|
+
*/
|
|
267
|
+
VariableDefinition.setStatic(function unDry(obj) {
|
|
268
|
+
return new this(obj);
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Get all available logical operators
|
|
273
|
+
*
|
|
274
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
275
|
+
* @since 0.1.6
|
|
276
|
+
* @version 0.1.6
|
|
277
|
+
*/
|
|
278
|
+
VariableDefinition.setMethod(function getLogicalOperators(value) {
|
|
279
|
+
return Object.values(this.constructor.logical_operators);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Get all available logical operators
|
|
284
|
+
*
|
|
285
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
286
|
+
* @since 0.1.6
|
|
287
|
+
* @version 0.1.6
|
|
288
|
+
*/
|
|
289
|
+
VariableDefinition.setMethod(function getAssignmentOperators(value) {
|
|
290
|
+
return Object.values(this.constructor.assignment_operators);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Create a value input element
|
|
295
|
+
*
|
|
296
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
297
|
+
* @since 0.1.6
|
|
298
|
+
* @version 0.1.6
|
|
299
|
+
*/
|
|
300
|
+
VariableDefinition.setMethod(function createValueInput(renderer, value_data) {
|
|
301
|
+
|
|
302
|
+
let input = renderer.createElement('input');
|
|
303
|
+
input.setAttribute('type', 'text');
|
|
304
|
+
|
|
305
|
+
return input;
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* The `equals` operator
|
|
310
|
+
*
|
|
311
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
312
|
+
* @since 0.1.6
|
|
313
|
+
* @version 0.1.6
|
|
314
|
+
*/
|
|
315
|
+
VariableDefinition.addLogicalOperator('equals');
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* The `not_equals` operator
|
|
319
|
+
*
|
|
320
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
321
|
+
* @since 0.1.6
|
|
322
|
+
* @version 0.1.6
|
|
323
|
+
*/
|
|
324
|
+
VariableDefinition.addLogicalOperator('not_equals');
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* The `is_empty` operator
|
|
328
|
+
*
|
|
329
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
330
|
+
* @since 0.1.6
|
|
331
|
+
* @version 0.1.6
|
|
332
|
+
*/
|
|
333
|
+
VariableDefinition.addLogicalOperator('is_empty');
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* The `is_null` operator
|
|
337
|
+
*
|
|
338
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
339
|
+
* @since 0.1.6
|
|
340
|
+
* @version 0.1.6
|
|
341
|
+
*/
|
|
342
|
+
VariableDefinition.addLogicalOperator('is_null');
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* The `set` operator sets a value
|
|
346
|
+
*
|
|
347
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
348
|
+
* @since 0.1.6
|
|
349
|
+
* @version 0.1.6
|
|
350
|
+
*/
|
|
351
|
+
VariableDefinition.addAssignmentOperator('set', 'Set');
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Boolean Value Type
|
|
3
|
+
*
|
|
4
|
+
* @constructor
|
|
5
|
+
*
|
|
6
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
7
|
+
* @since 0.1.6
|
|
8
|
+
* @version 0.1.6
|
|
9
|
+
*/
|
|
10
|
+
const BooleanDefinition = Function.inherits('Alchemy.QueryBuilder.VariableDefinition', 'Boolean');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Create a value input element
|
|
14
|
+
*
|
|
15
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
16
|
+
* @since 0.1.6
|
|
17
|
+
* @version 0.1.6
|
|
18
|
+
*
|
|
19
|
+
* @param {Hawkejs.Renderer}
|
|
20
|
+
*/
|
|
21
|
+
BooleanDefinition.setMethod(function createValueInput(renderer) {
|
|
22
|
+
let toggle = renderer.createElement('alchemy-toggle');
|
|
23
|
+
return toggle;
|
|
24
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Number Value Type
|
|
3
|
+
*
|
|
4
|
+
* @constructor
|
|
5
|
+
*
|
|
6
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
7
|
+
* @since 0.1.6
|
|
8
|
+
* @version 0.1.6
|
|
9
|
+
*/
|
|
10
|
+
const NumberDefinition = Function.inherits('Alchemy.QueryBuilder.VariableDefinition', 'Number');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The `<` operator
|
|
14
|
+
*
|
|
15
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
16
|
+
* @since 0.1.6
|
|
17
|
+
* @version 0.1.6
|
|
18
|
+
*/
|
|
19
|
+
NumberDefinition.addLogicalOperator('lt', 'Is Less Than');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The `<=` operator
|
|
23
|
+
*
|
|
24
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
25
|
+
* @since 0.1.6
|
|
26
|
+
* @version 0.1.6
|
|
27
|
+
*/
|
|
28
|
+
NumberDefinition.addLogicalOperator('lte', 'Is Less Or Equal Than');
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The `>` operator
|
|
32
|
+
*
|
|
33
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
34
|
+
* @since 0.1.6
|
|
35
|
+
* @version 0.1.6
|
|
36
|
+
*/
|
|
37
|
+
NumberDefinition.addLogicalOperator('gt', 'Is Greater Than');
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The `>=` operator
|
|
41
|
+
*
|
|
42
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
43
|
+
* @since 0.1.6
|
|
44
|
+
* @version 0.1.6
|
|
45
|
+
*/
|
|
46
|
+
NumberDefinition.addLogicalOperator('gte', 'Is Greater Or Equal Than');
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The `add` assignment operator adds a value
|
|
50
|
+
*
|
|
51
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
52
|
+
* @since 0.1.6
|
|
53
|
+
* @version 0.1.6
|
|
54
|
+
*/
|
|
55
|
+
NumberDefinition.addAssignmentOperator('add');
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The `subtract` assignment operator subtracts a value
|
|
59
|
+
*
|
|
60
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
61
|
+
* @since 0.1.6
|
|
62
|
+
* @version 0.1.6
|
|
63
|
+
*/
|
|
64
|
+
NumberDefinition.addAssignmentOperator('subtract');
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The `multiply` assignment operator multiplies a value
|
|
68
|
+
*
|
|
69
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
70
|
+
* @since 0.1.6
|
|
71
|
+
* @version 0.1.6
|
|
72
|
+
*/
|
|
73
|
+
NumberDefinition.addAssignmentOperator('multiply');
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The `divide` assignment operator divides a value
|
|
77
|
+
*
|
|
78
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
79
|
+
* @since 0.1.6
|
|
80
|
+
* @version 0.1.6
|
|
81
|
+
*/
|
|
82
|
+
NumberDefinition.addAssignmentOperator('divide');
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The `module` assignment operator leaves the rest
|
|
86
|
+
*
|
|
87
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
88
|
+
* @since 0.1.6
|
|
89
|
+
* @version 0.1.6
|
|
90
|
+
*/
|
|
91
|
+
NumberDefinition.addAssignmentOperator('modulo');
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Create a value input element
|
|
95
|
+
*
|
|
96
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
97
|
+
* @since 0.1.6
|
|
98
|
+
* @version 0.1.6
|
|
99
|
+
*/
|
|
100
|
+
NumberDefinition.setMethod(function createValueInput(renderer, value_data) {
|
|
101
|
+
|
|
102
|
+
let input = renderer.createElement('input');
|
|
103
|
+
input.setAttribute('type', 'number');
|
|
104
|
+
|
|
105
|
+
return input;
|
|
106
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The String Value Type
|
|
3
|
+
*
|
|
4
|
+
* @constructor
|
|
5
|
+
*
|
|
6
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
7
|
+
* @since 0.1.6
|
|
8
|
+
* @version 0.1.6
|
|
9
|
+
*/
|
|
10
|
+
const StringDefinition = Function.inherits('Alchemy.QueryBuilder.VariableDefinition', 'String');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The `contains` operator
|
|
14
|
+
*
|
|
15
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
16
|
+
* @since 0.1.6
|
|
17
|
+
* @version 0.1.6
|
|
18
|
+
*/
|
|
19
|
+
StringDefinition.addLogicalOperator('contains');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The `starts_with` operator
|
|
23
|
+
*
|
|
24
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
25
|
+
* @since 0.1.6
|
|
26
|
+
* @version 0.1.6
|
|
27
|
+
*/
|
|
28
|
+
StringDefinition.addLogicalOperator('starts_with');
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The `ends_with` operator
|
|
32
|
+
*
|
|
33
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
34
|
+
* @since 0.1.6
|
|
35
|
+
* @version 0.1.6
|
|
36
|
+
*/
|
|
37
|
+
StringDefinition.addLogicalOperator('ends_with');
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The `append` assignment operator adds text
|
|
41
|
+
*
|
|
42
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
43
|
+
* @since 0.1.6
|
|
44
|
+
* @version 0.1.6
|
|
45
|
+
*/
|
|
46
|
+
StringDefinition.addAssignmentOperator('append');
|
|
@@ -28,18 +28,65 @@ AlchemyField.constitute(function prepareSchema() {
|
|
|
28
28
|
// this.schema.addField('widgets', widgets, {array: true});
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Find the alchemy-form parent
|
|
33
|
+
*
|
|
34
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
35
|
+
* @since 0.1.4
|
|
36
|
+
* @version 0.1.4
|
|
37
|
+
*/
|
|
38
|
+
AlchemyField.enforceProperty(function alchemy_form(new_value) {
|
|
39
|
+
|
|
40
|
+
if (!new_value && this.config && this.config.alchemy_form) {
|
|
41
|
+
new_value = this.config.alchemy_form;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!new_value) {
|
|
45
|
+
|
|
46
|
+
let parent = this.parent_instance;
|
|
47
|
+
|
|
48
|
+
while (parent) {
|
|
49
|
+
|
|
50
|
+
new_value = parent.alchemy_form;
|
|
51
|
+
|
|
52
|
+
if (new_value) {
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (parent.element) {
|
|
57
|
+
new_value = parent.element.querySelector('alchemy-form');
|
|
58
|
+
|
|
59
|
+
if (new_value) {
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
parent = parent.parent_instance;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return new_value;
|
|
69
|
+
});
|
|
70
|
+
|
|
31
71
|
/**
|
|
32
72
|
* Populate the widget
|
|
33
73
|
*
|
|
34
74
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
35
75
|
* @since 0.1.0
|
|
36
|
-
* @version 0.1.
|
|
76
|
+
* @version 0.1.4
|
|
37
77
|
*/
|
|
38
78
|
AlchemyField.setMethod(function populateWidget() {
|
|
39
79
|
|
|
40
80
|
let config = this.config;
|
|
41
81
|
|
|
82
|
+
let alchemy_form = this.alchemy_form;
|
|
83
|
+
|
|
42
84
|
let field_el = this.createElement('alchemy-field');
|
|
85
|
+
|
|
86
|
+
if (alchemy_form) {
|
|
87
|
+
field_el.alchemy_form = alchemy_form;
|
|
88
|
+
}
|
|
89
|
+
|
|
43
90
|
field_el.field_name = config.field;
|
|
44
91
|
|
|
45
92
|
if (config.view) {
|
|
@@ -16,7 +16,7 @@ const AlchemyForm = Function.inherits('Alchemy.Widget', 'AlchemyForm');
|
|
|
16
16
|
*
|
|
17
17
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
18
18
|
* @since 0.1.0
|
|
19
|
-
* @version 0.1.
|
|
19
|
+
* @version 0.1.4
|
|
20
20
|
*/
|
|
21
21
|
AlchemyForm.setMethod(function populateWidget() {
|
|
22
22
|
|
|
@@ -31,7 +31,22 @@ AlchemyForm.setMethod(function populateWidget() {
|
|
|
31
31
|
form.classList.add('alchemy-widgets-container');
|
|
32
32
|
|
|
33
33
|
if (this.config && this.config.widgets) {
|
|
34
|
-
|
|
34
|
+
let widgets = this.config.widgets.slice(0),
|
|
35
|
+
widget,
|
|
36
|
+
i;
|
|
37
|
+
|
|
38
|
+
for (i = 0; i < widgets.length; i++) {
|
|
39
|
+
widget = widgets[i];
|
|
40
|
+
|
|
41
|
+
if (widget.type == 'alchemy_field') {
|
|
42
|
+
widget = Object.assign({}, widget);
|
|
43
|
+
widget.config = Object.assign({}, widget.config);
|
|
44
|
+
widget.config.alchemy_form = form;
|
|
45
|
+
widgets[i] = widget;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
col.widget.value = widgets;
|
|
35
50
|
}
|
|
36
51
|
|
|
37
52
|
let record = this.element.getContextVariable('record');
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A QueryBuilderAssignment field lets you set variable values
|
|
3
|
+
* using the QueryBuilder logic
|
|
4
|
+
*
|
|
5
|
+
* @constructor
|
|
6
|
+
*
|
|
7
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
8
|
+
* @since 0.1.6
|
|
9
|
+
* @version 0.1.6
|
|
10
|
+
*/
|
|
11
|
+
const QueryBuilderAssignment = Function.inherits('Alchemy.Field.QueryBuilder', 'QueryBuilderAssignment');
|