alchemy-form 0.1.10 → 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 +23 -0
- package/assets/stylesheets/form/alchemy_field.scss +33 -0
- package/controller/form_api_controller.js +0 -1
- package/element/00_form_base.js +48 -9
- package/element/alchemy_field.js +143 -51
- 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 +123 -38
- package/element/query_builder_entry.js +6 -5
- package/element/query_builder_value.js +1 -1
- package/helper/form_actions/url_action.js +2 -2
- 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 -23
- package/helper/widgets/alchemy_form_widget.js +26 -2
- package/helper/widgets/alchemy_table_widget.js +18 -1
- 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 +3 -2
- package/view/form/elements/alchemy_select_item.hwk +1 -3
- package/view/form/inputs/edit_inline/boolean.hwk +4 -0
- package/view/form/inputs/view_inline/boolean.hwk +19 -0
- package/view/form/inputs/view_inline/date.hwk +4 -0
- package/view/form/inputs/view_inline/enum.hwk +1 -0
- package/view/form/inputs/view_inline/objectid.hwk +1 -0
- package/view/form/select/qb_item.hwk +1 -0
- package/view/form/wrappers/edit_inline/default.hwk +1 -0
- package/view/form/wrappers/view_inline/default.hwk +1 -1
- package/view/form/inputs/view_inline/file.hwk +0 -6
|
@@ -11,12 +11,26 @@
|
|
|
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
|
*
|
|
17
31
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
18
32
|
* @since 0.1.0
|
|
19
|
-
* @version 0.1.
|
|
33
|
+
* @version 0.1.8
|
|
20
34
|
*/
|
|
21
35
|
AlchemyTable.setMethod(function populateWidget() {
|
|
22
36
|
|
|
@@ -46,5 +60,8 @@ AlchemyTable.setMethod(function populateWidget() {
|
|
|
46
60
|
table.recordsource = config.recordsource;
|
|
47
61
|
}
|
|
48
62
|
|
|
63
|
+
table.purpose = config.purpose || 'view';
|
|
64
|
+
table.mode = config.mode || 'inline';
|
|
65
|
+
|
|
49
66
|
this.element.append(table);
|
|
50
67
|
});
|
|
@@ -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
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alchemy-form",
|
|
3
3
|
"description": "Form plugin for Alchemy",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.12",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type" : "git",
|
|
7
7
|
"url" : "https://github.com/11ways/alchemy-form.git"
|
|
8
8
|
},
|
|
9
9
|
"peerDependencies": {
|
|
10
|
-
"alchemymvc"
|
|
10
|
+
"alchemymvc" : ">=1.2.0",
|
|
11
|
+
"alchemy-media" : "~0.6.3"
|
|
11
12
|
},
|
|
12
13
|
"license": "MIT",
|
|
13
14
|
"engines": {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<span
|
|
2
|
+
class="alchemy-field-value boolean-wrapper"
|
|
3
|
+
>
|
|
4
|
+
<%
|
|
5
|
+
new_class = '';
|
|
6
|
+
|
|
7
|
+
if (value) {
|
|
8
|
+
new_class = 'boolean-true';
|
|
9
|
+
} else if (value === false) {
|
|
10
|
+
new_class = 'boolean-false';
|
|
11
|
+
} else {
|
|
12
|
+
new_class = 'boolean-null';
|
|
13
|
+
value = 'empty';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
$0.classList.add(new_class);
|
|
17
|
+
%>
|
|
18
|
+
{{ value }}
|
|
19
|
+
</span>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<span class="alchemy-field-value alchemy-field-enum">{{ value }}</span>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<code class="alchemy-field-value">{{ value }}</code>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div class="wrapped-inline" data-he-name="field"></div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<div data-he-name="field"></div>
|
|
1
|
+
<div class="wrapped-inline" data-he-name="field"></div>
|