formiojs-eorion 0.1.21 → 0.1.22
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/Formio.js +1 -1
- package/components/Chart/Chart.js +9 -16
- package/components/CustomCheckBox/CustomCheckBox.js +7 -14
- package/components/CustomFile/CustomFile.js +65 -72
- package/components/CustomRadio/CustomRadio.js +13 -21
- package/components/CustomSelect/CustomSelect.js +32 -40
- package/components/CustomTable/CustomTable.js +7 -15
- package/components/CustomTextArea/CustomTextArea.js +4 -3
- package/components/CustomTextField/CustomTextField.js +7 -14
- package/components/Data/Data.js +15 -23
- package/components/DataChinaGrid/Data.js +2 -1
- package/components/DataChinaGridRow/Data.js +2 -1
- package/components/DataSource/DataSource.js +2 -1
- package/components/Department/Department.js +10 -17
- package/components/LocationInputTextField/LocationInputTextField.js +7 -14
- package/components/NocodbFile/NocodbFile.js +65 -72
- package/components/QrCode/QrCode.js +6 -13
- package/components/ScanInputTextField/ScanInputTextField.js +7 -14
- package/components/TaskCalendar/TaskCalendar.js +8 -16
- package/components/_classes/Department/Department.js +10 -17
- package/components/button/Button.js +2 -1
- package/components/echarts/ECharts.js +2 -1
- package/components/file/File.js +63 -71
- package/components/iconButton/IconButton.js +2 -1
- package/components/map/Map.js +14 -22
- package/components/progress/Progress.js +2 -1
- package/components/radio/Radio.js +45 -53
- package/components/select/Select.js +102 -110
- package/components/tree/Tree.js +10 -17
- package/dist/formio.contrib.js +2 -2
- package/dist/formio.contrib.min.js +1 -1
- package/dist/formio.contrib.min.js.LICENSE.txt +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.js +27 -27
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +1 -1
- package/dist/formio.full.js +27 -27
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +1 -1
- package/dist/formio.js +1 -1
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/package.json +1 -1
|
@@ -18,12 +18,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
18
18
|
value: true
|
|
19
19
|
});
|
|
20
20
|
exports.default = void 0;
|
|
21
|
-
require("core-js/modules/es.object.to-string.js");
|
|
22
21
|
require("core-js/modules/es.regexp.exec.js");
|
|
23
22
|
require("core-js/modules/es.string.replace.js");
|
|
24
23
|
require("core-js/modules/es.string.trim.js");
|
|
25
24
|
require("core-js/modules/es.array.concat.js");
|
|
26
25
|
require("core-js/modules/es.array.find.js");
|
|
26
|
+
require("core-js/modules/es.object.to-string.js");
|
|
27
27
|
require("core-js/modules/es.regexp.to-string.js");
|
|
28
28
|
require("core-js/modules/es.array.map.js");
|
|
29
29
|
require("core-js/modules/es.array.join.js");
|
|
@@ -87,26 +87,18 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
87
87
|
return _super.apply(this, arguments);
|
|
88
88
|
}
|
|
89
89
|
_createClass(SelectComponent, [{
|
|
90
|
-
key: "get",
|
|
91
|
-
value: function get(path, obj) {
|
|
92
|
-
var fb = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "${".concat(path, "}");
|
|
93
|
-
return path.split('.').reduce(function (res, key) {
|
|
94
|
-
return res[key] || fb;
|
|
95
|
-
}, obj);
|
|
96
|
-
}
|
|
97
|
-
}, {
|
|
98
90
|
key: "parseTpl",
|
|
99
|
-
value: function parseTpl(template, map
|
|
100
|
-
var _this = this;
|
|
91
|
+
value: function parseTpl(template, map) {
|
|
101
92
|
return template.replace(/\$\{.+?}/g, function (match) {
|
|
93
|
+
var _$get;
|
|
102
94
|
var path = match.substr(2, match.length - 3).trim();
|
|
103
|
-
return
|
|
95
|
+
return (_$get = _lodash.default.get(map, path)) !== null && _$get !== void 0 ? _$get : '--';
|
|
104
96
|
});
|
|
105
97
|
}
|
|
106
98
|
}, {
|
|
107
99
|
key: "init",
|
|
108
100
|
value: function init() {
|
|
109
|
-
var
|
|
101
|
+
var _this = this;
|
|
110
102
|
_get(_getPrototypeOf(SelectComponent.prototype), "init", this).call(this);
|
|
111
103
|
this.templateData = {};
|
|
112
104
|
this.validators = this.validators.concat(['select', 'onlyAvailableItems']);
|
|
@@ -118,15 +110,15 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
118
110
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
119
111
|
args[_key] = arguments[_key];
|
|
120
112
|
}
|
|
121
|
-
return
|
|
113
|
+
return _this.updateItems.apply(_this, args);
|
|
122
114
|
}, 100);
|
|
123
115
|
this.triggerUpdate = function () {
|
|
124
116
|
// Make sure we always resolve the previous promise before reassign it
|
|
125
|
-
if (typeof
|
|
126
|
-
|
|
117
|
+
if (typeof _this.itemsLoadedResolve === 'function') {
|
|
118
|
+
_this.itemsLoadedResolve();
|
|
127
119
|
}
|
|
128
|
-
|
|
129
|
-
|
|
120
|
+
_this.itemsLoaded = new _nativePromiseOnly.default(function (resolve) {
|
|
121
|
+
_this.itemsLoadedResolve = resolve;
|
|
130
122
|
});
|
|
131
123
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
132
124
|
args[_key2] = arguments[_key2];
|
|
@@ -151,7 +143,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
151
143
|
// If this component has been activated.
|
|
152
144
|
this.activated = false;
|
|
153
145
|
this.itemsLoaded = new _nativePromiseOnly.default(function (resolve) {
|
|
154
|
-
|
|
146
|
+
_this.itemsLoadedResolve = resolve;
|
|
155
147
|
});
|
|
156
148
|
this.shouldPositionDropdown = this.hasDataGridAncestor();
|
|
157
149
|
if (this.isHtmlRenderMode()) {
|
|
@@ -381,7 +373,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
381
373
|
}, {
|
|
382
374
|
key: "setItems",
|
|
383
375
|
value: function setItems(items, fromSearch) {
|
|
384
|
-
var
|
|
376
|
+
var _this2 = this,
|
|
385
377
|
_this$choices,
|
|
386
378
|
_this$choices$input;
|
|
387
379
|
// If the items is a string, then parse as JSON.
|
|
@@ -434,7 +426,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
434
426
|
if (!_lodash.default.isEmpty(this.dataValue) && this.component.idPath) {
|
|
435
427
|
var selectedOptionId = _lodash.default.get(this.dataValue, this.component.idPath, null);
|
|
436
428
|
var newOptionWithSameId = !_lodash.default.isNil(selectedOptionId) && items.find(function (item) {
|
|
437
|
-
var itemId = _lodash.default.get(item,
|
|
429
|
+
var itemId = _lodash.default.get(item, _this2.component.idPath);
|
|
438
430
|
return itemId === selectedOptionId;
|
|
439
431
|
});
|
|
440
432
|
if (newOptionWithSameId) {
|
|
@@ -454,9 +446,9 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
454
446
|
// Iterate through each of the items.
|
|
455
447
|
_lodash.default.each(items, function (item, index) {
|
|
456
448
|
// preventing references of the components inside the form to the parent form when building forms
|
|
457
|
-
if (
|
|
458
|
-
var itemValueAndLabel =
|
|
459
|
-
|
|
449
|
+
if (_this2.root && _this2.root.options.editForm && _this2.root.options.editForm._id && _this2.root.options.editForm._id === item._id) return;
|
|
450
|
+
var itemValueAndLabel = _this2.selectValueAndLabel(item);
|
|
451
|
+
_this2.addOption(itemValueAndLabel.value, itemValueAndLabel.label, {}, _lodash.default.get(item, _this2.component.idPath, String(index)));
|
|
460
452
|
});
|
|
461
453
|
if (this.choices) {
|
|
462
454
|
this.choices.setChoices(this.selectOptions, 'value', 'label', true);
|
|
@@ -503,13 +495,13 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
503
495
|
}, {
|
|
504
496
|
key: "itemValueForHTMLMode",
|
|
505
497
|
value: function itemValueForHTMLMode(value) {
|
|
506
|
-
var
|
|
498
|
+
var _this3 = this;
|
|
507
499
|
if (!this.isHtmlRenderMode()) {
|
|
508
500
|
return _get(_getPrototypeOf(SelectComponent.prototype), "itemValueForHTMLMode", this).call(this, value);
|
|
509
501
|
}
|
|
510
502
|
if (Array.isArray(value)) {
|
|
511
503
|
var values = value.map(function (item) {
|
|
512
|
-
return Array.isArray(item) ?
|
|
504
|
+
return Array.isArray(item) ? _this3.itemValueForHTMLMode(item) : _this3.getSingleItemValueForHTMLMode(item);
|
|
513
505
|
});
|
|
514
506
|
return values.join(', ');
|
|
515
507
|
}
|
|
@@ -529,7 +521,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
529
521
|
}, {
|
|
530
522
|
key: "getTemplateKeys",
|
|
531
523
|
value: function getTemplateKeys() {
|
|
532
|
-
var
|
|
524
|
+
var _this4 = this;
|
|
533
525
|
this.templateKeys = [];
|
|
534
526
|
if (this.options.readOnly && this.component.template) {
|
|
535
527
|
var keys = this.component.template.match(/({{\s*(.*?)\s*}})/g);
|
|
@@ -537,7 +529,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
537
529
|
keys.forEach(function (key) {
|
|
538
530
|
var propKey = key.match(/{{\s*item\.(.*?)\s*}}/);
|
|
539
531
|
if (propKey && propKey.length > 1) {
|
|
540
|
-
|
|
532
|
+
_this4.templateKeys.push(propKey[1]);
|
|
541
533
|
}
|
|
542
534
|
});
|
|
543
535
|
}
|
|
@@ -582,7 +574,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
582
574
|
}, {
|
|
583
575
|
key: "loadItems",
|
|
584
576
|
value: function loadItems(url, search, headers, options, method, body) {
|
|
585
|
-
var
|
|
577
|
+
var _this5 = this;
|
|
586
578
|
options = options || {};
|
|
587
579
|
|
|
588
580
|
// See if we should load items or not.
|
|
@@ -655,7 +647,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
655
647
|
if (!_lodash.default.isEmpty(query)) {
|
|
656
648
|
// Add the query string.
|
|
657
649
|
url += (!url.includes('?') ? '?' : '&') + _Formio.GlobalFormio.serialize(query, function (item) {
|
|
658
|
-
return
|
|
650
|
+
return _this5.interpolate(item);
|
|
659
651
|
});
|
|
660
652
|
}
|
|
661
653
|
|
|
@@ -675,19 +667,19 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
675
667
|
url: url
|
|
676
668
|
}), {
|
|
677
669
|
data: this.rootValue
|
|
678
|
-
}
|
|
670
|
+
})).url;
|
|
679
671
|
} catch (e) {}
|
|
680
672
|
_Formio.GlobalFormio.makeRequest(this.options.formio, 'select', url, method, body, options).then(function (response) {
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
673
|
+
_this5.loading = false;
|
|
674
|
+
_this5.error = null;
|
|
675
|
+
_this5.setItems(response, !!search);
|
|
684
676
|
}).catch(function (err) {
|
|
685
|
-
if (
|
|
686
|
-
|
|
687
|
-
|
|
677
|
+
if (_this5.itemsFromUrl) {
|
|
678
|
+
_this5.setItems([]);
|
|
679
|
+
_this5.disableInfiniteScroll();
|
|
688
680
|
}
|
|
689
|
-
|
|
690
|
-
|
|
681
|
+
_this5.isScrollLoading = false;
|
|
682
|
+
_this5.handleLoadingError(err);
|
|
691
683
|
});
|
|
692
684
|
}
|
|
693
685
|
}, {
|
|
@@ -710,7 +702,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
710
702
|
}, {
|
|
711
703
|
key: "requestHeaders",
|
|
712
704
|
get: function get() {
|
|
713
|
-
var
|
|
705
|
+
var _this6 = this;
|
|
714
706
|
// Create the headers object.
|
|
715
707
|
var headers = new _Formio.GlobalFormio.Headers();
|
|
716
708
|
|
|
@@ -719,7 +711,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
719
711
|
try {
|
|
720
712
|
_lodash.default.each(this.component.data.headers, function (header) {
|
|
721
713
|
if (header.key) {
|
|
722
|
-
headers.set(header.key,
|
|
714
|
+
headers.set(header.key, _this6.interpolate(header.value));
|
|
723
715
|
}
|
|
724
716
|
});
|
|
725
717
|
} catch (err) {
|
|
@@ -748,7 +740,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
748
740
|
}, {
|
|
749
741
|
key: "updateCustomItems",
|
|
750
742
|
value: function updateCustomItems(forceUpdate) {
|
|
751
|
-
var
|
|
743
|
+
var _this7 = this;
|
|
752
744
|
if (this.asyncCustomValues()) {
|
|
753
745
|
if (!forceUpdate && !this.active) {
|
|
754
746
|
this.itemsLoadedResolve();
|
|
@@ -756,10 +748,10 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
756
748
|
}
|
|
757
749
|
this.loading = true;
|
|
758
750
|
this.getCustomItems().then(function (items) {
|
|
759
|
-
|
|
760
|
-
|
|
751
|
+
_this7.loading = false;
|
|
752
|
+
_this7.setItems(items || []);
|
|
761
753
|
}).catch(function (err) {
|
|
762
|
-
|
|
754
|
+
_this7.handleLoadingError(err);
|
|
763
755
|
});
|
|
764
756
|
} else {
|
|
765
757
|
this.setItems(this.getCustomItems() || []);
|
|
@@ -942,7 +934,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
942
934
|
}, {
|
|
943
935
|
key: "attach",
|
|
944
936
|
value: function attach(element) {
|
|
945
|
-
var
|
|
937
|
+
var _this8 = this,
|
|
946
938
|
_this$choices2,
|
|
947
939
|
_this$choices2$contai,
|
|
948
940
|
_this$choices2$contai2;
|
|
@@ -956,7 +948,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
956
948
|
var autocompleteInput = this.refs.autocompleteInput;
|
|
957
949
|
if (autocompleteInput) {
|
|
958
950
|
this.addEventListener(autocompleteInput, 'change', function (event) {
|
|
959
|
-
|
|
951
|
+
_this8.setValue(event.target.value);
|
|
960
952
|
});
|
|
961
953
|
}
|
|
962
954
|
var input = this.refs.selectContainer;
|
|
@@ -964,7 +956,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
964
956
|
return;
|
|
965
957
|
}
|
|
966
958
|
this.addEventListener(input, this.inputInfo.changeEvent, function () {
|
|
967
|
-
return
|
|
959
|
+
return _this8.updateValue(null, {
|
|
968
960
|
modified: true
|
|
969
961
|
});
|
|
970
962
|
});
|
|
@@ -977,12 +969,12 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
977
969
|
}
|
|
978
970
|
this.focusableElement = input;
|
|
979
971
|
this.addEventListener(input, 'focus', function () {
|
|
980
|
-
return
|
|
972
|
+
return _this8.update();
|
|
981
973
|
});
|
|
982
974
|
this.addEventListener(input, 'keydown', function (event) {
|
|
983
975
|
var key = event.key;
|
|
984
976
|
if (['Backspace', 'Delete'].includes(key)) {
|
|
985
|
-
|
|
977
|
+
_this8.setValue(_this8.emptyValue);
|
|
986
978
|
}
|
|
987
979
|
});
|
|
988
980
|
return;
|
|
@@ -1010,20 +1002,20 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1010
1002
|
this.focusableElement = this.choices.containerInner.element;
|
|
1011
1003
|
this.choices.containerOuter.element.setAttribute('tabIndex', '-1');
|
|
1012
1004
|
this.addEventListener(this.choices.containerOuter.element, 'focus', function () {
|
|
1013
|
-
return
|
|
1005
|
+
return _this8.focusableElement.focus();
|
|
1014
1006
|
});
|
|
1015
1007
|
}
|
|
1016
1008
|
this.addFocusBlurEvents(this.focusableElement);
|
|
1017
1009
|
if (this.itemsFromUrl) {
|
|
1018
1010
|
this.scrollList = this.choices.choiceList.element;
|
|
1019
1011
|
this.addEventListener(this.scrollList, 'scroll', function () {
|
|
1020
|
-
return
|
|
1012
|
+
return _this8.onScroll();
|
|
1021
1013
|
});
|
|
1022
1014
|
}
|
|
1023
1015
|
}
|
|
1024
1016
|
if (window && this.choices && this.shouldPositionDropdown) {
|
|
1025
1017
|
this.addEventListener(window.document, 'scroll', function () {
|
|
1026
|
-
|
|
1018
|
+
_this8.positionDropdown(true);
|
|
1027
1019
|
}, false, true);
|
|
1028
1020
|
}
|
|
1029
1021
|
this.focusableElement.setAttribute('tabIndex', tabIndex);
|
|
@@ -1033,53 +1025,53 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1033
1025
|
// Make sure to clear the search when no value is provided.
|
|
1034
1026
|
if (this.choices && this.choices.input && this.choices.input.element) {
|
|
1035
1027
|
this.addEventListener(this.choices.input.element, 'input', function (event) {
|
|
1036
|
-
|
|
1028
|
+
_this8.isFromSearch = !!event.target.value;
|
|
1037
1029
|
if (!event.target.value) {
|
|
1038
|
-
|
|
1030
|
+
_this8.triggerUpdate();
|
|
1039
1031
|
} else {
|
|
1040
|
-
|
|
1041
|
-
|
|
1032
|
+
_this8.serverCount = null;
|
|
1033
|
+
_this8.downloadedResources = [];
|
|
1042
1034
|
}
|
|
1043
1035
|
});
|
|
1044
1036
|
}
|
|
1045
1037
|
this.addEventListener(input, 'choice', function () {
|
|
1046
|
-
if (
|
|
1047
|
-
|
|
1038
|
+
if (_this8.component.multiple && _this8.component.dataSrc === 'resource' && _this8.isFromSearch) {
|
|
1039
|
+
_this8.triggerUpdate();
|
|
1048
1040
|
}
|
|
1049
|
-
|
|
1041
|
+
_this8.isFromSearch = false;
|
|
1050
1042
|
});
|
|
1051
1043
|
// avoid spamming the resource/url endpoint when we have server side filtering enabled.
|
|
1052
1044
|
var debounceTimeout = (this.component.searchField || this.component.data.noco_db_conditions && this.component.data.noco_db_conditions.length > 0 && this.component.data.noco_db_conditions[0].name.length > 0) && (this.isSelectResource || this.isSelectURL) ? (this.component.searchDebounce === 0 ? 0 : this.component.searchDebounce || this.defaultSchema.searchDebounce) * 1000 : 0;
|
|
1053
1045
|
var updateComponent = function updateComponent(evt) {
|
|
1054
|
-
|
|
1046
|
+
_this8.triggerUpdate(evt.detail.value);
|
|
1055
1047
|
};
|
|
1056
1048
|
this.addEventListener(input, 'search', _lodash.default.debounce(function (e) {
|
|
1057
1049
|
updateComponent(e);
|
|
1058
|
-
|
|
1050
|
+
_this8.positionDropdown();
|
|
1059
1051
|
}, debounceTimeout));
|
|
1060
1052
|
this.addEventListener(input, 'stopSearch', function () {
|
|
1061
|
-
return
|
|
1053
|
+
return _this8.triggerUpdate();
|
|
1062
1054
|
});
|
|
1063
1055
|
this.addEventListener(input, 'hideDropdown', function () {
|
|
1064
|
-
if (
|
|
1065
|
-
|
|
1056
|
+
if (_this8.choices && _this8.choices.input && _this8.choices.input.element) {
|
|
1057
|
+
_this8.choices.input.element.value = '';
|
|
1066
1058
|
}
|
|
1067
|
-
|
|
1059
|
+
_this8.updateItems(null, true);
|
|
1068
1060
|
});
|
|
1069
1061
|
}
|
|
1070
1062
|
this.addEventListener(input, 'showDropdown', function () {
|
|
1071
|
-
|
|
1072
|
-
|
|
1063
|
+
_this8.update();
|
|
1064
|
+
_this8.positionDropdown();
|
|
1073
1065
|
});
|
|
1074
1066
|
if (this.shouldPositionDropdown) {
|
|
1075
1067
|
this.addEventListener(input, 'highlightChoice', function () {
|
|
1076
|
-
|
|
1068
|
+
_this8.positionDropdown();
|
|
1077
1069
|
});
|
|
1078
1070
|
}
|
|
1079
1071
|
if (this.choices && choicesOptions.placeholderValue && this.choices._isSelectOneElement) {
|
|
1080
1072
|
this.addPlaceholderItem(choicesOptions.placeholderValue);
|
|
1081
1073
|
this.addEventListener(input, 'removeItem', function () {
|
|
1082
|
-
|
|
1074
|
+
_this8.addPlaceholderItem(choicesOptions.placeholderValue);
|
|
1083
1075
|
});
|
|
1084
1076
|
}
|
|
1085
1077
|
|
|
@@ -1089,19 +1081,19 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1089
1081
|
if (this.isSelectResource && this.refs.addResource) {
|
|
1090
1082
|
this.addEventListener(this.refs.addResource, 'click', function (event) {
|
|
1091
1083
|
event.preventDefault();
|
|
1092
|
-
var formioForm =
|
|
1093
|
-
var dialog =
|
|
1094
|
-
var projectUrl = _lodash.default.get(
|
|
1095
|
-
var formUrl = "".concat(projectUrl, "/form/").concat(
|
|
1084
|
+
var formioForm = _this8.ce('div');
|
|
1085
|
+
var dialog = _this8.createModal(formioForm);
|
|
1086
|
+
var projectUrl = _lodash.default.get(_this8.root, 'formio.projectUrl', _Formio.GlobalFormio.getProjectUrl());
|
|
1087
|
+
var formUrl = "".concat(projectUrl, "/form/").concat(_this8.component.data.resource);
|
|
1096
1088
|
new _Form.default(formioForm, formUrl, {}).ready.then(function (form) {
|
|
1097
1089
|
form.on('submit', function (submission) {
|
|
1098
1090
|
// If valueProperty is set, replace the submission with the corresponding value
|
|
1099
|
-
var value =
|
|
1100
|
-
if (
|
|
1101
|
-
value = [].concat(_toConsumableArray(
|
|
1091
|
+
var value = _this8.valueProperty ? _lodash.default.get(submission, _this8.valueProperty) : submission;
|
|
1092
|
+
if (_this8.component.multiple) {
|
|
1093
|
+
value = [].concat(_toConsumableArray(_this8.dataValue), [value]);
|
|
1102
1094
|
}
|
|
1103
|
-
|
|
1104
|
-
|
|
1095
|
+
_this8.setValue(value);
|
|
1096
|
+
_this8.triggerUpdate();
|
|
1105
1097
|
dialog.close();
|
|
1106
1098
|
});
|
|
1107
1099
|
});
|
|
@@ -1149,13 +1141,13 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1149
1141
|
key: "positionDropdown",
|
|
1150
1142
|
value: function positionDropdown(scroll) {
|
|
1151
1143
|
var _this$choices$dropdow,
|
|
1152
|
-
|
|
1144
|
+
_this9 = this;
|
|
1153
1145
|
if (!this.shouldPositionDropdown || !this.choices || !((_this$choices$dropdow = this.choices.dropdown) !== null && _this$choices$dropdow !== void 0 && _this$choices$dropdow.isActive) && scroll) {
|
|
1154
1146
|
return;
|
|
1155
1147
|
}
|
|
1156
1148
|
this.setDropdownPosition();
|
|
1157
1149
|
this.itemsLoaded.then(function () {
|
|
1158
|
-
|
|
1150
|
+
_this9.setDropdownPosition();
|
|
1159
1151
|
});
|
|
1160
1152
|
}
|
|
1161
1153
|
}, {
|
|
@@ -1175,10 +1167,10 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1175
1167
|
}, {
|
|
1176
1168
|
key: "attachRefreshOnBlur",
|
|
1177
1169
|
value: function attachRefreshOnBlur() {
|
|
1178
|
-
var
|
|
1170
|
+
var _this10 = this;
|
|
1179
1171
|
if (this.component.refreshOnBlur) {
|
|
1180
1172
|
this.on('blur', function (instance) {
|
|
1181
|
-
|
|
1173
|
+
_this10.checkRefreshOn([{
|
|
1182
1174
|
instance: instance,
|
|
1183
1175
|
value: instance.dataValue
|
|
1184
1176
|
}], {
|
|
@@ -1254,7 +1246,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1254
1246
|
}, {
|
|
1255
1247
|
key: "addCurrentChoices",
|
|
1256
1248
|
value: function addCurrentChoices(values, items, keyValue) {
|
|
1257
|
-
var
|
|
1249
|
+
var _this11 = this;
|
|
1258
1250
|
if (!values) {
|
|
1259
1251
|
return false;
|
|
1260
1252
|
}
|
|
@@ -1271,14 +1263,14 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1271
1263
|
// `this.addOption` method, we assume that items has
|
|
1272
1264
|
// 'label' and 'value' properties. This assumption allows
|
|
1273
1265
|
// us to read correct value from the item.
|
|
1274
|
-
var isSelectOptions = items ===
|
|
1266
|
+
var isSelectOptions = items === _this11.selectOptions;
|
|
1275
1267
|
if (items && items.length) {
|
|
1276
1268
|
_lodash.default.each(items, function (choice) {
|
|
1277
1269
|
if (choice._id && value._id && choice._id === value._id) {
|
|
1278
1270
|
found = true;
|
|
1279
1271
|
return false;
|
|
1280
1272
|
}
|
|
1281
|
-
var itemValue = keyValue ? choice.value :
|
|
1273
|
+
var itemValue = keyValue ? choice.value : _this11.itemValue(choice, isSelectOptions);
|
|
1282
1274
|
found |= _lodash.default.isEqual(itemValue, value);
|
|
1283
1275
|
return found ? false : true;
|
|
1284
1276
|
});
|
|
@@ -1286,7 +1278,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1286
1278
|
|
|
1287
1279
|
// Add the default option if no item is found.
|
|
1288
1280
|
if (!found) {
|
|
1289
|
-
notFoundValuesToAdd.push(
|
|
1281
|
+
notFoundValuesToAdd.push(_this11.selectValueAndLabel(value));
|
|
1290
1282
|
return true;
|
|
1291
1283
|
}
|
|
1292
1284
|
return found || defaultAdded;
|
|
@@ -1296,7 +1288,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1296
1288
|
this.choices.setChoices(notFoundValuesToAdd, 'value', 'label');
|
|
1297
1289
|
}
|
|
1298
1290
|
notFoundValuesToAdd.map(function (notFoundValue) {
|
|
1299
|
-
|
|
1291
|
+
_this11.addOption(notFoundValue.value, notFoundValue.label);
|
|
1300
1292
|
});
|
|
1301
1293
|
}
|
|
1302
1294
|
return added;
|
|
@@ -1353,7 +1345,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1353
1345
|
}, {
|
|
1354
1346
|
key: "normalizeSingleValue",
|
|
1355
1347
|
value: function normalizeSingleValue(value, retainObject) {
|
|
1356
|
-
var
|
|
1348
|
+
var _this12 = this;
|
|
1357
1349
|
if (_lodash.default.isNil(value)) {
|
|
1358
1350
|
return;
|
|
1359
1351
|
}
|
|
@@ -1381,8 +1373,8 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1381
1373
|
var dataValue = this.dataValue;
|
|
1382
1374
|
if (dataValue && dataValue.length) {
|
|
1383
1375
|
dataValue.forEach(function (dataValueItem) {
|
|
1384
|
-
var dataValueItemValue =
|
|
1385
|
-
templateData[dataValueItemValue] =
|
|
1376
|
+
var dataValueItemValue = _this12.component.reference ? dataValueItem._id.toString() : dataValueItem;
|
|
1377
|
+
templateData[dataValueItemValue] = _this12.templateData[dataValueItemValue];
|
|
1386
1378
|
});
|
|
1387
1379
|
}
|
|
1388
1380
|
}
|
|
@@ -1443,10 +1435,10 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1443
1435
|
}, {
|
|
1444
1436
|
key: "normalizeValue",
|
|
1445
1437
|
value: function normalizeValue(value) {
|
|
1446
|
-
var
|
|
1438
|
+
var _this13 = this;
|
|
1447
1439
|
if (this.component.multiple && Array.isArray(value)) {
|
|
1448
1440
|
return value.map(function (singleValue) {
|
|
1449
|
-
return
|
|
1441
|
+
return _this13.normalizeSingleValue(singleValue, true);
|
|
1450
1442
|
});
|
|
1451
1443
|
}
|
|
1452
1444
|
return _get(_getPrototypeOf(SelectComponent.prototype), "normalizeValue", this).call(this, this.normalizeSingleValue(value, true));
|
|
@@ -1454,7 +1446,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1454
1446
|
}, {
|
|
1455
1447
|
key: "setValue",
|
|
1456
1448
|
value: function setValue(value) {
|
|
1457
|
-
var
|
|
1449
|
+
var _this14 = this;
|
|
1458
1450
|
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1459
1451
|
var previousValue = this.dataValue;
|
|
1460
1452
|
if (this.component.widget === 'html5' && (_lodash.default.isEqual(value, previousValue) || _lodash.default.isEqual(previousValue, {}) && _lodash.default.isEqual(flags, {}))) {
|
|
@@ -1480,7 +1472,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1480
1472
|
}
|
|
1481
1473
|
if (this.isHtmlRenderMode() && flags && flags.fromSubmission && changed) {
|
|
1482
1474
|
this.itemsLoaded.then(function () {
|
|
1483
|
-
|
|
1475
|
+
_this14.redraw();
|
|
1484
1476
|
});
|
|
1485
1477
|
return changed;
|
|
1486
1478
|
}
|
|
@@ -1501,8 +1493,8 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1501
1493
|
|
|
1502
1494
|
// Add the value options.
|
|
1503
1495
|
this.itemsLoaded.then(function () {
|
|
1504
|
-
|
|
1505
|
-
|
|
1496
|
+
_this14.addValueOptions();
|
|
1497
|
+
_this14.setChoicesValue(value, hasPreviousValue, flags);
|
|
1506
1498
|
});
|
|
1507
1499
|
return changed;
|
|
1508
1500
|
}
|
|
@@ -1572,7 +1564,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1572
1564
|
}, {
|
|
1573
1565
|
key: "validateValueAvailability",
|
|
1574
1566
|
value: function validateValueAvailability(setting, value) {
|
|
1575
|
-
var
|
|
1567
|
+
var _this15 = this;
|
|
1576
1568
|
if (!(0, _utils.boolValue)(setting) || !value) {
|
|
1577
1569
|
return true;
|
|
1578
1570
|
}
|
|
@@ -1580,7 +1572,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1580
1572
|
if (values) {
|
|
1581
1573
|
if (_lodash.default.isObject(value)) {
|
|
1582
1574
|
var compareComplexValues = function compareComplexValues(optionValue) {
|
|
1583
|
-
var normalizedOptionValue =
|
|
1575
|
+
var normalizedOptionValue = _this15.normalizeSingleValue(optionValue, true);
|
|
1584
1576
|
if (!_lodash.default.isObject(normalizedOptionValue)) {
|
|
1585
1577
|
return false;
|
|
1586
1578
|
}
|
|
@@ -1596,7 +1588,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1596
1588
|
}) !== -1;
|
|
1597
1589
|
}
|
|
1598
1590
|
return values.findIndex(function (optionValue) {
|
|
1599
|
-
return
|
|
1591
|
+
return _this15.normalizeSingleValue(optionValue) === value;
|
|
1600
1592
|
}) !== -1;
|
|
1601
1593
|
}
|
|
1602
1594
|
return false;
|
|
@@ -1621,7 +1613,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1621
1613
|
}, {
|
|
1622
1614
|
key: "getOptionsValues",
|
|
1623
1615
|
value: function getOptionsValues() {
|
|
1624
|
-
var
|
|
1616
|
+
var _this16 = this;
|
|
1625
1617
|
var rawItems = [];
|
|
1626
1618
|
switch (this.component.dataSrc) {
|
|
1627
1619
|
case 'values':
|
|
@@ -1646,7 +1638,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1646
1638
|
return;
|
|
1647
1639
|
}
|
|
1648
1640
|
return rawItems.map(function (item) {
|
|
1649
|
-
return
|
|
1641
|
+
return _this16.getOptionValue(_this16.itemValue(item));
|
|
1650
1642
|
});
|
|
1651
1643
|
}
|
|
1652
1644
|
|
|
@@ -1686,14 +1678,14 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1686
1678
|
}, {
|
|
1687
1679
|
key: "getNormalizedValues",
|
|
1688
1680
|
value: function getNormalizedValues() {
|
|
1689
|
-
var
|
|
1681
|
+
var _this17 = this;
|
|
1690
1682
|
if (!this.component || !this.component.data || !this.component.data.values) {
|
|
1691
1683
|
return;
|
|
1692
1684
|
}
|
|
1693
1685
|
return this.component.data.values.map(function (value) {
|
|
1694
1686
|
return {
|
|
1695
1687
|
label: value.label,
|
|
1696
|
-
value: String(
|
|
1688
|
+
value: String(_this17.normalizeSingleValue(value.value))
|
|
1697
1689
|
};
|
|
1698
1690
|
});
|
|
1699
1691
|
}
|
|
@@ -1701,7 +1693,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1701
1693
|
key: "asString",
|
|
1702
1694
|
value: function asString(value) {
|
|
1703
1695
|
var _value3,
|
|
1704
|
-
|
|
1696
|
+
_this18 = this;
|
|
1705
1697
|
value = (_value3 = value) !== null && _value3 !== void 0 ? _value3 : this.getValue();
|
|
1706
1698
|
//need to convert values to strings to be able to compare values with available options that are strings
|
|
1707
1699
|
var convertToString = function convertToString(data, valueProperty) {
|
|
@@ -1715,14 +1707,14 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1715
1707
|
}
|
|
1716
1708
|
return data;
|
|
1717
1709
|
}
|
|
1718
|
-
if (
|
|
1710
|
+
if (_this18.isBooleanOrNumber(data)) {
|
|
1719
1711
|
data = data.toString();
|
|
1720
1712
|
}
|
|
1721
1713
|
if (Array.isArray(data) && data.some(function (item) {
|
|
1722
|
-
return
|
|
1714
|
+
return _this18.isBooleanOrNumber(item);
|
|
1723
1715
|
})) {
|
|
1724
1716
|
data = data.map(function (item) {
|
|
1725
|
-
if (
|
|
1717
|
+
if (_this18.isBooleanOrNumber(item)) {
|
|
1726
1718
|
item = item.toString();
|
|
1727
1719
|
}
|
|
1728
1720
|
});
|
|
@@ -1743,7 +1735,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1743
1735
|
valueProperty = _ref4.valueProperty;
|
|
1744
1736
|
var getFromValues = function getFromValues() {
|
|
1745
1737
|
var initialValue = _lodash.default.find(items, [valueProperty, value]);
|
|
1746
|
-
var values =
|
|
1738
|
+
var values = _this18.defaultSchema.data.values || [];
|
|
1747
1739
|
return _lodash.default.isEqual(initialValue, values[0]) ? '-' : initialValue;
|
|
1748
1740
|
};
|
|
1749
1741
|
value = this.component.multiple && Array.isArray(value) ? _lodash.default.filter(items, function (item) {
|
|
@@ -1759,7 +1751,7 @@ var SelectComponent = /*#__PURE__*/function (_ListComponent) {
|
|
|
1759
1751
|
if (Array.isArray(value)) {
|
|
1760
1752
|
var _items = [];
|
|
1761
1753
|
value.forEach(function (item) {
|
|
1762
|
-
return _items.push(
|
|
1754
|
+
return _items.push(_this18.itemTemplate(item));
|
|
1763
1755
|
});
|
|
1764
1756
|
return _items.length > 0 ? _items.join('<br />') : '-';
|
|
1765
1757
|
}
|