alchemymvc 1.3.21 → 1.4.0-alpha.1
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/LICENSE +1 -1
- package/README.md +3 -3
- package/lib/app/behaviour/publishable_behaviour.js +5 -5
- package/lib/app/behaviour/revision_behaviour.js +10 -10
- package/lib/app/behaviour/sluggable_behaviour.js +14 -14
- package/lib/app/conduit/electron_conduit.js +9 -9
- package/lib/app/conduit/http_conduit.js +13 -13
- package/lib/app/conduit/loopback_conduit.js +15 -15
- package/lib/app/conduit/socket_conduit.js +43 -43
- package/lib/app/config/routes.js +26 -0
- package/lib/app/controller/00-default_app_controller.js +21 -0
- package/lib/app/controller/alchemy_info_controller.js +12 -12
- package/lib/app/datasource/mongo_datasource.js +16 -16
- package/lib/app/element/00-default_app_element.js +19 -0
- package/lib/app/element/time_ago.js +5 -5
- package/lib/app/helper/00-default_app_helper.js +11 -0
- package/lib/app/helper/alchemy_helper.js +22 -22
- package/lib/app/helper/backed_map.js +1 -1
- package/lib/app/helper/breadcrumb.js +10 -10
- package/lib/app/helper/client_collection.js +3 -3
- package/lib/app/helper/cron.js +29 -29
- package/lib/app/helper/enum_values.js +6 -6
- package/lib/app/helper/pagination_helper.js +36 -36
- package/lib/app/helper/router_helper.js +35 -35
- package/lib/app/helper/socket_helper.js +57 -57
- package/lib/app/helper/syncable.js +84 -59
- package/lib/app/helper_component/paginate_component.js +9 -9
- package/lib/app/helper_controller/component.js +1 -1
- package/lib/app/helper_controller/conduit.js +31 -31
- package/lib/app/helper_controller/controller.js +54 -39
- package/lib/app/helper_datasource/00-nosql_datasource.js +624 -70
- package/lib/app/helper_datasource/05-fallback_datasource.js +10 -10
- package/lib/app/helper_datasource/idb_datasource.js +6 -6
- package/lib/app/helper_datasource/indexed_db.js +22 -22
- package/lib/app/helper_datasource/remote_datasource.js +5 -5
- package/lib/app/helper_error/http_error.js +4 -4
- package/lib/app/helper_error/model_error.js +2 -2
- package/lib/app/helper_error/validation_error.js +12 -12
- package/lib/app/helper_field/00-objectid_field.js +7 -7
- package/lib/app/helper_field/05-string_field.js +16 -12
- package/lib/app/helper_field/06-text_field.js +2 -4
- package/lib/app/helper_field/10-number_field.js +9 -12
- package/lib/app/helper_field/11-date_field.js +15 -15
- package/lib/app/helper_field/15-local_temporal_field.js +10 -10
- package/lib/app/helper_field/20-decimal_field.js +8 -9
- package/lib/app/helper_field/belongsto_field.js +1 -1
- package/lib/app/helper_field/big_int_field.js +8 -8
- package/lib/app/helper_field/boolean_field.js +9 -11
- package/lib/app/helper_field/datetime_field.js +3 -3
- package/lib/app/helper_field/enum_field.js +13 -8
- package/lib/app/helper_field/fixed_decimal_field.js +6 -7
- package/lib/app/helper_field/geopoint_field.js +9 -10
- package/lib/app/helper_field/habtm_field.js +3 -3
- package/lib/app/helper_field/hasoneparent_field.js +1 -1
- package/lib/app/helper_field/html_field.js +2 -4
- package/lib/app/helper_field/integer_field.js +8 -11
- package/lib/app/helper_field/local_date_field.js +5 -5
- package/lib/app/helper_field/local_date_time_field.js +5 -5
- package/lib/app/helper_field/local_time_field.js +5 -5
- package/lib/app/helper_field/mixed_field.js +5 -5
- package/lib/app/helper_field/object_field.js +8 -8
- package/lib/app/helper_field/password_field.js +3 -3
- package/lib/app/helper_field/regexp_field.js +7 -9
- package/lib/app/helper_field/schema_field.js +91 -88
- package/lib/app/helper_field/settings_field.js +92 -0
- package/lib/app/helper_field/time_field.js +6 -6
- package/lib/app/helper_field/url_field.js +2 -4
- package/lib/app/helper_model/00-base_criteria.js +662 -0
- package/lib/app/helper_model/05-criteria_expressions.js +605 -0
- package/lib/app/helper_model/10-model_criteria.js +1182 -0
- package/lib/app/helper_model/data_provider.js +2 -2
- package/lib/app/helper_model/document.js +103 -92
- package/lib/app/helper_model/document_list.js +14 -14
- package/lib/app/helper_model/field_config.js +11 -11
- package/lib/app/helper_model/field_set.js +17 -17
- package/lib/app/helper_model/model.js +203 -124
- package/lib/app/helper_model/remote_data_provider.js +2 -2
- package/lib/app/helper_validator/00_validator.js +16 -16
- package/lib/app/helper_validator/not_empty_validator.js +9 -9
- package/lib/app/model/00-default_app_model.js +18 -0
- package/lib/app/model/05-system_model.js +27 -0
- package/lib/app/model/{alchemy_migration_model.js → system_migration_model.js} +4 -4
- package/lib/app/model/system_setting_model.js +154 -0
- package/lib/app/model/{alchemy_task_history_model.js → system_task_history_model.js} +7 -7
- package/lib/app/model/{alchemy_task_model.js → system_task_model.js} +11 -11
- package/lib/bootstrap.js +22 -312
- package/lib/class/accumulator.js +5 -5
- package/lib/class/behaviour.js +5 -5
- package/lib/class/component.js +3 -3
- package/lib/class/conduit.js +203 -163
- package/lib/class/controller.js +42 -42
- package/lib/class/datasource.js +74 -79
- package/lib/class/document.js +74 -95
- package/lib/class/document_list.js +5 -5
- package/lib/class/element.js +17 -17
- package/lib/class/error.js +3 -3
- package/lib/class/field.js +169 -91
- package/lib/class/field_value.js +6 -6
- package/lib/class/helper.js +3 -3
- package/lib/class/inode.js +17 -17
- package/lib/class/inode_dir.js +12 -12
- package/lib/class/inode_file.js +50 -25
- package/lib/class/inode_list.js +4 -4
- package/lib/class/migration.js +4 -4
- package/lib/class/model.js +182 -168
- package/lib/class/path_definition.js +22 -22
- package/lib/class/path_evaluator.js +5 -5
- package/lib/class/path_param_definition.js +7 -7
- package/lib/class/plugin.js +312 -0
- package/lib/class/postponement.js +29 -29
- package/lib/class/reciprocal.js +8 -8
- package/lib/class/route.js +33 -33
- package/lib/class/router.js +73 -73
- package/lib/class/schema.js +21 -21
- package/lib/class/schema_client.js +73 -67
- package/lib/class/session.js +63 -29
- package/lib/class/session_scene.js +4 -4
- package/lib/class/sitemap.js +16 -16
- package/lib/class/task.js +39 -39
- package/lib/class/task_service.js +43 -47
- package/lib/{init → core}/alchemy.js +413 -374
- package/lib/{init/functions.js → core/alchemy_functions.js} +171 -108
- package/lib/core/alchemy_load_functions.js +715 -0
- package/lib/core/base.js +50 -62
- package/lib/core/client_alchemy.js +144 -152
- package/lib/core/client_base.js +39 -52
- package/lib/core/discovery.js +16 -18
- package/lib/core/middleware.js +54 -43
- package/lib/core/{routing.js → prefix.js} +14 -16
- package/lib/core/setting.js +1684 -0
- package/lib/core/stage.js +758 -0
- package/lib/scripts/create_constants.js +119 -0
- package/lib/{init/languages.js → scripts/create_languages.js} +5 -5
- package/lib/scripts/create_settings.js +449 -0
- package/lib/scripts/create_shared_constants.js +95 -0
- package/lib/scripts/create_stages.js +55 -0
- package/lib/scripts/init_alchemy.js +51 -0
- package/lib/{init/requirements.js → scripts/preload_modules.js} +15 -2
- package/lib/scripts/setup_devwatch.js +238 -0
- package/lib/stages/00-load_core.js +342 -0
- package/lib/stages/05-load_app.js +57 -0
- package/lib/stages/10-datasource.js +61 -0
- package/lib/stages/15-tasks.js +27 -0
- package/lib/stages/20-settings.js +68 -0
- package/lib/stages/50-routes.js +218 -0
- package/lib/stages/90-server.js +347 -0
- package/package.json +5 -7
- package/lib/app/helper_model/criteria.js +0 -2294
- package/lib/app/helper_model/db_query.js +0 -1488
- package/lib/app/routes.js +0 -11
- package/lib/core/socket.js +0 -171
- package/lib/init/constants.js +0 -158
- package/lib/init/devwatch.js +0 -238
- package/lib/init/load_functions.js +0 -973
- package/lib/stages.js +0 -513
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The Remote DataProvider class
|
|
3
3
|
*
|
|
4
|
-
* @author Jelle De Loecker
|
|
4
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
5
5
|
* @since 1.2.2
|
|
6
6
|
* @version 1.2.2
|
|
7
7
|
*/
|
|
@@ -81,7 +81,7 @@ RemoteDataProvider.setMethod(function getById(id) {
|
|
|
81
81
|
* @since 1.2.2
|
|
82
82
|
* @version 1.3.13
|
|
83
83
|
*
|
|
84
|
-
* @param {
|
|
84
|
+
* @param {number} page 1-indexed page number
|
|
85
85
|
*/
|
|
86
86
|
RemoteDataProvider.setMethod(function getPage(page) {
|
|
87
87
|
return this.performSourceRequest('page', {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @constructor
|
|
6
6
|
*
|
|
7
|
-
* @author Jelle De Loecker
|
|
7
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
8
8
|
* @since 1.0.5
|
|
9
9
|
* @version 1.1.0
|
|
10
10
|
*
|
|
@@ -17,18 +17,18 @@ var Validator = Function.inherits('Alchemy.Base', 'Alchemy.Validator', function
|
|
|
17
17
|
/**
|
|
18
18
|
* The error message to use
|
|
19
19
|
*
|
|
20
|
-
* @author Jelle De Loecker
|
|
20
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
21
21
|
* @since 1.1.0
|
|
22
22
|
* @version 1.1.0
|
|
23
23
|
*
|
|
24
|
-
* @type {
|
|
24
|
+
* @type {string}
|
|
25
25
|
*/
|
|
26
26
|
Validator.setProperty('error_message', '{field} violates the {rule} rule');
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Revive a dried validator
|
|
30
30
|
*
|
|
31
|
-
* @author Jelle De Loecker
|
|
31
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
32
32
|
* @since 1.1.0
|
|
33
33
|
* @version 1.1.0
|
|
34
34
|
*
|
|
@@ -41,7 +41,7 @@ Validator.setStatic(function unDry(value) {
|
|
|
41
41
|
/**
|
|
42
42
|
* Return an object for json-drying this validator
|
|
43
43
|
*
|
|
44
|
-
* @author Jelle De Loecker
|
|
44
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
45
45
|
* @since 0.2.0
|
|
46
46
|
* @version 1.1.0
|
|
47
47
|
*
|
|
@@ -58,13 +58,13 @@ Validator.setMethod(function toDry() {
|
|
|
58
58
|
/**
|
|
59
59
|
* Get the invalid message for the given field
|
|
60
60
|
*
|
|
61
|
-
* @author Jelle De Loecker
|
|
61
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
62
62
|
* @since 1.1.0
|
|
63
63
|
* @version 1.3.1
|
|
64
64
|
*
|
|
65
65
|
* @param {FieldValue} fv The FieldValue instance
|
|
66
66
|
*
|
|
67
|
-
* @return {
|
|
67
|
+
* @return {string}
|
|
68
68
|
*/
|
|
69
69
|
Validator.setTypedMethod([Types.Alchemy.FieldValue], function getInvalidFieldMessage(fv) {
|
|
70
70
|
|
|
@@ -84,7 +84,7 @@ Validator.setTypedMethod([Types.Alchemy.FieldValue], function getInvalidFieldMes
|
|
|
84
84
|
/**
|
|
85
85
|
* Create a violation for this validator
|
|
86
86
|
*
|
|
87
|
-
* @author Jelle De Loecker
|
|
87
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
88
88
|
* @since 1.1.0
|
|
89
89
|
* @version 1.1.4
|
|
90
90
|
*
|
|
@@ -108,7 +108,7 @@ Validator.setMethod(function createFieldViolation(fv) {
|
|
|
108
108
|
/**
|
|
109
109
|
* Validate a value
|
|
110
110
|
*
|
|
111
|
-
* @author Jelle De Loecker
|
|
111
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
112
112
|
* @since 1.3.1
|
|
113
113
|
* @version 1.3.1
|
|
114
114
|
*
|
|
@@ -124,12 +124,12 @@ Validator.setTypedMethod([Types.Alchemy.Field, Types.Any], function validateFiel
|
|
|
124
124
|
/**
|
|
125
125
|
* Validate a value
|
|
126
126
|
*
|
|
127
|
-
* @author Jelle De Loecker
|
|
127
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
128
128
|
* @since 1.3.1
|
|
129
129
|
* @version 1.3.1
|
|
130
130
|
*
|
|
131
131
|
* @param {Field} field
|
|
132
|
-
* @param {
|
|
132
|
+
* @param {string} path
|
|
133
133
|
* @param {*} value
|
|
134
134
|
*
|
|
135
135
|
* @return {Promise<Violation|undefined>}
|
|
@@ -142,7 +142,7 @@ Validator.setTypedMethod([Types.Alchemy.Field, Types.String, Types.Any], functio
|
|
|
142
142
|
/**
|
|
143
143
|
* Validate a value
|
|
144
144
|
*
|
|
145
|
-
* @author Jelle De Loecker
|
|
145
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
146
146
|
* @since 1.1.0
|
|
147
147
|
* @version 1.3.1
|
|
148
148
|
*
|
|
@@ -190,7 +190,7 @@ Validator.setTypedMethod([Types.Alchemy.FieldValue.array()], async function vali
|
|
|
190
190
|
/**
|
|
191
191
|
* Validate the given document
|
|
192
192
|
*
|
|
193
|
-
* @author Jelle De Loecker
|
|
193
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
194
194
|
* @since 1.1.0
|
|
195
195
|
* @version 1.1.0
|
|
196
196
|
*
|
|
@@ -240,13 +240,13 @@ Validator.setMethod(async function validateDocument(root, context, schema) {
|
|
|
240
240
|
/**
|
|
241
241
|
* Does this rule apply to the given field?
|
|
242
242
|
*
|
|
243
|
-
* @author Jelle De Loecker
|
|
243
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
244
244
|
* @since 1.1.0
|
|
245
245
|
* @version 1.1.0
|
|
246
246
|
*
|
|
247
|
-
* @param {
|
|
247
|
+
* @param {string|Field} field The field to check
|
|
248
248
|
*
|
|
249
|
-
* @return {
|
|
249
|
+
* @return {boolean}
|
|
250
250
|
*/
|
|
251
251
|
Validator.setMethod(function appliesToField(field) {
|
|
252
252
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @constructor
|
|
6
6
|
*
|
|
7
|
-
* @author Jelle De Loecker
|
|
7
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
8
8
|
* @since 1.0.5
|
|
9
9
|
* @version 1.0.5
|
|
10
10
|
*
|
|
@@ -15,46 +15,46 @@ const NotEmpty = Function.inherits('Alchemy.Validator', 'NotEmpty');
|
|
|
15
15
|
/**
|
|
16
16
|
* The message to use inside errors
|
|
17
17
|
*
|
|
18
|
-
* @author Jelle De Loecker
|
|
18
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
19
19
|
* @since 1.1.0
|
|
20
20
|
* @version 1.1.0
|
|
21
21
|
*
|
|
22
|
-
* @type {
|
|
22
|
+
* @type {string}
|
|
23
23
|
*/
|
|
24
24
|
NotEmpty.setProperty('error_message', '{field} must not be empty');
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* The microcopy to use for users
|
|
28
28
|
*
|
|
29
|
-
* @author Jelle De Loecker
|
|
29
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
30
30
|
* @since 1.1.4
|
|
31
31
|
* @version 1.1.4
|
|
32
32
|
*
|
|
33
|
-
* @type {
|
|
33
|
+
* @type {string}
|
|
34
34
|
*/
|
|
35
35
|
NotEmpty.setProperty('error_microcopy', 'cannot-be-empty');
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* This validator should not pass when there are no values
|
|
39
39
|
*
|
|
40
|
-
* @author Jelle De Loecker
|
|
40
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
41
41
|
* @since 1.1.0
|
|
42
42
|
* @version 1.1.0
|
|
43
43
|
*
|
|
44
|
-
* @type {
|
|
44
|
+
* @type {boolean}
|
|
45
45
|
*/
|
|
46
46
|
NotEmpty.setProperty('error_when_no_values', true);
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Validate the value
|
|
50
50
|
*
|
|
51
|
-
* @author Jelle De Loecker
|
|
51
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
52
52
|
* @since 1.0.5
|
|
53
53
|
* @version 1.1.0
|
|
54
54
|
*
|
|
55
55
|
* @param {FieldValue} fv The FieldValue instance
|
|
56
56
|
*
|
|
57
|
-
* @return {
|
|
57
|
+
* @return {boolean}
|
|
58
58
|
*/
|
|
59
59
|
NotEmpty.setMethod(function validate(fv) {
|
|
60
60
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default App model class.
|
|
3
|
+
* The main app can use this to extend from and add custom functionality.
|
|
4
|
+
*
|
|
5
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
6
|
+
* @since 1.4.0
|
|
7
|
+
* @version 1.4.0
|
|
8
|
+
*/
|
|
9
|
+
const App = Function.inherits('Alchemy.Model', 'App');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Mark this class as being abstract
|
|
13
|
+
*
|
|
14
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
15
|
+
* @since 1.4.0
|
|
16
|
+
* @version 1.4.0
|
|
17
|
+
*/
|
|
18
|
+
App.makeAbstractClass();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The base System model class.
|
|
3
|
+
* Models meant for the Alchemy system.
|
|
4
|
+
*
|
|
5
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
6
|
+
* @since 1.4.0
|
|
7
|
+
* @version 1.4.0
|
|
8
|
+
*/
|
|
9
|
+
const System = Function.inherits('Alchemy.Model.App', 'Alchemy.Model.System', 'System');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Mark this class as being abstract
|
|
13
|
+
*
|
|
14
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
15
|
+
* @since 1.4.0
|
|
16
|
+
* @version 1.4.0
|
|
17
|
+
*/
|
|
18
|
+
System.makeAbstractClass();
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Use the `alchemy` prefix for the table name
|
|
22
|
+
*
|
|
23
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
24
|
+
* @since 1.4.0
|
|
25
|
+
* @version 1.4.0
|
|
26
|
+
*/
|
|
27
|
+
System.setTablePrefix('alchemy');
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @constructor
|
|
5
5
|
*
|
|
6
|
-
* @author Jelle De Loecker
|
|
6
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
7
7
|
* @since 1.2.0
|
|
8
8
|
* @version 1.2.0
|
|
9
9
|
*/
|
|
10
|
-
const
|
|
10
|
+
const Migration = Function.inherits('Alchemy.Model.System', 'Migration');
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Constitute the class wide schema
|
|
14
14
|
*
|
|
15
|
-
* @author Jelle De Loecker
|
|
15
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
16
16
|
* @since 1.2.0
|
|
17
17
|
* @version 1.2.0
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
Migration.constitute(function addTaskFields() {
|
|
20
20
|
|
|
21
21
|
// The name of the migration
|
|
22
22
|
this.addField('name', 'String');
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Alchemy Setting model:
|
|
3
|
+
* Contains all the system settings of Alchemy.
|
|
4
|
+
*
|
|
5
|
+
* @constructor
|
|
6
|
+
*
|
|
7
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
8
|
+
* @since 1.4.0
|
|
9
|
+
* @version 1.4.0
|
|
10
|
+
*/
|
|
11
|
+
const SystemSetting = Function.inherits('Alchemy.Model.System', 'Setting');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Constitute the class wide schema
|
|
15
|
+
*
|
|
16
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
17
|
+
* @since 1.4.0
|
|
18
|
+
* @version 1.4.0
|
|
19
|
+
*/
|
|
20
|
+
SystemSetting.constitute(function addTaskFields() {
|
|
21
|
+
|
|
22
|
+
this.addField('setting_id', 'Enum', {
|
|
23
|
+
description: 'The setting id',
|
|
24
|
+
values : Classes.Alchemy.Setting.SYSTEM.createEnumMap(),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
this.addField('configuration', 'Schema', {
|
|
28
|
+
description: 'The actual configuration of the setting',
|
|
29
|
+
schema : 'setting_id',
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Configure the default chimera fieldsets
|
|
35
|
+
*
|
|
36
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
37
|
+
* @since 1.4.0
|
|
38
|
+
* @version 1.4.0
|
|
39
|
+
*/
|
|
40
|
+
SystemSetting.constitute(function chimeraConfig() {
|
|
41
|
+
|
|
42
|
+
if (!this.chimera) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Get the list group
|
|
47
|
+
let list = this.chimera.getActionFields('list');
|
|
48
|
+
|
|
49
|
+
list.addField('setting_id');
|
|
50
|
+
|
|
51
|
+
// Get the edit group
|
|
52
|
+
let edit = this.chimera.getActionFields('edit');
|
|
53
|
+
|
|
54
|
+
edit.addField('setting_id');
|
|
55
|
+
edit.addField('configuration')
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Apply the given changes
|
|
60
|
+
*
|
|
61
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
62
|
+
* @since 1.4.0
|
|
63
|
+
* @version 1.4.0
|
|
64
|
+
*
|
|
65
|
+
* @param {Object} changes
|
|
66
|
+
* @param {Conduit} permission_context
|
|
67
|
+
*/
|
|
68
|
+
SystemSetting.setMethod(async function saveChanges(changes, permission_context) {
|
|
69
|
+
|
|
70
|
+
if (!changes) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let setting_id,
|
|
75
|
+
new_value,
|
|
76
|
+
setting,
|
|
77
|
+
doc;
|
|
78
|
+
|
|
79
|
+
for (setting_id in changes) {
|
|
80
|
+
new_value = changes[setting_id];
|
|
81
|
+
setting = Classes.Alchemy.Setting.SYSTEM.get(setting_id);
|
|
82
|
+
|
|
83
|
+
if (!setting) {
|
|
84
|
+
throw new Error('Unknown setting: ' + setting_id);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// We don't throw an error here:
|
|
88
|
+
// we assume the user should not have seen this setting anyway
|
|
89
|
+
if (!setting.canBeEditedBy(permission_context)) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
doc = await this.findByValues({
|
|
94
|
+
setting_id: setting_id
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
if (!doc) {
|
|
98
|
+
doc = this.createDocument({
|
|
99
|
+
setting_id
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
doc.configuration = setting.createConfigurationObject(new_value);
|
|
104
|
+
|
|
105
|
+
await doc.save();
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Do something before saving the record
|
|
111
|
+
*
|
|
112
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
113
|
+
* @since 1.4.0
|
|
114
|
+
* @version 1.4.0
|
|
115
|
+
*
|
|
116
|
+
* @param {Document.AlchemyTask} doc
|
|
117
|
+
*/
|
|
118
|
+
SystemSetting.setMethod(function beforeSave(doc) {
|
|
119
|
+
return doc.applySetting();
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Apply this setting
|
|
124
|
+
*
|
|
125
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
126
|
+
* @since 1.4.0
|
|
127
|
+
* @version 1.4.0
|
|
128
|
+
*
|
|
129
|
+
* @param {boolean} do_actions Should the setting actions be executed
|
|
130
|
+
*/
|
|
131
|
+
SystemSetting.setDocumentMethod(function applySetting(do_actions = true) {
|
|
132
|
+
|
|
133
|
+
if (!this.setting_id) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
let setting = Classes.Alchemy.Setting.SYSTEM.get(this.setting_id);
|
|
138
|
+
|
|
139
|
+
if (!setting) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
let existing_value = alchemy.system_settings.getPath(this.setting_id);
|
|
144
|
+
|
|
145
|
+
if (!existing_value) {
|
|
146
|
+
existing_value = setting.generateValue();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (do_actions) {
|
|
150
|
+
return existing_value.setValue(this.configuration.value);
|
|
151
|
+
} else {
|
|
152
|
+
return existing_value.setValueSilently(this.configuration.value);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
@@ -4,22 +4,22 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @constructor
|
|
6
6
|
*
|
|
7
|
-
* @author Jelle De Loecker
|
|
7
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
8
8
|
* @since 0.5.0
|
|
9
9
|
* @version 0.5.0
|
|
10
10
|
*/
|
|
11
|
-
const
|
|
11
|
+
const SystemTaskHistory = Function.inherits('Alchemy.Model.System', 'TaskHistory');
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Constitute the class wide schema
|
|
15
15
|
*
|
|
16
|
-
* @author Jelle De Loecker
|
|
16
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
17
17
|
* @since 0.5.0
|
|
18
18
|
* @version 1.3.17
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
SystemTaskHistory.constitute(function addTaskFields() {
|
|
21
21
|
|
|
22
|
-
this.belongsTo('
|
|
22
|
+
this.belongsTo('System.Task', {
|
|
23
23
|
description : 'The original AlchemyTask document it belonged to',
|
|
24
24
|
});
|
|
25
25
|
|
|
@@ -75,11 +75,11 @@ AlchemyTaskHistory.constitute(function addTaskFields() {
|
|
|
75
75
|
/**
|
|
76
76
|
* Configure the default chimera fieldsets
|
|
77
77
|
*
|
|
78
|
-
* @author Jelle De Loecker
|
|
78
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
79
79
|
* @since 1.3.17
|
|
80
80
|
* @version 1.3.17
|
|
81
81
|
*/
|
|
82
|
-
|
|
82
|
+
SystemTaskHistory.constitute(function chimeraConfig() {
|
|
83
83
|
|
|
84
84
|
if (!this.chimera) {
|
|
85
85
|
return;
|
|
@@ -4,20 +4,20 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @constructor
|
|
6
6
|
*
|
|
7
|
-
* @author Jelle De Loecker
|
|
7
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
8
8
|
* @since 1.3.17
|
|
9
9
|
* @version 1.3.17
|
|
10
10
|
*/
|
|
11
|
-
const
|
|
11
|
+
const SystemTask = Function.inherits('Alchemy.Model.System', 'Task');
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Constitute the class wide schema
|
|
15
15
|
*
|
|
16
|
-
* @author Jelle De Loecker
|
|
16
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
17
17
|
* @since 1.3.17
|
|
18
18
|
* @version 1.3.17
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
SystemTask.constitute(function addTaskFields() {
|
|
21
21
|
|
|
22
22
|
this.addField('title', 'String', {
|
|
23
23
|
description : 'The title of the task',
|
|
@@ -68,11 +68,11 @@ AlchemyTask.constitute(function addTaskFields() {
|
|
|
68
68
|
/**
|
|
69
69
|
* Configure the default chimera fieldsets
|
|
70
70
|
*
|
|
71
|
-
* @author Jelle De Loecker
|
|
71
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
72
72
|
* @since 1.3.17
|
|
73
73
|
* @version 1.3.17
|
|
74
74
|
*/
|
|
75
|
-
|
|
75
|
+
SystemTask.constitute(function chimeraConfig() {
|
|
76
76
|
|
|
77
77
|
if (!this.chimera) {
|
|
78
78
|
return;
|
|
@@ -101,13 +101,13 @@ AlchemyTask.constitute(function chimeraConfig() {
|
|
|
101
101
|
/**
|
|
102
102
|
* Do something before saving the record
|
|
103
103
|
*
|
|
104
|
-
* @author Jelle De Loecker
|
|
104
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
105
105
|
* @since 1.3.17
|
|
106
106
|
* @version 1.3.17
|
|
107
107
|
*
|
|
108
|
-
* @param {Document.
|
|
108
|
+
* @param {Document.SystemTask} doc
|
|
109
109
|
*/
|
|
110
|
-
|
|
110
|
+
SystemTask.setMethod(function beforeSave(doc) {
|
|
111
111
|
|
|
112
112
|
if (!doc.schedule_type) {
|
|
113
113
|
doc.schedule_type = 'user';
|
|
@@ -136,14 +136,14 @@ AlchemyTask.setMethod(function beforeSave(doc) {
|
|
|
136
136
|
/**
|
|
137
137
|
* Update the schedules after saving
|
|
138
138
|
*
|
|
139
|
-
* @author Jelle De Loecker
|
|
139
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
140
140
|
* @since 1.3.17
|
|
141
141
|
* @version 1.3.17
|
|
142
142
|
*
|
|
143
143
|
* @param {Object} main
|
|
144
144
|
* @param {Object} info
|
|
145
145
|
*/
|
|
146
|
-
|
|
146
|
+
SystemTask.setMethod(function afterSave(main, info) {
|
|
147
147
|
|
|
148
148
|
if (!main.type) {
|
|
149
149
|
return;
|