alchemy-form 0.1.10 → 0.1.12
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 +23 -0
- package/assets/stylesheets/form/alchemy_field.scss +33 -0
- package/controller/form_api_controller.js +0 -1
- package/element/00_form_base.js +48 -9
- package/element/alchemy_field.js +143 -51
- package/element/alchemy_field_schema.js +20 -8
- package/element/alchemy_pager.js +5 -5
- package/element/alchemy_select_item.js +18 -4
- package/element/alchemy_table.js +123 -38
- package/element/query_builder_entry.js +6 -5
- package/element/query_builder_value.js +1 -1
- package/helper/form_actions/url_action.js +2 -2
- package/helper/query_builder_ns.js +108 -0
- package/helper/query_builder_variable_definition/00_variable_definition.js +52 -1
- package/helper/widgets/alchemy_field_widget.js +6 -23
- package/helper/widgets/alchemy_form_widget.js +26 -2
- package/helper/widgets/alchemy_table_widget.js +18 -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 +3 -2
- package/view/form/elements/alchemy_select_item.hwk +1 -3
- package/view/form/inputs/edit_inline/boolean.hwk +4 -0
- package/view/form/inputs/view_inline/boolean.hwk +19 -0
- package/view/form/inputs/view_inline/date.hwk +4 -0
- package/view/form/inputs/view_inline/enum.hwk +1 -0
- package/view/form/inputs/view_inline/objectid.hwk +1 -0
- package/view/form/select/qb_item.hwk +1 -0
- package/view/form/wrappers/edit_inline/default.hwk +1 -0
- package/view/form/wrappers/view_inline/default.hwk +1 -1
- package/view/form/inputs/view_inline/file.hwk +0 -6
package/element/alchemy_table.js
CHANGED
|
@@ -25,7 +25,7 @@ Table.setTemplate(`<header class="aft-header"></header>
|
|
|
25
25
|
<tfoot></tfoot>
|
|
26
26
|
</table>
|
|
27
27
|
</div>
|
|
28
|
-
<footer class="aft-footer"></footer>`, {plain_html: true, render_immediate: true});
|
|
28
|
+
<footer data-he-slot="footer" class="aft-footer"></footer>`, {plain_html: true, render_immediate: true});
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* The stylesheet to load for this element
|
|
@@ -126,6 +126,15 @@ Table.setAttribute('page-size', {number: true});
|
|
|
126
126
|
*/
|
|
127
127
|
Table.setAttribute('show-filters', {boolean: true});
|
|
128
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Which optional view-type to use for field values
|
|
131
|
+
*
|
|
132
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
133
|
+
* @since 0.1.11
|
|
134
|
+
* @version 0.1.11
|
|
135
|
+
*/
|
|
136
|
+
Table.setAttribute('view-type');
|
|
137
|
+
|
|
129
138
|
/**
|
|
130
139
|
* Keep track of the loadRemote calls
|
|
131
140
|
*
|
|
@@ -287,7 +296,7 @@ Table.addObservedAttribute('src', function onSource(src) {
|
|
|
287
296
|
*
|
|
288
297
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
289
298
|
* @since 0.1.0
|
|
290
|
-
* @version 0.1.
|
|
299
|
+
* @version 0.1.11
|
|
291
300
|
*
|
|
292
301
|
* @param {*} config
|
|
293
302
|
*/
|
|
@@ -302,7 +311,11 @@ Table.setMethod(function setRecordsource(config) {
|
|
|
302
311
|
}
|
|
303
312
|
|
|
304
313
|
if (url == '#') {
|
|
305
|
-
|
|
314
|
+
let current_url = this.getCurrentUrl();
|
|
315
|
+
|
|
316
|
+
if (current_url) {
|
|
317
|
+
url = ''+current_url;
|
|
318
|
+
}
|
|
306
319
|
}
|
|
307
320
|
|
|
308
321
|
this.src = url;
|
|
@@ -350,7 +363,7 @@ Table.setMethod(function clearBody() {
|
|
|
350
363
|
*
|
|
351
364
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
352
365
|
* @since 0.1.0
|
|
353
|
-
* @version 0.1.
|
|
366
|
+
* @version 0.1.11
|
|
354
367
|
*
|
|
355
368
|
* @return {Number}
|
|
356
369
|
*/
|
|
@@ -365,14 +378,17 @@ Table.setMethod(function getWantedPage() {
|
|
|
365
378
|
if (this.id) {
|
|
366
379
|
let url = this.getCurrentUrl();
|
|
367
380
|
|
|
368
|
-
|
|
381
|
+
if (url) {
|
|
369
382
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
383
|
+
let data = url.param('aft');
|
|
384
|
+
|
|
385
|
+
if (data && data[this.id]) {
|
|
386
|
+
page = parseInt(data[this.id].page);
|
|
387
|
+
}
|
|
373
388
|
|
|
374
|
-
|
|
375
|
-
|
|
389
|
+
if (isFinite(page) && page > 0) {
|
|
390
|
+
return page;
|
|
391
|
+
}
|
|
376
392
|
}
|
|
377
393
|
}
|
|
378
394
|
|
|
@@ -384,7 +400,7 @@ Table.setMethod(function getWantedPage() {
|
|
|
384
400
|
*
|
|
385
401
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
386
402
|
* @since 0.1.0
|
|
387
|
-
* @version 0.1.
|
|
403
|
+
* @version 0.1.11
|
|
388
404
|
*
|
|
389
405
|
* @return {Number}
|
|
390
406
|
*/
|
|
@@ -405,11 +421,11 @@ Table.setMethod(function getWantedSort() {
|
|
|
405
421
|
let url_param = this.getBaseUrlParam() + '[sort]',
|
|
406
422
|
url = this.getCurrentUrl();
|
|
407
423
|
|
|
408
|
-
if (!result.field) {
|
|
424
|
+
if (!result.field && url) {
|
|
409
425
|
result.field = url.param(url_param + '[field]');
|
|
410
426
|
}
|
|
411
427
|
|
|
412
|
-
if (!result.dir) {
|
|
428
|
+
if (!result.dir && url) {
|
|
413
429
|
result.dir = url.param(url_param + '[dir]');
|
|
414
430
|
}
|
|
415
431
|
|
|
@@ -424,7 +440,7 @@ Table.setMethod(function getWantedSort() {
|
|
|
424
440
|
*
|
|
425
441
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
426
442
|
* @since 0.1.0
|
|
427
|
-
* @version 0.1.
|
|
443
|
+
* @version 0.1.11
|
|
428
444
|
*
|
|
429
445
|
* @return {Object}
|
|
430
446
|
*/
|
|
@@ -433,6 +449,11 @@ Table.setMethod(function getWantedFilters() {
|
|
|
433
449
|
if (!this.filters) {
|
|
434
450
|
|
|
435
451
|
let url = this.getCurrentUrl();
|
|
452
|
+
|
|
453
|
+
if (!url) {
|
|
454
|
+
return null;
|
|
455
|
+
}
|
|
456
|
+
|
|
436
457
|
let data = url.param('aft');
|
|
437
458
|
let filters;
|
|
438
459
|
|
|
@@ -486,15 +507,20 @@ Table.setMethod(function getBaseUrlParam() {
|
|
|
486
507
|
*
|
|
487
508
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
488
509
|
* @since 0.1.0
|
|
489
|
-
* @version 0.1.
|
|
510
|
+
* @version 0.1.11
|
|
490
511
|
*
|
|
491
512
|
* @return {RURL}
|
|
492
513
|
*/
|
|
493
514
|
Table.setMethod(function getCurrentStateUrl() {
|
|
494
515
|
|
|
516
|
+
let url = this.getCurrentUrl();
|
|
517
|
+
|
|
518
|
+
if (!url) {
|
|
519
|
+
return null;
|
|
520
|
+
}
|
|
521
|
+
|
|
495
522
|
let url_param = this.getBaseUrlParam(),
|
|
496
|
-
page = this.getWantedPage()
|
|
497
|
-
url = this.getCurrentUrl();
|
|
523
|
+
page = this.getWantedPage();
|
|
498
524
|
|
|
499
525
|
url.param(url_param + '[page]', page);
|
|
500
526
|
|
|
@@ -513,7 +539,7 @@ Table.setMethod(function getCurrentStateUrl() {
|
|
|
513
539
|
*
|
|
514
540
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
515
541
|
* @since 0.1.0
|
|
516
|
-
* @version 0.1.
|
|
542
|
+
* @version 0.1.11
|
|
517
543
|
*
|
|
518
544
|
* @param {Array} records
|
|
519
545
|
*/
|
|
@@ -526,7 +552,7 @@ Table.setMethod(function setRecords(records) {
|
|
|
526
552
|
let record;
|
|
527
553
|
|
|
528
554
|
for (record of records) {
|
|
529
|
-
this.
|
|
555
|
+
this.addDataRow(record);
|
|
530
556
|
}
|
|
531
557
|
|
|
532
558
|
this.showPagination();
|
|
@@ -565,7 +591,7 @@ Table.setMethod(function setFilter(field, value) {
|
|
|
565
591
|
*
|
|
566
592
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
567
593
|
* @since 0.1.0
|
|
568
|
-
* @version 0.1.
|
|
594
|
+
* @version 0.1.11
|
|
569
595
|
*/
|
|
570
596
|
Table.setMethod(function showPagination() {
|
|
571
597
|
|
|
@@ -575,6 +601,12 @@ Table.setMethod(function showPagination() {
|
|
|
575
601
|
return;
|
|
576
602
|
}
|
|
577
603
|
|
|
604
|
+
let url = this.getCurrentUrl();
|
|
605
|
+
|
|
606
|
+
if (!url) {
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
|
|
578
610
|
let pager = this.querySelector('alchemy-pager');
|
|
579
611
|
|
|
580
612
|
if (!pager) {
|
|
@@ -582,7 +614,7 @@ Table.setMethod(function showPagination() {
|
|
|
582
614
|
this.footer.append(pager);
|
|
583
615
|
}
|
|
584
616
|
|
|
585
|
-
pager.src =
|
|
617
|
+
pager.src = url;
|
|
586
618
|
pager.url_param = this.getBaseUrlParam();
|
|
587
619
|
pager.page_size = records.page_size;
|
|
588
620
|
|
|
@@ -594,7 +626,7 @@ Table.setMethod(function showPagination() {
|
|
|
594
626
|
*
|
|
595
627
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
596
628
|
* @since 0.1.8
|
|
597
|
-
* @version 0.1.
|
|
629
|
+
* @version 0.1.12
|
|
598
630
|
*
|
|
599
631
|
* @param {FieldConfig} field_config The config on how to display the field
|
|
600
632
|
* @param {Object} container The container where the field should be in
|
|
@@ -603,6 +635,10 @@ Table.setMethod(function showPagination() {
|
|
|
603
635
|
*/
|
|
604
636
|
Table.setMethod(function getFieldConfigView(field_config, container) {
|
|
605
637
|
|
|
638
|
+
if (typeof field_config == 'string') {
|
|
639
|
+
field_config = this.fieldset.get(field_config);
|
|
640
|
+
}
|
|
641
|
+
|
|
606
642
|
let value = field_config.getValueIn(container),
|
|
607
643
|
field;
|
|
608
644
|
|
|
@@ -624,7 +660,12 @@ Table.setMethod(function getFieldConfigView(field_config, container) {
|
|
|
624
660
|
}
|
|
625
661
|
|
|
626
662
|
let alchemy_field = this.createElement('alchemy-field');
|
|
627
|
-
alchemy_field.
|
|
663
|
+
alchemy_field.purpose = this.purpose || 'view';
|
|
664
|
+
alchemy_field.mode = this.mode || 'inline';
|
|
665
|
+
|
|
666
|
+
alchemy_field.applyOptions(field_config.options);
|
|
667
|
+
|
|
668
|
+
//alchemy_field.view_type = this.view_type || 'view_inline';
|
|
628
669
|
alchemy_field.field_name = field.name;
|
|
629
670
|
alchemy_field.config = field;
|
|
630
671
|
alchemy_field.original_value = value;
|
|
@@ -632,6 +673,34 @@ Table.setMethod(function getFieldConfigView(field_config, container) {
|
|
|
632
673
|
return alchemy_field;
|
|
633
674
|
});
|
|
634
675
|
|
|
676
|
+
/**
|
|
677
|
+
* Create and add a datarow
|
|
678
|
+
*
|
|
679
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
680
|
+
* @since 0.1.11
|
|
681
|
+
* @version 0.1.11
|
|
682
|
+
*
|
|
683
|
+
* @param {Object} entry
|
|
684
|
+
*
|
|
685
|
+
* @return <TR>
|
|
686
|
+
*/
|
|
687
|
+
Table.setMethod(function addDataRow(entry) {
|
|
688
|
+
|
|
689
|
+
if (!entry) {
|
|
690
|
+
entry = {};
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
let tr = this.createDataRow(entry);
|
|
694
|
+
|
|
695
|
+
if (!tr) {
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
this.table_body.append(tr);
|
|
700
|
+
|
|
701
|
+
return tr;
|
|
702
|
+
});
|
|
703
|
+
|
|
635
704
|
/**
|
|
636
705
|
* Create a datarow
|
|
637
706
|
*
|
|
@@ -645,13 +714,19 @@ Table.setMethod(function getFieldConfigView(field_config, container) {
|
|
|
645
714
|
*/
|
|
646
715
|
Table.setMethod(function createDataRow(entry) {
|
|
647
716
|
|
|
717
|
+
if (!entry) {
|
|
718
|
+
throw new Error('Unable to create datarow without data');
|
|
719
|
+
}
|
|
720
|
+
|
|
648
721
|
let field_set_config,
|
|
649
722
|
value,
|
|
650
723
|
tr = this.createElement('tr'),
|
|
651
724
|
td,
|
|
652
725
|
id = entry.$pk || entry._id || entry.id;
|
|
653
726
|
|
|
654
|
-
|
|
727
|
+
if (id) {
|
|
728
|
+
tr.dataset.pk = id;
|
|
729
|
+
}
|
|
655
730
|
|
|
656
731
|
for (field_set_config of this.fieldset) {
|
|
657
732
|
td = this.createElement('td');
|
|
@@ -813,7 +888,7 @@ Table.setMethod(function attachContextMenus() {
|
|
|
813
888
|
*
|
|
814
889
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
815
890
|
* @since 0.1.0
|
|
816
|
-
* @version 0.1.
|
|
891
|
+
* @version 0.1.12
|
|
817
892
|
*/
|
|
818
893
|
Table.setMethod(function onFieldsetAssignment(value, old_value) {
|
|
819
894
|
|
|
@@ -866,18 +941,22 @@ Table.setMethod(function onFieldsetAssignment(value, old_value) {
|
|
|
866
941
|
names_row.append(col);
|
|
867
942
|
|
|
868
943
|
col = this.createElement('th');
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
944
|
+
|
|
945
|
+
if (field.options.filter !== false) {
|
|
946
|
+
input = this.createElement('input');
|
|
947
|
+
input.dataset.field = field.path;
|
|
948
|
+
input.classList.add('filter');
|
|
949
|
+
input.setAttribute('type', 'search');
|
|
950
|
+
input.setAttribute('aria-label', 'Filter ' + field.title);
|
|
951
|
+
|
|
952
|
+
// If filters have been defined already, put it in the value
|
|
953
|
+
if (this.filters && this.filters[field.path]) {
|
|
954
|
+
input.setAttribute('value', this.filters[field.path]);
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
col.append(input);
|
|
878
958
|
}
|
|
879
959
|
|
|
880
|
-
col.append(input);
|
|
881
960
|
filter_row.append(col);
|
|
882
961
|
}
|
|
883
962
|
|
|
@@ -899,7 +978,7 @@ Table.setMethod(function onFieldsetAssignment(value, old_value) {
|
|
|
899
978
|
*
|
|
900
979
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
901
980
|
* @since 0.1.0
|
|
902
|
-
* @version 0.1.
|
|
981
|
+
* @version 0.1.11
|
|
903
982
|
*
|
|
904
983
|
* @param {String|RURL} base_url
|
|
905
984
|
*/
|
|
@@ -911,6 +990,10 @@ Table.setMethod(function updateAnchors(base_url) {
|
|
|
911
990
|
base_url = RURL.parse(base_url);
|
|
912
991
|
}
|
|
913
992
|
|
|
993
|
+
if (!base_url) {
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
|
|
914
997
|
let anchors = this.querySelectorAll('a.sorting-anchor'),
|
|
915
998
|
anchor,
|
|
916
999
|
url,
|
|
@@ -969,7 +1052,7 @@ Table.setMethod(function onRecordsAssignment(value, old_value) {
|
|
|
969
1052
|
*
|
|
970
1053
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
971
1054
|
* @since 0.1.0
|
|
972
|
-
* @version 0.1.
|
|
1055
|
+
* @version 0.1.11
|
|
973
1056
|
*
|
|
974
1057
|
* @param <TR>
|
|
975
1058
|
*/
|
|
@@ -985,7 +1068,9 @@ Table.setMethod(function selectRow(row) {
|
|
|
985
1068
|
child.classList.remove('aft-selected');
|
|
986
1069
|
}
|
|
987
1070
|
|
|
988
|
-
row
|
|
1071
|
+
if (row) {
|
|
1072
|
+
row.classList.add('aft-selected');
|
|
1073
|
+
}
|
|
989
1074
|
});
|
|
990
1075
|
|
|
991
1076
|
/**
|
|
@@ -127,7 +127,7 @@ QueryBuilderEntry.setProperty(function value() {
|
|
|
127
127
|
*
|
|
128
128
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
129
129
|
* @since 0.1.6
|
|
130
|
-
* @version 0.1.
|
|
130
|
+
* @version 0.1.12
|
|
131
131
|
*/
|
|
132
132
|
QueryBuilderEntry.setMethod(async function loadData(config, element) {
|
|
133
133
|
|
|
@@ -149,10 +149,11 @@ QueryBuilderEntry.setMethod(async function loadData(config, element) {
|
|
|
149
149
|
items = await this.loadValueTypeData(config);
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
152
|
+
if (items) {
|
|
153
|
+
items.clean(null);
|
|
154
|
+
items.clean(undefined);
|
|
155
|
+
items.clean(false);
|
|
156
|
+
}
|
|
156
157
|
|
|
157
158
|
return {
|
|
158
159
|
items: items,
|
|
@@ -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.1.
|
|
26
|
+
* @version 0.1.11
|
|
27
27
|
*
|
|
28
28
|
* @return {HTMLElement}
|
|
29
29
|
*/
|
|
@@ -35,7 +35,7 @@ UrlAction.setMethod(function _constructElement(renderer) {
|
|
|
35
35
|
|
|
36
36
|
if (this.icon) {
|
|
37
37
|
let alico = renderer.createElement('al-ico');
|
|
38
|
-
alico.
|
|
38
|
+
alico.setIcon(this.icon);
|
|
39
39
|
anchor.append(alico);
|
|
40
40
|
} else {
|
|
41
41
|
anchor.textContent = this.title || this.name;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
const QueryBuilder = Fn.getNamespace('Alchemy.QueryBuilder');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Apply query builder settings to a criteria
|
|
5
|
+
*
|
|
6
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
7
|
+
* @since 0.1.12
|
|
8
|
+
* @version 0.1.12
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} conditions
|
|
11
|
+
* @param {Criteria} criteria
|
|
12
|
+
* @param {Boolean} inverted
|
|
13
|
+
*/
|
|
14
|
+
QueryBuilder.applyToCriteria = function applyToCriteria(conditions, criteria, inverted) {
|
|
15
|
+
|
|
16
|
+
if (!conditions || !conditions.rules?.length) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let group;
|
|
21
|
+
|
|
22
|
+
if (conditions.condition == 'or') {
|
|
23
|
+
group = criteria.or();
|
|
24
|
+
} else {
|
|
25
|
+
group = criteria.and();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (inverted == null) {
|
|
29
|
+
inverted = false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (conditions.inverted) {
|
|
33
|
+
inverted = !inverted;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
for (let rule of conditions.rules) {
|
|
37
|
+
applyRule(rule, criteria, inverted);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Apply a single rule to a criteria
|
|
43
|
+
*
|
|
44
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
45
|
+
* @since 0.1.12
|
|
46
|
+
* @version 0.1.12
|
|
47
|
+
*
|
|
48
|
+
* @param {Object} rule
|
|
49
|
+
* @param {Criteria} criteria
|
|
50
|
+
* @param {Boolean} inverted
|
|
51
|
+
*/
|
|
52
|
+
function applyRule(rule, criteria, inverted) {
|
|
53
|
+
|
|
54
|
+
if (rule.type == 'group') {
|
|
55
|
+
return QueryBuilder.applyToCriteria(rule, criteria, inverted);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (rule.type != 'qb_entry') {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Referencing other fields is not supported
|
|
63
|
+
if (rule.value_variable) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let context = criteria.where(rule.field);
|
|
68
|
+
|
|
69
|
+
if (inverted) {
|
|
70
|
+
context = context.not();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (rule.operator == 'is_empty') {
|
|
74
|
+
context.isEmpty();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (rule.operator == 'is_null') {
|
|
79
|
+
context.isNull();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let value = rule.value_explicit.value;
|
|
84
|
+
|
|
85
|
+
let method;
|
|
86
|
+
|
|
87
|
+
switch (rule.operator) {
|
|
88
|
+
case 'ne':
|
|
89
|
+
case 'not_equals':
|
|
90
|
+
method = 'ne';
|
|
91
|
+
break;
|
|
92
|
+
|
|
93
|
+
case 'starts_with':
|
|
94
|
+
value = RegExp.interpret('^' + value);
|
|
95
|
+
method = 'equals';
|
|
96
|
+
break;
|
|
97
|
+
|
|
98
|
+
case 'ends_with':
|
|
99
|
+
value = RegExp.interpret(value + '$');
|
|
100
|
+
method = 'equals';
|
|
101
|
+
break;
|
|
102
|
+
|
|
103
|
+
default:
|
|
104
|
+
method = rule.operator;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
context[method](value);
|
|
108
|
+
}
|
|
@@ -102,12 +102,48 @@ VariableDefinition.constitute(function prepareOperators() {
|
|
|
102
102
|
this.assignment_operators = {};
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Get a list of definitions from the input
|
|
107
|
+
*
|
|
108
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
109
|
+
* @since 0.1.12
|
|
110
|
+
* @version 0.1.12
|
|
111
|
+
*
|
|
112
|
+
* @param {*} input
|
|
113
|
+
*
|
|
114
|
+
* @return {VariableDefinition[]}
|
|
115
|
+
*/
|
|
116
|
+
VariableDefinition.setStatic(function fromMany(input) {
|
|
117
|
+
|
|
118
|
+
let result = [];
|
|
119
|
+
|
|
120
|
+
if (input) {
|
|
121
|
+
|
|
122
|
+
let schema = input.schema;
|
|
123
|
+
|
|
124
|
+
if (schema && schema instanceof Classes.Alchemy.Schema) {
|
|
125
|
+
|
|
126
|
+
for (let entry of schema) {
|
|
127
|
+
|
|
128
|
+
let instance = VariableDefinition.cast(entry);
|
|
129
|
+
|
|
130
|
+
if (instance) {
|
|
131
|
+
result.push(instance);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return result;
|
|
139
|
+
});
|
|
140
|
+
|
|
105
141
|
/**
|
|
106
142
|
* Create the correct variable definition
|
|
107
143
|
*
|
|
108
144
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
109
145
|
* @since 0.1.6
|
|
110
|
-
* @version 0.1.
|
|
146
|
+
* @version 0.1.12
|
|
111
147
|
*/
|
|
112
148
|
VariableDefinition.setStatic(function cast(entry) {
|
|
113
149
|
|
|
@@ -119,6 +155,21 @@ VariableDefinition.setStatic(function cast(entry) {
|
|
|
119
155
|
return entry;
|
|
120
156
|
}
|
|
121
157
|
|
|
158
|
+
if (entry instanceof Classes.Alchemy.Field) {
|
|
159
|
+
let field = entry;
|
|
160
|
+
|
|
161
|
+
entry = {
|
|
162
|
+
name : field.name,
|
|
163
|
+
title : field.title,
|
|
164
|
+
description : field.options.description,
|
|
165
|
+
type : field.constructor.type_name,
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
if (!VariableDefinition.getMember(entry.type)) {
|
|
169
|
+
entry.type = 'string';
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
122
173
|
if (!entry.type) {
|
|
123
174
|
return null;
|
|
124
175
|
}
|
|
@@ -16,16 +16,13 @@ const AlchemyField = Function.inherits('Alchemy.Widget', 'AlchemyField');
|
|
|
16
16
|
*
|
|
17
17
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
18
18
|
* @since 0.1.0
|
|
19
|
-
* @version 0.1.
|
|
19
|
+
* @version 0.1.12
|
|
20
20
|
*/
|
|
21
21
|
AlchemyField.constitute(function prepareSchema() {
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// widgets.addField('config', 'Schema', {schema: 'type'});
|
|
27
|
-
|
|
28
|
-
// this.schema.addField('widgets', widgets, {array: true});
|
|
23
|
+
this.setAddChecker(function(widget_element) {
|
|
24
|
+
return false;
|
|
25
|
+
});
|
|
29
26
|
});
|
|
30
27
|
|
|
31
28
|
/**
|
|
@@ -73,7 +70,7 @@ AlchemyField.enforceProperty(function alchemy_form(new_value) {
|
|
|
73
70
|
*
|
|
74
71
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
75
72
|
* @since 0.1.0
|
|
76
|
-
* @version 0.1.
|
|
73
|
+
* @version 0.1.12
|
|
77
74
|
*/
|
|
78
75
|
AlchemyField.setMethod(function populateWidget() {
|
|
79
76
|
|
|
@@ -89,21 +86,7 @@ AlchemyField.setMethod(function populateWidget() {
|
|
|
89
86
|
|
|
90
87
|
field_el.field_name = config.field;
|
|
91
88
|
|
|
92
|
-
|
|
93
|
-
field_el.field_view = config.view;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (config.readonly) {
|
|
97
|
-
field_el.readonly = true;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (config.widget_settings) {
|
|
101
|
-
field_el.widget_settings = config.widget_settings;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (config.data_src) {
|
|
105
|
-
field_el.data_src = config.data_src;
|
|
106
|
-
}
|
|
89
|
+
field_el.applyOptions(config);
|
|
107
90
|
|
|
108
91
|
this.element.append(field_el);
|
|
109
92
|
});
|
|
@@ -11,12 +11,26 @@
|
|
|
11
11
|
*/
|
|
12
12
|
const AlchemyForm = Function.inherits('Alchemy.Widget', 'AlchemyForm');
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Prepare the schema
|
|
16
|
+
*
|
|
17
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
18
|
+
* @since 0.1.12
|
|
19
|
+
* @version 0.1.12
|
|
20
|
+
*/
|
|
21
|
+
AlchemyForm.constitute(function prepareSchema() {
|
|
22
|
+
|
|
23
|
+
this.setAddChecker(function(widget_element) {
|
|
24
|
+
return false;
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
14
28
|
/**
|
|
15
29
|
* Populate the widget
|
|
16
30
|
*
|
|
17
31
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
18
32
|
* @since 0.1.0
|
|
19
|
-
* @version 0.1.
|
|
33
|
+
* @version 0.1.11
|
|
20
34
|
*/
|
|
21
35
|
AlchemyForm.setMethod(function populateWidget() {
|
|
22
36
|
|
|
@@ -30,6 +44,14 @@ AlchemyForm.setMethod(function populateWidget() {
|
|
|
30
44
|
|
|
31
45
|
form.classList.add('alchemy-widgets-container');
|
|
32
46
|
|
|
47
|
+
if (config.purpose) {
|
|
48
|
+
form.purpose = config.purpose;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (config.mode) {
|
|
52
|
+
form.mode = config.mode;
|
|
53
|
+
}
|
|
54
|
+
|
|
33
55
|
if (this.config && this.config.widgets) {
|
|
34
56
|
let widgets = this.config.widgets.slice(0),
|
|
35
57
|
widget,
|
|
@@ -59,7 +81,9 @@ AlchemyForm.setMethod(function populateWidget() {
|
|
|
59
81
|
form.model = config.model;
|
|
60
82
|
}
|
|
61
83
|
|
|
62
|
-
|
|
84
|
+
if (config.view_type) {
|
|
85
|
+
form.view_type = config.view_type;
|
|
86
|
+
}
|
|
63
87
|
|
|
64
88
|
form.append(col.widget);
|
|
65
89
|
|