@maro-tech/form 0.0.2 → 0.0.4
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.
|
@@ -45,7 +45,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImpo
|
|
|
45
45
|
class MaroFormsApiService {
|
|
46
46
|
http = inject(HttpClient);
|
|
47
47
|
getSuggestByName(name, query = '') {
|
|
48
|
-
const suffix = query ? `?
|
|
48
|
+
const suffix = query ? `?q=${encodeURIComponent(query)}` : '';
|
|
49
49
|
return this.http.get(`/api/suggest/${encodeURIComponent(name)}${suffix}`);
|
|
50
50
|
}
|
|
51
51
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: MaroFormsApiService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -67,7 +67,10 @@ class UiFormLookupService {
|
|
|
67
67
|
return this.http.get(endpoint);
|
|
68
68
|
}
|
|
69
69
|
const path = endpoint.startsWith('/') ? endpoint : `/${endpoint}`;
|
|
70
|
-
|
|
70
|
+
const requestUrl = path.startsWith('/api/') || path === '/api'
|
|
71
|
+
? path
|
|
72
|
+
: `/api${path}`;
|
|
73
|
+
return this.http.get(requestUrl);
|
|
71
74
|
}
|
|
72
75
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: UiFormLookupService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
73
76
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: UiFormLookupService });
|
|
@@ -2447,9 +2450,6 @@ class UiDynamicFormComponent {
|
|
|
2447
2450
|
this.getSelectSearchStream(field, key).next(String(query ?? ''));
|
|
2448
2451
|
}
|
|
2449
2452
|
ensureOptionsSourceOptionsLoaded(model) {
|
|
2450
|
-
if (!this.optionsSourceResolvers.length) {
|
|
2451
|
-
return;
|
|
2452
|
-
}
|
|
2453
2453
|
const sourceKeys = [...new Set(this.getLeafFields()
|
|
2454
2454
|
.filter((field) => (field.type ?? 'text') === 'select' && !!field.optionsSource)
|
|
2455
2455
|
.map((field) => String(field.optionsSource || '').trim())
|
|
@@ -2469,7 +2469,9 @@ class UiDynamicFormComponent {
|
|
|
2469
2469
|
const version = (this.optionsSourceRequestVersions.get(sourceKey) || 0) + 1;
|
|
2470
2470
|
this.optionsSourceRequestVersions.set(sourceKey, version);
|
|
2471
2471
|
forkJoin(sourceFields.map((field) => {
|
|
2472
|
-
const resolved = resolver
|
|
2472
|
+
const resolved = resolver
|
|
2473
|
+
? resolver.resolve({ source: sourceKey, field, model })
|
|
2474
|
+
: this.formsApi.getSuggestByName(sourceKey);
|
|
2473
2475
|
return resolved instanceof Observable ? resolved : from(Promise.resolve(resolved));
|
|
2474
2476
|
})).subscribe({
|
|
2475
2477
|
next: (results) => {
|
|
@@ -2481,7 +2483,7 @@ class UiDynamicFormComponent {
|
|
|
2481
2483
|
.map((item) => ({
|
|
2482
2484
|
label: String(item?.label ?? ''),
|
|
2483
2485
|
value: item?.value == null ? null : String(item.value),
|
|
2484
|
-
disabled: item?.disabled,
|
|
2486
|
+
disabled: typeof item?.disabled === 'boolean' ? item.disabled : undefined,
|
|
2485
2487
|
imageUrl: item?.imageUrl ? String(item.imageUrl) : undefined,
|
|
2486
2488
|
}))
|
|
2487
2489
|
.filter((item) => !!item.label || item.value !== null);
|