alchemy-form 0.1.11 → 0.2.0
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 +29 -0
- package/assets/stylesheets/form/alchemy_form.scss +2 -16
- package/assets/stylesheets/form/elements/_button.scss +52 -0
- package/assets/stylesheets/form/{alchemy_code_input.scss → elements/_code_input.scss} +1 -1
- package/assets/stylesheets/form/{alchemy_feedback_input.scss → elements/_feedback_input.scss} +6 -8
- package/assets/stylesheets/form/{alchemy_field.scss → elements/_field.scss} +1 -1
- package/assets/stylesheets/form/{alchemy_field_array.scss → elements/_field_array.scss} +2 -2
- package/assets/stylesheets/form/{alchemy_field_translatable.scss → elements/_field_translatable.scss} +1 -1
- package/assets/stylesheets/form/elements/_form.scss +16 -0
- package/assets/stylesheets/form/{alchemy_pager.scss → elements/_pager.scss} +1 -1
- package/assets/stylesheets/form/{query_builder.scss → elements/_query_builder.scss} +7 -7
- package/assets/stylesheets/form/{alchemy_select.scss → elements/_select.scss} +2 -2
- package/assets/stylesheets/form/elements/_state.scss +8 -0
- package/assets/stylesheets/form/{alchemy_table.scss → elements/_table.scss} +2 -2
- package/assets/stylesheets/form/elements/_tabs.scss +47 -0
- package/assets/stylesheets/form/{alchemy_toggle.scss → elements/_toggle.scss} +1 -1
- package/assets/stylesheets/form/elements/index.scss +14 -0
- package/controller/form_api_controller.js +0 -1
- package/element/00_form_base.js +16 -8
- package/element/05_feedback_input.js +4 -13
- package/element/10_alchemy_field_custom.js +13 -15
- package/element/10_dataprovider.js +282 -0
- package/element/15_alchemy_field_entry.js +8 -10
- package/element/20_query_builder_base.js +4 -13
- package/element/25_query_builder_data.js +2 -2
- package/element/30_tab_base.js +29 -0
- package/element/40_stateful.js +125 -0
- package/element/al_button.js +109 -0
- package/element/{code_input.js → al_code_input.js} +1 -10
- package/element/{alchemy_field.js → al_field.js} +82 -41
- package/element/{alchemy_field_array.js → al_field_array.js} +7 -18
- package/element/{alchemy_field_array_entry.js → al_field_array_entry.js} +7 -9
- package/element/{alchemy_field_schema.js → al_field_schema.js} +23 -11
- package/element/{alchemy_field_translatable.js → al_field_translatable.js} +6 -17
- package/element/{alchemy_field_translatable_entry.js → al_field_translatable_entry.js} +2 -4
- package/element/{alchemy_form.js → al_form.js} +7 -16
- package/element/{alchemy_label.js → al_label.js} +1 -10
- package/element/{number_input.js → al_number_input.js} +2 -2
- package/element/{alchemy_pager.js → al_pager.js} +49 -41
- package/element/{alchemy_password_input.js → al_password_input.js} +0 -0
- package/element/{query_builder.js → al_query_builder.js} +3 -12
- package/element/{query_builder_entry.js → al_query_builder_entry.js} +8 -7
- package/element/{query_builder_group.js → al_query_builder_group.js} +7 -7
- package/element/{query_builder_value.js → al_query_builder_value.js} +2 -2
- package/element/{query_builder_variable.js → al_query_builder_variable.js} +1 -1
- package/element/{alchemy_select.js → al_select.js} +35 -108
- package/element/{alchemy_select_item.js → al_select_item.js} +33 -13
- package/element/al_state.js +26 -0
- package/element/{string_input.js → al_string_input.js} +2 -2
- package/element/al_tab_button.js +138 -0
- package/element/al_tab_context.js +102 -0
- package/element/al_tab_list.js +66 -0
- package/element/al_tab_panel.js +44 -0
- package/element/{alchemy_table.js → al_table.js} +204 -185
- package/element/{alchemy_toggle.js → al_toggle.js} +1 -10
- package/helper/form_actions/00_form_action.js +15 -4
- package/helper/form_actions/url_action.js +3 -2
- package/helper/query_builder_ns.js +108 -0
- package/helper/query_builder_variable_definition/00_variable_definition.js +52 -1
- package/helper/query_builder_variable_definition/boolean_variable_definition.js +1 -1
- package/helper_field/query_builder_field.js +49 -28
- package/helper_field/query_builder_value.js +0 -45
- package/helper_field/query_builder_variable.js +0 -45
- package/package.json +2 -2
- package/view/form/elements/alchemy_button.hwk +1 -0
- package/view/form/elements/alchemy_field.hwk +4 -4
- package/view/form/elements/alchemy_field_array.hwk +2 -2
- package/view/form/elements/alchemy_field_schema.hwk +2 -2
- package/view/form/elements/alchemy_field_translatable.hwk +2 -2
- package/view/form/elements/alchemy_field_translatable_entry.hwk +2 -2
- package/view/form/elements/alchemy_select_item.hwk +1 -3
- package/view/form/elements/query_builder.hwk +1 -1
- package/view/form/elements/query_builder_entry.hwk +6 -6
- package/view/form/elements/query_builder_value.hwk +2 -2
- package/view/form/elements/query_builder_variable.hwk +2 -2
- package/view/form/inputs/edit/belongs_to.hwk +2 -2
- package/view/form/inputs/edit/boolean.hwk +2 -2
- package/view/form/inputs/edit/enum.hwk +2 -2
- package/view/form/inputs/edit/has_and_belongs_to_many.hwk +2 -2
- package/view/form/inputs/edit/html.hwk +2 -2
- package/view/form/inputs/edit/query_builder.hwk +2 -2
- package/view/form/inputs/edit/query_builder_assignment.hwk +2 -2
- package/view/form/inputs/edit/query_builder_value.hwk +2 -2
- package/view/form/inputs/edit/query_builder_variable.hwk +2 -2
- package/view/form/inputs/edit/schema.hwk +2 -2
- package/view/form/inputs/edit/sourcecode.hwk +2 -2
- package/view/form/inputs/edit_inline/boolean.hwk +2 -2
- package/view/form/inputs/view/string.hwk +6 -1
- package/view/form/inputs/view_inline/datetime.hwk +8 -4
- package/view/form/inputs/view_inline/enum.hwk +1 -0
- package/view/form/inputs/view_inline/string.hwk +6 -1
- package/view/form/select/qb_item.hwk +1 -0
- package/view/form/wrappers/default/default.hwk +2 -2
- package/helper/widgets/alchemy_field_widget.js +0 -137
- package/helper/widgets/alchemy_form_widget.js +0 -169
- package/helper/widgets/alchemy_table_widget.js +0 -53
- package/view/form/inputs/view_inline/file.hwk +0 -6
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
const OLD_ROWS = Symbol('old_rows');
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
* The
|
|
4
|
+
* The al-table element
|
|
3
5
|
*
|
|
4
6
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
5
7
|
* @since 0.1.0
|
|
6
8
|
* @version 0.1.0
|
|
7
9
|
*/
|
|
8
|
-
const Table = Function.inherits('Alchemy.Element.Form.
|
|
10
|
+
const Table = Function.inherits('Alchemy.Element.Form.WithDataprovider', 'Table');
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* The template code
|
|
@@ -27,15 +29,6 @@ Table.setTemplate(`<header class="aft-header"></header>
|
|
|
27
29
|
</div>
|
|
28
30
|
<footer data-he-slot="footer" class="aft-footer"></footer>`, {plain_html: true, render_immediate: true});
|
|
29
31
|
|
|
30
|
-
/**
|
|
31
|
-
* The stylesheet to load for this element
|
|
32
|
-
*
|
|
33
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
34
|
-
* @since 0.1.0
|
|
35
|
-
* @version 0.1.0
|
|
36
|
-
*/
|
|
37
|
-
Table.setStylesheetFile('form/alchemy_table');
|
|
38
|
-
|
|
39
32
|
/**
|
|
40
33
|
* Getter for the header element
|
|
41
34
|
*
|
|
@@ -100,31 +93,22 @@ Table.addElementGetter('column_names_row', 'tr.aft-column-names');
|
|
|
100
93
|
Table.addElementGetter('column_filters_row', 'tr.aft-column-filters');
|
|
101
94
|
|
|
102
95
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
106
|
-
* @since 0.1.0
|
|
107
|
-
* @version 0.1.0
|
|
108
|
-
*/
|
|
109
|
-
Table.setAttribute('page', {number: true});
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* The page-size attribute
|
|
96
|
+
* Should filters be shown?
|
|
113
97
|
*
|
|
114
98
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
115
99
|
* @since 0.1.0
|
|
116
100
|
* @version 0.1.0
|
|
117
101
|
*/
|
|
118
|
-
Table.setAttribute('
|
|
102
|
+
Table.setAttribute('show-filters', {boolean: true});
|
|
119
103
|
|
|
120
104
|
/**
|
|
121
|
-
* Should
|
|
105
|
+
* Should the url be used for pagination?
|
|
122
106
|
*
|
|
123
107
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
124
|
-
* @since 0.
|
|
125
|
-
* @version 0.
|
|
108
|
+
* @since 0.2.0
|
|
109
|
+
* @version 0.2.0
|
|
126
110
|
*/
|
|
127
|
-
Table.setAttribute('
|
|
111
|
+
Table.setAttribute('use-url-pagination', {boolean: true});
|
|
128
112
|
|
|
129
113
|
/**
|
|
130
114
|
* Which optional view-type to use for field values
|
|
@@ -136,13 +120,13 @@ Table.setAttribute('show-filters', {boolean: true});
|
|
|
136
120
|
Table.setAttribute('view-type');
|
|
137
121
|
|
|
138
122
|
/**
|
|
139
|
-
*
|
|
123
|
+
* Should existing rows be re-used when new data is loaded?
|
|
140
124
|
*
|
|
141
|
-
* @author Jelle De Loecker
|
|
142
|
-
* @since 0.
|
|
143
|
-
* @version 0.
|
|
125
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
126
|
+
* @since 0.2.0
|
|
127
|
+
* @version 0.2.0
|
|
144
128
|
*/
|
|
145
|
-
Table.
|
|
129
|
+
Table.setAttribute('update-existing-rows', {boolean: true});
|
|
146
130
|
|
|
147
131
|
/**
|
|
148
132
|
* Look for changes to the show-filters attribute
|
|
@@ -251,76 +235,15 @@ Table.setAssignedProperty('records');
|
|
|
251
235
|
Table.setAssignedProperty('filters');
|
|
252
236
|
|
|
253
237
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
257
|
-
* @since 0.1.0
|
|
258
|
-
* @version 0.1.0
|
|
259
|
-
*/
|
|
260
|
-
Table.setAssignedProperty('recordsource', null, function onRecordsource(value) {
|
|
261
|
-
this.setRecordsource(value);
|
|
262
|
-
return value;
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Look for a new src value
|
|
267
|
-
*
|
|
268
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
269
|
-
* @since 0.1.0
|
|
270
|
-
* @version 0.1.0
|
|
271
|
-
*/
|
|
272
|
-
Table.enforceProperty(function src(new_value, old_value) {
|
|
273
|
-
|
|
274
|
-
if (new_value == old_value) {
|
|
275
|
-
return new_value;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
this.setAttributeSilent('src', new_value);
|
|
279
|
-
|
|
280
|
-
return new_value;
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Look for a new src value
|
|
238
|
+
* Get the active row
|
|
285
239
|
*
|
|
286
240
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
287
|
-
* @since 0.
|
|
288
|
-
* @version 0.
|
|
241
|
+
* @since 0.2.0
|
|
242
|
+
* @version 0.2.0
|
|
289
243
|
*/
|
|
290
|
-
Table.
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Clear the header elements
|
|
296
|
-
*
|
|
297
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
298
|
-
* @since 0.1.0
|
|
299
|
-
* @version 0.1.11
|
|
300
|
-
*
|
|
301
|
-
* @param {*} config
|
|
302
|
-
*/
|
|
303
|
-
Table.setMethod(function setRecordsource(config) {
|
|
304
|
-
|
|
305
|
-
let url;
|
|
306
|
-
|
|
307
|
-
if (typeof config == 'object') {
|
|
308
|
-
url = alchemy.routeUrl(config.route, config.parameters);
|
|
309
|
-
} else {
|
|
310
|
-
url = config;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
if (url == '#') {
|
|
314
|
-
let current_url = this.getCurrentUrl();
|
|
315
|
-
|
|
316
|
-
if (current_url) {
|
|
317
|
-
url = ''+current_url;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
this.src = url;
|
|
322
|
-
|
|
323
|
-
this.loadRemoteData();
|
|
244
|
+
Table.setProperty(function active_row() {
|
|
245
|
+
let result = this.queryAllNotNested('tr.aft-selected');
|
|
246
|
+
return result[0];
|
|
324
247
|
});
|
|
325
248
|
|
|
326
249
|
/**
|
|
@@ -358,6 +281,35 @@ Table.setMethod(function clearBody() {
|
|
|
358
281
|
Hawkejs.removeChildren(this.table_body);
|
|
359
282
|
});
|
|
360
283
|
|
|
284
|
+
/**
|
|
285
|
+
* Get the current rows by their pk
|
|
286
|
+
*
|
|
287
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
288
|
+
* @since 0.2.0
|
|
289
|
+
* @version 0.2.0
|
|
290
|
+
*
|
|
291
|
+
* @return {Object<string,HTMLTableRowElement>}
|
|
292
|
+
*/
|
|
293
|
+
Table.setMethod(function getTableRowsByPk() {
|
|
294
|
+
|
|
295
|
+
let result = {},
|
|
296
|
+
rows = this.table_body.queryAllNotNested('tr[data-pk]'),
|
|
297
|
+
row,
|
|
298
|
+
pk,
|
|
299
|
+
i;
|
|
300
|
+
|
|
301
|
+
for (i = 0; i < rows.length; i++) {
|
|
302
|
+
row = rows[i];
|
|
303
|
+
pk = row.dataset.pk;
|
|
304
|
+
|
|
305
|
+
if (pk) {
|
|
306
|
+
result[pk] = row;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return result;
|
|
311
|
+
});
|
|
312
|
+
|
|
361
313
|
/**
|
|
362
314
|
* Get the wanted page
|
|
363
315
|
*
|
|
@@ -539,7 +491,7 @@ Table.setMethod(function getCurrentStateUrl() {
|
|
|
539
491
|
*
|
|
540
492
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
541
493
|
* @since 0.1.0
|
|
542
|
-
* @version 0.
|
|
494
|
+
* @version 0.2.0
|
|
543
495
|
*
|
|
544
496
|
* @param {Array} records
|
|
545
497
|
*/
|
|
@@ -547,6 +499,12 @@ Table.setMethod(function setRecords(records) {
|
|
|
547
499
|
|
|
548
500
|
this.assigned_data.records = records;
|
|
549
501
|
|
|
502
|
+
if (this.update_existing_rows) {
|
|
503
|
+
this[OLD_ROWS] = this.getTableRowsByPk();
|
|
504
|
+
} else {
|
|
505
|
+
this[OLD_ROWS] = null;
|
|
506
|
+
}
|
|
507
|
+
|
|
550
508
|
this.clearBody();
|
|
551
509
|
|
|
552
510
|
let record;
|
|
@@ -555,6 +513,10 @@ Table.setMethod(function setRecords(records) {
|
|
|
555
513
|
this.addDataRow(record);
|
|
556
514
|
}
|
|
557
515
|
|
|
516
|
+
if (this.update_existing_rows) {
|
|
517
|
+
this[OLD_ROWS] = null;
|
|
518
|
+
}
|
|
519
|
+
|
|
558
520
|
this.showPagination();
|
|
559
521
|
this.attachContextMenus();
|
|
560
522
|
});
|
|
@@ -591,7 +553,7 @@ Table.setMethod(function setFilter(field, value) {
|
|
|
591
553
|
*
|
|
592
554
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
593
555
|
* @since 0.1.0
|
|
594
|
-
* @version 0.
|
|
556
|
+
* @version 0.2.0
|
|
595
557
|
*/
|
|
596
558
|
Table.setMethod(function showPagination() {
|
|
597
559
|
|
|
@@ -601,21 +563,30 @@ Table.setMethod(function showPagination() {
|
|
|
601
563
|
return;
|
|
602
564
|
}
|
|
603
565
|
|
|
604
|
-
|
|
566
|
+
const use_url_pagination = this.use_url_pagination;
|
|
605
567
|
|
|
606
|
-
|
|
607
|
-
|
|
568
|
+
let url;
|
|
569
|
+
|
|
570
|
+
if (use_url_pagination) {
|
|
571
|
+
url = this.getCurrentUrl();
|
|
572
|
+
|
|
573
|
+
if (!url) {
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
608
576
|
}
|
|
609
577
|
|
|
610
|
-
let pager = this.querySelector('
|
|
578
|
+
let pager = this.querySelector('al-pager');
|
|
611
579
|
|
|
612
580
|
if (!pager) {
|
|
613
|
-
pager = this.createElement('
|
|
581
|
+
pager = this.createElement('al-pager');
|
|
614
582
|
this.footer.append(pager);
|
|
615
583
|
}
|
|
616
584
|
|
|
617
|
-
|
|
618
|
-
|
|
585
|
+
if (use_url_pagination) {
|
|
586
|
+
pager.src = url;
|
|
587
|
+
pager.url_param = this.getBaseUrlParam();
|
|
588
|
+
}
|
|
589
|
+
|
|
619
590
|
pager.page_size = records.page_size;
|
|
620
591
|
|
|
621
592
|
pager.showPage(records.page, Math.ceil(records.available / records.page_size));
|
|
@@ -626,7 +597,7 @@ Table.setMethod(function showPagination() {
|
|
|
626
597
|
*
|
|
627
598
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
628
599
|
* @since 0.1.8
|
|
629
|
-
* @version 0.
|
|
600
|
+
* @version 0.2.0
|
|
630
601
|
*
|
|
631
602
|
* @param {FieldConfig} field_config The config on how to display the field
|
|
632
603
|
* @param {Object} container The container where the field should be in
|
|
@@ -659,10 +630,12 @@ Table.setMethod(function getFieldConfigView(field_config, container) {
|
|
|
659
630
|
return Hawkejs.createText(text);
|
|
660
631
|
}
|
|
661
632
|
|
|
662
|
-
let alchemy_field = this.createElement('
|
|
633
|
+
let alchemy_field = this.createElement('al-field');
|
|
663
634
|
alchemy_field.purpose = this.purpose || 'view';
|
|
664
635
|
alchemy_field.mode = this.mode || 'inline';
|
|
665
636
|
|
|
637
|
+
alchemy_field.applyOptions(field_config.options);
|
|
638
|
+
|
|
666
639
|
//alchemy_field.view_type = this.view_type || 'view_inline';
|
|
667
640
|
alchemy_field.field_name = field.name;
|
|
668
641
|
alchemy_field.config = field;
|
|
@@ -704,7 +677,7 @@ Table.setMethod(function addDataRow(entry) {
|
|
|
704
677
|
*
|
|
705
678
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
706
679
|
* @since 0.1.0
|
|
707
|
-
* @version 0.
|
|
680
|
+
* @version 0.2.0
|
|
708
681
|
*
|
|
709
682
|
* @param {Object} entry
|
|
710
683
|
*
|
|
@@ -717,49 +690,97 @@ Table.setMethod(function createDataRow(entry) {
|
|
|
717
690
|
}
|
|
718
691
|
|
|
719
692
|
let field_set_config,
|
|
720
|
-
|
|
721
|
-
tr
|
|
722
|
-
|
|
723
|
-
|
|
693
|
+
is_existing_row,
|
|
694
|
+
tr,
|
|
695
|
+
id = entry.$pk || entry._id || entry.id;
|
|
696
|
+
|
|
697
|
+
if (id && this[OLD_ROWS] && this[OLD_ROWS][id]) {
|
|
698
|
+
tr = this[OLD_ROWS][id];
|
|
699
|
+
is_existing_row = true;
|
|
700
|
+
} else {
|
|
701
|
+
tr = this.createElement('tr');
|
|
702
|
+
}
|
|
724
703
|
|
|
725
704
|
if (id) {
|
|
726
705
|
tr.dataset.pk = id;
|
|
727
706
|
}
|
|
728
707
|
|
|
729
708
|
for (field_set_config of this.fieldset) {
|
|
730
|
-
td = this.createElement('td');
|
|
731
709
|
|
|
732
|
-
let
|
|
710
|
+
let create_new_contents = true,
|
|
711
|
+
td;
|
|
712
|
+
|
|
713
|
+
if (is_existing_row && field_set_config.path) {
|
|
714
|
+
td = tr.querySelector('td[data-path="' + field_set_config.path + '"]');
|
|
715
|
+
|
|
716
|
+
if (td) {
|
|
717
|
+
let checksum = Object.checksum(field_set_config.getValueIn(entry));
|
|
718
|
+
|
|
719
|
+
if (td.dataset.checksum == checksum) {
|
|
720
|
+
create_new_contents = false;
|
|
721
|
+
} else {
|
|
722
|
+
Hawkejs.removeChildren(td);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
if (!td) {
|
|
728
|
+
td = this.createElement('td');
|
|
729
|
+
td.dataset.path = field_set_config.path;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
if (create_new_contents) {
|
|
733
|
+
let element = this.getFieldConfigView(field_set_config, entry);
|
|
734
|
+
|
|
735
|
+
if (element) {
|
|
736
|
+
if (this.update_existing_rows) {
|
|
737
|
+
let checksum = Object.checksum(element.original_value);
|
|
738
|
+
td.dataset.checksum = checksum;
|
|
739
|
+
}
|
|
733
740
|
|
|
734
|
-
|
|
735
|
-
|
|
741
|
+
td.append(element);
|
|
742
|
+
}
|
|
736
743
|
}
|
|
737
744
|
|
|
738
|
-
|
|
745
|
+
if (!is_existing_row) {
|
|
746
|
+
tr.append(td);
|
|
747
|
+
}
|
|
739
748
|
}
|
|
740
749
|
|
|
741
750
|
if (this.has_actions) {
|
|
742
|
-
|
|
743
|
-
td
|
|
744
|
-
|
|
751
|
+
|
|
752
|
+
let td;
|
|
753
|
+
|
|
754
|
+
if (is_existing_row) {
|
|
755
|
+
td = tr.querySelector('td.aft-actions');
|
|
756
|
+
if (td) {
|
|
757
|
+
Hawkejs.removeChildren(td);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
if (!td) {
|
|
762
|
+
td = this.createElement('td');
|
|
763
|
+
td.classList.add('aft-actions');
|
|
764
|
+
tr.append(td);
|
|
765
|
+
}
|
|
745
766
|
|
|
746
767
|
let actions = this.getEntryActions(entry, 'row');
|
|
747
768
|
|
|
748
769
|
if (actions && actions.length) {
|
|
749
770
|
|
|
750
771
|
let action,
|
|
751
|
-
|
|
772
|
+
element;
|
|
752
773
|
|
|
753
774
|
// Iterate over all the defined actions
|
|
754
775
|
for (action of actions) {
|
|
755
776
|
|
|
756
|
-
|
|
777
|
+
element = action.constructElement(this);
|
|
757
778
|
|
|
758
|
-
if (!
|
|
779
|
+
if (!element) {
|
|
759
780
|
continue;
|
|
760
781
|
}
|
|
761
782
|
|
|
762
|
-
td.append(
|
|
783
|
+
td.append(element);
|
|
763
784
|
}
|
|
764
785
|
}
|
|
765
786
|
|
|
@@ -886,7 +907,7 @@ Table.setMethod(function attachContextMenus() {
|
|
|
886
907
|
*
|
|
887
908
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
888
909
|
* @since 0.1.0
|
|
889
|
-
* @version 0.1.
|
|
910
|
+
* @version 0.1.12
|
|
890
911
|
*/
|
|
891
912
|
Table.setMethod(function onFieldsetAssignment(value, old_value) {
|
|
892
913
|
|
|
@@ -920,7 +941,7 @@ Table.setMethod(function onFieldsetAssignment(value, old_value) {
|
|
|
920
941
|
|
|
921
942
|
if (field.options.sortable !== false) {
|
|
922
943
|
col.classList.add('sortable');
|
|
923
|
-
icon = this.createElement('al-
|
|
944
|
+
icon = this.createElement('al-icon');
|
|
924
945
|
icon.setAttribute('type', 'sorting-arrow');
|
|
925
946
|
|
|
926
947
|
// Wrap it in an anchor
|
|
@@ -939,18 +960,22 @@ Table.setMethod(function onFieldsetAssignment(value, old_value) {
|
|
|
939
960
|
names_row.append(col);
|
|
940
961
|
|
|
941
962
|
col = this.createElement('th');
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
963
|
+
|
|
964
|
+
if (field.options.filter !== false) {
|
|
965
|
+
input = this.createElement('input');
|
|
966
|
+
input.dataset.field = field.path;
|
|
967
|
+
input.classList.add('filter');
|
|
968
|
+
input.setAttribute('type', 'search');
|
|
969
|
+
input.setAttribute('aria-label', 'Filter ' + field.title);
|
|
970
|
+
|
|
971
|
+
// If filters have been defined already, put it in the value
|
|
972
|
+
if (this.filters && this.filters[field.path]) {
|
|
973
|
+
input.setAttribute('value', this.filters[field.path]);
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
col.append(input);
|
|
951
977
|
}
|
|
952
978
|
|
|
953
|
-
col.append(input);
|
|
954
979
|
filter_row.append(col);
|
|
955
980
|
}
|
|
956
981
|
|
|
@@ -972,7 +997,7 @@ Table.setMethod(function onFieldsetAssignment(value, old_value) {
|
|
|
972
997
|
*
|
|
973
998
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
974
999
|
* @since 0.1.0
|
|
975
|
-
* @version 0.
|
|
1000
|
+
* @version 0.2.0
|
|
976
1001
|
*
|
|
977
1002
|
* @param {String|RURL} base_url
|
|
978
1003
|
*/
|
|
@@ -1002,7 +1027,7 @@ Table.setMethod(function updateAnchors(base_url) {
|
|
|
1002
1027
|
for (i = 0; i < anchors.length; i++) {
|
|
1003
1028
|
anchor = anchors[i];
|
|
1004
1029
|
|
|
1005
|
-
ico = anchor.querySelector('al-
|
|
1030
|
+
ico = anchor.querySelector('al-icon');
|
|
1006
1031
|
|
|
1007
1032
|
ico.classList.remove('up');
|
|
1008
1033
|
ico.classList.remove('down');
|
|
@@ -1023,7 +1048,7 @@ Table.setMethod(function updateAnchors(base_url) {
|
|
|
1023
1048
|
anchor.setAttribute('href', url);
|
|
1024
1049
|
}
|
|
1025
1050
|
|
|
1026
|
-
let pager = this.querySelector('
|
|
1051
|
+
let pager = this.querySelector('al-pager');
|
|
1027
1052
|
|
|
1028
1053
|
if (pager) {
|
|
1029
1054
|
pager.src = base_url;
|
|
@@ -1068,64 +1093,58 @@ Table.setMethod(function selectRow(row) {
|
|
|
1068
1093
|
});
|
|
1069
1094
|
|
|
1070
1095
|
/**
|
|
1071
|
-
*
|
|
1096
|
+
* Construct the config object used to fetch data
|
|
1072
1097
|
*
|
|
1073
|
-
* @author Jelle De Loecker
|
|
1074
|
-
* @since 0.
|
|
1075
|
-
* @version 0.
|
|
1098
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1099
|
+
* @since 0.2.0
|
|
1100
|
+
* @version 0.2.0
|
|
1076
1101
|
*/
|
|
1077
|
-
Table.setMethod(function
|
|
1102
|
+
Table.setMethod(function getRemoteFetchConfig() {
|
|
1078
1103
|
|
|
1079
|
-
let
|
|
1080
|
-
src = this.src;
|
|
1081
|
-
|
|
1082
|
-
let body = {
|
|
1104
|
+
let config = {
|
|
1083
1105
|
fields : this.fieldset.toJSON(),
|
|
1084
1106
|
};
|
|
1085
1107
|
|
|
1086
1108
|
if (this.page_size) {
|
|
1087
|
-
|
|
1088
|
-
|
|
1109
|
+
config.page_size = this.page_size;
|
|
1110
|
+
config.page = this.getWantedPage();
|
|
1089
1111
|
}
|
|
1090
1112
|
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
let options = {
|
|
1095
|
-
href : this.src,
|
|
1096
|
-
post : true,
|
|
1097
|
-
body : body
|
|
1098
|
-
};
|
|
1099
|
-
|
|
1100
|
-
let load_remote_id = ++this.load_remote_counter;
|
|
1101
|
-
|
|
1102
|
-
this.delayAssemble(async function() {
|
|
1113
|
+
config.sort = this.getWantedSort();
|
|
1114
|
+
config.filters = this.getWantedFilters();
|
|
1103
1115
|
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
let result = await that.getResource(options);
|
|
1116
|
+
return config;
|
|
1117
|
+
});
|
|
1109
1118
|
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1119
|
+
/**
|
|
1120
|
+
* Apply the fetched data
|
|
1121
|
+
*
|
|
1122
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1123
|
+
* @since 0.2.0
|
|
1124
|
+
* @version 0.2.0
|
|
1125
|
+
*/
|
|
1126
|
+
Table.setMethod(function applyFetchedData(err, result, config) {
|
|
1113
1127
|
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1128
|
+
if (err) {
|
|
1129
|
+
console.error(err);
|
|
1130
|
+
return;
|
|
1131
|
+
}
|
|
1117
1132
|
|
|
1118
|
-
|
|
1133
|
+
let records;
|
|
1119
1134
|
|
|
1120
|
-
|
|
1135
|
+
if (Array.isArray(result)) {
|
|
1136
|
+
records = result;
|
|
1137
|
+
} else {
|
|
1138
|
+
records = result.records;
|
|
1139
|
+
}
|
|
1121
1140
|
|
|
1122
|
-
|
|
1141
|
+
this.records = records;
|
|
1142
|
+
this.updateAnchors();
|
|
1123
1143
|
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
});
|
|
1144
|
+
if (Blast.isBrowser) {
|
|
1145
|
+
let current_url = this.getCurrentStateUrl();
|
|
1146
|
+
history.pushState(null, document.title, current_url+'');
|
|
1147
|
+
}
|
|
1129
1148
|
});
|
|
1130
1149
|
|
|
1131
1150
|
/**
|
|
@@ -1160,7 +1179,7 @@ Table.setMethod(function sortData() {
|
|
|
1160
1179
|
*
|
|
1161
1180
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1162
1181
|
* @since 0.1.0
|
|
1163
|
-
* @version 0.
|
|
1182
|
+
* @version 0.2.0
|
|
1164
1183
|
*/
|
|
1165
1184
|
Table.setMethod(function introduced() {
|
|
1166
1185
|
|
|
@@ -1218,7 +1237,7 @@ Table.setMethod(function introduced() {
|
|
|
1218
1237
|
}
|
|
1219
1238
|
}, 300, false, true));
|
|
1220
1239
|
|
|
1221
|
-
let pager = this.querySelector('
|
|
1240
|
+
let pager = this.querySelector('al-pager');
|
|
1222
1241
|
|
|
1223
1242
|
if (pager) {
|
|
1224
1243
|
pager.addEventListener('pager-request', function requestPage(e) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
2
|
+
* The al-toggle custom element
|
|
3
3
|
*
|
|
4
4
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
5
5
|
* @since 0.1.0
|
|
@@ -16,15 +16,6 @@ const AlchemyToggle = Function.inherits('Alchemy.Element.Form.Base', 'Toggle');
|
|
|
16
16
|
*/
|
|
17
17
|
AlchemyToggle.setTemplateFile('form/elements/alchemy_toggle');
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* The stylesheet to load for this element
|
|
21
|
-
*
|
|
22
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
23
|
-
* @since 0.1.0
|
|
24
|
-
* @version 0.1.0
|
|
25
|
-
*/
|
|
26
|
-
AlchemyToggle.setStylesheetFile('form/alchemy_toggle');
|
|
27
|
-
|
|
28
19
|
/**
|
|
29
20
|
* Get/set the value
|
|
30
21
|
*
|
|
@@ -226,15 +226,26 @@ FormAction.setMethod(function constructElement(renderer) {
|
|
|
226
226
|
*
|
|
227
227
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
228
228
|
* @since 0.1.6
|
|
229
|
-
* @version 0.
|
|
229
|
+
* @version 0.2.0
|
|
230
230
|
*
|
|
231
231
|
* @return {HTMLElement}
|
|
232
232
|
*/
|
|
233
233
|
FormAction.setMethod(function _constructElement(renderer) {
|
|
234
234
|
|
|
235
|
-
let
|
|
236
|
-
|
|
237
|
-
|
|
235
|
+
let button = renderer.createElement('al-button');
|
|
236
|
+
button.action_instance = this;
|
|
237
|
+
|
|
238
|
+
if (this.icon) {
|
|
239
|
+
let icon = renderer.createElement('al-icon');
|
|
240
|
+
icon.icon_name = this.icon;
|
|
241
|
+
button.append(icon);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (this.title) {
|
|
245
|
+
button.append(this.title);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return button;
|
|
238
249
|
});
|
|
239
250
|
|
|
240
251
|
/**
|
|
@@ -23,7 +23,7 @@ UrlAction.addConfigProperty('url');
|
|
|
23
23
|
*
|
|
24
24
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
25
25
|
* @since 0.1.6
|
|
26
|
-
* @version 0.
|
|
26
|
+
* @version 0.2.0
|
|
27
27
|
*
|
|
28
28
|
* @return {HTMLElement}
|
|
29
29
|
*/
|
|
@@ -34,7 +34,7 @@ UrlAction.setMethod(function _constructElement(renderer) {
|
|
|
34
34
|
anchor.dataset.name = this.name;
|
|
35
35
|
|
|
36
36
|
if (this.icon) {
|
|
37
|
-
let alico = renderer.createElement('al-
|
|
37
|
+
let alico = renderer.createElement('al-icon');
|
|
38
38
|
alico.setIcon(this.icon);
|
|
39
39
|
anchor.append(alico);
|
|
40
40
|
} else {
|
|
@@ -42,6 +42,7 @@ UrlAction.setMethod(function _constructElement(renderer) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
anchor.setAttribute('href', this.url);
|
|
45
|
+
anchor.setAttribute('title', this.title || this.name);
|
|
45
46
|
|
|
46
47
|
return anchor;
|
|
47
48
|
});
|