alchemy-form 0.1.12 → 0.2.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.
Files changed (89) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/assets/stylesheets/form/alchemy_form.scss +2 -16
  3. package/assets/stylesheets/form/elements/_button.scss +52 -0
  4. package/assets/stylesheets/form/{alchemy_code_input.scss → elements/_code_input.scss} +1 -1
  5. package/assets/stylesheets/form/{alchemy_feedback_input.scss → elements/_feedback_input.scss} +6 -8
  6. package/assets/stylesheets/form/{alchemy_field.scss → elements/_field.scss} +1 -1
  7. package/assets/stylesheets/form/{alchemy_field_array.scss → elements/_field_array.scss} +2 -2
  8. package/assets/stylesheets/form/{alchemy_field_translatable.scss → elements/_field_translatable.scss} +1 -1
  9. package/assets/stylesheets/form/elements/_form.scss +16 -0
  10. package/assets/stylesheets/form/{alchemy_pager.scss → elements/_pager.scss} +1 -1
  11. package/assets/stylesheets/form/{query_builder.scss → elements/_query_builder.scss} +14 -8
  12. package/assets/stylesheets/form/{alchemy_select.scss → elements/_select.scss} +2 -2
  13. package/assets/stylesheets/form/elements/_state.scss +8 -0
  14. package/assets/stylesheets/form/{alchemy_table.scss → elements/_table.scss} +2 -2
  15. package/assets/stylesheets/form/elements/_tabs.scss +47 -0
  16. package/assets/stylesheets/form/{alchemy_toggle.scss → elements/_toggle.scss} +1 -1
  17. package/assets/stylesheets/form/elements/index.scss +14 -0
  18. package/controller/form_api_controller.js +6 -2
  19. package/element/00_form_base.js +16 -8
  20. package/element/05_feedback_input.js +4 -13
  21. package/element/10_alchemy_field_custom.js +13 -15
  22. package/element/10_dataprovider.js +282 -0
  23. package/element/15_alchemy_field_entry.js +8 -10
  24. package/element/20_query_builder_base.js +4 -13
  25. package/element/25_query_builder_data.js +2 -2
  26. package/element/30_tab_base.js +29 -0
  27. package/element/40_stateful.js +125 -0
  28. package/element/al_button.js +147 -0
  29. package/element/{code_input.js → al_code_input.js} +1 -10
  30. package/element/{alchemy_field.js → al_field.js} +18 -25
  31. package/element/{alchemy_field_array.js → al_field_array.js} +7 -18
  32. package/element/{alchemy_field_array_entry.js → al_field_array_entry.js} +7 -9
  33. package/element/{alchemy_field_schema.js → al_field_schema.js} +3 -3
  34. package/element/{alchemy_field_translatable.js → al_field_translatable.js} +6 -17
  35. package/element/{alchemy_field_translatable_entry.js → al_field_translatable_entry.js} +2 -4
  36. package/element/{alchemy_form.js → al_form.js} +11 -18
  37. package/element/{alchemy_label.js → al_label.js} +1 -10
  38. package/element/{number_input.js → al_number_input.js} +2 -2
  39. package/element/{alchemy_pager.js → al_pager.js} +49 -41
  40. package/element/{alchemy_password_input.js → al_password_input.js} +0 -0
  41. package/element/{query_builder.js → al_query_builder.js} +3 -12
  42. package/element/{query_builder_entry.js → al_query_builder_entry.js} +52 -16
  43. package/element/{query_builder_group.js → al_query_builder_group.js} +7 -7
  44. package/element/{query_builder_value.js → al_query_builder_value.js} +16 -7
  45. package/element/{query_builder_variable.js → al_query_builder_variable.js} +1 -1
  46. package/element/{alchemy_select.js → al_select.js} +64 -118
  47. package/element/{alchemy_select_item.js → al_select_item.js} +15 -9
  48. package/element/al_state.js +26 -0
  49. package/element/{string_input.js → al_string_input.js} +2 -2
  50. package/element/al_tab_button.js +138 -0
  51. package/element/al_tab_context.js +102 -0
  52. package/element/al_tab_list.js +66 -0
  53. package/element/al_tab_panel.js +44 -0
  54. package/element/{alchemy_table.js → al_table.js} +187 -174
  55. package/element/{alchemy_toggle.js → al_toggle.js} +1 -10
  56. package/helper/form_actions/00_form_action.js +15 -4
  57. package/helper/form_actions/url_action.js +3 -2
  58. package/helper/query_builder_variable_definition/boolean_variable_definition.js +1 -1
  59. package/helper_field/query_builder_field.js +2 -2
  60. package/package.json +2 -2
  61. package/view/form/elements/alchemy_button.hwk +1 -0
  62. package/view/form/elements/alchemy_field.hwk +4 -4
  63. package/view/form/elements/alchemy_field_array.hwk +2 -2
  64. package/view/form/elements/alchemy_field_schema.hwk +2 -2
  65. package/view/form/elements/alchemy_field_translatable.hwk +2 -2
  66. package/view/form/elements/alchemy_field_translatable_entry.hwk +2 -2
  67. package/view/form/elements/query_builder.hwk +1 -1
  68. package/view/form/elements/query_builder_entry.hwk +20 -11
  69. package/view/form/elements/query_builder_value.hwk +2 -2
  70. package/view/form/elements/query_builder_variable.hwk +2 -2
  71. package/view/form/inputs/edit/belongs_to.hwk +2 -2
  72. package/view/form/inputs/edit/boolean.hwk +2 -2
  73. package/view/form/inputs/edit/enum.hwk +2 -2
  74. package/view/form/inputs/edit/has_and_belongs_to_many.hwk +2 -2
  75. package/view/form/inputs/edit/html.hwk +2 -2
  76. package/view/form/inputs/edit/query_builder.hwk +2 -2
  77. package/view/form/inputs/edit/query_builder_assignment.hwk +2 -2
  78. package/view/form/inputs/edit/query_builder_value.hwk +2 -2
  79. package/view/form/inputs/edit/query_builder_variable.hwk +2 -2
  80. package/view/form/inputs/edit/schema.hwk +2 -2
  81. package/view/form/inputs/edit/sourcecode.hwk +2 -2
  82. package/view/form/inputs/edit_inline/boolean.hwk +2 -2
  83. package/view/form/inputs/view/string.hwk +6 -1
  84. package/view/form/inputs/view_inline/datetime.hwk +8 -4
  85. package/view/form/inputs/view_inline/string.hwk +6 -1
  86. package/view/form/wrappers/default/default.hwk +2 -2
  87. package/helper/widgets/alchemy_field_widget.js +0 -112
  88. package/helper/widgets/alchemy_form_widget.js +0 -183
  89. package/helper/widgets/alchemy_table_widget.js +0 -67
