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
package/helper/chimera_helper.js
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
var Chimera = Function.inherits('Alchemy.Helper', function Chimera(view) {
|
|
2
|
-
Chimera.super.call(this, view);
|
|
3
|
-
});
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Print the chimera field
|
|
7
|
-
*
|
|
8
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
9
|
-
* @since 0.2.0
|
|
10
|
-
* @version 0.3.0
|
|
11
|
-
*
|
|
12
|
-
* @param {Object} record_value Object containg fieldType and value
|
|
13
|
-
* @param {Object} options
|
|
14
|
-
*
|
|
15
|
-
* @return {Placeholder}
|
|
16
|
-
*/
|
|
17
|
-
Chimera.setMethod(function printField(record_value, options) {
|
|
18
|
-
|
|
19
|
-
var that = this,
|
|
20
|
-
placeholder,
|
|
21
|
-
viewElement,
|
|
22
|
-
variables,
|
|
23
|
-
fblock;
|
|
24
|
-
|
|
25
|
-
if (!options) {
|
|
26
|
-
options = {};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Print the wrapper by default
|
|
30
|
-
if (!options.template) {
|
|
31
|
-
options.template = 'chimera/field_wrappers/_wrapper';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (options.print_wrapper == null) {
|
|
35
|
-
options.print_wrapper = true;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (options.print_entries == null) {
|
|
39
|
-
options.print_entries = true;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
variables = {
|
|
43
|
-
data: record_value,
|
|
44
|
-
template: {
|
|
45
|
-
field: record_value.field.viewname,
|
|
46
|
-
action: record_value.field.viewaction,
|
|
47
|
-
wrapper: record_value.field.viewwrapper
|
|
48
|
-
},
|
|
49
|
-
print_wrapper: options.print_wrapper,
|
|
50
|
-
print_entries: options.print_entries,
|
|
51
|
-
is_nested: options.is_nested
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
if (options.variables) {
|
|
55
|
-
Object.assign(variables, options.variables);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Print the placeholder element
|
|
59
|
-
placeholder = this.view.print_element(options.template, variables);
|
|
60
|
-
|
|
61
|
-
// Add the container classname to the wrapper element
|
|
62
|
-
placeholder.element.classList.add('chimeraField-container');
|
|
63
|
-
|
|
64
|
-
if (options.is_nested) {
|
|
65
|
-
placeholder.element.classList.add('chimeraField-is-nested');
|
|
66
|
-
|
|
67
|
-
if (options.nested_id) {
|
|
68
|
-
placeholder.element.classList.add('nid-' + options.nested_id);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Create the 'fields' blockbuffer
|
|
73
|
-
fblock = placeholder.renderer.createBlock('field', {created_manually: true});
|
|
74
|
-
|
|
75
|
-
// Add the intake classname to the field wrapper element
|
|
76
|
-
fblock.attributes['class'] = 'chimeraField-intake';
|
|
77
|
-
|
|
78
|
-
return placeholder;
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Print the actions for a given action type
|
|
83
|
-
*
|
|
84
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
85
|
-
* @since 0.2.0
|
|
86
|
-
* @version 0.5.1
|
|
87
|
-
*
|
|
88
|
-
* @param {String} type model, list or record
|
|
89
|
-
*/
|
|
90
|
-
Chimera.setMethod(function printActions(type, options, subject) {
|
|
91
|
-
|
|
92
|
-
var actionData,
|
|
93
|
-
routeName,
|
|
94
|
-
className,
|
|
95
|
-
variables,
|
|
96
|
-
rOptions,
|
|
97
|
-
actions,
|
|
98
|
-
action,
|
|
99
|
-
view,
|
|
100
|
-
list,
|
|
101
|
-
name,
|
|
102
|
-
item,
|
|
103
|
-
temp,
|
|
104
|
-
val;
|
|
105
|
-
|
|
106
|
-
if (!type) {
|
|
107
|
-
throw new TypeError('Invalid action type given');
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (options == null) {
|
|
111
|
-
options = {};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
view = this.view;
|
|
115
|
-
actionData = view.set('actions');
|
|
116
|
-
|
|
117
|
-
// The default route name to use
|
|
118
|
-
routeName = type.classify() + 'Action';
|
|
119
|
-
|
|
120
|
-
if (subject == null) {
|
|
121
|
-
subject = {};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (actionData[type] == null) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
actions = actionData[type].createIterator();
|
|
129
|
-
list = [];
|
|
130
|
-
|
|
131
|
-
while (actions.hasNext()) {
|
|
132
|
-
action = actions.next().value;
|
|
133
|
-
|
|
134
|
-
if (!action) {
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
temp = {
|
|
139
|
-
controller: action.controller,
|
|
140
|
-
action: action.name,
|
|
141
|
-
subject: view.internal('modelName')
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
if (view.internal('recordId')) {
|
|
145
|
-
temp.id = view.internal('recordId');
|
|
146
|
-
} else if (subject.id) {
|
|
147
|
-
temp.id = subject.id;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
className = 'action-' + action.name;
|
|
151
|
-
|
|
152
|
-
if (options.className) {
|
|
153
|
-
className += ' ' + options.className;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
name = action.name;
|
|
157
|
-
|
|
158
|
-
if (action.title) {
|
|
159
|
-
name = action.title;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
rOptions = {
|
|
163
|
-
title : action.name,
|
|
164
|
-
content : name,
|
|
165
|
-
className : className
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
if (action.handleManual) {
|
|
169
|
-
rOptions.handleManual = true;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
list.push({
|
|
173
|
-
route_name : action.route_name || routeName,
|
|
174
|
-
parameters : temp,
|
|
175
|
-
options : rOptions
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
variables = Object.assign({}, {actions: list}, options.variables);
|
|
180
|
-
|
|
181
|
-
view.print_element('chimera/elements/editor_actions', variables);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Set the page title
|
|
186
|
-
*
|
|
187
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
188
|
-
* @since 0.3.0
|
|
189
|
-
* @version 0.3.0
|
|
190
|
-
*
|
|
191
|
-
* @param {Object} options
|
|
192
|
-
*/
|
|
193
|
-
Chimera.setMethod(function setTitle(options) {
|
|
194
|
-
|
|
195
|
-
if (typeof options == 'string') {
|
|
196
|
-
options = {
|
|
197
|
-
title : options
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
this.view.set_title('Chimera: ' + options.title);
|
|
202
|
-
});
|
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Chimera Action Fields: collection of fields
|
|
3
|
-
*
|
|
4
|
-
* @constructor
|
|
5
|
-
*
|
|
6
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
7
|
-
* @since 0.2.0
|
|
8
|
-
* @version 0.3.0
|
|
9
|
-
*/
|
|
10
|
-
var ActionFields = Function.inherits('Alchemy.Base', function ChimeraActionFields(ModelClass, name, options) {
|
|
11
|
-
|
|
12
|
-
this.ModelClass = ModelClass;
|
|
13
|
-
|
|
14
|
-
this.schema = ModelClass.schema;
|
|
15
|
-
|
|
16
|
-
this.name = name;
|
|
17
|
-
this.options = Object.assign({}, options);
|
|
18
|
-
|
|
19
|
-
this.groups = new Deck();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Add a field to this action group
|
|
24
|
-
*
|
|
25
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
26
|
-
* @since 0.2.0
|
|
27
|
-
* @version 0.2.0
|
|
28
|
-
*
|
|
29
|
-
* @param {String} name The name of the field inside the schema
|
|
30
|
-
* @param {Object} options
|
|
31
|
-
*/
|
|
32
|
-
ActionFields.setMethod(function addField(groupName, name, options) {
|
|
33
|
-
|
|
34
|
-
var fieldType,
|
|
35
|
-
group,
|
|
36
|
-
field;
|
|
37
|
-
|
|
38
|
-
if (typeof name !== 'string') {
|
|
39
|
-
options = name;
|
|
40
|
-
name = groupName;
|
|
41
|
-
groupName = null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (this.schema == null) {
|
|
45
|
-
throw new Error('Can not get "' + name + '" from non existing schema (' + this.name + ')');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Get the fieldType instance from the model
|
|
49
|
-
fieldType = this.schema.getField(name);
|
|
50
|
-
|
|
51
|
-
if (fieldType == null) {
|
|
52
|
-
throw new Error('Field "' + name + '" does not exist inside group "' + groupName + '" of schema "' + (this.schema.name || this.schema.modelName) + '"');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (options == null) {
|
|
56
|
-
options = {};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (options.action == null) {
|
|
60
|
-
options.action = this.name;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (options.group == null) {
|
|
64
|
-
options.group = groupName || 'general';
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Get the chimera field
|
|
68
|
-
field = fieldType.getChimeraField(options, name);
|
|
69
|
-
|
|
70
|
-
// Get the group deck
|
|
71
|
-
group = this.groups.get(options.group, Deck.create);
|
|
72
|
-
|
|
73
|
-
group.push(field);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Get a field
|
|
78
|
-
*
|
|
79
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
80
|
-
* @since 0.2.0
|
|
81
|
-
* @version 0.2.0
|
|
82
|
-
*
|
|
83
|
-
* @param {String} name
|
|
84
|
-
*
|
|
85
|
-
* @return {ChimeraField}
|
|
86
|
-
*/
|
|
87
|
-
ActionFields.setMethod(function getField(name) {
|
|
88
|
-
|
|
89
|
-
var group,
|
|
90
|
-
field,
|
|
91
|
-
key,
|
|
92
|
-
id;
|
|
93
|
-
|
|
94
|
-
for (key in this.groups.dict) {
|
|
95
|
-
group = this.groups.dict[key];
|
|
96
|
-
|
|
97
|
-
for (id in group.value.dict) {
|
|
98
|
-
field = group.value.dict[id].value;
|
|
99
|
-
|
|
100
|
-
if (field.fieldType.name == name) {
|
|
101
|
-
return field;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Get the fields of a specific group as a deck
|
|
110
|
-
*
|
|
111
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
112
|
-
* @since 0.2.0
|
|
113
|
-
* @version 0.2.0
|
|
114
|
-
*
|
|
115
|
-
* @param {String} group The name of the group (general)
|
|
116
|
-
*
|
|
117
|
-
* @return {Deck}
|
|
118
|
-
*/
|
|
119
|
-
ActionFields.setMethod(function getGroup(name, clone) {
|
|
120
|
-
|
|
121
|
-
var fieldname,
|
|
122
|
-
group;
|
|
123
|
-
|
|
124
|
-
if (name == null) {
|
|
125
|
-
name = 'general';
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
group = this.groups.get(name);
|
|
129
|
-
|
|
130
|
-
if (group == null) {
|
|
131
|
-
for (fieldname in this.schema.dict) {
|
|
132
|
-
this.addField(name, fieldname);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
group = this.groups.get(name);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (clone == null || clone) {
|
|
139
|
-
group = group.clone();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return group;
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Process found records
|
|
147
|
-
*
|
|
148
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
149
|
-
* @since 0.2.0
|
|
150
|
-
* @version 0.2.0
|
|
151
|
-
*
|
|
152
|
-
* @param {String|Array|Deck} groups
|
|
153
|
-
* @param {Array} records
|
|
154
|
-
* @param {ActionFields~groupedRecords} callback
|
|
155
|
-
*/
|
|
156
|
-
ActionFields.setMethod(function processRecords(_groups, model, records, callback) {
|
|
157
|
-
|
|
158
|
-
var that = this,
|
|
159
|
-
groupTasks,
|
|
160
|
-
length,
|
|
161
|
-
groups,
|
|
162
|
-
group,
|
|
163
|
-
name;
|
|
164
|
-
|
|
165
|
-
if (typeof records == 'function') {
|
|
166
|
-
callback = records;
|
|
167
|
-
records = model;
|
|
168
|
-
model = _groups;
|
|
169
|
-
groups = null;
|
|
170
|
-
} else if (typeof _groups === 'string') {
|
|
171
|
-
groups = [_groups];
|
|
172
|
-
} else if (_groups instanceof Deck) {
|
|
173
|
-
groups = Object.keys(_groups.dict);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Get all the groups if none were given
|
|
177
|
-
if (groups == null) {
|
|
178
|
-
|
|
179
|
-
// If no groups were defined, add everything of the schema to general
|
|
180
|
-
if (this.groups.insertCount === 0) {
|
|
181
|
-
|
|
182
|
-
for (name in this.schema.dict) {
|
|
183
|
-
this.addField(name);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// Get the names of all the defined groups
|
|
188
|
-
groups = Object.keys(this.groups.dict);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// Make sure records is an array
|
|
192
|
-
if (records.length == null) {
|
|
193
|
-
records = [records];
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
length = records.length;
|
|
197
|
-
groupTasks = {};
|
|
198
|
-
|
|
199
|
-
groups.forEach(function eachGroup(groupName) {
|
|
200
|
-
|
|
201
|
-
var tasks = new Array(length);
|
|
202
|
-
|
|
203
|
-
records.forEach(function eachRecord(record, index) {
|
|
204
|
-
tasks[index] = function taskRecord(nextRecord) {
|
|
205
|
-
that.processRecord(groupName, model, record, nextRecord);
|
|
206
|
-
};
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
groupTasks[groupName] = function taskGroup(next) {
|
|
210
|
-
Function.parallel(tasks, next);
|
|
211
|
-
};
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
Function.parallel(groupTasks, function doneProcessingGroups(err, results) {
|
|
215
|
-
callback(err, results);
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Process a single record
|
|
221
|
-
*
|
|
222
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
223
|
-
* @since 0.2.0
|
|
224
|
-
* @version 0.2.0
|
|
225
|
-
*
|
|
226
|
-
* @param {String} groupName
|
|
227
|
-
* @param {Object} record
|
|
228
|
-
* @param {Function} callback
|
|
229
|
-
*/
|
|
230
|
-
ActionFields.setMethod(function processRecord(groupName, model, record, callback) {
|
|
231
|
-
|
|
232
|
-
var that = this,
|
|
233
|
-
fields,
|
|
234
|
-
tasks,
|
|
235
|
-
group,
|
|
236
|
-
temp,
|
|
237
|
-
id;
|
|
238
|
-
|
|
239
|
-
if (typeof groupName !== 'string') {
|
|
240
|
-
callback = record;
|
|
241
|
-
record = model;
|
|
242
|
-
model = groupName;
|
|
243
|
-
groupName = 'general';
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (record instanceof Classes.Alchemy.Document) {
|
|
247
|
-
id = record._id;
|
|
248
|
-
} else if (record != null && record._id != null) {
|
|
249
|
-
id = record._id;
|
|
250
|
-
temp = {};
|
|
251
|
-
temp[model.name] = record;
|
|
252
|
-
record = temp;
|
|
253
|
-
} else if (record != null && record[model.name] != null && record[model.name]._id != null) {
|
|
254
|
-
id = record[model.name]._id;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
tasks = [];
|
|
258
|
-
|
|
259
|
-
// Get the group
|
|
260
|
-
group = this.getGroup(groupName, false);
|
|
261
|
-
|
|
262
|
-
// If the group doesn't exist, the schema is probably empty
|
|
263
|
-
if (!group) {
|
|
264
|
-
return callback(null, {id: id, fields: []});
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// Get the group fields
|
|
268
|
-
fields = group.getSorted(false);
|
|
269
|
-
|
|
270
|
-
fields.forEach(function eachField(field, index) {
|
|
271
|
-
|
|
272
|
-
tasks.push(function taskFieldValue(nextValue) {
|
|
273
|
-
field.actionValue(that.name, record, function gotValue(err, result) {
|
|
274
|
-
|
|
275
|
-
if (err != null) {
|
|
276
|
-
return nextValue(err);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
nextValue(null, {field: field, value: result});
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
Function.parallel(tasks, function afterFieldTasks(err, results) {
|
|
285
|
-
|
|
286
|
-
if (err) {
|
|
287
|
-
return callback(err);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
callback(null, {id: id, fields: results});
|
|
291
|
-
});
|
|
292
|
-
});
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Belongsto 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 BelongsTo = Function.inherits('Alchemy.ChimeraField', function BelongsToChimeraField(fieldType, options) {
|
|
13
|
-
|
|
14
|
-
BelongsToChimeraField.super.call(this, fieldType, options);
|
|
15
|
-
|
|
16
|
-
this.script_file = [{name: 'jquery', path: '//code.jquery.com/jquery-1.11.3.min.js'}, 'selectize/0.12/selectize', 'chimera/assoc_field'];
|
|
17
|
-
//this.style_file = 'selectize/0.12/selectize';
|
|
18
|
-
|
|
19
|
-
this.viewname = 'belongsto';
|
|
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.4
|
|
29
|
-
*
|
|
30
|
-
* @param {Conduit} conduit
|
|
31
|
-
*/
|
|
32
|
-
BelongsTo.setMethod(function sendRelatedData(conduit, item, options) {
|
|
33
|
-
|
|
34
|
-
var that = this,
|
|
35
|
-
fieldType = this.fieldType,
|
|
36
|
-
model = Model.get(fieldType.options.modelName),
|
|
37
|
-
find_options,
|
|
38
|
-
fields,
|
|
39
|
-
type,
|
|
40
|
-
id;
|
|
41
|
-
|
|
42
|
-
if (typeof options != 'object') {
|
|
43
|
-
options = {};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
fields = ['_id', 'title', 'name'].concat(model.displayField);
|
|
47
|
-
find_options = {};
|
|
48
|
-
|
|
49
|
-
if (options.display_field_only) {
|
|
50
|
-
|
|
51
|
-
// This means we only want the title of the selected value
|
|
52
|
-
// So if there IS NO selected value, we should return nothing
|
|
53
|
-
id = Object.path(item, this.path);
|
|
54
|
-
|
|
55
|
-
if (!id) {
|
|
56
|
-
return conduit.end('');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
find_options.conditions = {_id: Object.path(item, this.path)};
|
|
60
|
-
type = 'list';
|
|
61
|
-
} else {
|
|
62
|
-
type = 'all';
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (model.display_field_select) {
|
|
66
|
-
find_options.select = model.display_field_select.slice(0);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
model.find(type, find_options, function gotData(err, results) {
|
|
70
|
-
|
|
71
|
-
var response,
|
|
72
|
-
item;
|
|
73
|
-
|
|
74
|
-
if (err) {
|
|
75
|
-
return conduit.error(err);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (options.display_field_only) {
|
|
79
|
-
item = results[0];
|
|
80
|
-
|
|
81
|
-
if (item) {
|
|
82
|
-
response = item[model.displayField] || item.title || item.name || item._id;
|
|
83
|
-
} else {
|
|
84
|
-
response = '';
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
response = {
|
|
88
|
-
items: results.toSimpleArray(fields),
|
|
89
|
-
displayField: model.displayField
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
conduit.end(response);
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Get the value to use in the action
|
|
99
|
-
*
|
|
100
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
101
|
-
* @since 0.3.0
|
|
102
|
-
* @version 0.5.4
|
|
103
|
-
*
|
|
104
|
-
* @param {String} actionType
|
|
105
|
-
* @param {Object} main_record
|
|
106
|
-
* @param {Function} callback
|
|
107
|
-
*/
|
|
108
|
-
BelongsTo.setMethod(function actionValue(actionType, record, callback) {
|
|
109
|
-
|
|
110
|
-
var find_options,
|
|
111
|
-
assoc_id,
|
|
112
|
-
result,
|
|
113
|
-
model;
|
|
114
|
-
|
|
115
|
-
// Get the associated ObjectId
|
|
116
|
-
assoc_id = this.getRecordValue(record);
|
|
117
|
-
|
|
118
|
-
// Prepare the result object
|
|
119
|
-
result = {assoc_id: assoc_id};
|
|
120
|
-
|
|
121
|
-
// If no id is set, nothing needs to be fetched anyway
|
|
122
|
-
if (!assoc_id || (actionType != 'list' && actionType != 'peek')) {
|
|
123
|
-
return setImmediate(function() {
|
|
124
|
-
callback(null, result);
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
model = this.getModel(this.fieldType.options.modelName);
|
|
129
|
-
|
|
130
|
-
find_options = {
|
|
131
|
-
fields: ['_id', 'title', 'name'].concat(model.displayField),
|
|
132
|
-
conditions: {_id: assoc_id}
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
if (model.display_field_select) {
|
|
136
|
-
find_options.fields = model.display_field_select.slice(0);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
model.find('all', find_options, function gotData(err, results) {
|
|
140
|
-
|
|
141
|
-
var response,
|
|
142
|
-
item;
|
|
143
|
-
|
|
144
|
-
if (err) {
|
|
145
|
-
return callback(err);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
item = results[0];
|
|
149
|
-
|
|
150
|
-
if (item) {
|
|
151
|
-
response = item[model.displayField] || item.title || item.name || item._id;
|
|
152
|
-
} else {
|
|
153
|
-
response = '';
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
result.display_value = String(response);
|
|
157
|
-
|
|
158
|
-
callback(null, result);
|
|
159
|
-
});
|
|
160
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Boolean 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 BooleanChimeraField = Function.inherits('Alchemy.ChimeraField', function BooleanChimeraField(fieldType, options) {
|
|
13
|
-
|
|
14
|
-
BooleanChimeraField.super.call(this, fieldType, options);
|
|
15
|
-
|
|
16
|
-
this.script_file = 'chimera/boolean_field';
|
|
17
|
-
|
|
18
|
-
this.viewname = 'boolean';
|
|
19
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Date Chimera Field
|
|
3
|
-
*
|
|
4
|
-
* @constructor
|
|
5
|
-
*
|
|
6
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
7
|
-
* @since 0.2.0
|
|
8
|
-
* @version 0.4.0
|
|
9
|
-
*
|
|
10
|
-
* @param {FieldType}
|
|
11
|
-
*/
|
|
12
|
-
var DateChimeraField = Function.inherits('Alchemy.ChimeraField', function DateChimeraField(fieldType, options) {
|
|
13
|
-
|
|
14
|
-
DateChimeraField.super.call(this, fieldType, options);
|
|
15
|
-
|
|
16
|
-
this.script_file = ['chimera/date_field'];
|
|
17
|
-
|
|
18
|
-
this.viewname = 'date';
|
|
19
|
-
this.viewwrapper = 'date';
|
|
20
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Datetime 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 DatetimeChimeraField = Function.inherits('Alchemy.ChimeraField', function DatetimeChimeraField(fieldType, options) {
|
|
13
|
-
|
|
14
|
-
DatetimeChimeraField.super.call(this, fieldType, options);
|
|
15
|
-
|
|
16
|
-
this.script_file = ['chimera/date_field'];
|
|
17
|
-
|
|
18
|
-
this.viewname = 'datetime';
|
|
19
|
-
this.viewwrapper = 'date';
|
|
20
|
-
});
|