alchemy-chimera 1.2.2 → 1.2.3
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 +5 -0
- package/assets/stylesheets/chimera/chimera.scss +2 -1
- package/config/routes.js +20 -0
- package/controller/chimera_editor_controller.js +48 -3
- package/lib/chimera_config.js +32 -1
- package/package.json +1 -1
- package/view/chimera/editor/add.hwk +12 -0
- package/view/chimera/editor/edit.hwk +33 -0
package/CHANGELOG.md
CHANGED
package/config/routes.js
CHANGED
|
@@ -58,6 +58,26 @@ chimera_section.add({
|
|
|
58
58
|
paths : '/api/content/sidebar',
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
+
alchemy.sputnik.after('base_app', () => {
|
|
62
|
+
|
|
63
|
+
let prefixes = Prefix.all();
|
|
64
|
+
let preview_paths = {
|
|
65
|
+
'': '/editor/{model}/preview/{pk}',
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
for (let prefix in prefixes) {
|
|
69
|
+
preview_paths[prefix] = '/editor/{model}/preview/{pk}';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Preview action
|
|
73
|
+
chimera_section.add({
|
|
74
|
+
name : 'Chimera.Editor#preview',
|
|
75
|
+
methods : ['get', 'post'],
|
|
76
|
+
paths : preview_paths,
|
|
77
|
+
breadcrumb : 'chimera.editor.{model}.preview.{pk}'
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
61
81
|
return
|
|
62
82
|
var chimera_menu;
|
|
63
83
|
|
|
@@ -117,7 +117,7 @@ Editor.setAction(async function add(conduit, model_name) {
|
|
|
117
117
|
this.set('widget_config', widget_config);
|
|
118
118
|
this.setTitle(model.constructor.title + ' Add');
|
|
119
119
|
|
|
120
|
-
this.render('chimera/
|
|
120
|
+
this.render('chimera/editor/add');
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
/**
|
|
@@ -125,7 +125,7 @@ Editor.setAction(async function add(conduit, model_name) {
|
|
|
125
125
|
*
|
|
126
126
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
127
127
|
* @since 0.1.0
|
|
128
|
-
* @version 1.2.
|
|
128
|
+
* @version 1.2.3
|
|
129
129
|
*
|
|
130
130
|
* @param {Conduit} conduit
|
|
131
131
|
* @param {String} model_name
|
|
@@ -181,10 +181,55 @@ Editor.setAction(async function edit(conduit, model_name, pk_val) {
|
|
|
181
181
|
|
|
182
182
|
widget_config.class_names.push('chimera-editor-widgets');
|
|
183
183
|
|
|
184
|
+
if (model.chimera.record_preview) {
|
|
185
|
+
this.set('add_preview_button', true);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
this.set('record_pk', record.$pk);
|
|
189
|
+
this.set('model_name', model.model_name.toLowerCase());
|
|
184
190
|
this.set('widget_config', widget_config);
|
|
185
191
|
this.setTitle(model.constructor.title + ' Edit');
|
|
186
192
|
|
|
187
|
-
this.render('chimera/
|
|
193
|
+
this.render('chimera/editor/edit');
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* The preview action
|
|
198
|
+
*
|
|
199
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
200
|
+
* @since 1.2.3
|
|
201
|
+
* @version 1.2.3
|
|
202
|
+
*
|
|
203
|
+
* @param {Conduit} conduit
|
|
204
|
+
* @param {String} model_name
|
|
205
|
+
* @param {String} pk_val
|
|
206
|
+
*/
|
|
207
|
+
Editor.setAction(async function preview(conduit, model_name, pk_val) {
|
|
208
|
+
|
|
209
|
+
let model = this.getModel(model_name);
|
|
210
|
+
const action_name = model?.chimera?.record_preview_action;
|
|
211
|
+
|
|
212
|
+
if (!action_name) {
|
|
213
|
+
return conduit.notFound();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
let record = await model.findByPk(pk_val);
|
|
217
|
+
|
|
218
|
+
if (!record) {
|
|
219
|
+
return conduit.notFound();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const controller = Controller.get(model.chimera.record_preview_controller, conduit);
|
|
223
|
+
|
|
224
|
+
console.log(conduit.view_render.variables);
|
|
225
|
+
|
|
226
|
+
if (!controller) {
|
|
227
|
+
return conduit.notFound();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
console.log('URLPARAMS:', controller.view_render?.variables?.__urlparams)
|
|
231
|
+
|
|
232
|
+
controller.doAction(action_name, [conduit, record]);
|
|
188
233
|
});
|
|
189
234
|
|
|
190
235
|
/**
|
package/lib/chimera_config.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
9
9
|
* @since 0.2.0
|
|
10
|
-
* @version 1.
|
|
10
|
+
* @version 1.2.3
|
|
11
11
|
*
|
|
12
12
|
* @param {Model} ModelClass
|
|
13
13
|
*/
|
|
@@ -18,6 +18,37 @@ const Config = Function.inherits('Alchemy.Base', 'Alchemy.Chimera', function Con
|
|
|
18
18
|
|
|
19
19
|
// The different default field sets
|
|
20
20
|
this.field_sets = {};
|
|
21
|
+
|
|
22
|
+
// The record preview action
|
|
23
|
+
this.record_preview = null;
|
|
24
|
+
this.record_preview_controller = null;
|
|
25
|
+
this.record_preview_action = null;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Set a record preview
|
|
30
|
+
*
|
|
31
|
+
* @deprecated
|
|
32
|
+
*
|
|
33
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
34
|
+
* @since 1.2.3
|
|
35
|
+
* @version 1.2.3
|
|
36
|
+
*
|
|
37
|
+
* @param {String} target The controller#method to use
|
|
38
|
+
*/
|
|
39
|
+
Config.setMethod(function setRecordPreview(target) {
|
|
40
|
+
this.record_preview = target;
|
|
41
|
+
this.record_preview_controller = null;
|
|
42
|
+
this.record_preview_action = null;
|
|
43
|
+
|
|
44
|
+
if (target && typeof target == 'string') {
|
|
45
|
+
let parts = target.split('#');
|
|
46
|
+
|
|
47
|
+
if (parts.length == 2) {
|
|
48
|
+
this.record_preview_controller = parts[0];
|
|
49
|
+
this.record_preview_action = parts[1];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
21
52
|
});
|
|
22
53
|
|
|
23
54
|
/**
|
package/package.json
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{% include "layouts/chimera_basics" %}
|
|
2
|
+
|
|
3
|
+
{% block "page-actions" %}
|
|
4
|
+
|
|
5
|
+
{% if add_preview_button %}
|
|
6
|
+
<a
|
|
7
|
+
!Route="Chimera.Editor#preview"
|
|
8
|
+
+model={% model_name %}
|
|
9
|
+
+pk={% record_pk %}
|
|
10
|
+
class="btn"
|
|
11
|
+
target="_blank"
|
|
12
|
+
>
|
|
13
|
+
<al-icon icon-name="eye"></al-icon>
|
|
14
|
+
{%t "preview" model=model_name %}
|
|
15
|
+
</a>
|
|
16
|
+
{% /if %}
|
|
17
|
+
|
|
18
|
+
<a
|
|
19
|
+
!Route="Chimera.Editor#add"
|
|
20
|
+
#model={% model_name %}
|
|
21
|
+
class="btn"
|
|
22
|
+
>
|
|
23
|
+
<al-icon icon-name="plus"></al-icon>
|
|
24
|
+
{%t "new" model=model_name %}
|
|
25
|
+
</a>
|
|
26
|
+
{% /block %}
|
|
27
|
+
|
|
28
|
+
{% block "main" %}
|
|
29
|
+
<al-widgets
|
|
30
|
+
#context_variables={% context_variables %}
|
|
31
|
+
#value={% widget_config %}
|
|
32
|
+
></al-widgets>
|
|
33
|
+
{% /block %}
|