alchemy-form 0.1.11 → 0.1.12
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 +17 -0
- package/controller/form_api_controller.js +0 -1
- package/element/alchemy_field.js +67 -17
- package/element/alchemy_field_schema.js +20 -8
- package/element/alchemy_pager.js +5 -5
- package/element/alchemy_select_item.js +18 -4
- package/element/alchemy_table.js +18 -12
- package/element/query_builder_entry.js +6 -5
- package/helper/query_builder_ns.js +108 -0
- package/helper/query_builder_variable_definition/00_variable_definition.js +52 -1
- package/helper/widgets/alchemy_field_widget.js +6 -31
- package/helper/widgets/alchemy_form_widget.js +14 -0
- package/helper/widgets/alchemy_table_widget.js +14 -0
- package/helper_field/query_builder_field.js +49 -28
- package/helper_field/query_builder_value.js +0 -45
- package/helper_field/query_builder_variable.js +0 -45
- package/package.json +1 -1
- package/view/form/elements/alchemy_select_item.hwk +1 -3
- package/view/form/inputs/view_inline/enum.hwk +1 -0
- package/view/form/select/qb_item.hwk +1 -0
- package/view/form/inputs/view_inline/file.hwk +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## 0.1.12 (2022-10-12)
|
|
2
|
+
|
|
3
|
+
* Don't let users manually add form widgets
|
|
4
|
+
* Allow overriding alchemy-field title & description in extra widget settings
|
|
5
|
+
* Allow overriding an alchemy-field's used wrapper-view
|
|
6
|
+
* Add `AlchemyField#applyOptions(options)` method
|
|
7
|
+
* Allow an alchemy-field's field_title property to be set
|
|
8
|
+
* Allow turning off specific column filters in alchemy-table
|
|
9
|
+
* Add inline enum field view
|
|
10
|
+
* Fix alchemy-pager icons
|
|
11
|
+
* Use `Model#getDisplayTitle()` to get the display title of records for alchemy-select-items
|
|
12
|
+
* Make the QueryBuilder field's source data configurable
|
|
13
|
+
* Add `VariableDefinition.fromMany()` method
|
|
14
|
+
* `VariableDefinition.cast()` now also accepts `Field` instances
|
|
15
|
+
* Add `QueryBuilder.applyToCriteria()` method
|
|
16
|
+
* Fix schema fields sometimes getting the wrong schema from an Enum value
|
|
17
|
+
|
|
1
18
|
## 0.1.11 (2022-07-23)
|
|
2
19
|
|
|
3
20
|
* Upgrade to `alchemy-media` v0.6.3
|
package/element/alchemy_field.js
CHANGED
|
@@ -70,6 +70,15 @@ Field.setAttribute('field-type');
|
|
|
70
70
|
*/
|
|
71
71
|
Field.setAttribute('field-view');
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* The wrapper view override
|
|
75
|
+
*
|
|
76
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
77
|
+
* @since 0.1.12
|
|
78
|
+
* @version 0.1.12
|
|
79
|
+
*/
|
|
80
|
+
Field.setAttribute('wrapper-view');
|
|
81
|
+
|
|
73
82
|
/**
|
|
74
83
|
* Is this a read only field?
|
|
75
84
|
*
|
|
@@ -260,22 +269,19 @@ Field.setProperty(function is_translatable() {
|
|
|
260
269
|
*
|
|
261
270
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
262
271
|
* @since 0.1.0
|
|
263
|
-
* @version 0.1.
|
|
272
|
+
* @version 0.1.12
|
|
264
273
|
*/
|
|
265
274
|
Field.setProperty(function field_title() {
|
|
266
275
|
|
|
267
|
-
let
|
|
268
|
-
result;
|
|
269
|
-
|
|
270
|
-
if (config) {
|
|
271
|
-
result = config.title;
|
|
272
|
-
}
|
|
276
|
+
let result = this._title || this.widget_settings?.title || this.config?.title;
|
|
273
277
|
|
|
274
278
|
if (!result && this.field_name) {
|
|
275
279
|
result = this.field_name.titleize();
|
|
276
280
|
}
|
|
277
281
|
|
|
278
282
|
return result;
|
|
283
|
+
}, function setTitle(value) {
|
|
284
|
+
this._title = value;
|
|
279
285
|
});
|
|
280
286
|
|
|
281
287
|
/**
|
|
@@ -283,16 +289,11 @@ Field.setProperty(function field_title() {
|
|
|
283
289
|
*
|
|
284
290
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
285
291
|
* @since 0.1.0
|
|
286
|
-
* @version 0.1.
|
|
292
|
+
* @version 0.1.12
|
|
287
293
|
*/
|
|
288
294
|
Field.setProperty(function field_description() {
|
|
289
295
|
|
|
290
|
-
let
|
|
291
|
-
result;
|
|
292
|
-
|
|
293
|
-
if (config && config.options) {
|
|
294
|
-
result = config.options.description;
|
|
295
|
-
}
|
|
296
|
+
let result = this.widget_settings?.description || this.config?.description;
|
|
296
297
|
|
|
297
298
|
return result;
|
|
298
299
|
});
|
|
@@ -393,11 +394,11 @@ Field.enforceProperty(function wrapper_file(new_value, old_value) {
|
|
|
393
394
|
return false;
|
|
394
395
|
}
|
|
395
396
|
|
|
396
|
-
let
|
|
397
|
+
let wrapper_view = this.wrapper_view || this.getFieldType(),
|
|
397
398
|
view_type = this.view_type;
|
|
398
399
|
|
|
399
|
-
if (
|
|
400
|
-
return this.generateTemplatePath('wrappers', view_type,
|
|
400
|
+
if (wrapper_view) {
|
|
401
|
+
return this.generateTemplatePath('wrappers', view_type, wrapper_view);
|
|
401
402
|
}
|
|
402
403
|
}
|
|
403
404
|
|
|
@@ -584,6 +585,55 @@ Field.setProperty(function value() {
|
|
|
584
585
|
}
|
|
585
586
|
});
|
|
586
587
|
|
|
588
|
+
/**
|
|
589
|
+
* Apply options
|
|
590
|
+
*
|
|
591
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
592
|
+
* @since 0.1.12
|
|
593
|
+
* @version 0.1.12
|
|
594
|
+
*
|
|
595
|
+
* @param {Object} options
|
|
596
|
+
*/
|
|
597
|
+
Field.setMethod(function applyOptions(options) {
|
|
598
|
+
|
|
599
|
+
if (!options || typeof options != 'object') {
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
if (options.purpose) {
|
|
604
|
+
this.purpose = options.purpose;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
if (options.mode) {
|
|
608
|
+
this.mode = options.mode;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
if (options.view) {
|
|
612
|
+
this.field_view = options.view;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
if (options.wrapper) {
|
|
616
|
+
this.wrapper_view = options.wrapper;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
if (options.readonly) {
|
|
620
|
+
this.readonly = true;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
if (options.widget_settings) {
|
|
624
|
+
this.widget_settings = options.widget_settings;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
if (options.data_src) {
|
|
628
|
+
this.data_src = options.data_src;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
if (options.title) {
|
|
632
|
+
this.field_title = options.title;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
});
|
|
636
|
+
|
|
587
637
|
/**
|
|
588
638
|
* Get the field type
|
|
589
639
|
*
|
|
@@ -5,9 +5,7 @@
|
|
|
5
5
|
* @since 0.1.0
|
|
6
6
|
* @version 0.1.0
|
|
7
7
|
*/
|
|
8
|
-
var FieldSchema = Function.inherits('Alchemy.Element.Form.FieldCustom',
|
|
9
|
-
FieldSchema.super.call(this);
|
|
10
|
-
});
|
|
8
|
+
var FieldSchema = Function.inherits('Alchemy.Element.Form.FieldCustom', 'FieldSchema');
|
|
11
9
|
|
|
12
10
|
/**
|
|
13
11
|
* The template to use for the content of this element
|
|
@@ -23,7 +21,7 @@ FieldSchema.setTemplateFile('form/elements/alchemy_field_schema');
|
|
|
23
21
|
*
|
|
24
22
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
25
23
|
* @since 0.1.0
|
|
26
|
-
* @version 0.1.
|
|
24
|
+
* @version 0.1.12
|
|
27
25
|
*/
|
|
28
26
|
FieldSchema.setProperty(function schema() {
|
|
29
27
|
|
|
@@ -38,15 +36,29 @@ FieldSchema.setProperty(function schema() {
|
|
|
38
36
|
let values = other_field.config.options.values;
|
|
39
37
|
|
|
40
38
|
if (values) {
|
|
39
|
+
let value;
|
|
41
40
|
|
|
42
41
|
if (values instanceof Classes.Alchemy.Map.Backed) {
|
|
43
|
-
|
|
42
|
+
value = values.get(other_field.value);
|
|
44
43
|
} else {
|
|
45
|
-
|
|
44
|
+
value = values[other_field.value];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (value) {
|
|
48
|
+
if (value.schema) {
|
|
49
|
+
schema = value.schema;
|
|
50
|
+
} else if (value.value) {
|
|
51
|
+
// Enumified values can be wrapped on the server-side
|
|
52
|
+
value = value.value;
|
|
53
|
+
|
|
54
|
+
if (value.schema) {
|
|
55
|
+
schema = value.schema;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
46
58
|
}
|
|
47
59
|
|
|
48
|
-
if (schema
|
|
49
|
-
schema =
|
|
60
|
+
if (!schema) {
|
|
61
|
+
schema = value;
|
|
50
62
|
}
|
|
51
63
|
}
|
|
52
64
|
}
|
package/element/alchemy_pager.js
CHANGED
|
@@ -12,28 +12,28 @@ const Pager = Function.inherits('Alchemy.Element.Form.Base', 'Pager');
|
|
|
12
12
|
*
|
|
13
13
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
14
14
|
* @since 0.1.0
|
|
15
|
-
* @version 0.1.
|
|
15
|
+
* @version 0.1.12
|
|
16
16
|
*/
|
|
17
17
|
Pager.setTemplate(`<ul>
|
|
18
18
|
<li class="afp-first">
|
|
19
19
|
<a href="#" aria-label="First page">
|
|
20
|
-
<al-ico
|
|
20
|
+
<al-ico icon-name="left-to-line"></al-ico>
|
|
21
21
|
</a>
|
|
22
22
|
</li>
|
|
23
23
|
<li class="afp-prev">
|
|
24
24
|
<a href="#" aria-label="Previous page">
|
|
25
|
-
<al-ico
|
|
25
|
+
<al-ico icon-name="left"></al-ico>
|
|
26
26
|
</a>
|
|
27
27
|
</li>
|
|
28
28
|
|
|
29
29
|
<li class="afp-next">
|
|
30
30
|
<a href="#" aria-label="Next page">
|
|
31
|
-
<al-ico
|
|
31
|
+
<al-ico icon-name="right"></al-ico>
|
|
32
32
|
</a>
|
|
33
33
|
</li>
|
|
34
34
|
<li class="afp-last">
|
|
35
35
|
<a href="#" aria-label="Last page">
|
|
36
|
-
<al-ico
|
|
36
|
+
<al-ico icon-name="right-to-line"></al-ico>
|
|
37
37
|
</a>
|
|
38
38
|
</li>
|
|
39
39
|
</ul>`, true);
|
|
@@ -85,13 +85,27 @@ Item.enforceProperty(function alchemy_select(new_value) {
|
|
|
85
85
|
*
|
|
86
86
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
87
87
|
* @since 0.1.5
|
|
88
|
-
* @version 0.1.
|
|
88
|
+
* @version 0.1.12
|
|
89
89
|
*/
|
|
90
90
|
Item.setProperty(function display_title() {
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
let result;
|
|
93
|
+
|
|
94
|
+
if (this.data) {
|
|
95
|
+
const model = this.data.$model;
|
|
96
|
+
|
|
97
|
+
if (model) {
|
|
98
|
+
result = model.getDisplayTitle(this.data, ['title', 'name']);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (!result) {
|
|
103
|
+
if (this.data) {
|
|
104
|
+
result = this.data.title || this.data.name || this.data.$pk || this.value;
|
|
105
|
+
} else {
|
|
106
|
+
result = this.value;
|
|
107
|
+
}
|
|
94
108
|
}
|
|
95
109
|
|
|
96
|
-
return
|
|
110
|
+
return result || '';
|
|
97
111
|
});
|
package/element/alchemy_table.js
CHANGED
|
@@ -626,7 +626,7 @@ Table.setMethod(function showPagination() {
|
|
|
626
626
|
*
|
|
627
627
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
628
628
|
* @since 0.1.8
|
|
629
|
-
* @version 0.1.
|
|
629
|
+
* @version 0.1.12
|
|
630
630
|
*
|
|
631
631
|
* @param {FieldConfig} field_config The config on how to display the field
|
|
632
632
|
* @param {Object} container The container where the field should be in
|
|
@@ -663,6 +663,8 @@ Table.setMethod(function getFieldConfigView(field_config, container) {
|
|
|
663
663
|
alchemy_field.purpose = this.purpose || 'view';
|
|
664
664
|
alchemy_field.mode = this.mode || 'inline';
|
|
665
665
|
|
|
666
|
+
alchemy_field.applyOptions(field_config.options);
|
|
667
|
+
|
|
666
668
|
//alchemy_field.view_type = this.view_type || 'view_inline';
|
|
667
669
|
alchemy_field.field_name = field.name;
|
|
668
670
|
alchemy_field.config = field;
|
|
@@ -886,7 +888,7 @@ Table.setMethod(function attachContextMenus() {
|
|
|
886
888
|
*
|
|
887
889
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
888
890
|
* @since 0.1.0
|
|
889
|
-
* @version 0.1.
|
|
891
|
+
* @version 0.1.12
|
|
890
892
|
*/
|
|
891
893
|
Table.setMethod(function onFieldsetAssignment(value, old_value) {
|
|
892
894
|
|
|
@@ -939,18 +941,22 @@ Table.setMethod(function onFieldsetAssignment(value, old_value) {
|
|
|
939
941
|
names_row.append(col);
|
|
940
942
|
|
|
941
943
|
col = this.createElement('th');
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
944
|
+
|
|
945
|
+
if (field.options.filter !== false) {
|
|
946
|
+
input = this.createElement('input');
|
|
947
|
+
input.dataset.field = field.path;
|
|
948
|
+
input.classList.add('filter');
|
|
949
|
+
input.setAttribute('type', 'search');
|
|
950
|
+
input.setAttribute('aria-label', 'Filter ' + field.title);
|
|
951
|
+
|
|
952
|
+
// If filters have been defined already, put it in the value
|
|
953
|
+
if (this.filters && this.filters[field.path]) {
|
|
954
|
+
input.setAttribute('value', this.filters[field.path]);
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
col.append(input);
|
|
951
958
|
}
|
|
952
959
|
|
|
953
|
-
col.append(input);
|
|
954
960
|
filter_row.append(col);
|
|
955
961
|
}
|
|
956
962
|
|
|
@@ -127,7 +127,7 @@ QueryBuilderEntry.setProperty(function value() {
|
|
|
127
127
|
*
|
|
128
128
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
129
129
|
* @since 0.1.6
|
|
130
|
-
* @version 0.1.
|
|
130
|
+
* @version 0.1.12
|
|
131
131
|
*/
|
|
132
132
|
QueryBuilderEntry.setMethod(async function loadData(config, element) {
|
|
133
133
|
|
|
@@ -149,10 +149,11 @@ QueryBuilderEntry.setMethod(async function loadData(config, element) {
|
|
|
149
149
|
items = await this.loadValueTypeData(config);
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
152
|
+
if (items) {
|
|
153
|
+
items.clean(null);
|
|
154
|
+
items.clean(undefined);
|
|
155
|
+
items.clean(false);
|
|
156
|
+
}
|
|
156
157
|
|
|
157
158
|
return {
|
|
158
159
|
items: items,
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
const QueryBuilder = Fn.getNamespace('Alchemy.QueryBuilder');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Apply query builder settings to a criteria
|
|
5
|
+
*
|
|
6
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
7
|
+
* @since 0.1.12
|
|
8
|
+
* @version 0.1.12
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} conditions
|
|
11
|
+
* @param {Criteria} criteria
|
|
12
|
+
* @param {Boolean} inverted
|
|
13
|
+
*/
|
|
14
|
+
QueryBuilder.applyToCriteria = function applyToCriteria(conditions, criteria, inverted) {
|
|
15
|
+
|
|
16
|
+
if (!conditions || !conditions.rules?.length) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let group;
|
|
21
|
+
|
|
22
|
+
if (conditions.condition == 'or') {
|
|
23
|
+
group = criteria.or();
|
|
24
|
+
} else {
|
|
25
|
+
group = criteria.and();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (inverted == null) {
|
|
29
|
+
inverted = false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (conditions.inverted) {
|
|
33
|
+
inverted = !inverted;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
for (let rule of conditions.rules) {
|
|
37
|
+
applyRule(rule, criteria, inverted);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Apply a single rule to a criteria
|
|
43
|
+
*
|
|
44
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
45
|
+
* @since 0.1.12
|
|
46
|
+
* @version 0.1.12
|
|
47
|
+
*
|
|
48
|
+
* @param {Object} rule
|
|
49
|
+
* @param {Criteria} criteria
|
|
50
|
+
* @param {Boolean} inverted
|
|
51
|
+
*/
|
|
52
|
+
function applyRule(rule, criteria, inverted) {
|
|
53
|
+
|
|
54
|
+
if (rule.type == 'group') {
|
|
55
|
+
return QueryBuilder.applyToCriteria(rule, criteria, inverted);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (rule.type != 'qb_entry') {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Referencing other fields is not supported
|
|
63
|
+
if (rule.value_variable) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let context = criteria.where(rule.field);
|
|
68
|
+
|
|
69
|
+
if (inverted) {
|
|
70
|
+
context = context.not();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (rule.operator == 'is_empty') {
|
|
74
|
+
context.isEmpty();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (rule.operator == 'is_null') {
|
|
79
|
+
context.isNull();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let value = rule.value_explicit.value;
|
|
84
|
+
|
|
85
|
+
let method;
|
|
86
|
+
|
|
87
|
+
switch (rule.operator) {
|
|
88
|
+
case 'ne':
|
|
89
|
+
case 'not_equals':
|
|
90
|
+
method = 'ne';
|
|
91
|
+
break;
|
|
92
|
+
|
|
93
|
+
case 'starts_with':
|
|
94
|
+
value = RegExp.interpret('^' + value);
|
|
95
|
+
method = 'equals';
|
|
96
|
+
break;
|
|
97
|
+
|
|
98
|
+
case 'ends_with':
|
|
99
|
+
value = RegExp.interpret(value + '$');
|
|
100
|
+
method = 'equals';
|
|
101
|
+
break;
|
|
102
|
+
|
|
103
|
+
default:
|
|
104
|
+
method = rule.operator;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
context[method](value);
|
|
108
|
+
}
|
|
@@ -102,12 +102,48 @@ VariableDefinition.constitute(function prepareOperators() {
|
|
|
102
102
|
this.assignment_operators = {};
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Get a list of definitions from the input
|
|
107
|
+
*
|
|
108
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
109
|
+
* @since 0.1.12
|
|
110
|
+
* @version 0.1.12
|
|
111
|
+
*
|
|
112
|
+
* @param {*} input
|
|
113
|
+
*
|
|
114
|
+
* @return {VariableDefinition[]}
|
|
115
|
+
*/
|
|
116
|
+
VariableDefinition.setStatic(function fromMany(input) {
|
|
117
|
+
|
|
118
|
+
let result = [];
|
|
119
|
+
|
|
120
|
+
if (input) {
|
|
121
|
+
|
|
122
|
+
let schema = input.schema;
|
|
123
|
+
|
|
124
|
+
if (schema && schema instanceof Classes.Alchemy.Schema) {
|
|
125
|
+
|
|
126
|
+
for (let entry of schema) {
|
|
127
|
+
|
|
128
|
+
let instance = VariableDefinition.cast(entry);
|
|
129
|
+
|
|
130
|
+
if (instance) {
|
|
131
|
+
result.push(instance);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return result;
|
|
139
|
+
});
|
|
140
|
+
|
|
105
141
|
/**
|
|
106
142
|
* Create the correct variable definition
|
|
107
143
|
*
|
|
108
144
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
109
145
|
* @since 0.1.6
|
|
110
|
-
* @version 0.1.
|
|
146
|
+
* @version 0.1.12
|
|
111
147
|
*/
|
|
112
148
|
VariableDefinition.setStatic(function cast(entry) {
|
|
113
149
|
|
|
@@ -119,6 +155,21 @@ VariableDefinition.setStatic(function cast(entry) {
|
|
|
119
155
|
return entry;
|
|
120
156
|
}
|
|
121
157
|
|
|
158
|
+
if (entry instanceof Classes.Alchemy.Field) {
|
|
159
|
+
let field = entry;
|
|
160
|
+
|
|
161
|
+
entry = {
|
|
162
|
+
name : field.name,
|
|
163
|
+
title : field.title,
|
|
164
|
+
description : field.options.description,
|
|
165
|
+
type : field.constructor.type_name,
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
if (!VariableDefinition.getMember(entry.type)) {
|
|
169
|
+
entry.type = 'string';
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
122
173
|
if (!entry.type) {
|
|
123
174
|
return null;
|
|
124
175
|
}
|
|
@@ -16,16 +16,13 @@ const AlchemyField = Function.inherits('Alchemy.Widget', 'AlchemyField');
|
|
|
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.12
|
|
20
20
|
*/
|
|
21
21
|
AlchemyField.constitute(function prepareSchema() {
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// widgets.addField('config', 'Schema', {schema: 'type'});
|
|
27
|
-
|
|
28
|
-
// this.schema.addField('widgets', widgets, {array: true});
|
|
23
|
+
this.setAddChecker(function(widget_element) {
|
|
24
|
+
return false;
|
|
25
|
+
});
|
|
29
26
|
});
|
|
30
27
|
|
|
31
28
|
/**
|
|
@@ -73,7 +70,7 @@ AlchemyField.enforceProperty(function alchemy_form(new_value) {
|
|
|
73
70
|
*
|
|
74
71
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
75
72
|
* @since 0.1.0
|
|
76
|
-
* @version 0.1.
|
|
73
|
+
* @version 0.1.12
|
|
77
74
|
*/
|
|
78
75
|
AlchemyField.setMethod(function populateWidget() {
|
|
79
76
|
|
|
@@ -89,29 +86,7 @@ AlchemyField.setMethod(function populateWidget() {
|
|
|
89
86
|
|
|
90
87
|
field_el.field_name = config.field;
|
|
91
88
|
|
|
92
|
-
|
|
93
|
-
field_el.purpose = config.purpose;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (config.mode) {
|
|
97
|
-
field_el.mode = config.mode;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (config.view) {
|
|
101
|
-
field_el.field_view = config.view;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (config.readonly) {
|
|
105
|
-
field_el.readonly = true;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (config.widget_settings) {
|
|
109
|
-
field_el.widget_settings = config.widget_settings;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (config.data_src) {
|
|
113
|
-
field_el.data_src = config.data_src;
|
|
114
|
-
}
|
|
89
|
+
field_el.applyOptions(config);
|
|
115
90
|
|
|
116
91
|
this.element.append(field_el);
|
|
117
92
|
});
|
|
@@ -11,6 +11,20 @@
|
|
|
11
11
|
*/
|
|
12
12
|
const AlchemyForm = Function.inherits('Alchemy.Widget', 'AlchemyForm');
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Prepare the schema
|
|
16
|
+
*
|
|
17
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
18
|
+
* @since 0.1.12
|
|
19
|
+
* @version 0.1.12
|
|
20
|
+
*/
|
|
21
|
+
AlchemyForm.constitute(function prepareSchema() {
|
|
22
|
+
|
|
23
|
+
this.setAddChecker(function(widget_element) {
|
|
24
|
+
return false;
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
14
28
|
/**
|
|
15
29
|
* Populate the widget
|
|
16
30
|
*
|
|
@@ -11,6 +11,20 @@
|
|
|
11
11
|
*/
|
|
12
12
|
const AlchemyTable = Function.inherits('Alchemy.Widget', 'AlchemyTable');
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Prepare the schema
|
|
16
|
+
*
|
|
17
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
18
|
+
* @since 0.1.12
|
|
19
|
+
* @version 0.1.12
|
|
20
|
+
*/
|
|
21
|
+
AlchemyTable.constitute(function prepareSchema() {
|
|
22
|
+
|
|
23
|
+
this.setAddChecker(function(widget_element) {
|
|
24
|
+
return false;
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
14
28
|
/**
|
|
15
29
|
* Populate the widget
|
|
16
30
|
*
|
|
@@ -50,42 +50,63 @@ QueryBuilderField.setMethod(function cast(value, to_datasource) {
|
|
|
50
50
|
*
|
|
51
51
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
52
52
|
* @since 0.1.6
|
|
53
|
-
* @version 0.1.
|
|
53
|
+
* @version 0.1.12
|
|
54
54
|
*
|
|
55
55
|
* @param {Object} config
|
|
56
56
|
* @param {HTMLElement} element
|
|
57
57
|
*/
|
|
58
58
|
QueryBuilderField.setMethod(function loadData(config, element) {
|
|
59
59
|
|
|
60
|
+
const options = this.options || {},
|
|
61
|
+
source_type = options.variable_data || 'document',
|
|
62
|
+
add_form_value = options.add_form_value || false;
|
|
63
|
+
|
|
64
|
+
let api_route,
|
|
65
|
+
form;
|
|
66
|
+
|
|
67
|
+
let body = {
|
|
68
|
+
source_type,
|
|
69
|
+
config,
|
|
70
|
+
};
|
|
71
|
+
|
|
60
72
|
if (element) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (form) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (doc && doc.root_document) {
|
|
67
|
-
doc = doc.root_document;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
let model_name,
|
|
71
|
-
$pk;
|
|
72
|
-
|
|
73
|
-
if (doc) {
|
|
74
|
-
model_name = doc.$model_name;
|
|
75
|
-
$pk = doc.$pk;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return element.hawkejs_helpers.Alchemy.getResource({
|
|
79
|
-
name : 'FormApi#queryBuilderData',
|
|
80
|
-
post : true,
|
|
81
|
-
body : {
|
|
82
|
-
model : model_name,
|
|
83
|
-
$pk : $pk,
|
|
84
|
-
config : config,
|
|
85
|
-
}
|
|
86
|
-
});
|
|
73
|
+
form = element.queryParents('alchemy-form');
|
|
74
|
+
|
|
75
|
+
if (add_form_value && form) {
|
|
76
|
+
body.form_value = form.value;
|
|
87
77
|
}
|
|
88
78
|
}
|
|
89
79
|
|
|
90
|
-
|
|
80
|
+
// Use the current document data to get the variable data
|
|
81
|
+
if (form && source_type == 'document') {
|
|
82
|
+
|
|
83
|
+
let doc = form.document;
|
|
84
|
+
|
|
85
|
+
if (doc && doc.root_document) {
|
|
86
|
+
doc = doc.root_document;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
let model_name,
|
|
90
|
+
$pk;
|
|
91
|
+
|
|
92
|
+
if (doc) {
|
|
93
|
+
model_name = doc.$model_name;
|
|
94
|
+
$pk = doc.$pk;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
body.model = model_name;
|
|
98
|
+
body.$pk = $pk;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (options.route) {
|
|
102
|
+
api_route = options.route;
|
|
103
|
+
} else {
|
|
104
|
+
api_route = 'FormApi#queryBuilderData';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return element.hawkejs_helpers.Alchemy.getResource({
|
|
108
|
+
name : api_route,
|
|
109
|
+
post : true,
|
|
110
|
+
body,
|
|
111
|
+
});
|
|
91
112
|
});
|
|
@@ -9,48 +9,3 @@
|
|
|
9
9
|
* @version 0.1.6
|
|
10
10
|
*/
|
|
11
11
|
const QueryBuilderValue = Function.inherits('Alchemy.Field.QueryBuilder', 'QueryBuilderValue');
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Load remote data
|
|
15
|
-
*
|
|
16
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
17
|
-
* @since 0.1.6
|
|
18
|
-
* @version 0.1.6
|
|
19
|
-
*
|
|
20
|
-
* @param {Object} config
|
|
21
|
-
* @param {HTMLElement} element
|
|
22
|
-
*/
|
|
23
|
-
QueryBuilderValue.setMethod(function loadData(config, element) {
|
|
24
|
-
|
|
25
|
-
if (element) {
|
|
26
|
-
let form = element.queryParents('alchemy-form');
|
|
27
|
-
|
|
28
|
-
if (form) {
|
|
29
|
-
let doc = form.document;
|
|
30
|
-
|
|
31
|
-
if (doc && doc.root_document) {
|
|
32
|
-
doc = doc.root_document;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
let model_name,
|
|
36
|
-
$pk;
|
|
37
|
-
|
|
38
|
-
if (doc) {
|
|
39
|
-
model_name = doc.$model_name;
|
|
40
|
-
$pk = doc.$pk;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return element.hawkejs_helpers.Alchemy.getResource({
|
|
44
|
-
name : 'FormApi#queryBuilderData',
|
|
45
|
-
post : true,
|
|
46
|
-
body : {
|
|
47
|
-
model : model_name,
|
|
48
|
-
$pk : $pk,
|
|
49
|
-
config : config,
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return [];
|
|
56
|
-
});
|
|
@@ -9,48 +9,3 @@
|
|
|
9
9
|
* @version 0.1.6
|
|
10
10
|
*/
|
|
11
11
|
const QueryBuilderVariable = Function.inherits('Alchemy.Field.QueryBuilder', 'QueryBuilderVariable');
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Load remote data
|
|
15
|
-
*
|
|
16
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
17
|
-
* @since 0.1.6
|
|
18
|
-
* @version 0.1.6
|
|
19
|
-
*
|
|
20
|
-
* @param {Object} config
|
|
21
|
-
* @param {HTMLElement} element
|
|
22
|
-
*/
|
|
23
|
-
QueryBuilderVariable.setMethod(function loadData(config, element) {
|
|
24
|
-
|
|
25
|
-
if (element) {
|
|
26
|
-
let form = element.queryParents('alchemy-form');
|
|
27
|
-
|
|
28
|
-
if (form) {
|
|
29
|
-
let doc = form.document;
|
|
30
|
-
|
|
31
|
-
if (doc && doc.root_document) {
|
|
32
|
-
doc = doc.root_document;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
let model_name,
|
|
36
|
-
$pk;
|
|
37
|
-
|
|
38
|
-
if (doc) {
|
|
39
|
-
model_name = doc.$model_name;
|
|
40
|
-
$pk = doc.$pk;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return element.hawkejs_helpers.Alchemy.getResource({
|
|
44
|
-
name : 'FormApi#queryBuilderData',
|
|
45
|
-
post : true,
|
|
46
|
-
body : {
|
|
47
|
-
model : model_name,
|
|
48
|
-
$pk : $pk,
|
|
49
|
-
config : config,
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return [];
|
|
56
|
-
});
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<span class="alchemy-field-value alchemy-field-enum">{{ value }}</span>
|