cat-qw-lib 2.6.33 → 2.6.35
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
CHANGED
|
@@ -3986,6 +3986,21 @@ class WidgetAdminFormComponent extends BaseFormComponent {
|
|
|
3986
3986
|
this.handleAPIChange(this.record.apiConfigId);
|
|
3987
3987
|
});
|
|
3988
3988
|
}
|
|
3989
|
+
/**
|
|
3990
|
+
* Widget Items / Badges dropdowns bind to dictionaryID + dictionaryItemID (template).
|
|
3991
|
+
* API may send dataDictionaryId + dictionaryItemID (or any mix). Keep both in sync.
|
|
3992
|
+
*/
|
|
3993
|
+
syncRowDictionaryKeys(row) {
|
|
3994
|
+
const dictionaryId = row?.dataDictionaryId || row?.dictionaryID || '';
|
|
3995
|
+
const dictionaryItemId = row?.dictionaryItemId || row?.dictionaryItemID || '';
|
|
3996
|
+
return {
|
|
3997
|
+
...row,
|
|
3998
|
+
dataDictionaryId: dictionaryId,
|
|
3999
|
+
dictionaryID: dictionaryId,
|
|
4000
|
+
dictionaryItemId: dictionaryItemId,
|
|
4001
|
+
dictionaryItemID: dictionaryItemId,
|
|
4002
|
+
};
|
|
4003
|
+
}
|
|
3989
4004
|
/**
|
|
3990
4005
|
* Normalize backend dictionary keys into UI form keys on edit load.
|
|
3991
4006
|
* This lets dropdowns preselect values immediately without user re-selection.
|
|
@@ -3993,16 +4008,8 @@ class WidgetAdminFormComponent extends BaseFormComponent {
|
|
|
3993
4008
|
normalizeIncomingDictionaryAliases(record) {
|
|
3994
4009
|
return {
|
|
3995
4010
|
...record,
|
|
3996
|
-
dataItems: (record.dataItems || []).map((item) => (
|
|
3997
|
-
|
|
3998
|
-
dataDictionaryId: item.dataDictionaryId || item.dictionaryID || '',
|
|
3999
|
-
dictionaryItemId: item.dictionaryItemId || item.dictionaryItemID || '',
|
|
4000
|
-
})),
|
|
4001
|
-
badges: (record.badges || []).map((badge) => ({
|
|
4002
|
-
...badge,
|
|
4003
|
-
dataDictionaryId: badge.dataDictionaryId || badge.dictionaryID || '',
|
|
4004
|
-
dictionaryItemId: badge.dictionaryItemId || badge.dictionaryItemID || '',
|
|
4005
|
-
})),
|
|
4011
|
+
dataItems: (record.dataItems || []).map((item) => this.syncRowDictionaryKeys(item)),
|
|
4012
|
+
badges: (record.badges || []).map((badge) => this.syncRowDictionaryKeys(badge)),
|
|
4006
4013
|
};
|
|
4007
4014
|
}
|
|
4008
4015
|
handleWidgetItemAddBtnClick() {
|
|
@@ -4089,6 +4096,9 @@ class WidgetAdminFormComponent extends BaseFormComponent {
|
|
|
4089
4096
|
});
|
|
4090
4097
|
}
|
|
4091
4098
|
const itemsForDictionary = (dictionaryId) => this.getDictionaryItemsByDictionaryId(allDictionaryItemRecords, dictionaryId);
|
|
4099
|
+
// Edit payload can miss dictionaryID/dataDictionaryId while providing dictionaryItemID.
|
|
4100
|
+
// Infer dictionary ids first so dictionary dropdowns can preselect correctly.
|
|
4101
|
+
this.hydrateMissingDictionaryIdsFromItemSelection(allDictionaryItemRecords);
|
|
4092
4102
|
const r = this.record;
|
|
4093
4103
|
this.headerDictionaryItems = itemsForDictionary(r.headerDictionaryID);
|
|
4094
4104
|
this.subHeaderDictionaryItems = itemsForDictionary(r.subHeaderDictionaryID);
|
|
@@ -4096,6 +4106,41 @@ class WidgetAdminFormComponent extends BaseFormComponent {
|
|
|
4096
4106
|
this.badgeDictionaryItemArray = (r.badges || []).map((badge) => itemsForDictionary(badge.dataDictionaryId || badge.dictionaryID));
|
|
4097
4107
|
});
|
|
4098
4108
|
}
|
|
4109
|
+
hydrateMissingDictionaryIdsFromItemSelection(allDictionaryItemRecords) {
|
|
4110
|
+
const inferDictionaryId = (dictionaryItemId) => {
|
|
4111
|
+
if (!dictionaryItemId) {
|
|
4112
|
+
return '';
|
|
4113
|
+
}
|
|
4114
|
+
const matched = allDictionaryItemRecords.find((item) => String(item?._id) === String(dictionaryItemId));
|
|
4115
|
+
return (matched?.dataDictionaryId || matched?.dictionaryID || '');
|
|
4116
|
+
};
|
|
4117
|
+
this.record.dataItems = (this.record.dataItems || []).map((item) => {
|
|
4118
|
+
const currentDictionaryId = item?.dataDictionaryId || item?.dictionaryID || '';
|
|
4119
|
+
const dictionaryItemId = item?.dictionaryItemId || item?.dictionaryItemID || '';
|
|
4120
|
+
const inferredDictionaryId = inferDictionaryId(dictionaryItemId);
|
|
4121
|
+
const resolvedDictId = currentDictionaryId || inferredDictionaryId || this.record.headerDictionaryID || '';
|
|
4122
|
+
return this.syncRowDictionaryKeys({
|
|
4123
|
+
...item,
|
|
4124
|
+
dataDictionaryId: resolvedDictId,
|
|
4125
|
+
dictionaryID: resolvedDictId,
|
|
4126
|
+
dictionaryItemId: dictionaryItemId,
|
|
4127
|
+
dictionaryItemID: dictionaryItemId,
|
|
4128
|
+
});
|
|
4129
|
+
});
|
|
4130
|
+
this.record.badges = (this.record.badges || []).map((badge) => {
|
|
4131
|
+
const currentDictionaryId = badge?.dataDictionaryId || badge?.dictionaryID || '';
|
|
4132
|
+
const dictionaryItemId = badge?.dictionaryItemId || badge?.dictionaryItemID || '';
|
|
4133
|
+
const inferredDictionaryId = inferDictionaryId(dictionaryItemId);
|
|
4134
|
+
const resolvedDictId = currentDictionaryId || inferredDictionaryId || this.record.headerDictionaryID || '';
|
|
4135
|
+
return this.syncRowDictionaryKeys({
|
|
4136
|
+
...badge,
|
|
4137
|
+
dataDictionaryId: resolvedDictId,
|
|
4138
|
+
dictionaryID: resolvedDictId,
|
|
4139
|
+
dictionaryItemId: dictionaryItemId,
|
|
4140
|
+
dictionaryItemID: dictionaryItemId,
|
|
4141
|
+
});
|
|
4142
|
+
});
|
|
4143
|
+
}
|
|
4099
4144
|
getDictionaryItemsByDictionaryId(allDictionaryItemRecords, dictionaryId) {
|
|
4100
4145
|
if (!dictionaryId) {
|
|
4101
4146
|
return [];
|
|
@@ -4210,22 +4255,26 @@ class WidgetAdminFormComponent extends BaseFormComponent {
|
|
|
4210
4255
|
this.record.style = this.service.parseStylePayload(this.record.style);
|
|
4211
4256
|
this.record.dataItems = this.record.dataItems.map((item) => {
|
|
4212
4257
|
const raw = item;
|
|
4213
|
-
const
|
|
4258
|
+
const dictionaryID = raw.dataDictionaryId || raw.dictionaryID || '';
|
|
4259
|
+
const dictionaryItemID = raw.dictionaryItemId || raw.dictionaryItemID || '';
|
|
4260
|
+
const { dataDictionaryId: _dd, dictionaryItemId: _di, ...rest } = raw;
|
|
4214
4261
|
return {
|
|
4215
4262
|
...rest,
|
|
4216
|
-
dictionaryID
|
|
4217
|
-
dictionaryItemID
|
|
4263
|
+
dictionaryID,
|
|
4264
|
+
dictionaryItemID,
|
|
4218
4265
|
style: this.service.parseStylePayload(raw.style),
|
|
4219
4266
|
};
|
|
4220
4267
|
});
|
|
4221
4268
|
if (this.record.badges && Array.isArray(this.record.badges)) {
|
|
4222
4269
|
this.record.badges = this.record.badges.map((badge) => {
|
|
4223
4270
|
const raw = badge;
|
|
4224
|
-
const
|
|
4271
|
+
const dictionaryID = raw.dataDictionaryId || raw.dictionaryID || '';
|
|
4272
|
+
const dictionaryItemID = raw.dictionaryItemId || raw.dictionaryItemID || '';
|
|
4273
|
+
const { dataDictionaryId: _dd, dictionaryItemId: _di, ...rest } = raw;
|
|
4225
4274
|
return {
|
|
4226
4275
|
...rest,
|
|
4227
|
-
dictionaryID
|
|
4228
|
-
dictionaryItemID
|
|
4276
|
+
dictionaryID,
|
|
4277
|
+
dictionaryItemID,
|
|
4229
4278
|
style: this.service.parseStylePayload(raw.style),
|
|
4230
4279
|
};
|
|
4231
4280
|
});
|