alchemy-chimera 1.2.3 → 1.2.4

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.2.4 (2023-04-20)
2
+
3
+ * Add document watcher & toolbar manager support
4
+
1
5
  ## 1.2.3 (2023-03-10)
2
6
 
3
7
  * Add support for setting a record preview action per model
@@ -210,6 +210,10 @@ body {
210
210
  display: block;
211
211
  font-size: 1.2rem;
212
212
  }
213
+
214
+ > al-widgets-column > [type="header"] h1 {
215
+ padding-top: 0;
216
+ }
213
217
  }
214
218
 
215
219
  al-widgets-navigation {
@@ -565,6 +569,17 @@ al-field[mode="inline"] {
565
569
  background: initial;
566
570
  }
567
571
  }
572
+
573
+ al-editor-toolbar {
574
+ width: 100%;
575
+ align-items: center;
576
+ justify-content: space-between;
577
+
578
+ [data-area="buttons"] {
579
+ display: flex;
580
+ gap: 1rem;
581
+ }
582
+ }
568
583
  }
569
584
 
570
585
  al-field {
@@ -13,4 +13,35 @@ let ChimeraController = Function.inherits('Alchemy.Controller', 'Alchemy.Control
13
13
  if (alchemy.plugins.chimera.theme) {
14
14
  this.view_render.setTheme(alchemy.plugins.chimera.theme);
15
15
  }
16
+ });
17
+
18
+ /**
19
+ * Do something before the action is executed
20
+ *
21
+ * @author Jelle De Loecker <jelle@elevenways.be>
22
+ * @since 1.2.4
23
+ * @version 1.2.4
24
+ */
25
+ ChimeraController.setMethod(function beforeAction() {
26
+ this.set('toolbar_manager', this.toolbar_manager);
27
+ this.toolbar_manager.queueModelFallback(this.conduit.params.model);
28
+ });
29
+
30
+ /**
31
+ * Get this client's toolbar manager
32
+ *
33
+ * @author Jelle De Loecker <jelle@elevenways.be>
34
+ * @since 1.2.4
35
+ * @version 1.2.4
36
+ *
37
+ * @return {Alchemy.Widget.EditorToolbarManager}
38
+ */
39
+ ChimeraController.enforceProperty(function toolbar_manager(new_value) {
40
+
41
+ if (!new_value && this.conduit) {
42
+ new_value = Classes.Alchemy.Widget.EditorToolbarManager.create(this.conduit);
43
+ new_value.scenario = 'chimera';
44
+ }
45
+
46
+ return new_value;
16
47
  });
@@ -12,7 +12,7 @@ const Editor = Function.inherits('Alchemy.Controller.Chimera', 'Editor');
12
12
  *
13
13
  * @author Jelle De Loecker <jelle@elevenways.be>
14
14
  * @since 1.0.1
15
- * @version 1.0.5
15
+ * @version 1.2.4
16
16
  *
17
17
  * @param {String} title
18
18
  */
@@ -39,6 +39,22 @@ Editor.setMethod(function setTitle(title) {
39
39
 
40
40
  this.set('page_title', page_title);
41
41
  this.set('window_title', window_title || page_title);
42
+ this.toolbar_manager.title = page_title;
43
+ });
44
+
45
+ /**
46
+ * Set the context document
47
+ *
48
+ * @author Jelle De Loecker <jelle@elevenways.be>
49
+ * @since 1.2.4
50
+ * @version 1.2.4
51
+ *
52
+ * @param {Document} doc
53
+ */
54
+ Editor.setMethod(function setContextDocument(doc) {
55
+ let document_watcher = this.toolbar_manager.setDocument(doc);
56
+ this.toolbar_manager.setModel(doc.$model_name);
57
+ document_watcher.addWatcher(this.conduit);
42
58
  });
43
59
 
44
60
  /**
@@ -125,7 +141,7 @@ Editor.setAction(async function add(conduit, model_name) {
125
141
  *
126
142
  * @author Jelle De Loecker <jelle@elevenways.be>
127
143
  * @since 0.1.0
128
- * @version 1.2.3
144
+ * @version 1.2.4
129
145
  *
130
146
  * @param {Conduit} conduit
131
147
  * @param {String} model_name
@@ -185,6 +201,8 @@ Editor.setAction(async function edit(conduit, model_name, pk_val) {
185
201
  this.set('add_preview_button', true);
186
202
  }
187
203
 
204
+ this.setContextDocument(record);
205
+
188
206
  this.set('record_pk', record.$pk);
189
207
  this.set('model_name', model.model_name.toLowerCase());
190
208
  this.set('widget_config', widget_config);
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.3",
4
+ "version": "1.2.4",
5
5
  "author": "Jelle De Loecker <jelle@elevenways.be>",
6
6
  "keywords": [
7
7
  "alchemy",
@@ -0,0 +1,8 @@
1
+ <a
2
+ !Route="Chimera.Editor#add"
3
+ #model={% model_name %}
4
+ class="btn"
5
+ >
6
+ <al-icon icon-name="plus"></al-icon>
7
+ {%t "new" model=model_name %}
8
+ </a>
@@ -0,0 +1,10 @@
1
+ <a
2
+ !Route="Chimera.Editor#edit"
3
+ +model={% model_name %}
4
+ +pk={% record_pk %}
5
+ class="btn"
6
+ target="_blank"
7
+ >
8
+ <al-icon icon-name="pencil"></al-icon>
9
+ {%t "edit" model=model_name in="backend" %}
10
+ </a>
@@ -0,0 +1,10 @@
1
+ <a
2
+ !Route="Chimera.Editor#preview"
3
+ +model={% model_name %}
4
+ +pk={% record_pk %}
5
+ class="btn"
6
+ target="_blank"
7
+ >
8
+ <al-icon icon-name="eye"></al-icon>
9
+ {%t "preview" model=model_name %}
10
+ </a>
@@ -12,9 +12,39 @@
12
12
  </div>
13
13
  <div class="chimera-content">
14
14
  <div class="chimera-page-header">
15
- <div class="page-title" data-he-name="page-title"></div>
16
- <div class="page-notification" data-he-name="page-notification"></div>
17
- <div class="page-actions" data-he-name="page-actions"></div>
15
+ <div hidden>
16
+ <div class="page-title" data-he-name="page-title"></div>
17
+ <div class="page-notification" data-he-name="page-notification"></div>
18
+ <div class="page-actions" data-he-name="page-actions"></div>
19
+ </div>
20
+
21
+ <al-editor-toolbar
22
+ #toolbar_manager={% toolbar_manager %}
23
+ >
24
+ <div slot="left">
25
+ <div class="page-title">
26
+ <span data-toolbar="title"></span>
27
+ </div>
28
+ </div>
29
+
30
+ <div slot="center">
31
+ <al-user-avatar-group
32
+ class="watchers"
33
+ ></al-user-avatar-group>
34
+ </div>
35
+
36
+ <div slot="right">
37
+ <div data-area="buttons">
38
+
39
+ </div>
40
+ </div>
41
+ </al-editor-toolbar>
42
+
43
+ {#
44
+ <al-user-avatar
45
+ #user={% Acl.data %}
46
+ ></al-user-avatar>
47
+ #}
18
48
  </div>
19
49
  <div data-he-name="main" class="chimera-main">
20
50