kwikid-forms 0.5.12 → 0.5.13
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.
|
@@ -4115,11 +4115,24 @@
|
|
|
4115
4115
|
*/
|
|
4116
4116
|
KwikIDFormViewComponent.prototype.updateFiles = function (file, state, key) {
|
|
4117
4117
|
var _h;
|
|
4118
|
+
var _a;
|
|
4118
4119
|
var fileWithState = kwikidToolkit.mergeObjects(file, { state: state });
|
|
4119
|
-
var
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4120
|
+
var field = getFormFieldByKey(this.formFields, key);
|
|
4121
|
+
if ((_a = field.properties) === null || _a === void 0 ? void 0 : _a.multiple) {
|
|
4122
|
+
// If field.properties?.multiple is true, it means multiple files are allowed for this field.
|
|
4123
|
+
// Update the existing files array for the specific key with the new file.
|
|
4124
|
+
var updatedFiles = __spreadArray(__spreadArray([], __read(this.files[key].filter(function (f) { return f.name !== fileWithState.name || f.size !== fileWithState.size; }))), [
|
|
4125
|
+
fileWithState
|
|
4126
|
+
]);
|
|
4127
|
+
// Apply the filterDuplicatesFiles function to ensure uniqueness in the updatedFiles array.
|
|
4128
|
+
this.files[key] = filterDuplicatesFiles(updatedFiles);
|
|
4129
|
+
}
|
|
4130
|
+
else {
|
|
4131
|
+
// If field.properties?.multiple is false, only one file is allowed for this field.
|
|
4132
|
+
// Replace the existing files array for the specific key with an array containing the new file.
|
|
4133
|
+
this.files[key] = [fileWithState];
|
|
4134
|
+
}
|
|
4135
|
+
// Update the formData and formGroup controls for the specific key with the normalFiles array.
|
|
4123
4136
|
var normalFiles = this.files[key].filter(function (file) {
|
|
4124
4137
|
return file.state === "NORMAL";
|
|
4125
4138
|
});
|