alchemy-chimera 0.5.4 → 1.0.2
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 +39 -4
- package/assets/scripts/chimera/chimera.js +13 -288
- package/assets/stylesheets/chimera/chimera.scss +451 -0
- package/bootstrap.js +6 -302
- package/config/routes.js +53 -5
- package/controller/00-chimera_controller.js +16 -0
- package/controller/chimera_editor_controller.js +159 -614
- package/controller/chimera_static_controller.js +102 -9
- package/lib/chimera_config.js +138 -163
- package/model/model.js +1 -1
- package/package.json +8 -12
- package/view/chimera/dashboard.hwk +8 -0
- package/view/chimera/editor/index.hwk +20 -0
- package/view/chimera/sidebar.hwk +4 -0
- package/view/chimera/widgets.hwk +8 -0
- package/view/layouts/chimera_base.hwk +15 -0
- package/view/layouts/chimera_basics.hwk +15 -0
- package/view/layouts/chimera_body.hwk +24 -0
- package/assets/scripts/chimera/assoc_field.js +0 -311
- package/assets/scripts/chimera/boolean_field.js +0 -53
- package/assets/scripts/chimera/chimera_field.js +0 -622
- package/assets/scripts/chimera/chimera_field_wrapper.js +0 -558
- package/assets/scripts/chimera/date_field.js +0 -170
- package/assets/scripts/chimera/geopoint_field.js +0 -147
- package/assets/scripts/chimera/medium-button.js +0 -6
- package/assets/scripts/chimera/object_field.js +0 -51
- package/assets/scripts/chimera/page-editor.js +0 -3
- package/assets/scripts/chimera/password_field.js +0 -73
- package/assets/scripts/chimera/schema_field.js +0 -300
- package/assets/scripts/chimera/text_field.js +0 -119
- package/assets/scripts/rome/rome.js +0 -4978
- package/assets/scripts/vex/vex.dialog.js +0 -151
- package/assets/scripts/vex/vex.js +0 -193
- package/assets/stylesheets/chimera/chimera.less +0 -1075
- package/assets/stylesheets/chimera_old/chimera.less +0 -351
- package/assets/stylesheets/chimera_old/core.less +0 -315
- package/assets/stylesheets/chimera_old/font.less +0 -38
- package/assets/stylesheets/chimera_old/mixins.less +0 -35
- package/assets/stylesheets/chimera_old/page-editor.less +0 -23
- package/assets/stylesheets/rome/rome.less +0 -130
- package/assets/stylesheets/vex/vex-theme-bottom-right-corner.less +0 -613
- package/assets/stylesheets/vex/vex.default.less +0 -501
- package/assets/stylesheets/vex/vex.flat.less +0 -443
- package/assets/stylesheets/vex/vex.less +0 -320
- package/controller/chimera_page_controller.js +0 -14
- package/controller/chimera_settings_controller.js +0 -129
- package/controller/tasks_chimera_controller.js +0 -106
- package/helper/chimera_helper.js +0 -202
- package/lib/chimera_action_fields.js +0 -292
- package/lib/chimera_field/belongsto_chimera_field.js +0 -160
- package/lib/chimera_field/boolean_chimera_field.js +0 -19
- package/lib/chimera_field/date_chimera_field.js +0 -20
- package/lib/chimera_field/datetime_chimera_field.js +0 -20
- package/lib/chimera_field/enum_chimera_field.js +0 -131
- package/lib/chimera_field/geopoint_chimera_field.js +0 -20
- package/lib/chimera_field/habtm_chimera_field.js +0 -55
- package/lib/chimera_field/hasoneparent_chimera_field.js +0 -18
- package/lib/chimera_field/html_chimera_field.js +0 -20
- package/lib/chimera_field/object_chimera_field.js +0 -18
- package/lib/chimera_field/password_chimera_field.js +0 -18
- package/lib/chimera_field/schema_chimera_field.js +0 -149
- package/lib/chimera_field/text_chimera_field.js +0 -20
- package/lib/chimera_field/time_chimera_field.js +0 -18
- package/lib/chimera_field.js +0 -208
- package/model/setting_model.js +0 -51
- package/public/chimera/codedor.svg +0 -28
- package/view/chimera/dashboard.ejs +0 -5
- package/view/chimera/editor/add.ejs +0 -32
- package/view/chimera/editor/edit.ejs +0 -33
- package/view/chimera/editor/index.ejs +0 -87
- package/view/chimera/editor/remove.ejs +0 -23
- package/view/chimera/editor/view.ejs +0 -54
- package/view/chimera/elements/editor_actions.ejs +0 -4
- package/view/chimera/elements/empty +0 -0
- package/view/chimera/field_wrappers/_entries.ejs +0 -91
- package/view/chimera/field_wrappers/_wrapper.ejs +0 -82
- package/view/chimera/field_wrappers/date_edit.ejs +0 -23
- package/view/chimera/field_wrappers/date_list.ejs +0 -3
- package/view/chimera/field_wrappers/date_view.ejs +0 -16
- package/view/chimera/field_wrappers/default_edit.ejs +0 -22
- package/view/chimera/field_wrappers/default_list.ejs +0 -3
- package/view/chimera/field_wrappers/default_peek.ejs +0 -3
- package/view/chimera/field_wrappers/default_view.ejs +0 -14
- package/view/chimera/field_wrappers/geopoint_edit.ejs +0 -25
- package/view/chimera/field_wrappers/geopoint_list.ejs +0 -5
- package/view/chimera/field_wrappers/geopoint_view.ejs +0 -18
- package/view/chimera/field_wrappers/schema_edit.ejs +0 -19
- package/view/chimera/field_wrappers/text_edit.ejs +0 -22
- package/view/chimera/field_wrappers/text_list.ejs +0 -1
- package/view/chimera/fields/belongsto_edit.ejs +0 -4
- package/view/chimera/fields/belongsto_list.ejs +0 -1
- package/view/chimera/fields/belongsto_peek.ejs +0 -1
- package/view/chimera/fields/boolean_edit.ejs +0 -17
- package/view/chimera/fields/boolean_list.ejs +0 -3
- package/view/chimera/fields/boolean_view.ejs +0 -3
- package/view/chimera/fields/date_edit.ejs +0 -14
- package/view/chimera/fields/date_list.ejs +0 -9
- package/view/chimera/fields/date_peek.ejs +0 -9
- package/view/chimera/fields/date_view.ejs +0 -9
- package/view/chimera/fields/datetime_edit.ejs +0 -24
- package/view/chimera/fields/datetime_list.ejs +0 -9
- package/view/chimera/fields/datetime_view.ejs +0 -10
- package/view/chimera/fields/default_edit.ejs +0 -10
- package/view/chimera/fields/default_list.ejs +0 -15
- package/view/chimera/fields/default_view.ejs +0 -1
- package/view/chimera/fields/enum_edit.ejs +0 -10
- package/view/chimera/fields/geopoint_edit.ejs +0 -10
- package/view/chimera/fields/geopoint_list.ejs +0 -9
- package/view/chimera/fields/geopoint_view.ejs +0 -9
- package/view/chimera/fields/habtm_edit.ejs +0 -5
- package/view/chimera/fields/hasoneparent_edit.ejs +0 -6
- package/view/chimera/fields/hasoneparent_list.ejs +0 -1
- package/view/chimera/fields/object_edit.ejs +0 -8
- package/view/chimera/fields/password_edit.ejs +0 -12
- package/view/chimera/fields/schema_edit.ejs +0 -14
- package/view/chimera/fields/text_edit.ejs +0 -5
- package/view/chimera/fields/text_list.ejs +0 -9
- package/view/chimera/fields/text_view.ejs +0 -3
- package/view/chimera/fields/time_edit.ejs +0 -15
- package/view/chimera/fields/time_list.ejs +0 -9
- package/view/chimera/fields/time_view.ejs +0 -9
- package/view/chimera/page/edit.ejs +0 -18
- package/view/chimera/page_editor.ejs +0 -5
- package/view/chimera/sidebar.ejs +0 -40
- package/view/chimera/tasks/index.ejs +0 -114
- package/view/layouts/chimera.ejs +0 -12
- package/view/layouts/chimera_base.ejs +0 -11
- package/view/layouts/chimera_body.ejs +0 -43
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Enum Chimera Field
|
|
3
|
-
*
|
|
4
|
-
* @constructor
|
|
5
|
-
*
|
|
6
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
7
|
-
* @since 0.2.0
|
|
8
|
-
* @version 0.3.0
|
|
9
|
-
*
|
|
10
|
-
* @param {FieldType}
|
|
11
|
-
*/
|
|
12
|
-
var Enum = Function.inherits('Alchemy.ChimeraField', function EnumChimeraField(fieldType, options) {
|
|
13
|
-
|
|
14
|
-
EnumChimeraField.super.call(this, fieldType, options);
|
|
15
|
-
|
|
16
|
-
this.script_file = [{name: 'jquery', path: '//code.jquery.com/jquery-1.11.3.min.js'}, 'selectize/0.11/selectize', 'chimera/assoc_field'];
|
|
17
|
-
//this.style_file = 'selectize/0.11/selectize';
|
|
18
|
-
|
|
19
|
-
this.viewname = 'enum';
|
|
20
|
-
this.viewwrapper = 'default';
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Respond with related data values for this field
|
|
25
|
-
*
|
|
26
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
27
|
-
* @since 0.2.0
|
|
28
|
-
* @version 0.3.0
|
|
29
|
-
*
|
|
30
|
-
* @param {Conduit} conduit
|
|
31
|
-
*/
|
|
32
|
-
Enum.setMethod(function sendRelatedData(conduit) {
|
|
33
|
-
|
|
34
|
-
var fieldType = this.fieldType,
|
|
35
|
-
results = [],
|
|
36
|
-
schema = fieldType.schema,
|
|
37
|
-
values,
|
|
38
|
-
title,
|
|
39
|
-
entry,
|
|
40
|
-
key;
|
|
41
|
-
|
|
42
|
-
// Get the enum values
|
|
43
|
-
values = fieldType.getValues();
|
|
44
|
-
|
|
45
|
-
// Iterate over the values and get the correct id & title
|
|
46
|
-
for (key in values) {
|
|
47
|
-
|
|
48
|
-
entry = values[key];
|
|
49
|
-
|
|
50
|
-
title = this.getDisplayValue(entry);
|
|
51
|
-
|
|
52
|
-
results.push({_id: key, title: title+''});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
conduit.end(results);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Get the display value
|
|
60
|
-
*
|
|
61
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
62
|
-
* @since 0.3.0
|
|
63
|
-
* @version 0.3.0
|
|
64
|
-
*
|
|
65
|
-
* @param {Object} entry
|
|
66
|
-
*/
|
|
67
|
-
Enum.setMethod(function getDisplayValue(entry, default_value) {
|
|
68
|
-
|
|
69
|
-
var display_value;
|
|
70
|
-
|
|
71
|
-
if (entry == null) {
|
|
72
|
-
return default_value;
|
|
73
|
-
} else if (Object.isPrimitive(entry)) {
|
|
74
|
-
display_value = entry;
|
|
75
|
-
} else if (Classes.Alchemy.I18n && entry instanceof Classes.Alchemy.I18n) {
|
|
76
|
-
// We're aware of the I18n class, even though it's an alchemy plugin
|
|
77
|
-
display_value = entry;
|
|
78
|
-
} else {
|
|
79
|
-
display_value = entry.title || entry.name;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (!display_value) {
|
|
83
|
-
display_value = default_value;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return display_value;
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Get the value to use in the action
|
|
91
|
-
*
|
|
92
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
93
|
-
* @since 0.3.0
|
|
94
|
-
* @version 0.3.0
|
|
95
|
-
*
|
|
96
|
-
* @param {String} action_type
|
|
97
|
-
* @param {Object} main_record
|
|
98
|
-
* @param {Function} callback
|
|
99
|
-
*/
|
|
100
|
-
Enum.setMethod(function actionValue(action_type, record, callback) {
|
|
101
|
-
|
|
102
|
-
var display_value,
|
|
103
|
-
values,
|
|
104
|
-
value;
|
|
105
|
-
|
|
106
|
-
// Use custom method if set in the options
|
|
107
|
-
if (this.options.actionValue) {
|
|
108
|
-
return this.options.actionValue.call(this, actionType, record, callback);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
value = this.getRecordValue(record);
|
|
112
|
-
|
|
113
|
-
// Return the identifier when it's not a peek or a list
|
|
114
|
-
if (action_type != 'list' && action_type != 'peek') {
|
|
115
|
-
display_value = value;
|
|
116
|
-
} else {
|
|
117
|
-
// Get all the possible values
|
|
118
|
-
values = this.fieldType.getValues();
|
|
119
|
-
|
|
120
|
-
if (!values || !values[value]) {
|
|
121
|
-
display_value = value;
|
|
122
|
-
} else {
|
|
123
|
-
display_value = this.getDisplayValue(values[value]);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
setImmediate(function() {
|
|
129
|
-
callback(null, display_value);
|
|
130
|
-
});
|
|
131
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Geopoint chimera Field
|
|
3
|
-
*
|
|
4
|
-
* @constructor
|
|
5
|
-
*
|
|
6
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
7
|
-
* @since 0.2.0
|
|
8
|
-
* @version 0.3.0
|
|
9
|
-
*
|
|
10
|
-
* @param {FieldType}
|
|
11
|
-
*/
|
|
12
|
-
var GeopointChimeraField = Function.inherits('Alchemy.ChimeraField', function GeopointChimeraField(fieldType, options) {
|
|
13
|
-
|
|
14
|
-
GeopointChimeraField.super.call(this, fieldType, options);
|
|
15
|
-
|
|
16
|
-
this.script_file = 'chimera/geopoint_field';
|
|
17
|
-
|
|
18
|
-
this.viewname = 'geopoint';
|
|
19
|
-
this.viewwrapper = 'geopoint';
|
|
20
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HasAndBelongstoMany Chimera Field
|
|
3
|
-
*
|
|
4
|
-
* @constructor
|
|
5
|
-
*
|
|
6
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
7
|
-
* @since 0.2.0
|
|
8
|
-
* @version 0.3.0
|
|
9
|
-
*
|
|
10
|
-
* @param {FieldType}
|
|
11
|
-
*/
|
|
12
|
-
var HABTM = Function.inherits('Alchemy.ChimeraField', function HasAndBelongsToManyChimeraField(fieldType, options) {
|
|
13
|
-
|
|
14
|
-
HasAndBelongsToManyChimeraField.super.call(this, fieldType, options);
|
|
15
|
-
|
|
16
|
-
this.script_file = [{name: 'jquery', path: '//code.jquery.com/jquery-1.11.3.min.js'}, 'selectize/0.11/selectize', 'chimera/assoc_field'];
|
|
17
|
-
//this.style_file = ['selectize/0.11/selectize'];
|
|
18
|
-
|
|
19
|
-
this.viewname = 'habtm';
|
|
20
|
-
this.viewwrapper = 'default';
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Respond with related data values for this field
|
|
25
|
-
*
|
|
26
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
27
|
-
* @since 0.2.0
|
|
28
|
-
* @version 0.5.2
|
|
29
|
-
*
|
|
30
|
-
* @param {Conduit} conduit
|
|
31
|
-
*/
|
|
32
|
-
HABTM.setMethod(function sendRelatedData(conduit) {
|
|
33
|
-
|
|
34
|
-
var fieldType = this.fieldType,
|
|
35
|
-
model = Model.get(fieldType.options.modelName),
|
|
36
|
-
fields;
|
|
37
|
-
|
|
38
|
-
fields = ['_id', 'title', 'name'].concat(model.displayField);
|
|
39
|
-
|
|
40
|
-
model.find('all', function gotData(err, results) {
|
|
41
|
-
|
|
42
|
-
var response;
|
|
43
|
-
|
|
44
|
-
if (err) {
|
|
45
|
-
return conduit.error(err);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
response = {
|
|
49
|
-
items: results.toSimpleArray(fields),
|
|
50
|
-
displayField: model.displayField
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
conduit.end(response);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HasOneParent Chimera Field
|
|
3
|
-
*
|
|
4
|
-
* @constructor
|
|
5
|
-
*
|
|
6
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
7
|
-
* @since 0.2.0
|
|
8
|
-
* @version 0.3.0
|
|
9
|
-
*
|
|
10
|
-
* @param {FieldType}
|
|
11
|
-
*/
|
|
12
|
-
var HOP = Function.inherits('Alchemy.BelongsToChimeraField', function HasOneParentChimeraField(fieldType, options) {
|
|
13
|
-
|
|
14
|
-
HasOneParentChimeraField.super.call(this, fieldType, options);
|
|
15
|
-
|
|
16
|
-
this.viewname = 'hasoneparent';
|
|
17
|
-
this.viewwrapper = 'default';
|
|
18
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Html Chimera Field
|
|
3
|
-
*
|
|
4
|
-
* @constructor
|
|
5
|
-
*
|
|
6
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
7
|
-
* @since 0.2.0
|
|
8
|
-
* @version 0.3.0
|
|
9
|
-
*
|
|
10
|
-
* @param {FieldType}
|
|
11
|
-
*/
|
|
12
|
-
var HtmlChimeraField = Function.inherits('Alchemy.ChimeraField', function HtmlChimeraField(fieldType, options) {
|
|
13
|
-
|
|
14
|
-
HtmlChimeraField.super.call(this, fieldType, options);
|
|
15
|
-
|
|
16
|
-
this.script_file = ['/public/ckeditor/4.4/ckeditor', 'chimera/text_field'];
|
|
17
|
-
|
|
18
|
-
this.viewname = 'text';
|
|
19
|
-
this.viewwrapper = 'text';
|
|
20
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Object Chimera Field
|
|
3
|
-
*
|
|
4
|
-
* @constructor
|
|
5
|
-
*
|
|
6
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
7
|
-
* @since 0.3.0
|
|
8
|
-
* @version 0.3.0
|
|
9
|
-
*
|
|
10
|
-
* @param {FieldType}
|
|
11
|
-
*/
|
|
12
|
-
var ObjectChimeraField = Function.inherits('Alchemy.ChimeraField', function ObjectChimeraField(fieldType, options) {
|
|
13
|
-
|
|
14
|
-
ObjectChimeraField.super.call(this, fieldType, options);
|
|
15
|
-
|
|
16
|
-
this.script_file = 'chimera/object_field';
|
|
17
|
-
this.viewname = 'object';
|
|
18
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Password Chimera Field
|
|
3
|
-
*
|
|
4
|
-
* @constructor
|
|
5
|
-
*
|
|
6
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
7
|
-
* @since 0.2.0
|
|
8
|
-
* @version 0.3.0
|
|
9
|
-
*
|
|
10
|
-
* @param {FieldType}
|
|
11
|
-
*/
|
|
12
|
-
var PasswordChimeraField = Function.inherits('Alchemy.ChimeraField', function PasswordChimeraField(fieldType, options) {
|
|
13
|
-
|
|
14
|
-
PasswordChimeraField.super.call(this, fieldType, options);
|
|
15
|
-
|
|
16
|
-
this.script_file = 'chimera/password_field';
|
|
17
|
-
this.viewname = 'password';
|
|
18
|
-
});
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Schema Chimera Field
|
|
3
|
-
*
|
|
4
|
-
* @constructor
|
|
5
|
-
*
|
|
6
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
7
|
-
* @since 0.2.0
|
|
8
|
-
* @version 0.3.0
|
|
9
|
-
*
|
|
10
|
-
* @param {FieldType}
|
|
11
|
-
*/
|
|
12
|
-
var SchemaChimeraField = Function.inherits('Alchemy.ChimeraField', function SchemaChimeraField(fieldType, options) {
|
|
13
|
-
|
|
14
|
-
SchemaChimeraField.super.call(this, fieldType, options);
|
|
15
|
-
|
|
16
|
-
this.script_file = 'chimera/schema_field';
|
|
17
|
-
|
|
18
|
-
this.viewname = 'schema';
|
|
19
|
-
this.viewwrapper = 'schema';
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Schema field instances should not be cached
|
|
24
|
-
*
|
|
25
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
26
|
-
* @since 0.2.1
|
|
27
|
-
* @version 0.2.1
|
|
28
|
-
*/
|
|
29
|
-
SchemaChimeraField.setProperty('allow_cache', false);
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Get the value to use in the action
|
|
33
|
-
*
|
|
34
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
35
|
-
* @since 0.2.0
|
|
36
|
-
* @version 0.3.0
|
|
37
|
-
*
|
|
38
|
-
* @param {String} actionType
|
|
39
|
-
* @param {Object} main_record
|
|
40
|
-
* @param {Function} callback
|
|
41
|
-
*/
|
|
42
|
-
SchemaChimeraField.setMethod(function actionValue(actionType, main_record, callback) {
|
|
43
|
-
|
|
44
|
-
var that = this,
|
|
45
|
-
actionFields,
|
|
46
|
-
subRecord,
|
|
47
|
-
is_array,
|
|
48
|
-
results,
|
|
49
|
-
schema,
|
|
50
|
-
field,
|
|
51
|
-
temp;
|
|
52
|
-
|
|
53
|
-
schema = this.fieldType.getSubschema(main_record);
|
|
54
|
-
|
|
55
|
-
if (typeof schema != 'object' || schema == null) {
|
|
56
|
-
return callback(null);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
actionFields = new Classes.Alchemy.ChimeraActionFields(schema, 'edit');
|
|
60
|
-
subRecord = Object.path(main_record, this.path);
|
|
61
|
-
is_array = Array.isArray(subRecord);
|
|
62
|
-
results = [];
|
|
63
|
-
|
|
64
|
-
// Always turn the element into an array
|
|
65
|
-
if (!is_array) {
|
|
66
|
-
subRecord = [subRecord];
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
Function.forEach.parallel(subRecord, function eachRecord(record, index, next) {
|
|
70
|
-
|
|
71
|
-
actionFields.processRecord(schema, record, function gotResults(err, result) {
|
|
72
|
-
|
|
73
|
-
if (err != null) {
|
|
74
|
-
return next(err);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Make sure the requirement files are arrays
|
|
78
|
-
that.script_file = Array.cast(that.script_file);
|
|
79
|
-
that.style_file = Array.cast(that.style_file);
|
|
80
|
-
|
|
81
|
-
// Add the script files of the sub fields to the schema field requirements
|
|
82
|
-
result.fields.forEach(function eachSubField(entry) {
|
|
83
|
-
if (entry.field.script_file) {
|
|
84
|
-
that.script_file.include(entry.field.script_file);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (entry.field.style_file) {
|
|
88
|
-
that.style_file.include(entry.field.style_file);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
// Remove any empty strings
|
|
93
|
-
that.script_file.clean('');
|
|
94
|
-
that.style_file.clean('');
|
|
95
|
-
|
|
96
|
-
results[index] = result;
|
|
97
|
-
next();
|
|
98
|
-
});
|
|
99
|
-
}, function done(err) {
|
|
100
|
-
|
|
101
|
-
if (err) {
|
|
102
|
-
return callback(err);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
callback(null, results);
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Respond with related data values for this field
|
|
111
|
-
*
|
|
112
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
113
|
-
* @since 0.4.0
|
|
114
|
-
* @version 0.4.0
|
|
115
|
-
*
|
|
116
|
-
* @param {Conduit} conduit
|
|
117
|
-
*/
|
|
118
|
-
SchemaChimeraField.setMethod(function sendRelatedData(conduit, item, options) {
|
|
119
|
-
|
|
120
|
-
var that = this,
|
|
121
|
-
target_path,
|
|
122
|
-
new_value,
|
|
123
|
-
nested_in;
|
|
124
|
-
|
|
125
|
-
target_path = conduit.param('path_of_new_value');
|
|
126
|
-
new_value = conduit.param('new_value');
|
|
127
|
-
nested_in = conduit.param('nested_in');
|
|
128
|
-
|
|
129
|
-
if (!item) {
|
|
130
|
-
item = {};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// If this field is nested, get the nested record
|
|
134
|
-
if (nested_in) {
|
|
135
|
-
item = Object.path(item, nested_in);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Set the new value
|
|
139
|
-
Object.setPath(item, target_path, new_value);
|
|
140
|
-
|
|
141
|
-
this.actionValue('edit', item, function gotResult(err, result) {
|
|
142
|
-
|
|
143
|
-
if (err) {
|
|
144
|
-
return conduit.error(err);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
conduit.end(result[0]);
|
|
148
|
-
});
|
|
149
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Text Chimera Field
|
|
3
|
-
*
|
|
4
|
-
* @constructor
|
|
5
|
-
*
|
|
6
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
7
|
-
* @since 0.2.0
|
|
8
|
-
* @version 0.3.0
|
|
9
|
-
*
|
|
10
|
-
* @param {FieldType}
|
|
11
|
-
*/
|
|
12
|
-
var TextChimeraField = Function.inherits('Alchemy.ChimeraField', function TextChimeraField(fieldType, options) {
|
|
13
|
-
|
|
14
|
-
TextChimeraField.super.call(this, fieldType, options);
|
|
15
|
-
|
|
16
|
-
this.script_file = ['/public/ckeditor/4.4/ckeditor', 'chimera/text_field'];
|
|
17
|
-
|
|
18
|
-
this.viewname = 'text';
|
|
19
|
-
this.viewwrapper = 'text';
|
|
20
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Time Chimera Field
|
|
3
|
-
*
|
|
4
|
-
* @constructor
|
|
5
|
-
*
|
|
6
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
7
|
-
* @since 0.2.0
|
|
8
|
-
* @version 0.3.0
|
|
9
|
-
*
|
|
10
|
-
* @param {FieldType}
|
|
11
|
-
*/
|
|
12
|
-
var TimeChimeraField = Function.inherits('Alchemy.ChimeraField', function TimeChimeraField(fieldType, options) {
|
|
13
|
-
|
|
14
|
-
TimeChimeraField.super.call(this, fieldType, options);
|
|
15
|
-
|
|
16
|
-
this.viewname = 'time';
|
|
17
|
-
this.viewwrapper = 'date';
|
|
18
|
-
});
|
package/lib/chimera_field.js
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
var cf_map = new WeakMap();
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Chimera Field
|
|
5
|
-
*
|
|
6
|
-
* @constructor
|
|
7
|
-
*
|
|
8
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
9
|
-
* @since 0.2.0
|
|
10
|
-
* @version 0.3.0
|
|
11
|
-
*
|
|
12
|
-
* @param {FieldType}
|
|
13
|
-
*/
|
|
14
|
-
var ChimeraField = Function.inherits('Alchemy.Base', function ChimeraField(fieldType, options) {
|
|
15
|
-
|
|
16
|
-
if (options == null) {
|
|
17
|
-
options = {};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
this.fieldType = fieldType;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Optional script file(s) to require
|
|
24
|
-
*
|
|
25
|
-
* @type {String|Array}
|
|
26
|
-
*/
|
|
27
|
-
this.script_file = '';
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Optional style file(s) to require
|
|
31
|
-
*
|
|
32
|
-
* @type {String|Array}
|
|
33
|
-
*/
|
|
34
|
-
this.style_file = '';
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* The `view` part in `chimera/fields/{view}_{action}.ejs` template to use
|
|
38
|
-
*
|
|
39
|
-
* @type {String}
|
|
40
|
-
*/
|
|
41
|
-
this.viewname = 'default';
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* The `wrapper` part in `chimera/field_wrappers/{wrapper}_{action}.ejs` template to use
|
|
45
|
-
*
|
|
46
|
-
* @type {String}
|
|
47
|
-
*/
|
|
48
|
-
this.viewwrapper = 'default';
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* The `action` part in `chimera/fields/{view}_{action}.ejs` template to use
|
|
52
|
-
*
|
|
53
|
-
* @type {String}
|
|
54
|
-
*/
|
|
55
|
-
this.viewaction = options.action || 'list';
|
|
56
|
-
|
|
57
|
-
// Store the options
|
|
58
|
-
this.options = options;
|
|
59
|
-
|
|
60
|
-
// If there is a custom action value function,
|
|
61
|
-
// add a `super` property link
|
|
62
|
-
if (options.actionValue) {
|
|
63
|
-
options.actionValue.super = this.actionValue;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (fieldType.schema) {
|
|
67
|
-
if (fieldType.schema.parent) {
|
|
68
|
-
this.in_sub_schema = true;
|
|
69
|
-
this.path = fieldType.name;
|
|
70
|
-
} else if (fieldType.schema.name) {
|
|
71
|
-
this.path = fieldType.schema.name + '.' + fieldType.name;
|
|
72
|
-
} else {
|
|
73
|
-
console.log('Schema of', fieldType, 'has no name?')
|
|
74
|
-
this.path = fieldType.name;
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
this.path = fieldType.name;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Allow the field instance to be cached
|
|
83
|
-
*
|
|
84
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
85
|
-
* @since 0.3.0
|
|
86
|
-
* @version 0.3.0
|
|
87
|
-
*/
|
|
88
|
-
ChimeraField.setProperty('allow_cache', true);
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Get the database value from the given record
|
|
92
|
-
*
|
|
93
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
94
|
-
* @since 0.2.0
|
|
95
|
-
* @version 0.2.0
|
|
96
|
-
*
|
|
97
|
-
* @param {Object} record
|
|
98
|
-
*
|
|
99
|
-
* @return {Mixed}
|
|
100
|
-
*/
|
|
101
|
-
ChimeraField.setMethod(function getRecordValue(record) {
|
|
102
|
-
return Object.path(record, this.path);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Get the value to use in the action
|
|
107
|
-
*
|
|
108
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
109
|
-
* @since 0.2.0
|
|
110
|
-
* @version 0.3.0
|
|
111
|
-
*
|
|
112
|
-
* @param {String} actionType
|
|
113
|
-
* @param {Object} record
|
|
114
|
-
* @param {Function} callback
|
|
115
|
-
*/
|
|
116
|
-
ChimeraField.setMethod(function actionValue(actionType, record, callback) {
|
|
117
|
-
|
|
118
|
-
var value;
|
|
119
|
-
|
|
120
|
-
// Use custom method if set in the options
|
|
121
|
-
if (this.options.actionValue) {
|
|
122
|
-
return this.options.actionValue.call(this, actionType, record, callback);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
value = this.getRecordValue(record);
|
|
126
|
-
|
|
127
|
-
setImmediate(function() {
|
|
128
|
-
callback(null, value);
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Respond with related data values for this field
|
|
134
|
-
*
|
|
135
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
136
|
-
* @since 0.2.0
|
|
137
|
-
* @version 0.2.0
|
|
138
|
-
*
|
|
139
|
-
* @param {Conduit} conduit
|
|
140
|
-
*/
|
|
141
|
-
ChimeraField.setMethod(function sendRelatedData(conduit) {
|
|
142
|
-
conduit.end('[]');
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Extend the FieldType model:
|
|
147
|
-
* return a correct new associated Chimera Field instance
|
|
148
|
-
*
|
|
149
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
150
|
-
* @since 0.2.0
|
|
151
|
-
* @version 0.4.0
|
|
152
|
-
*/
|
|
153
|
-
FieldType.setMethod(function getChimeraField(options) {
|
|
154
|
-
|
|
155
|
-
var className,
|
|
156
|
-
CfClass,
|
|
157
|
-
serial,
|
|
158
|
-
cache;
|
|
159
|
-
|
|
160
|
-
if (!options) {
|
|
161
|
-
options = {};
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// See if a modified type has been given
|
|
165
|
-
if (options.type) {
|
|
166
|
-
className = options.type + 'ChimeraField';
|
|
167
|
-
|
|
168
|
-
if (Classes.Alchemy[className] == null) {
|
|
169
|
-
className = null;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// If no classname is yet set, get the default one for this field
|
|
174
|
-
if (className == null) {
|
|
175
|
-
|
|
176
|
-
if (this.constructor.type_name) {
|
|
177
|
-
className = this.constructor.type_name.classify() + 'ChimeraField';
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (Classes.Alchemy[className] == null) {
|
|
181
|
-
className = 'ChimeraField';
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// Get the CF class constructor
|
|
186
|
-
CfClass = Classes.Alchemy[className];
|
|
187
|
-
|
|
188
|
-
if (CfClass.prototype.allow_cache) {
|
|
189
|
-
|
|
190
|
-
serial = Object.checksum(options);
|
|
191
|
-
|
|
192
|
-
// Get the CF cache
|
|
193
|
-
cache = cf_map.get(this);
|
|
194
|
-
|
|
195
|
-
if (!cache) {
|
|
196
|
-
cache = {};
|
|
197
|
-
cf_map.set(this, cache);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (!cache[serial]) {
|
|
201
|
-
cache[serial] = new CfClass(this, options);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return cache[serial];
|
|
205
|
-
} else {
|
|
206
|
-
return new CfClass(this, options);
|
|
207
|
-
}
|
|
208
|
-
});
|