alchemy-chimera 1.2.7 → 1.3.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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.3.0-alpha.1 (2024-02-15)
2
+
3
+ * Upgrade to Alchemy v1.4.0
4
+
1
5
  ## 1.2.7 (2023-11-27)
2
6
 
3
7
  * Fix expecting underscored model names
@@ -426,6 +426,10 @@ al-field[mode="inline"] {
426
426
  &:empty {
427
427
  display: none;
428
428
  }
429
+
430
+ &:has(> micro-copy:empty) {
431
+ display: none;
432
+ }
429
433
  }
430
434
  }
431
435
 
@@ -470,6 +474,21 @@ al-field[mode="inline"] {
470
474
  border: none;
471
475
  padding: 0;
472
476
  }
477
+
478
+ textarea,
479
+ input[type=text],
480
+ input[type=number],
481
+ input[type=color],
482
+ input[type=datetime-local],
483
+ input[type=date],
484
+ input[type=password],
485
+ select {
486
+ &:disabled {
487
+ background-color: rgb(223 223 223 / 30%);
488
+ color: rgb(84, 84, 84);
489
+ border-color: rgba(118, 118, 118, 0.3);
490
+ }
491
+ }
473
492
  }
474
493
  }
475
494
 
package/bootstrap.js CHANGED
@@ -1,14 +1,27 @@
1
1
  alchemy.requirePlugin('widget');
2
2
  alchemy.requirePlugin('form');
3
3
 