@@ -165,14 +165,23 @@ QueryBuilderEntry.setMethod(async function loadData(config, element) {
165
165
  *
166
166
  * @author Jelle De Loecker <jelle@elevenways.be>
167
167
  * @since 0.1.6
168
- * @version 0.1.6
168
+ * @version 0.2.1
169
169
  */
170
170
  QueryBuilderEntry.setMethod(async function loadValueTypeData(config) {
171
171
 
172
172
  let items = [];
173
173
 
174
- items.push({id: 'variable', title: 'Other variable'});
175
- items.push({id: 'value', title: 'Value'});
174
+ items.push({
175
+ id: 'variable',
176
+ title: 'Variable',
177
+ description: 'Use the value of a variable',
178
+ });
179
+
180
+ items.push({
181
+ id: 'value',
182
+ title: 'Value',
183
+ description: 'Supply the value now',
184
+ });
176
185
 
177
186
  return items;
178
187
  });
@@ -231,12 +240,46 @@ QueryBuilderEntry.setMethod(async function loadVariableData(config) {
231
240
  return result;
232
241
  });
233
242
 
243
+ /**
244
+ * Get the field_select variable definition
245
+ *
246
+ * @author Jelle De Loecker <jelle@elevenways.be>
247
+ * @since 0.2.1
248
+ * @version 0.2.1
249
+ *
250
+ * @return {Promise<Object>}
251
+ */
252
+ QueryBuilderEntry.setMethod(async function getFieldSelectVariableDefinition(variable_name, attempt = 0) {
253
+
254
+ let variable_def = this.field_select.getValueData(variable_name);
255
+
256
+ if (variable_def) {
257
+ return variable_def;
258
+ }
259
+
260
+ await this.field_select.waitForTasks();
261
+ variable_def = this.field_select.getValueData(variable_name);
262
+
263
+ if (!variable_def) {
264
+ variable_def = await this.field_select.awaitValueData(variable_name);
265
+ }
266
+
267
+ if (!variable_def && attempt == 0) {
268
+ // There is an annoying race condition where one select gets valid data,
269
+ // but the other field doesn't. So in that case: wait a little bit and try agian.
270
+ await Pledge.after(250);
271
+ return this.getFieldSelectVariableDefinition(variable_name, 1);
272
+ }
273
+
274
+ return variable_def;
275
+ });
276
+
234
277
  /**
235
278
  * Load operator data
236
279
  *
237
280
  * @author Jelle De Loecker <jelle@elevenways.be>
238
281
  * @since 0.1.6
239
- * @version 0.1.6
282
+ * @version 0.2.1
240
283
  */
241
284
  QueryBuilderEntry.setMethod(async function loadOperatorData(config) {
242
285
 
@@ -246,12 +289,11 @@ QueryBuilderEntry.setMethod(async function loadOperatorData(config) {
246
289
  return;
247
290
  }
248
291
 
249
- let variable_def = this.field_select.getValueData(type);
292
+ let variable_def = await this.getFieldSelectVariableDefinition(type);
250
293
 
251
294
  let items = [];
252
295
 
253
296
  if (variable_def) {
254
-
255
297
  if (!this.type || this.type == 'logical') {
256
298
  items.include(variable_def.getLogicalOperators());
257
299
  } else if (this.type == 'assignment') {
@@ -267,7 +309,7 @@ QueryBuilderEntry.setMethod(async function loadOperatorData(config) {
267
309
  *
268
310
  * @author Jelle De Loecker <jelle@elevenways.be>
269
311
  * @since 0.1.6
270
- * @version 0.1.6
312
+ * @version 0.2.1
271
313
  */
272
314
  QueryBuilderEntry.setMethod(async function showValueInput() {
273
315
 
@@ -277,13 +319,7 @@ QueryBuilderEntry.setMethod(async function showValueInput() {
277
319
  return;
278
320
  }
279
321
 
280
- let entry = this.field_select.getValueData(variable_name);
281
-
282
- if (!entry) {
283
- await this.field_select.waitForTasks();
284
-
285
- entry = this.field_select.getValueData(variable_name);
286
- }
322
+ let entry = await this.getFieldSelectVariableDefinition(variable_name);
287
323
 
288
324
  if (!entry) {
289
325
  return;
@@ -335,7 +371,7 @@ QueryBuilderEntry.setMethod(async function applyValue(value) {
335
371
  *
336
372
  * @author Jelle De Loecker <jelle@elevenways.be>
337
373
  * @since 0.1.6
338
- * @version 0.1.6
374
+ * @version 0.2.0
339
375
  */
340
376
  QueryBuilderEntry.setMethod(async function applyValueTypeChanges() {
341
377
 
@@ -344,7 +380,7 @@ QueryBuilderEntry.setMethod(async function applyValueTypeChanges() {
344
380
  let type = this.value_type_select.value;
345
381
 
346
382
  if (type == 'variable') {
347
- let select = this.createElement('alchemy-select');
383
+ let select = this.createElement('al-select');
348
384
  select.value_item_template = 'form/select/qb_item';
349
385
  select.option_item_template = 'form/select/qb_item';
350
386
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The alchemy-toggle custom element
2
+ * The al-query-builder-group custom element
3
3
  *
4
4
  * @author Jelle De Loecker <jelle@elevenways.be>
5
5
  * @since 0.1.6
@@ -171,7 +171,7 @@ QueryBuilderGroup.setProperty(function value() {
171
171
  *
172
172
  * @author Jelle De Loecker <jelle@elevenways.be>
173
173
  * @since 0.1.6
174
- * @version 0.1.7
174
+ * @version 0.2.0
175
175
  */
176
176
  QueryBuilderGroup.setMethod(function applyValue(value) {
177
177
 
@@ -198,9 +198,9 @@ QueryBuilderGroup.setMethod(function applyValue(value) {
198
198
 
199
199
  for (rule of value.rules) {
200
200
  if (rule.type == 'qb_entry') {
201
- element = this.createElement('alchemy-query-builder-entry');
201
+ element = this.createElement('al-query-builder-entry');
202
202
  } else {
203
- element = this.createElement('alchemy-query-builder-group');
203
+ element = this.createElement('al-query-builder-group');
204
204
  }
205
205
 
206
206
  element.assigned_data.value = rule;
@@ -214,7 +214,7 @@ QueryBuilderGroup.setMethod(function applyValue(value) {
214
214
  *
215
215
  * @author Jelle De Loecker <jelle@elevenways.be>
216
216
  * @since 0.1.6
217
- * @version 0.1.7
217
+ * @version 0.2.0
218
218
  */
219
219
  QueryBuilderGroup.setMethod(function introduced() {
220
220
 
@@ -225,14 +225,14 @@ QueryBuilderGroup.setMethod(function introduced() {
225
225
  add_rule.addEventListener('click', e => {
226
226
  e.preventDefault();
227
227
 
228
- let new_rule = this.createElement('alchemy-query-builder-entry');
228
+ let new_rule = this.createElement('al-query-builder-entry');
229
229
  this.rules_list.append(new_rule);
230
230
  });
231
231
 
232
232
  add_group.addEventListener('click', e => {
233
233
  e.preventDefault();
234
234
 
235
- let new_group = this.createElement('alchemy-query-builder-group');
235
+ let new_group = this.createElement('al-query-builder-group');
236
236
  this.rules_list.append(new_group);
237
237
  });
238
238
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The alchemy-query-builder-value custom element
2
+ * The al-query-builder-value custom element
3
3
  *
4
4
  * @author Jelle De Loecker <jelle@elevenways.be>
5
5
  * @since 0.1.6
@@ -80,7 +80,7 @@ QueryBuilderValue.addElementGetter('value_input_wrapper', '.qb-value-input-wrapp
80
80
  *
81
81
  * @author Jelle De Loecker <jelle@elevenways.be>
82
82
  * @since 0.1.6
83
- * @version 0.1.6
83
+ * @version 0.2.1
84
84
  */
85
85
  QueryBuilderValue.setProperty(function value() {
86
86
 
@@ -105,7 +105,7 @@ QueryBuilderValue.setProperty(function value() {
105
105
  if (input) {
106
106
 
107
107
  let value_explicit = {
108
- type : this.getValueType(input),
108
+ type : this.getValueType(input) || 'unknown_value_type',
109
109
  value : null,
110
110
  }
111
111
 
@@ -129,14 +129,23 @@ QueryBuilderValue.setProperty(function value() {
129
129
  *
130
130
  * @author Jelle De Loecker <jelle@elevenways.be>
131
131
  * @since 0.1.6
132
- * @version 0.1.6
132
+ * @version 0.2.1
133
133
  */
134
134
  QueryBuilderValue.setMethod(async function loadSourceTypeData(config) {
135
135
 
136
136
  let items = [];
137
137
 
138
- items.push({id: 'variable', title: 'Variable'});
139
- items.push({id: 'value', title: 'Value'});
138
+ items.push({
139
+ id: 'variable',
140
+ title: 'Variable',
141
+ description: 'Use the value of a variable',
142
+ });
143
+
144
+ items.push({
145
+ id: 'value',
146
+ title: 'Value',
147
+ description: 'Supply the value now',
148
+ });
140
149
 
141
150
  return items;
142
151
  });
@@ -186,7 +195,7 @@ QueryBuilderValue.setMethod(async function applySourceTypeChanges() {
186
195
  let type = this.source_type_select.value;
187
196
 
188
197
  if (type == 'variable') {
189
- let select = this.createElement('alchemy-select');
198
+ let select = this.createElement('al-select');
190
199
  select.dataprovider = this;
191
200
  select.classList.add('qb-value-variable');
192
201
  this.value_input_wrapper.append(select);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The alchemy-query-builder-value custom element
2
+ * The al-query-builder-value custom element
3
3
  *
4
4
  * @author Jelle De Loecker <jelle@elevenways.be>
5
5
  * @since 0.1.7
@@ -1,20 +1,11 @@
1
1
  /**
2
- * The alchemy-select element
2
+ * The al-select element
3
3
  *
4
4
  * @author Jelle De Loecker <jelle@develry.be>
5
5
  * @since 0.1.0
6
6
  * @version 0.1.0
7
7
  */
8
- const AlchemySelect = Function.inherits('Alchemy.Element.Form.Base', 'Select');
9
-
10
- /**
11
- * The remote url attribute
12
- *
13
- * @author Jelle De Loecker <jelle@develry.be>
14
- * @since 0.1.0
15
- * @version 0.1.0
16
- */
17
- AlchemySelect.setAttribute('src');
8
+ const AlchemySelect = Function.inherits('Alchemy.Element.Form.WithDataprovider', 'Select');
18
9
 
19
10
  /**
20
11
  * The value clear count
@@ -63,15 +54,6 @@ AlchemySelect.setAttribute('option-item-template');
63
54
  */
64
55
  AlchemySelect.setTemplateFile('form/elements/alchemy_select');
65
56
 
66
- /**
67
- * The stylesheet to load for this element
68
- *
69
- * @author Jelle De Loecker <jelle@develry.be>
70
- * @since 0.1.0
71
- * @version 0.1.0
72
- */
73
- AlchemySelect.setStylesheetFile('form/alchemy_select');
74
-
75
57
  /**
76
58
  * Getter for the value-wrapper div
77
59
  *
@@ -135,16 +117,6 @@ AlchemySelect.addElementGetter('result_info', '.result-info');
135
117
  */
136
118
  AlchemySelect.setAssignedProperty('sortable');
137
119
 
138
- /**
139
- * The dataprovider is an instance of something that will load
140
- * the remote data for this element
141
- *
142
- * @author Jelle De Loecker <jelle@elevenways.be>
143
- * @since 0.1.0
144
- * @version 0.1.0
145
- */
146
- AlchemySelect.setAssignedProperty('dataprovider');
147
-
148
120
  /**
149
121
  * The value property
150
122
  *
@@ -165,7 +137,11 @@ AlchemySelect.setAssignedProperty('value', function getValue(value) {
165
137
  });
166
138
 
167
139
  /**
168
- * The options property (will be stored in assigned_data)
140
+ * The options property:
141
+ * this contains configuration options of this element.
142
+ *
143
+ * It does NOT contain things to select from.
144
+ * Use `values` for that instead!
169
145
  *
170
146
  * @author Jelle De Loecker <jelle@develry.be>
171
147
  * @since 0.1.0
@@ -268,7 +244,7 @@ AlchemySelect.setProperty(function loaded_items() {
268
244
  */
269
245
  AlchemySelect.setProperty(function loaded_item_count() {
270
246
  if (this.options.values) {
271
- return this.options.values.size;
247
+ return this.options.values.size || 0;
272
248
  } else {
273
249
  return 0;
274
250
  }
@@ -495,7 +471,7 @@ AlchemySelect.setMethod(function introduced() {
495
471
 
496
472
  this.addEventListener('keydown', function onKeydown(e) {
497
473
 
498
- // Only listen for keydowns on the alchemy-select itself
474
+ // Only listen for keydowns on the al-select itself
499
475
  if (e.target != that) {
500
476
  return;
501
477
  }
@@ -774,12 +750,28 @@ AlchemySelect.setMethod(function getValueData(value) {
774
750
  return data;
775
751
  });
776
752
 
753
+ /**
754
+ * Get the data for a specific value,
755
+ * but make sure it's loaded
756
+ *
757
+ * @author Jelle De Loecker <jelle@develry.be>
758
+ * @since 0.2.1
759
+ * @version 0.2.1
760
+ *
761
+ * @param {*} value
762
+ *
763
+ * @return {Pledge<Object>}
764
+ */
765
+ AlchemySelect.setMethod(function awaitValueData(value) {
766
+ return this._ensureValueData(value);
767
+ });
768
+
777
769
  /**
778
770
  * Ensure the data for the given value is loaded
779
771
  *
780
772
  * @author Jelle De Loecker <jelle@develry.be>
781
773
  * @since 0.1.0
782
- * @version 0.1.0
774
+ * @version 0.2.0
783
775
  *
784
776
  * @param {Number} page
785
777
  *
@@ -802,7 +794,7 @@ AlchemySelect.setMethod(function _ensureValueData(value) {
802
794
 
803
795
  this.delayAssemble(pledge);
804
796
 
805
- this._loadRemote({value: value}).done(function gotValueData(err, result) {
797
+ this.fetchRemoteData({value: value}).done(function gotValueData(err, result) {
806
798
 
807
799
  if (err) {
808
800
  return pledge.reject(err);
@@ -821,7 +813,7 @@ AlchemySelect.setMethod(function _ensureValueData(value) {
821
813
  *
822
814
  * @author Jelle De Loecker <jelle@develry.be>
823
815
  * @since 0.1.0
824
- * @version 0.1.4
816
+ * @version 0.2.1
825
817
  */
826
818
  AlchemySelect.setMethod(function _processPreloadedValues() {
827
819
 
@@ -836,12 +828,14 @@ AlchemySelect.setMethod(function _processPreloadedValues() {
836
828
  items : [],
837
829
  };
838
830
 
839
- let item,
840
- key;
831
+ let item;
841
832
 
842
833
  let enum_values = new Classes.Alchemy.Map.Enum(values),
843
834
  value;
844
835
 
836
+ // Make sure to use this new enum instance from now on
837
+ this.options.values = enum_values;
838
+
845
839
  for (let key of enum_values.keys()) {
846
840
  value = enum_values.get(key);
847
841
 
@@ -875,9 +869,7 @@ AlchemySelect.setMethod(function _processResponseData(response, page) {
875
869
  this.total_item_count = response.available;
876
870
  }
877
871
 
878
- let records = response.items || response.records,
879
- record,
880
- item;
872
+ let records = response.items || response.records;
881
873
 
882
874
  if (!records) {
883
875
  records = [];
@@ -928,93 +920,49 @@ AlchemySelect.setMethod(function _processResponseList(list, page) {
928
920
  });
929
921
 
930
922
  /**
931
- * Load remote content
932
- *
933
- * @author Jelle De Loecker <jelle@develry.be>
934
- * @since 0.1.0
935
- * @version 0.1.8
936
- *
937
- * @param {Number} page
923
+ * Construct the config object used to fetch data
938
924
  *
939
- * @return {Pledge}
925
+ * @author Jelle De Loecker <jelle@elevenways.be>
926
+ * @since 0.2.0
927
+ * @version 0.2.0
940
928
  */
941
- AlchemySelect.setMethod(function loadRemote(page) {
942
-
943
- let pledge = new Classes.Pledge();
929
+ AlchemySelect.setMethod(function getRemoteFetchConfig() {
944
930
 
945
931
  // Don't perform request when everything has already been loaded
946
932
  if (this.total_item_count >= this.loaded_item_count) {
947
- pledge.resolve(true);
948
933
  return;
949
934
  }
950
935
 
951
- if (!this.src && !this.dataprovider) {
952
- pledge.resolve(false);
953
- return pledge;
954
- }
955
-
956
- if (page == null) {
957
- page = 1;
958
- }
959
-
960
- const that = this;
961
-
962
- this.loading_dropdown = true;
963
-
964
- let data = {
936
+ let config = {
965
937
  search : this.search_value,
966
- page : page
967
- };
968
-
969
- this._loadRemote(data).done(gotResponse);
970
-
971
- function gotResponse(err, data) {
972
-
973
- if (err) {
974
- that.loading_dropdown = false;
975
- pledge.resolve(false);
976
- throw err;
977
- }
978
-
979
- if (page == null || page == 1) {
980
- Hawkejs.removeChildren(that.dropdown_content);
981
- }
982
-
983
- that._processResponseData(data, page);
984
-
985
- pledge.resolve(true);
938
+ page : this.page || 1,
986
939
  };
987
940
 
988
- return pledge;
941
+ return config;
989
942
  });
990
943
 
944
+
991
945
  /**
992
- * Load remote content
993
- *
994
- * @author Jelle De Loecker <jelle@develry.be>
995
- * @since 0.1.0
996
- * @version 0.1.0
997
- *
998
- * @param {Object) config
946
+ * Apply the fetched data
999
947
  *
1000
- * @return {Pledge}
948
+ * @author Jelle De Loecker <jelle@elevenways.be>
949
+ * @since 0.2.0
950
+ * @version 0.2.0
1001
951
  */
1002
- AlchemySelect.setMethod(function _loadRemote(config) {
952
+ AlchemySelect.setMethod(function applyFetchedData(err, result, config) {
1003
953
 
1004
- let pledge;
954
+ if (err) {
955
+ this.loading_dropdown = false;
956
+ return;
957
+ }
1005
958
 
1006
- if (this.dataprovider) {
1007
- pledge = Blast.Classes.Pledge.cast(this.dataprovider.loadData(config, this));
1008
- } else {
1009
- let url = this.src;
959
+ let page = config.page;
1010
960
 
1011
- pledge = this.hawkejs_helpers.Alchemy.getResource({
1012
- href : url,
1013
- get : config
1014
- });
961
+ if (page == null || page == 1) {
962
+ Hawkejs.removeChildren(this.dropdown_content);
1015
963
  }
1016
964
 
1017
- return pledge;
965
+ this._processResponseData(result, page);
1018
966
  });
1019
967
 
1020
968
  /**
@@ -1027,8 +975,7 @@ AlchemySelect.setMethod(function _loadRemote(config) {
1027
975
  AlchemySelect.setMethod(function recreateDropdownElements() {
1028
976
 
1029
977
  let items = this.loaded_items,
1030
- item,
1031
- key;
978
+ item;
1032
979
 
1033
980
  Hawkejs.removeChildren(this.dropdown_content);
1034
981
 
@@ -1091,7 +1038,7 @@ AlchemySelect.setMethod(function setLastSuccessfulLoadedPage(page) {
1091
1038
  *
1092
1039
  * @author Jelle De Loecker <jelle@develry.be>
1093
1040
  * @since 0.1.0
1094
- * @version 0.1.8
1041
+ * @version 0.2.0
1095
1042
  *
1096
1043
  * @param {Number} page
1097
1044
  */
@@ -1131,9 +1078,8 @@ AlchemySelect.setMethod(function loadOptions(page) {
1131
1078
  return;
1132
1079
  }
1133
1080
 
1134
- // If an URL is provided, use that
1135
- if (this.src || this.dataprovider) {
1136
- return this.loadRemote(page);
1081
+ if (this.can_fetch_remote_data) {
1082
+ return this.loadRemoteData({page});
1137
1083
  }
1138
1084
 
1139
1085
  let field = this.model_field;
@@ -1291,7 +1237,7 @@ AlchemySelect.setMethod(function close(event) {
1291
1237
  *
1292
1238
  * @author Jelle De Loecker <jelle@develry.be>
1293
1239
  * @since 0.1.0
1294
- * @version 0.1.6
1240
+ * @version 0.2.0
1295
1241
  *
1296
1242
  * @param {String} type "value" or "option"
1297
1243
  * @param {Mixed} value The actual value of this item
@@ -1301,7 +1247,7 @@ AlchemySelect.setMethod(function close(event) {
1301
1247
  */
1302
1248
  AlchemySelect.setMethod(function _makeValueItem(type, value, data) {
1303
1249
 
1304
- let item = this.createElement('alchemy-select-item');
1250
+ let item = this.createElement('al-select-item');
1305
1251
 
1306
1252
  // Set the type ("value" or "option")
1307
1253
  item.type = type;
@@ -1350,7 +1296,7 @@ AlchemySelect.setMethod(function _makeValueItem(type, value, data) {
1350
1296
  item.prepareRenderVariables = async function() {
1351
1297
 
1352
1298
  try {
1353
- await that.loadRemote();
1299
+ await that.loadRemoteData();
1354
1300
  } catch (err) {
1355
1301
  return
1356
1302
  }
@@ -1796,11 +1742,11 @@ AlchemySelect.setMethod(function applyLocalFilter(query) {
1796
1742
  *
1797
1743
  * @author Jelle De Loecker <jelle@develry.be>
1798
1744
  * @since 0.1.0
1799
- * @version 0.1.8
1745
+ * @version 0.2.0
1800
1746
  */
1801
1747
  AlchemySelect.setMethod('refreshRemote', Fn.throttle(function refreshRemote() {
1802
1748
  this.loaded_page = 0;
1803
- this.loadRemote();
1749
+ this.loadRemoteData();
1804
1750
  }, {
1805
1751
  minimum_wait : 350,
1806
1752
  immediate : false,
@@ -1,14 +1,11 @@
1
1
  /**
2
- * The alchemy-select-item element
2
+ * The al-select-item element
3
3
  *
4
4
  * @author Jelle De Loecker <jelle@elevenways.be>
5
5
  * @since 0.1.0
6
- * @version 0.1.0
6
+ * @version 0.2.0
7
7
  */
8
- const Item = Function.inherits('Alchemy.Element.Form.Base', function SelectItem() {
9
- SelectItem.super.call(this);
10
- this.setAttribute('tabindex', '-1');
11
- });
8
+ const Item = Function.inherits('Alchemy.Element.Form.Base', 'SelectItem');
12
9
 
13
10
  /**
14
11
  * Set the default inner template
@@ -28,6 +25,15 @@ Item.setTemplateFile('form/elements/alchemy_select_item');
28
25
  */
29
26
  Item.setAttribute('type');
30
27
 
28
+ /**
29
+ * The type of this item: "value" or "option"
30
+ *
31
+ * @author Jelle De Loecker <jelle@elevenways.be>
32
+ * @since 0.2.0
33
+ * @version 0.2.0
34
+ */
35
+ Item.setAttribute('tabindex', {default: -1});
36
+
31
37
  /**
32
38
  * Is this item selected?
33
39
  *
@@ -65,16 +71,16 @@ Item.setAssignedProperty('value');
65
71
  Item.setAssignedProperty('data');
66
72
 
67
73
  /**
68
- * The parent alchemy-select item
74
+ * The parent al-select item
69
75
  *
70
76
  * @author Jelle De Loecker <jelle@elevenways.be>
71
77
  * @since 0.1.5
72
- * @version 0.1.5
78
+ * @version 0.2.0
73
79
  */
74
80
  Item.enforceProperty(function alchemy_select(new_value) {
75
81
 
76
82
  if (new_value == null) {
77
- new_value = this.closest('alchemy-select');
83
+ new_value = this.closest('al-select');
78
84
  }
79
85
 
80
86
  return new_value;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The al-state element
3
+ *
4
+ * @author Jelle De Loecker <jelle@elevenways.be>
5
+ * @since 0.2.0
6
+ * @version 0.2.0
7
+ */
8
+ const State = Function.inherits('Alchemy.Element.Form.Stateful', 'State');
9
+
10
+ /**
11
+ * The name of the state this element represents
12
+ *
13
+ * @author Jelle De Loecker <jelle@elevenways.be>
14
+ * @since 0.2.0
15
+ * @version 0.2.0
16
+ */
17
+ State.setAttribute('state-name');
18
+
19
+ /**
20
+ * Is this state active?
21
+ *
22
+ * @author Jelle De Loecker <jelle@elevenways.be>
23
+ * @since 0.2.0
24
+ * @version 0.2.0
25
+ */
26
+ State.setAttribute('active', {boolean: true});
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The alchemy-string-input custom element
2
+ * The al-string-input custom element
3
3
  *
4
4
  * @author Jelle De Loecker <jelle@elevenways.be>
5
5
  * @since 0.1.0
@@ -306,7 +306,7 @@ StringInput.setMethod(async function revalidate(trigger, force) {
306
306
  * @since 0.1.3
307
307
  * @version 0.1.3
308
308
  */
309
- StringInput.setMethod(function introduced() {
309
+ StringInput.setMethod(function introduced() {
310
310
 
311
311
  const that = this,
312
312
  input = this.input_el;