@elite.framework/ng.core 1.0.16 → 1.0.18
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.
|
@@ -3805,18 +3805,22 @@ class GenericSelectorTypeComponent extends FieldType {
|
|
|
3805
3805
|
}
|
|
3806
3806
|
loadDefaultValue() {
|
|
3807
3807
|
this.loading = true;
|
|
3808
|
-
const defaultFilter = { isDefault: true };
|
|
3809
3808
|
const vf = this.to['valueField'] || 'id';
|
|
3810
|
-
this.
|
|
3809
|
+
const fixedFilters = this.to['fixedFilters'] || {};
|
|
3810
|
+
const searchParams = {
|
|
3811
|
+
isDefault: true,
|
|
3812
|
+
...fixedFilters,
|
|
3813
|
+
};
|
|
3814
|
+
this.api.getList(searchParams)
|
|
3811
3815
|
.subscribe({
|
|
3812
3816
|
next: (res) => {
|
|
3813
3817
|
// Assuming the API returns a list and you want to select the first one
|
|
3814
|
-
if (res && res.
|
|
3818
|
+
if (res && res.items && res.items.length > 0) {
|
|
3815
3819
|
if (this.to['multiple']) {
|
|
3816
|
-
this.formControl.setValue(res.
|
|
3820
|
+
this.formControl.setValue(res.items.map((c) => c[vf]));
|
|
3817
3821
|
}
|
|
3818
3822
|
else {
|
|
3819
|
-
const defaultValue = res.
|
|
3823
|
+
const defaultValue = res.items[0];
|
|
3820
3824
|
this.formControl.setValue(defaultValue?.[vf]);
|
|
3821
3825
|
}
|
|
3822
3826
|
}
|
|
@@ -5861,6 +5865,7 @@ class BaseCrud {
|
|
|
5861
5865
|
dialogVisible = false;
|
|
5862
5866
|
drawerVisible = false;
|
|
5863
5867
|
selectedItem = null;
|
|
5868
|
+
defaultModel = null;
|
|
5864
5869
|
// selectedItem: T | any = {};
|
|
5865
5870
|
isViewMode = false;
|
|
5866
5871
|
isEditMode = false;
|
|
@@ -5959,7 +5964,7 @@ class BaseCrud {
|
|
|
5959
5964
|
this.mode = mode;
|
|
5960
5965
|
// this.drawerVisible = !this.drawerVisible;
|
|
5961
5966
|
if (item == null) {
|
|
5962
|
-
this.selectedItem = {};
|
|
5967
|
+
this.selectedItem = this.defaultModel || {};
|
|
5963
5968
|
}
|
|
5964
5969
|
else {
|
|
5965
5970
|
this.selectedItem = item;
|