4
- // Define the default options
5
- let options = {
6
- // The name to use in the routing
7
- base_path: 'chimera',
4
+ /**
5
+ * Convert a model name to an string to be used in a url
6
+ *
7
+ * @author Jelle De Loecker <jelle@elevenways.be>
8
+ * @since 1.3.0
9
+ * @version 1.3.0
10
+ *
11
+ * @param {string} model_name
12
+ */
13
+ Plugin.modelNameToUrl = function modelNameToUrl(model_name) {
8
14
 
9
- // Use a custom theme?
10
- theme : false
15
+ let path = Blast.parseClassPath(model_name),
16
+ result = [];
17
+
18
+ for (let entry of path) {
19
+ result.push(entry.underscore());
20
+ }
21
+
22
+ return result.join('.');
11
23
  };
12
24
 
13
- // Inject the user-overridden options
14
- alchemy.plugins.chimera = Object.merge(options, alchemy.plugins.chimera);
25
+ // Load the following files right now:
26
+ Plugin.useOnce('lib/chimera_config');
27
+ Plugin.useOnce('model/model');
package/config/routes.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Create a new chimera section.
2
2
  // By default this will be /chimera
3
- let chimera_section = Router.section('chimera', '/' + alchemy.plugins.chimera.base_path);
3
+ let chimera_section = Router.section('chimera', '/chimera');
4
4
 
5
5
  chimera_section.requirePermission('chimera');
6
6
 
@@ -12,6 +12,14 @@ chimera_section.add({
12
12
  paths : '/',
13
13
  handler : 'Chimera.Static#dashboard',
14
14
  });
15
+
16
+ // Settings editor
17
+ chimera_section.add({
18
+ name : 'Chimera.Settings#editor',
19
+ methods : ['post', 'get'],
20
+ paths : '/settings',
21
+ });
22
+
15
23
  // Editor index action
16
24
  chimera_section.add({
17
25
  name : 'Chimera.Editor#index',
@@ -79,129 +87,3 @@ alchemy.sputnik.after('base_app', () => {
79
87
  breadcrumb : 'chimera.editor.{model}.preview.{pk}'
80
88
  });
81
89
  });
82
-
83
- return
84
- var chimera_menu;
85
-
86
- // Link to the dashboard
87
- chimera_section.add({
88
- title : __('chimera', 'Dashboard'),
89
- name : 'Dashboard',
90
- methods : 'get',
91
- paths : '/',
92
- handler : 'Chimera.Static#dashboard',
93
- breadcrumb : 'chimera.dashboard'
94
- });
95
-
96
- chimera_section.add({
97
- name : 'IdActionLink',
98
- methods : ['get', 'post'],
99
- paths : '/{controller}/{action}/{[ObjectId]id}',
100
- handler : 'Chimera.{controller}#{action}',
101
- breadcrumb : 'chimera.{controller}.{action}.{id}'
102
- });
103
-
104
- chimera_section.add({
105
- name : 'ActionLink',
106
- methods : ['get', 'post'],
107
- paths : '/{controller}/{action}',
108
- handler : 'Chimera.{controller}#{action}',
109
- breadcrumb : 'chimera.{controller}.{action}'
110
- });
111
-
112
- chimera_section.add({
113
- name : 'RecordAction',
114
- methods : ['get', 'post'],
115
- paths : '/{controller}/{subject}/{action}/{[ObjectId]id}',
116
- handler : 'Chimera.{controller}#{action}',
117
- breadcrumb : 'chimera.{controller}.{subject}.{action}.{id}'
118
- });
119
-
120
- chimera_section.add({
121
- name : 'ModelAction',
122
- methods : ['get', 'post'],
123
- paths : '/{controller}/{subject}/{action}',
124
- handler : 'Chimera.{controller}#{action}',
125
- breadcrumb : 'chimera.{controller}.{subject}'
126
- });
127
-
128
- chimera_section.add({
129
- name : 'SettingsAction',
130
- methods : ['get', 'post'],
131
- paths : '/settings',
132
- handler : 'Chimera.Settings#index',
133
- breadcrumb : 'chimera.settings'
134
- });
135
-
136
- chimera_section.get('PageEditor', '/page_editor', 'Chimera.Static#pageEditor');
137
-
138
- // @TODO: add this to the chimera router
139
- Router.socket('al-rcommand-action', 'TaskChimera#action');
140
-
141
- // alchemy.plugins.chimera.menu_items.addItem('route', {
142
- // title : 'Dashboard',
143
- // route : 'chimera@Dashboard',
144
- // parameters : {}
145
- // });
146
-
147
-
148
- // Set user data for chimera
149
- chimera_section.use(function setChimeraData(req, res, next) {
150
-
151
- // Always set the user data
152
- req.conduit.internal('UserData', req.conduit.session('UserData') || {});
153
-
154
- // Set the theme to use
155
- req.conduit.renderer.setTheme(alchemy.plugins.chimera.view_settings.theme);
156
-
157
- // Skip the rest if it's an ajax call
158
- if (req.conduit.ajax) {
159
- return next();
160
- }
161
-
162
- // req.conduit.getModel('Menu').getPosition('chimera_main_sidebar', function gotMainSidebarMenu(err, result) {
163
- // // Do nothing on an error,
164
- // if (err) {
165
- // return console.error('ERROR: ' + err);
166
- // }
167
- // });
168
-
169
- // Send the ACL layout options to the client
170
- req.conduit.expose('chimera-view-setting', alchemy.plugins.chimera.view_settings);
171
-
172
- // var chimera_menu = [];
173
-
174
- // chimera_menu.push({
175
- // title: 'Dashboard',
176
- // route: 'chimera@Dashboard',
177
- // parameters: {},
178
- // icon: {svg: 'chimera/home'}
179
- // });
180
-
181
- // chimera_menu.push({
182
- // title: 'Dashboard2',
183
- // route: 'chimera@Dashboard',
184
- // parameters: {},
185
- // children: [
186
- // {
187
- // title: 'Child',
188
- // route: 'chimera@Dashboard',
189
- // parameters: {},
190
- // icon: {svg: 'chimera/home'}
191
- // }
192
- // ]
193
- // });
194
-
195
- req.conduit.set('chimera_menu', alchemy.plugins.chimera.menu);
196
- req.conduit.set('project_title', alchemy.plugins.chimera.title || 'Chimera');
197
-
198
- next();
199
- });
200
-
201
- Router.get('ChimeraCmsRedirect', '/cms', function(conduit) {
202
- conduit.redirect('/' + alchemy.plugins.chimera.routename);
203
- });
204
-
205
- Router.get('ChimeraAdminRedirect', '/admin', function(conduit) {
206
- conduit.redirect('/' + alchemy.plugins.chimera.routename);
207
- });
@@ -204,7 +204,7 @@ Editor.setAction(async function edit(conduit, model_name, pk_val) {
204
204
  this.setContextDocument(record);
205
205
 
206
206
  this.set('record_pk', record.$pk);
207
- this.set('model_name', model.model_name.toLowerCase());
207
+ this.set('model_name', model.model_name);
208
208
  this.set('widget_config', widget_config);
209
209
  this.setTitle(model.constructor.title + ' Edit');
210
210
 
@@ -239,14 +239,10 @@ Editor.setAction(async function preview(conduit, model_name, pk_val) {
239
239
 
240
240
  const controller = Controller.get(model.chimera.record_preview_controller, conduit);
241
241
 
242
- console.log(conduit.view_render.variables);
243
-
244
242
  if (!controller) {
245
243
  return conduit.notFound();
246
244
  }
247
245
 
248
- console.log('URLPARAMS:', controller.view_render?.variables?.__urlparams)
249
-
250
246
  controller.doAction(action_name, [conduit, record]);
251
247
  });
252
248
 
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The Chimera Settings Controller:
3
+ * Allows editing the application settings
4
+ *
5
+ * @author Jelle De Loecker <jelle@elevenways.be>
6
+ * @since 1.3.0
7
+ * @version 1.3.0
8
+ */
9
+ const SettingsController = Function.inherits('Alchemy.Controller.Chimera', 'Settings');
10
+
11
+ /**
12
+ * The settings editor action
13
+ *
14
+ * @author Jelle De Loecker <jelle@elevenways.be>
15
+ * @since 1.3.0
16
+ * @version 1.3.0
17
+ *
18
+ * @param {Alchemy.Conduit} conduit
19
+ */
20
+ SettingsController.setAction(async function editor(conduit) {
21
+
22
+ if (conduit.method == 'post') {
23
+ let changes = conduit.body;
24
+
25
+ if (!changes) {
26
+ return conduit.end();
27
+ }
28
+
29
+ const AlchemySetting = this.getModel('AlchemySetting');
30
+
31
+ console.log('Changes:', changes);
32
+
33
+ await AlchemySetting.saveChanges(changes, conduit);
34
+
35
+ return conduit.end();
36
+ }
37
+
38
+ const settings_config = Classes.Alchemy.Setting.SYSTEM.getEditorConfiguration(alchemy.system_settings, conduit);
39
+
40
+ this.set('settings_config', settings_config);
41
+
42
+ this.render('chimera/settings/editor');
43
+ });
@@ -80,7 +80,10 @@ ChimeraStatic.setAction(function sidebar(conduit) {
80
80
  link_settings: {
81
81
  route : 'Chimera.Editor#index',
82
82
  parameters: [
83
- {name: 'model', value: model.constructor.type_name},
83
+ {
84
+ name: 'model',
85
+ value: Plugin.modelNameToUrl(model.constructor.model_name),
86
+ },
84
87
  ],
85
88
  },
86
89
  text: title
@@ -94,6 +97,17 @@ ChimeraStatic.setAction(function sidebar(conduit) {
94
97
  let models = Model.getAllChildren();
95
98
  models.sortByPath(1, 'model_name');
96
99
 
100
+ widgets.push({
101
+ type : 'link',
102
+ config : {
103
+ link_type: 'route',
104
+ link_settings: {
105
+ route : 'Chimera.Settings#editor',
106
+ },
107
+ text: new Classes.Alchemy.Microcopy('alchemy.settings'),
108
+ }
109
+ });
110
+
97
111
  for (let model of models) {
98
112
 
99
113
  // Skip abstract classes (like `App`)
@@ -109,7 +123,10 @@ ChimeraStatic.setAction(function sidebar(conduit) {
109
123
  link_settings: {
110
124
  route : 'Chimera.Editor#index',
111
125
  parameters: [
112
- {name: 'model', value: model.type_name},
126
+ {
127
+ name: 'model',
128
+ value: Plugin.modelNameToUrl(model.model_name),
129
+ },
113
130
  ],
114
131
  },
115
132
  text: model.title
@@ -269,7 +269,7 @@ Config.setMethod(function getWidgetConfig(action, conduit) {
269
269
  {
270
270
  "type": "alchemy_form",
271
271
  "config": {
272
- model : this.ModelClass.type_name,
272
+ model : Plugin.modelNameToUrl(this.ModelClass.model_name),
273
273
  purpose : 'edit',
274
274
  widgets : action_widgets
275
275
  }
@@ -315,12 +315,12 @@ Config.setMethod(function getWidgetConfig(action, conduit) {
315
315
  fieldset : fieldset,
316
316
  page_size : 25,
317
317
  show_filters : true,
318
- id : 'aft-' + this.ModelClass.type_name,
318
+ id : 'aft-' + this.ModelClass.model_name,
319
319
  use_url_pagination : true,
320
320
  recordsource : {
321
321
  route : 'Chimera.Editor#records',
322
322
  parameters : {
323
- model : this.ModelClass.type_name
323
+ model : Plugin.modelNameToUrl(this.ModelClass.model_name),
324
324
  }
325
325
  }
326
326
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "alchemy-chimera",
3
3
  "description": "Chimera plugin for Alchemy MVC",
4
- "version": "1.2.7",
4
+ "version": "1.3.0-alpha.1",
5
5
  "author": "Jelle De Loecker <jelle@elevenways.be>",
6
6
  "keywords": [
7
7
  "alchemy",
@@ -11,10 +11,10 @@
11
11
  ],
12
12
  "repository": "11ways/alchemy-chimera",
13
13
  "peerDependencies": {
14
- "alchemy-acl" : "~0.8.4",
15
- "alchemymvc" : ">=1.3.16",
16
- "alchemy-form" : "~0.2.7",
17
- "alchemy-widget" : "~0.2.1"
14
+ "alchemy-acl" : "~0.9.0||~0.9.0-alpha",
15
+ "alchemymvc" : ">=1.4.0||>=1.4.0-alpha",
16
+ "alchemy-form" : "~0.3.0||~0.3.0-alpha",
17
+ "alchemy-widget" : "~0.3.0||~0.3.0-alpha"
18
18
  },
19
19
  "license": "MIT",
20
20
  "engines": {
@@ -0,0 +1,12 @@
1
+ {% include "layouts/chimera_basics" %}
2
+
3
+ {% block "page-actions" %}
4
+
5
+ {% /block %}
6
+
7
+ {% block "main" %}
8
+ <al-settings-editor
9
+ !Route="Chimera.Settings#editor"
10
+ #settings_config={% settings_config %}
11
+ ></al-settings-editor>
12
+ {% /block %}