osl-base-extended 1.0.3 → 1.0.5
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.
|
@@ -137,6 +137,36 @@ class baseComponent {
|
|
|
137
137
|
disableClose: true,
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
|
+
isValidBeforeSave(formElements, model) {
|
|
141
|
+
const errors = [];
|
|
142
|
+
this._collectValidationErrors(formElements, model, errors);
|
|
143
|
+
return errors;
|
|
144
|
+
}
|
|
145
|
+
_collectValidationErrors(formElements, model, errors) {
|
|
146
|
+
for (const el of formElements) {
|
|
147
|
+
if (el.elementType === 'fieldset') {
|
|
148
|
+
if (el.rows?.length) {
|
|
149
|
+
this._collectValidationErrors(el.rows, model, errors);
|
|
150
|
+
}
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (el.elementType === 'button' || el.elementType === 'templateRef' || el.elementType === 'spacer') {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (el.hideIf?.(model)) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const isRequired = el.required || el.requiredIf?.(model);
|
|
160
|
+
if (isRequired) {
|
|
161
|
+
const value = model[el.key];
|
|
162
|
+
const isEmpty = value === null || value === undefined || value === ''
|
|
163
|
+
|| (Array.isArray(value) && value.length === 0);
|
|
164
|
+
if (isEmpty) {
|
|
165
|
+
errors.push(`${el.label} is required`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
140
170
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: baseComponent, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
141
171
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: baseComponent });
|
|
142
172
|
}
|
|
@@ -1824,7 +1854,7 @@ class DynamicForm {
|
|
|
1824
1854
|
if (elem.elementType === 'fieldset' && elem.rows?.length) {
|
|
1825
1855
|
this._loadForList(elem.rows);
|
|
1826
1856
|
}
|
|
1827
|
-
else if (elem.apiService && elem.apiMethod && elem.searchType == 'Local') {
|
|
1857
|
+
else if (elem.apiService && elem.apiMethod && (!elem.searchType || elem.searchType == 'Local')) {
|
|
1828
1858
|
elem.loadingIf = () => true;
|
|
1829
1859
|
const data = await this.datasourceCache.load(elem.apiService, elem.apiMethod, elem.apiBody);
|
|
1830
1860
|
elem.loadingIf = () => false;
|