cat-qw-lib 2.6.30 → 2.6.31
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/fesm2022/cat-qw-lib.mjs +70 -45
- package/fesm2022/cat-qw-lib.mjs.map +1 -1
- package/lib/admin/widget-admin/components/widget-admin-form/widget-admin-form.component.d.ts +1 -0
- package/lib/admin/widget-admin/models/widget.model.d.ts +4 -4
- package/lib/admin/widget-admin/state/widget-admin.service.d.ts +1 -1
- package/package.json +1 -1
package/fesm2022/cat-qw-lib.mjs
CHANGED
|
@@ -3730,14 +3730,14 @@ class WidgetAdminService extends BaseService {
|
|
|
3730
3730
|
listLabelProperty: "name",
|
|
3731
3731
|
},
|
|
3732
3732
|
{
|
|
3733
|
-
name: "
|
|
3733
|
+
name: "dataDictionaryId",
|
|
3734
3734
|
dataSource: DATASOURCES.DICTIONARY,
|
|
3735
3735
|
listValueProperty: "_id",
|
|
3736
3736
|
listLabelProperty: "name",
|
|
3737
3737
|
},
|
|
3738
3738
|
{
|
|
3739
|
-
name: "
|
|
3740
|
-
dataSource:
|
|
3739
|
+
name: "dictionaryItemId",
|
|
3740
|
+
dataSource: DATASOURCES.DELETEDICTIONARYITEM,
|
|
3741
3741
|
listValueProperty: "_id",
|
|
3742
3742
|
listLabelProperty: "key",
|
|
3743
3743
|
},
|
|
@@ -3812,7 +3812,7 @@ class WidgetAdminService extends BaseService {
|
|
|
3812
3812
|
return String(value);
|
|
3813
3813
|
}
|
|
3814
3814
|
/**
|
|
3815
|
-
* Parses style from form (string or
|
|
3815
|
+
* Parses style from form (string or object) and returns an object payload for API submit.
|
|
3816
3816
|
*/
|
|
3817
3817
|
parseStylePayload(input) {
|
|
3818
3818
|
if (input === null || input === undefined) {
|
|
@@ -3893,8 +3893,8 @@ class WidgetModel extends BaseModel {
|
|
|
3893
3893
|
*/
|
|
3894
3894
|
class WidgetItemModel extends BaseModel {
|
|
3895
3895
|
name;
|
|
3896
|
-
|
|
3897
|
-
|
|
3896
|
+
dictionaryItemId;
|
|
3897
|
+
dataDictionaryId;
|
|
3898
3898
|
style;
|
|
3899
3899
|
isActive = true;
|
|
3900
3900
|
}
|
|
@@ -3902,8 +3902,8 @@ class WidgetItemModel extends BaseModel {
|
|
|
3902
3902
|
* BadgeModel class represents the model of a badge.
|
|
3903
3903
|
*/
|
|
3904
3904
|
class BadgeModel {
|
|
3905
|
-
|
|
3906
|
-
|
|
3905
|
+
dictionaryItemId;
|
|
3906
|
+
dataDictionaryId;
|
|
3907
3907
|
style;
|
|
3908
3908
|
}
|
|
3909
3909
|
|
|
@@ -3981,8 +3981,10 @@ class WidgetAdminFormComponent extends BaseFormComponent {
|
|
|
3981
3981
|
if (Array.isArray(this.record.dataItems)) {
|
|
3982
3982
|
const hasEmptyItem = this.record.dataItems.some((item) => {
|
|
3983
3983
|
const isItemNameEmpty = !item.name || item.name.trim() === SHARED.EMPTY;
|
|
3984
|
-
const
|
|
3985
|
-
const
|
|
3984
|
+
const dictionaryId = item.dataDictionaryId || item.dictionaryID;
|
|
3985
|
+
const dictionaryItemId = item.dictionaryItemId || item.dictionaryItemID;
|
|
3986
|
+
const isDictionaryEmpty = !dictionaryId || dictionaryId.trim() === SHARED.EMPTY;
|
|
3987
|
+
const isDictionaryItemEmpty = !dictionaryItemId || dictionaryItemId.trim() === SHARED.EMPTY;
|
|
3986
3988
|
return isItemNameEmpty && isDictionaryItemEmpty && isDictionaryEmpty;
|
|
3987
3989
|
});
|
|
3988
3990
|
if (hasEmptyItem) {
|
|
@@ -3997,9 +3999,9 @@ class WidgetAdminFormComponent extends BaseFormComponent {
|
|
|
3997
3999
|
}
|
|
3998
4000
|
handleAPIChange(apiConfigId) {
|
|
3999
4001
|
this.query.getLists().subscribe((allLists) => {
|
|
4000
|
-
const allDictionaryRecords = allLists.find((list) => list.forProperty === '
|
|
4002
|
+
const allDictionaryRecords = allLists.find((list) => list.forProperty === 'dataDictionaryId')?.records;
|
|
4001
4003
|
this.dictionaries =
|
|
4002
|
-
allDictionaryRecords?.filter((item) => String(item.apiConfigId ?? '') === String(apiConfigId ?? '')) || [];
|
|
4004
|
+
allDictionaryRecords?.filter((item) => String(item.apiConfigId ?? item.apiConfigID ?? '') === String(apiConfigId ?? '')) || [];
|
|
4003
4005
|
this.refreshDictionaryItemListsForRecord();
|
|
4004
4006
|
});
|
|
4005
4007
|
}
|
|
@@ -4009,33 +4011,47 @@ class WidgetAdminFormComponent extends BaseFormComponent {
|
|
|
4009
4011
|
*/
|
|
4010
4012
|
refreshDictionaryItemListsForRecord() {
|
|
4011
4013
|
this.query.getLists().subscribe((allLists) => {
|
|
4012
|
-
const allDictionaryItemRecords = allLists.find((list) => list.forProperty === '
|
|
4013
|
-
const itemsForDictionary = (dictionaryId) => dictionaryId
|
|
4014
|
-
? allDictionaryItemRecords.filter((item) => item.dictionaryID === dictionaryId)
|
|
4015
|
-
: [];
|
|
4014
|
+
const allDictionaryItemRecords = allLists.find((list) => list.forProperty === 'dictionaryItemId')?.records || [];
|
|
4015
|
+
const itemsForDictionary = (dictionaryId) => this.getDictionaryItemsByDictionaryId(allDictionaryItemRecords, dictionaryId);
|
|
4016
4016
|
const r = this.record;
|
|
4017
4017
|
this.headerDictionaryItems = itemsForDictionary(r.headerDictionaryID);
|
|
4018
4018
|
this.subHeaderDictionaryItems = itemsForDictionary(r.subHeaderDictionaryID);
|
|
4019
|
-
this.dictionaryItemArray = (r.dataItems || []).map((item) => itemsForDictionary(item.dictionaryID));
|
|
4020
|
-
this.badgeDictionaryItemArray = (r.badges || []).map((badge) => itemsForDictionary(badge.dictionaryID));
|
|
4019
|
+
this.dictionaryItemArray = (r.dataItems || []).map((item) => itemsForDictionary(item.dataDictionaryId || item.dictionaryID));
|
|
4020
|
+
this.badgeDictionaryItemArray = (r.badges || []).map((badge) => itemsForDictionary(badge.dataDictionaryId || badge.dictionaryID));
|
|
4021
4021
|
});
|
|
4022
4022
|
}
|
|
4023
|
+
getDictionaryItemsByDictionaryId(allDictionaryItemRecords, dictionaryId) {
|
|
4024
|
+
if (!dictionaryId) {
|
|
4025
|
+
return [];
|
|
4026
|
+
}
|
|
4027
|
+
const byLegacyDictionaryId = allDictionaryItemRecords.filter((item) => item.dataDictionaryId === dictionaryId);
|
|
4028
|
+
if (byLegacyDictionaryId.length > 0) {
|
|
4029
|
+
return byLegacyDictionaryId;
|
|
4030
|
+
}
|
|
4031
|
+
const selectedDictionary = this.dictionaries.find((d) => d._id === dictionaryId);
|
|
4032
|
+
const dictionaryItemsIds = selectedDictionary?.dictionaryItemsIds || [];
|
|
4033
|
+
if (!Array.isArray(dictionaryItemsIds) || dictionaryItemsIds.length === 0) {
|
|
4034
|
+
return [];
|
|
4035
|
+
}
|
|
4036
|
+
const dictionaryItemsIdSet = new Set(dictionaryItemsIds.map((id) => String(id)));
|
|
4037
|
+
return allDictionaryItemRecords.filter((item) => dictionaryItemsIdSet.has(String(item._id)));
|
|
4038
|
+
}
|
|
4023
4039
|
handleHeaderDictionarySelect(dictionaryId) {
|
|
4024
4040
|
this.query.getLists().subscribe((allLists) => {
|
|
4025
|
-
const allDictionaryItemRecords = allLists.find((list) => list.forProperty === '
|
|
4026
|
-
this.headerDictionaryItems = allDictionaryItemRecords
|
|
4041
|
+
const allDictionaryItemRecords = allLists.find((list) => list.forProperty === 'dictionaryItemId')?.records;
|
|
4042
|
+
this.headerDictionaryItems = this.getDictionaryItemsByDictionaryId(allDictionaryItemRecords || [], dictionaryId);
|
|
4027
4043
|
});
|
|
4028
4044
|
}
|
|
4029
4045
|
handleSubHeaderDictionarySelect(dictionaryId) {
|
|
4030
4046
|
this.query.getLists().subscribe((allLists) => {
|
|
4031
|
-
const allDictionaryItemRecords = allLists.find((list) => list.forProperty === '
|
|
4032
|
-
this.subHeaderDictionaryItems = allDictionaryItemRecords
|
|
4047
|
+
const allDictionaryItemRecords = allLists.find((list) => list.forProperty === 'dictionaryItemId')?.records;
|
|
4048
|
+
this.subHeaderDictionaryItems = this.getDictionaryItemsByDictionaryId(allDictionaryItemRecords || [], dictionaryId);
|
|
4033
4049
|
});
|
|
4034
4050
|
}
|
|
4035
4051
|
handleWidgetItemDictionarySelect(dictionaryId, index) {
|
|
4036
4052
|
this.query.getLists().subscribe((allLists) => {
|
|
4037
|
-
const allDictionaryItemRecords = allLists.find((list) => list.forProperty === '
|
|
4038
|
-
this.dictionaryItemArray[index] = allDictionaryItemRecords
|
|
4053
|
+
const allDictionaryItemRecords = allLists.find((list) => list.forProperty === 'dictionaryItemId')?.records;
|
|
4054
|
+
this.dictionaryItemArray[index] = this.getDictionaryItemsByDictionaryId(allDictionaryItemRecords || [], dictionaryId);
|
|
4039
4055
|
});
|
|
4040
4056
|
}
|
|
4041
4057
|
handleBadgeAddBtnClick() {
|
|
@@ -4043,8 +4059,10 @@ class WidgetAdminFormComponent extends BaseFormComponent {
|
|
|
4043
4059
|
return;
|
|
4044
4060
|
if (Array.isArray(this.record.badges)) {
|
|
4045
4061
|
const hasEmptyBadge = this.record.badges.some((badge) => {
|
|
4046
|
-
const
|
|
4047
|
-
const
|
|
4062
|
+
const dictionaryId = badge.dataDictionaryId || badge.dictionaryID;
|
|
4063
|
+
const dictionaryItemId = badge.dictionaryItemId || badge.dictionaryItemID;
|
|
4064
|
+
const isDictionaryEmpty = !dictionaryId || dictionaryId.trim() === SHARED.EMPTY;
|
|
4065
|
+
const isDictionaryItemEmpty = !dictionaryItemId || dictionaryItemId.trim() === SHARED.EMPTY;
|
|
4048
4066
|
return isDictionaryItemEmpty && isDictionaryEmpty;
|
|
4049
4067
|
});
|
|
4050
4068
|
if (hasEmptyBadge) {
|
|
@@ -4059,8 +4077,8 @@ class WidgetAdminFormComponent extends BaseFormComponent {
|
|
|
4059
4077
|
}
|
|
4060
4078
|
handleBadgeDictionarySelect(dictionaryId, index) {
|
|
4061
4079
|
this.query.getLists().subscribe((allLists) => {
|
|
4062
|
-
const allDictionaryItemRecords = allLists.find((list) => list.forProperty === '
|
|
4063
|
-
this.badgeDictionaryItemArray[index] = allDictionaryItemRecords
|
|
4080
|
+
const allDictionaryItemRecords = allLists.find((list) => list.forProperty === 'dictionaryItemId')?.records;
|
|
4081
|
+
this.badgeDictionaryItemArray[index] = this.getDictionaryItemsByDictionaryId(allDictionaryItemRecords || [], dictionaryId);
|
|
4064
4082
|
});
|
|
4065
4083
|
}
|
|
4066
4084
|
handleDeleteBadge(index) {
|
|
@@ -4085,31 +4103,38 @@ class WidgetAdminFormComponent extends BaseFormComponent {
|
|
|
4085
4103
|
* Text-box controls expect stringified JSON; API returns nested objects → "[object Object]" without this.
|
|
4086
4104
|
*/
|
|
4087
4105
|
normalizeLoadedRecordStyles(record) {
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
}
|
|
4106
|
+
// Always normalize top-level style for text-box binding.
|
|
4107
|
+
record.style = this.service.coerceStyleToJsonText(record.style);
|
|
4091
4108
|
record.dataItems?.forEach((item) => {
|
|
4092
|
-
|
|
4093
|
-
item.style = this.service.coerceStyleToJsonText(item.style);
|
|
4094
|
-
}
|
|
4109
|
+
item.style = this.service.coerceStyleToJsonText(item.style);
|
|
4095
4110
|
});
|
|
4096
4111
|
record.badges?.forEach((badge) => {
|
|
4097
|
-
|
|
4098
|
-
badge.style = this.service.coerceStyleToJsonText(badge.style);
|
|
4099
|
-
}
|
|
4112
|
+
badge.style = this.service.coerceStyleToJsonText(badge.style);
|
|
4100
4113
|
});
|
|
4101
4114
|
}
|
|
4102
4115
|
handleSubmit() {
|
|
4103
4116
|
this.record.style = this.service.parseStylePayload(this.record.style);
|
|
4104
|
-
this.record.dataItems = this.record.dataItems.map((item) =>
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4117
|
+
this.record.dataItems = this.record.dataItems.map((item) => {
|
|
4118
|
+
const raw = item;
|
|
4119
|
+
const { dataDictionaryId, dictionaryItemId, ...rest } = raw;
|
|
4120
|
+
return {
|
|
4121
|
+
...rest,
|
|
4122
|
+
dictionaryID: dataDictionaryId || raw.dictionaryID || '',
|
|
4123
|
+
dictionaryItemID: dictionaryItemId || raw.dictionaryItemID || '',
|
|
4124
|
+
style: this.service.parseStylePayload(raw.style),
|
|
4125
|
+
};
|
|
4126
|
+
});
|
|
4108
4127
|
if (this.record.badges && Array.isArray(this.record.badges)) {
|
|
4109
|
-
this.record.badges = this.record.badges.map((badge) =>
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4128
|
+
this.record.badges = this.record.badges.map((badge) => {
|
|
4129
|
+
const raw = badge;
|
|
4130
|
+
const { dataDictionaryId, dictionaryItemId, ...rest } = raw;
|
|
4131
|
+
return {
|
|
4132
|
+
...rest,
|
|
4133
|
+
dictionaryID: dataDictionaryId || raw.dictionaryID || '',
|
|
4134
|
+
dictionaryItemID: dictionaryItemId || raw.dictionaryItemID || '',
|
|
4135
|
+
style: this.service.parseStylePayload(raw.style),
|
|
4136
|
+
};
|
|
4137
|
+
});
|
|
4113
4138
|
}
|
|
4114
4139
|
else {
|
|
4115
4140
|
this.record.badges = [];
|