alchemy-widget 0.2.1 → 0.2.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 CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.2.2 (2022-12-23)
2
+
3
+ * Fix widgets not being populated properly
4
+
1
5
  ## 0.2.1 (2022-12-23)
2
6
 
3
7
  * Add a `-first` modifier class to the first visible entry of a table-of-contents element
@@ -215,7 +215,7 @@ Widget.setMethod(function getValueFromRecord(record) {
215
215
  *
216
216
  * @author Jelle De Loecker <jelle@elevenways.be>
217
217
  * @since 0.1.5
218
- * @version 0.1.6
218
+ * @version 0.2.1
219
219
  */
220
220
  Widget.setMethod(function applyValue(value) {
221
221
 
@@ -255,7 +255,7 @@ Widget.setMethod(function applyValue(value) {
255
255
  }
256
256
 
257
257
  this.instance.config = config;
258
- let promise = this.instance.populateWidget();
258
+ let promise = this.instance.loadWidget();
259
259
 
260
260
  if (promise) {
261
261
  this.delayAssemble(promise);
@@ -627,7 +627,7 @@ Widget.setMethod(function _createWidgetElement() {
627
627
  *
628
628
  * @author Jelle De Loecker <jelle@elevenways.be>
629
629
  * @since 0.1.0
630
- * @version 0.1.0
630
+ * @version 0.2.2
631
631
  *
632
632
  * @return {HTMLElement}
633
633
  */
@@ -641,14 +641,41 @@ Widget.setMethod(function _createPopulatedWidgetElement() {
641
641
 
642
642
  this.widget = element;
643
643
 
644
- // See if it can be populated
645
- if (typeof this.populateWidget == 'function') {
646
- this.populateWidget(element);
647
- }
644
+ this.loadWidget();
648
645
 
649
646
  return element;
650
647
  });
651
648
 
649
+ /**
650
+ * Load the widget element: populate it & finalize it
651
+ *
652
+ * @author Jelle De Loecker <jelle@elevenways.be>
653
+ * @since 0.2.2
654
+ * @version 0.2.2
655
+ *
656
+ * @return {Promise|null}
657
+ */
658
+ Widget.setMethod(function loadWidget() {
659
+
660
+ let populate = this.populateWidget();
661
+
662
+ if (Pledge.isThenable(populate)) {
663
+ let pledge = new Pledge();
664
+
665
+ Pledge.done(populate, (err, result) => {
666
+
667
+ if (err) {
668
+ pledge.reject(err);
669
+ }
670
+
671
+ pledge.resolve(this.finalizePopulatedWidget());
672
+ });
673
+
674
+ return pledge;
675
+ } else {
676
+ return this.finalizePopulatedWidget();
677
+ }
678
+ });
652
679
 
653
680
  /**
654
681
  * Populate the actual widget
@@ -826,14 +853,13 @@ Widget.setMethod(function stopEditor() {
826
853
  *
827
854
  * @author Jelle De Loecker <jelle@elevenways.be>
828
855
  * @since 0.1.0
829
- * @version 0.2.1
856
+ * @version 0.2.2
830
857
  */
831
858
  Widget.setMethod(async function rerender() {
832
859
 
833
860
  Hawkejs.removeChildren(this.widget);
834
861
 
835
- await this.populateWidget();
836
- await this.finalizePopulatedWidget();
862
+ await this.loadWidget();
837
863
 
838
864
  if (this.editing) {
839
865
  this.startEditor();
@@ -38,12 +38,10 @@ Container.constitute(function prepareSchema() {
38
38
  *
39
39
  * @author Jelle De Loecker <jelle@elevenways.be>
40
40
  * @since 0.1.0
41
- * @version 0.1.0
42
- *
43
- * @return {HTMLElement}
41
+ * @version 0.2.2
44
42
  */
45
43
  Container.setMethod(function initContainer() {
46
- this.populateWidget();
44
+ return this.loadWidget();
47
45
  });
48
46
 
49
47
  /**
@@ -178,7 +178,7 @@ Tabs.setMethod(function _startEditor() {
178
178
  *
179
179
  * @author Jelle De Loecker <jelle@elevenways.be>
180
180
  * @since 0.2.0
181
- * @version 0.2.0
181
+ * @version 0.2.2
182
182
  */
183
183
  Tabs.setMethod(function _stopEditor() {
184
184
 
@@ -189,5 +189,5 @@ Tabs.setMethod(function _stopEditor() {
189
189
  sub_widget.stopEditor();
190
190
  }
191
191
 
192
- this.populateWidget();
192
+ this.loadWidget();
193
193
  });
@@ -74,14 +74,14 @@ Markdown.setMethod(async function _startEditor() {
74
74
  *
75
75
  * @author Jelle De Loecker <jelle@elevenways.be>
76
76
  * @since 0.1.0
77
- * @version 0.1.0
77
+ * @version 0.2.2
78
78
  */
79
79
  Markdown.setMethod(function _stopEditor() {
80
80
 
81
81
  Hawkejs.removeChildren(this.widget);
82
82
  this.easy_mde = null;
83
83
 
84
- this.populateWidget();
84
+ return this.loadWidget();
85
85
  });
86
86
 
87
87
  /**
@@ -161,7 +161,7 @@ Partial.setMethod(function _startEditor() {
161
161
  *
162
162
  * @author Jelle De Loecker <jelle@elevenways.be>
163
163
  * @since 0.1.6
164
- * @version 0.1.6
164
+ * @version 0.2.2
165
165
  */
166
166
  Partial.setMethod(function _stopEditor() {
167
167
 
@@ -172,7 +172,7 @@ Partial.setMethod(function _stopEditor() {
172
172
  sub_widget.stopEditor();
173
173
  }
174
174
 
175
- this.populateWidget();
175
+ return this.loadWidget();
176
176
  });
177
177
 
178
178
  /**
@@ -80,13 +80,13 @@ Sourcecode.setMethod(function _startEditor() {
80
80
  *
81
81
  * @author Jelle De Loecker <jelle@elevenways.be>
82
82
  * @since 0.1.0
83
- * @version 0.1.0
83
+ * @version 0.2.2
84
84
  */
85
85
  Sourcecode.setMethod(function _stopEditor() {
86
86
 
87
87
  Hawkejs.removeChildren(this.widget);
88
88
 
89
- this.populateWidget();
89
+ return this.loadWidget();
90
90
  });
91
91
 
92
92
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "alchemy-widget",
3
3
  "description": "The widget plugin for the AlchemyMVC",
4
- "version": "0.2.1",
4
+ "version": "0.2.2",
5
5
  "author": "Jelle De Loecker <jelle@elevenways.be>",
6
6
  "keywords": [
7
7
  "alchemy",