cat-qw-lib 2.6.34 → 2.6.36
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/cat-qw-lib.d.ts.map +1 -0
- package/fesm2022/cat-qw-lib.mjs +280 -53
- package/fesm2022/cat-qw-lib.mjs.map +1 -1
- package/lib/admin/action-admin/action-admin.module.d.ts.map +1 -0
- package/lib/admin/action-admin/components/admin-action-form/admin-action-form.component.d.ts.map +1 -0
- package/lib/admin/action-admin/components/admin-action-list/admin-action-list.component.d.ts.map +1 -0
- package/lib/admin/action-admin/models/admin-action.model.d.ts.map +1 -0
- package/lib/admin/action-admin/state/admin-action.service.d.ts.map +1 -0
- package/lib/admin/action-admin/state/admin-action.store.d.ts.map +1 -0
- package/lib/admin/api-admin/api-admin.module.d.ts.map +1 -0
- package/lib/admin/api-admin/components/api-admin-form/api-admin-form.component.d.ts.map +1 -0
- package/lib/admin/api-admin/components/api-admin-list/api-admin-list.component.d.ts.map +1 -0
- package/lib/admin/api-admin/models/api-config.model.d.ts.map +1 -0
- package/lib/admin/api-admin/state/api-admin.service.d.ts.map +1 -0
- package/lib/admin/api-admin/state/api-admin.store.d.ts.map +1 -0
- package/lib/admin/dd-admin/components/dd-admin-form/dd-admin-form.component.d.ts.map +1 -0
- package/lib/admin/dd-admin/components/dd-admin-item-form/dd-admin-item-form.component.d.ts.map +1 -0
- package/lib/admin/dd-admin/components/dd-admin-list/dd-admin-list.component.d.ts.map +1 -0
- package/lib/admin/dd-admin/dd-admin.module.d.ts.map +1 -0
- package/lib/admin/dd-admin/models/api-property.model.d.ts.map +1 -0
- package/lib/admin/dd-admin/models/dd-attribute-sidebar-view.model.d.ts.map +1 -0
- package/lib/admin/dd-admin/models/dictionary.model.d.ts.map +1 -0
- package/lib/admin/dd-admin/state/dictionary.query.d.ts.map +1 -0
- package/lib/admin/dd-admin/state/dictionary.service.d.ts.map +1 -0
- package/lib/admin/dd-admin/state/dictionary.store.d.ts.map +1 -0
- package/lib/admin/queue-admin/components/queue-admin-form/queue-admin-form.component.d.ts.map +1 -0
- package/lib/admin/queue-admin/components/queue-admin-list/queue-admin-list.component.d.ts.map +1 -0
- package/lib/admin/queue-admin/components/queue-application-list/queue-application-list.component.d.ts.map +1 -0
- package/lib/admin/queue-admin/models/queue.model.d.ts.map +1 -0
- package/lib/admin/queue-admin/queue-admin-routing.module.d.ts.map +1 -0
- package/lib/admin/queue-admin/queue-admin.module.d.ts.map +1 -0
- package/lib/admin/queue-admin/state/queue.query.d.ts.map +1 -0
- package/lib/admin/queue-admin/state/queue.service.d.ts.map +1 -0
- package/lib/admin/queue-admin/state/queue.state.d.ts.map +1 -0
- package/lib/admin/queue-admin/state/queue.store.d.ts.map +1 -0
- package/lib/admin/template-admin/components/template-admin-form/template-admin-form.component.d.ts.map +1 -0
- package/lib/admin/template-admin/components/template-admin-list/template-admin-list.component.d.ts.map +1 -0
- package/lib/admin/template-admin/models/template.model.d.ts.map +1 -0
- package/lib/admin/template-admin/state/template-admin.query.d.ts.map +1 -0
- package/lib/admin/template-admin/state/template-admin.service.d.ts.map +1 -0
- package/lib/admin/template-admin/state/template-admin.store.d.ts.map +1 -0
- package/lib/admin/template-admin/template-admin.module.d.ts.map +1 -0
- package/lib/admin/widget-admin/components/widget-admin-form/widget-admin-form.component.d.ts +12 -0
- package/lib/admin/widget-admin/components/widget-admin-form/widget-admin-form.component.d.ts.map +1 -0
- package/lib/admin/widget-admin/components/widget-admin-list/widget-admin-list.component.d.ts.map +1 -0
- package/lib/admin/widget-admin/models/widget.model.d.ts.map +1 -0
- package/lib/admin/widget-admin/state/widget-admin.query.d.ts.map +1 -0
- package/lib/admin/widget-admin/state/widget-admin.service.d.ts +24 -5
- package/lib/admin/widget-admin/state/widget-admin.service.d.ts.map +1 -0
- package/lib/admin/widget-admin/state/widget-admin.store.d.ts.map +1 -0
- package/lib/admin/widget-admin/widget-admin.module.d.ts.map +1 -0
- package/lib/queue/components/queue-container/queue-container.component.d.ts.map +1 -0
- package/lib/queue/components/queue-filter-dropdown/queue-filter-dropdown.component.d.ts.map +1 -0
- package/lib/queue/components/queue-item/queue-item.component.d.ts.map +1 -0
- package/lib/queue/components/queue-list/queue-list.component.d.ts.map +1 -0
- package/lib/queue/components/queue-record-table/queue-record-table.component.d.ts.map +1 -0
- package/lib/queue/components/queue-search/queue-search.component.d.ts.map +1 -0
- package/lib/queue/models/queue.model.d.ts.map +1 -0
- package/lib/queue/queue-routing.module.d.ts.map +1 -0
- package/lib/queue/queue.module.d.ts.map +1 -0
- package/lib/queue/services/queue-business.service.d.ts.map +1 -0
- package/lib/queue/services/queue-filter-dropdown.service.d.ts.map +1 -0
- package/lib/queue/services/queue-record-table-builder.service.d.ts.map +1 -0
- package/lib/queue/state/queue.query.d.ts.map +1 -0
- package/lib/queue/state/queue.service.d.ts.map +1 -0
- package/lib/queue/state/queue.state.d.ts.map +1 -0
- package/lib/queue/state/queue.store.d.ts.map +1 -0
- package/lib/shared/_base/base-container/base-container.component.d.ts.map +1 -0
- package/lib/shared/_base/base-control/base-control.component.d.ts.map +1 -0
- package/lib/shared/_base/base-form/base-form.component.d.ts.map +1 -0
- package/lib/shared/_base/base-list/base-list.component.d.ts.map +1 -0
- package/lib/shared/components/form-container/form-container.component.d.ts.map +1 -0
- package/lib/shared/components/list/block-list.component.d.ts.map +1 -0
- package/lib/shared/components/queue-search-customer/queue-search-customer.component.d.ts.map +1 -0
- package/lib/shared/components/sidebar/sidebar.component.d.ts.map +1 -0
- package/lib/shared/components/skeleton/skeleton.component.d.ts.map +1 -0
- package/lib/shared/constant/CSS.d.ts.map +1 -0
- package/lib/shared/constant/DATASOURCES.d.ts.map +1 -0
- package/lib/shared/constant/ERROR.d.ts.map +1 -0
- package/lib/shared/constant/HEADERS.d.ts.map +1 -0
- package/lib/shared/constant/LIST-CONFIG.d.ts.map +1 -0
- package/lib/shared/constant/LOOKUPS.d.ts.map +1 -0
- package/lib/shared/constant/MESSAGES.d.ts.map +1 -0
- package/lib/shared/constant/PERMISSION.d.ts.map +1 -0
- package/lib/shared/constant/ROUTES.d.ts.map +1 -0
- package/lib/shared/constant/SHARED.d.ts.map +1 -0
- package/lib/shared/constant/URLS.d.ts.map +1 -0
- package/lib/shared/controls/button/button.component.d.ts.map +1 -0
- package/lib/shared/controls/check-box/check-box.component.d.ts.map +1 -0
- package/lib/shared/controls/date/date.component.d.ts.map +1 -0
- package/lib/shared/controls/dropdown/dropdown.component.d.ts.map +1 -0
- package/lib/shared/controls/file-upload/file-upload.component.d.ts.map +1 -0
- package/lib/shared/controls/password/password.component.d.ts.map +1 -0
- package/lib/shared/controls/text-area/text-area.component.d.ts.map +1 -0
- package/lib/shared/controls/text-box/text-box.component.d.ts.map +1 -0
- package/lib/shared/controls/username/username.component.d.ts.map +1 -0
- package/lib/shared/directives/permission.directive.d.ts.map +1 -0
- package/lib/shared/index.d.ts.map +1 -0
- package/lib/shared/models/attribute.model.d.ts.map +1 -0
- package/lib/shared/models/base.model.d.ts.map +1 -0
- package/lib/shared/models/custom-widget.model.d.ts.map +1 -0
- package/lib/shared/models/list.model.d.ts.map +1 -0
- package/lib/shared/models/meta-data.model.d.ts.map +1 -0
- package/lib/shared/pipe/capitalize-words.pipe.d.ts.map +1 -0
- package/lib/shared/services/app-config.service.d.ts.map +1 -0
- package/lib/shared/services/auth/auth.guard.d.ts.map +1 -0
- package/lib/shared/services/custom-widget.service.d.ts.map +1 -0
- package/lib/shared/services/data-transformer.service.d.ts.map +1 -0
- package/lib/shared/services/date-parser.service.d.ts.map +1 -0
- package/lib/shared/services/form-state.service.d.ts.map +1 -0
- package/lib/shared/services/list.service.d.ts.map +1 -0
- package/lib/shared/services/session.service.d.ts.map +1 -0
- package/lib/shared/services/style-builder.service.d.ts.map +1 -0
- package/lib/shared/services/table.builder.d.ts.map +1 -0
- package/lib/shared/services/validator.service.d.ts.map +1 -0
- package/lib/shared/shared.module.d.ts.map +1 -0
- package/lib/shared/state/base.query.d.ts.map +1 -0
- package/lib/shared/state/base.service.d.ts.map +1 -0
- package/lib/shared/state/base.state.d.ts.map +1 -0
- package/lib/shared/state/base.store.d.ts.map +1 -0
- package/lib/shared/table-primary/components/table-primary.component.d.ts.map +1 -0
- package/lib/shared/table-primary/models/table-primary-header.model.d.ts.map +1 -0
- package/lib/shared/table-primary/models/table-primary.model.d.ts.map +1 -0
- package/lib/shared/table-secondary/components/table-secondary.component.d.ts.map +1 -0
- package/lib/shared/table-secondary/models/table-secondary-header.model.d.ts.map +1 -0
- package/lib/shared/table-secondary/models/table-secondary.model.d.ts.map +1 -0
- package/lib/widget/components/custom-widget/custom-widget.component.d.ts.map +1 -0
- package/lib/widget/components/widget-body/widget-body.component.d.ts.map +1 -0
- package/lib/widget/components/widget-container/widget-container.component.d.ts.map +1 -0
- package/lib/widget/components/widget-footer/widget-footer.component.d.ts.map +1 -0
- package/lib/widget/components/widget-header/widget-header.component.d.ts.map +1 -0
- package/lib/widget/components/widget-item/widget-item.component.d.ts.map +1 -0
- package/lib/widget/components/widget-main/widget-main.component.d.ts.map +1 -0
- package/lib/widget/components/widget-menu/widget-menu.component.d.ts.map +1 -0
- package/lib/widget/components/widget-menu-body/widget-menu-body.component.d.ts.map +1 -0
- package/lib/widget/components/widget-menu-container/widget-menu-container.component.d.ts.map +1 -0
- package/lib/widget/components/widget-menu-header/widget-menu-header.component.d.ts.map +1 -0
- package/lib/widget/components/widget-menu-item/widget-menu-item.component.d.ts.map +1 -0
- package/lib/widget/components/widget-row-tile/widget-row-tile.component.d.ts.map +1 -0
- package/lib/widget/models/custom-widget.model.d.ts.map +1 -0
- package/lib/widget/models/progress-chart.model.d.ts.map +1 -0
- package/lib/widget/models/widget.model.d.ts.map +1 -0
- package/lib/widget/state/widget.query.d.ts.map +1 -0
- package/lib/widget/state/widget.service.d.ts.map +1 -0
- package/lib/widget/state/widget.store.d.ts.map +1 -0
- package/lib/widget/widget.module.d.ts.map +1 -0
- package/package.json +1 -1
- package/public-api.d.ts.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cat-qw-lib.d.ts","sourceRoot":"","sources":["../../projects/cat-qw-lib/src/cat-qw-lib.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,cAAc,cAAc,CAAC"}
|
package/fesm2022/cat-qw-lib.mjs
CHANGED
|
@@ -3710,6 +3710,38 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImpor
|
|
|
3710
3710
|
args: [{ providedIn: 'root' }]
|
|
3711
3711
|
}], ctorParameters: () => [] });
|
|
3712
3712
|
|
|
3713
|
+
/** Widget root `record.style` — user may pass JSON objects; API expects JSON strings. */
|
|
3714
|
+
const WIDGET_ROOT_STYLE_JSON_KEYS = [
|
|
3715
|
+
'headerStyle',
|
|
3716
|
+
'subHeaderStyle',
|
|
3717
|
+
'headerIconStyle',
|
|
3718
|
+
'styleExpression',
|
|
3719
|
+
'widgetStyle',
|
|
3720
|
+
'widgetCardStyle',
|
|
3721
|
+
'widgetCardStyleExpression',
|
|
3722
|
+
];
|
|
3723
|
+
/** `dataItems[].style` */
|
|
3724
|
+
const WIDGET_DATA_ITEM_STYLE_JSON_KEYS = [
|
|
3725
|
+
'value',
|
|
3726
|
+
'keyIconStyle',
|
|
3727
|
+
'valueIconStyleExpression',
|
|
3728
|
+
'valueIconStyle',
|
|
3729
|
+
'itemStyle',
|
|
3730
|
+
'styleExpression',
|
|
3731
|
+
];
|
|
3732
|
+
/** `badges[].style` */
|
|
3733
|
+
const WIDGET_BADGE_STYLE_JSON_KEYS = [
|
|
3734
|
+
'value',
|
|
3735
|
+
'valueIconStyleExpression',
|
|
3736
|
+
'valueIconStyle',
|
|
3737
|
+
'itemStyle',
|
|
3738
|
+
'styleExpression',
|
|
3739
|
+
];
|
|
3740
|
+
function uniqueSortedKeys(...groups) {
|
|
3741
|
+
return [...new Set(groups.flat())];
|
|
3742
|
+
}
|
|
3743
|
+
/** Union for repairing malformed style text (e.g. `"styleExpression": "{"a":1}"`). */
|
|
3744
|
+
const ALL_STYLE_JSON_REPAIR_KEYS = uniqueSortedKeys([...WIDGET_ROOT_STYLE_JSON_KEYS], [...WIDGET_DATA_ITEM_STYLE_JSON_KEYS], [...WIDGET_BADGE_STYLE_JSON_KEYS]);
|
|
3713
3745
|
/**
|
|
3714
3746
|
* Service for managing widget configurations.
|
|
3715
3747
|
*/
|
|
@@ -3767,13 +3799,27 @@ class WidgetAdminService extends BaseService {
|
|
|
3767
3799
|
return null;
|
|
3768
3800
|
}
|
|
3769
3801
|
}
|
|
3802
|
+
styleJsonKeysForKind(kind) {
|
|
3803
|
+
switch (kind) {
|
|
3804
|
+
case 'widget':
|
|
3805
|
+
return WIDGET_ROOT_STYLE_JSON_KEYS;
|
|
3806
|
+
case 'item':
|
|
3807
|
+
return WIDGET_DATA_ITEM_STYLE_JSON_KEYS;
|
|
3808
|
+
case 'badge':
|
|
3809
|
+
return WIDGET_BADGE_STYLE_JSON_KEYS;
|
|
3810
|
+
default:
|
|
3811
|
+
return WIDGET_ROOT_STYLE_JSON_KEYS;
|
|
3812
|
+
}
|
|
3813
|
+
}
|
|
3770
3814
|
/**
|
|
3771
|
-
*
|
|
3772
|
-
*
|
|
3815
|
+
* For the listed keys only: plain objects → JSON string so the payload matches the API.
|
|
3816
|
+
* Other keys (width, hasSeparator, plain strings, etc.) are unchanged.
|
|
3773
3817
|
*/
|
|
3774
|
-
|
|
3818
|
+
stringifyStyleJsonKeys(style, keys) {
|
|
3775
3819
|
const out = { ...style };
|
|
3776
|
-
for (const key of
|
|
3820
|
+
for (const key of keys) {
|
|
3821
|
+
if (!Object.prototype.hasOwnProperty.call(out, key))
|
|
3822
|
+
continue;
|
|
3777
3823
|
const v = out[key];
|
|
3778
3824
|
if (v !== null && typeof v === 'object' && !Array.isArray(v)) {
|
|
3779
3825
|
out[key] = JSON.stringify(v);
|
|
@@ -3781,10 +3827,117 @@ class WidgetAdminService extends BaseService {
|
|
|
3781
3827
|
}
|
|
3782
3828
|
return out;
|
|
3783
3829
|
}
|
|
3830
|
+
/**
|
|
3831
|
+
* Minify JSON blob strings for known keys (parseable object/array → stable JSON string).
|
|
3832
|
+
*/
|
|
3833
|
+
canonicalizeJsonBlobStrings(style, keys) {
|
|
3834
|
+
const out = { ...style };
|
|
3835
|
+
for (const key of keys) {
|
|
3836
|
+
if (!Object.prototype.hasOwnProperty.call(out, key))
|
|
3837
|
+
continue;
|
|
3838
|
+
const v = out[key];
|
|
3839
|
+
if (typeof v !== 'string')
|
|
3840
|
+
continue;
|
|
3841
|
+
const t = v.trim();
|
|
3842
|
+
if (!t || (t[0] !== '{' && t[0] !== '['))
|
|
3843
|
+
continue;
|
|
3844
|
+
try {
|
|
3845
|
+
const parsed = JSON.parse(t);
|
|
3846
|
+
if (typeof parsed === 'object' && parsed !== null) {
|
|
3847
|
+
out[key] = JSON.stringify(parsed);
|
|
3848
|
+
}
|
|
3849
|
+
}
|
|
3850
|
+
catch {
|
|
3851
|
+
/* keep original string */
|
|
3852
|
+
}
|
|
3853
|
+
}
|
|
3854
|
+
return out;
|
|
3855
|
+
}
|
|
3856
|
+
/** Final pass before PUT/POST for this style level. */
|
|
3857
|
+
finalizeStylePayloadForApi(style, keys) {
|
|
3858
|
+
const normalized = this.stringifyStyleJsonKeys(style, keys);
|
|
3859
|
+
return this.canonicalizeJsonBlobStrings(normalized, keys);
|
|
3860
|
+
}
|
|
3861
|
+
/**
|
|
3862
|
+
* Fixes `"styleExpression": "{"a":1}"` (invalid JSON) by re-encoding the inner object as a proper JSON string value.
|
|
3863
|
+
*/
|
|
3864
|
+
repairBrokenQuotedJsonObjectValues(raw, keys) {
|
|
3865
|
+
let s = raw;
|
|
3866
|
+
for (const key of keys) {
|
|
3867
|
+
const label = `"${key}"`;
|
|
3868
|
+
let searchFrom = 0;
|
|
3869
|
+
while (searchFrom < s.length) {
|
|
3870
|
+
const keyPos = s.indexOf(label, searchFrom);
|
|
3871
|
+
if (keyPos === -1)
|
|
3872
|
+
break;
|
|
3873
|
+
const afterKey = keyPos + label.length;
|
|
3874
|
+
let p = afterKey;
|
|
3875
|
+
while (p < s.length && /\s/.test(s[p]))
|
|
3876
|
+
p++;
|
|
3877
|
+
if (p >= s.length || s[p] !== ':') {
|
|
3878
|
+
searchFrom = afterKey;
|
|
3879
|
+
continue;
|
|
3880
|
+
}
|
|
3881
|
+
p++;
|
|
3882
|
+
while (p < s.length && /\s/.test(s[p]))
|
|
3883
|
+
p++;
|
|
3884
|
+
if (p >= s.length || s[p] !== '"') {
|
|
3885
|
+
searchFrom = afterKey;
|
|
3886
|
+
continue;
|
|
3887
|
+
}
|
|
3888
|
+
const openQuote = p;
|
|
3889
|
+
p++;
|
|
3890
|
+
if (p >= s.length || s[p] !== '{') {
|
|
3891
|
+
searchFrom = afterKey;
|
|
3892
|
+
continue;
|
|
3893
|
+
}
|
|
3894
|
+
const braceStart = p;
|
|
3895
|
+
let depth = 0;
|
|
3896
|
+
let q = p;
|
|
3897
|
+
for (; q < s.length; q++) {
|
|
3898
|
+
const ch = s[q];
|
|
3899
|
+
if (ch === '{')
|
|
3900
|
+
depth++;
|
|
3901
|
+
else if (ch === '}') {
|
|
3902
|
+
depth--;
|
|
3903
|
+
if (depth === 0) {
|
|
3904
|
+
q++;
|
|
3905
|
+
break;
|
|
3906
|
+
}
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
if (depth !== 0) {
|
|
3910
|
+
searchFrom = afterKey;
|
|
3911
|
+
continue;
|
|
3912
|
+
}
|
|
3913
|
+
const innerJson = s.slice(braceStart, q);
|
|
3914
|
+
try {
|
|
3915
|
+
JSON.parse(innerJson);
|
|
3916
|
+
}
|
|
3917
|
+
catch {
|
|
3918
|
+
searchFrom = afterKey;
|
|
3919
|
+
continue;
|
|
3920
|
+
}
|
|
3921
|
+
let r = q;
|
|
3922
|
+
while (r < s.length && /\s/.test(s[r]))
|
|
3923
|
+
r++;
|
|
3924
|
+
if (r >= s.length || s[r] !== '"') {
|
|
3925
|
+
searchFrom = afterKey;
|
|
3926
|
+
continue;
|
|
3927
|
+
}
|
|
3928
|
+
const closeQuote = r;
|
|
3929
|
+
const encoded = JSON.stringify(innerJson);
|
|
3930
|
+
s = s.slice(0, openQuote) + encoded + s.slice(closeQuote + 1);
|
|
3931
|
+
searchFrom = openQuote + encoded.length;
|
|
3932
|
+
}
|
|
3933
|
+
}
|
|
3934
|
+
return s;
|
|
3935
|
+
}
|
|
3784
3936
|
/**
|
|
3785
3937
|
* Converts widget / item / badge style for text-box binding (avoids "[object Object]").
|
|
3786
3938
|
*/
|
|
3787
|
-
coerceStyleToJsonText(value) {
|
|
3939
|
+
coerceStyleToJsonText(value, kind = 'widget') {
|
|
3940
|
+
const keys = this.styleJsonKeysForKind(kind);
|
|
3788
3941
|
if (value === null || value === undefined) {
|
|
3789
3942
|
return '';
|
|
3790
3943
|
}
|
|
@@ -3796,7 +3949,7 @@ class WidgetAdminService extends BaseService {
|
|
|
3796
3949
|
try {
|
|
3797
3950
|
const parsed = JSON.parse(trimmed);
|
|
3798
3951
|
if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)) {
|
|
3799
|
-
const normalized = this.
|
|
3952
|
+
const normalized = this.stringifyStyleJsonKeys(parsed, keys);
|
|
3800
3953
|
return JSON.stringify(normalized, null, 2);
|
|
3801
3954
|
}
|
|
3802
3955
|
}
|
|
@@ -3806,7 +3959,7 @@ class WidgetAdminService extends BaseService {
|
|
|
3806
3959
|
return value;
|
|
3807
3960
|
}
|
|
3808
3961
|
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
3809
|
-
const normalized = this.
|
|
3962
|
+
const normalized = this.stringifyStyleJsonKeys(value, keys);
|
|
3810
3963
|
return JSON.stringify(normalized, null, 2);
|
|
3811
3964
|
}
|
|
3812
3965
|
return String(value);
|
|
@@ -3814,12 +3967,13 @@ class WidgetAdminService extends BaseService {
|
|
|
3814
3967
|
/**
|
|
3815
3968
|
* Parses style from form (string or object) and returns an object payload for API submit.
|
|
3816
3969
|
*/
|
|
3817
|
-
parseStylePayload(input) {
|
|
3970
|
+
parseStylePayload(input, kind = 'widget') {
|
|
3971
|
+
const keys = this.styleJsonKeysForKind(kind);
|
|
3818
3972
|
if (input === null || input === undefined) {
|
|
3819
3973
|
return {};
|
|
3820
3974
|
}
|
|
3821
3975
|
if (typeof input === 'object' && !Array.isArray(input)) {
|
|
3822
|
-
return input;
|
|
3976
|
+
return this.finalizeStylePayloadForApi({ ...input }, keys);
|
|
3823
3977
|
}
|
|
3824
3978
|
if (typeof input !== 'string') {
|
|
3825
3979
|
return {};
|
|
@@ -3828,16 +3982,32 @@ class WidgetAdminService extends BaseService {
|
|
|
3828
3982
|
if (!trimmed) {
|
|
3829
3983
|
return {};
|
|
3830
3984
|
}
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3985
|
+
const tryParse = (s) => {
|
|
3986
|
+
try {
|
|
3987
|
+
const parsed = JSON.parse(s);
|
|
3988
|
+
if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)) {
|
|
3989
|
+
return parsed;
|
|
3990
|
+
}
|
|
3991
|
+
}
|
|
3992
|
+
catch {
|
|
3993
|
+
/* continue */
|
|
3994
|
+
}
|
|
3995
|
+
return null;
|
|
3996
|
+
};
|
|
3997
|
+
let parsedObj = tryParse(trimmed);
|
|
3998
|
+
if (!parsedObj) {
|
|
3999
|
+
const repaired = this.repairBrokenQuotedJsonObjectValues(trimmed, ALL_STYLE_JSON_REPAIR_KEYS);
|
|
4000
|
+
parsedObj = tryParse(repaired);
|
|
3836
4001
|
}
|
|
3837
|
-
|
|
4002
|
+
if (!parsedObj) {
|
|
3838
4003
|
const fallback = this.sanitizeStyleString(trimmed);
|
|
3839
|
-
|
|
4004
|
+
if (fallback) {
|
|
4005
|
+
return this.finalizeStylePayloadForApi(fallback, keys);
|
|
4006
|
+
}
|
|
4007
|
+
const fallback2 = this.sanitizeStyleString(this.repairBrokenQuotedJsonObjectValues(trimmed, ALL_STYLE_JSON_REPAIR_KEYS));
|
|
4008
|
+
return fallback2 ? this.finalizeStylePayloadForApi(fallback2, keys) : {};
|
|
3840
4009
|
}
|
|
4010
|
+
return this.finalizeStylePayloadForApi(parsedObj, keys);
|
|
3841
4011
|
}
|
|
3842
4012
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: WidgetAdminService, deps: [{ token: i1$1.HttpClient }, { token: WidgetAdminStore }, { token: AppConfigService }, { token: ListService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3843
4013
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: WidgetAdminService, providedIn: 'root' });
|
|
@@ -3986,6 +4156,21 @@ class WidgetAdminFormComponent extends BaseFormComponent {
|
|
|
3986
4156
|
this.handleAPIChange(this.record.apiConfigId);
|
|
3987
4157
|
});
|
|
3988
4158
|
}
|
|
4159
|
+
/**
|
|
4160
|
+
* Widget Items / Badges dropdowns bind to dictionaryID + dictionaryItemID (template).
|
|
4161
|
+
* API may send dataDictionaryId + dictionaryItemID (or any mix). Keep both in sync.
|
|
4162
|
+
*/
|
|
4163
|
+
syncRowDictionaryKeys(row) {
|
|
4164
|
+
const dictionaryId = row?.dataDictionaryId || row?.dictionaryID || '';
|
|
4165
|
+
const dictionaryItemId = row?.dictionaryItemId || row?.dictionaryItemID || '';
|
|
4166
|
+
return {
|
|
4167
|
+
...row,
|
|
4168
|
+
dataDictionaryId: dictionaryId,
|
|
4169
|
+
dictionaryID: dictionaryId,
|
|
4170
|
+
dictionaryItemId: dictionaryItemId,
|
|
4171
|
+
dictionaryItemID: dictionaryItemId,
|
|
4172
|
+
};
|
|
4173
|
+
}
|
|
3989
4174
|
/**
|
|
3990
4175
|
* Normalize backend dictionary keys into UI form keys on edit load.
|
|
3991
4176
|
* This lets dropdowns preselect values immediately without user re-selection.
|
|
@@ -3993,16 +4178,8 @@ class WidgetAdminFormComponent extends BaseFormComponent {
|
|
|
3993
4178
|
normalizeIncomingDictionaryAliases(record) {
|
|
3994
4179
|
return {
|
|
3995
4180
|
...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
|
-
})),
|
|
4181
|
+
dataItems: (record.dataItems || []).map((item) => this.syncRowDictionaryKeys(item)),
|
|
4182
|
+
badges: (record.badges || []).map((badge) => this.syncRowDictionaryKeys(badge)),
|
|
4006
4183
|
};
|
|
4007
4184
|
}
|
|
4008
4185
|
handleWidgetItemAddBtnClick() {
|
|
@@ -4111,21 +4288,27 @@ class WidgetAdminFormComponent extends BaseFormComponent {
|
|
|
4111
4288
|
const currentDictionaryId = item?.dataDictionaryId || item?.dictionaryID || '';
|
|
4112
4289
|
const dictionaryItemId = item?.dictionaryItemId || item?.dictionaryItemID || '';
|
|
4113
4290
|
const inferredDictionaryId = inferDictionaryId(dictionaryItemId);
|
|
4114
|
-
|
|
4291
|
+
const resolvedDictId = currentDictionaryId || inferredDictionaryId || this.record.headerDictionaryID || '';
|
|
4292
|
+
return this.syncRowDictionaryKeys({
|
|
4115
4293
|
...item,
|
|
4116
|
-
dataDictionaryId:
|
|
4294
|
+
dataDictionaryId: resolvedDictId,
|
|
4295
|
+
dictionaryID: resolvedDictId,
|
|
4117
4296
|
dictionaryItemId: dictionaryItemId,
|
|
4118
|
-
|
|
4297
|
+
dictionaryItemID: dictionaryItemId,
|
|
4298
|
+
});
|
|
4119
4299
|
});
|
|
4120
4300
|
this.record.badges = (this.record.badges || []).map((badge) => {
|
|
4121
4301
|
const currentDictionaryId = badge?.dataDictionaryId || badge?.dictionaryID || '';
|
|
4122
4302
|
const dictionaryItemId = badge?.dictionaryItemId || badge?.dictionaryItemID || '';
|
|
4123
4303
|
const inferredDictionaryId = inferDictionaryId(dictionaryItemId);
|
|
4124
|
-
|
|
4304
|
+
const resolvedDictId = currentDictionaryId || inferredDictionaryId || this.record.headerDictionaryID || '';
|
|
4305
|
+
return this.syncRowDictionaryKeys({
|
|
4125
4306
|
...badge,
|
|
4126
|
-
dataDictionaryId:
|
|
4307
|
+
dataDictionaryId: resolvedDictId,
|
|
4308
|
+
dictionaryID: resolvedDictId,
|
|
4127
4309
|
dictionaryItemId: dictionaryItemId,
|
|
4128
|
-
|
|
4310
|
+
dictionaryItemID: dictionaryItemId,
|
|
4311
|
+
});
|
|
4129
4312
|
});
|
|
4130
4313
|
}
|
|
4131
4314
|
getDictionaryItemsByDictionaryId(allDictionaryItemRecords, dictionaryId) {
|
|
@@ -4227,46 +4410,90 @@ class WidgetAdminFormComponent extends BaseFormComponent {
|
|
|
4227
4410
|
normalizeLoadedRecordStyles(record) {
|
|
4228
4411
|
return {
|
|
4229
4412
|
...record,
|
|
4230
|
-
style: this.service.coerceStyleToJsonText(record.style),
|
|
4413
|
+
style: this.service.coerceStyleToJsonText(record.style, 'widget'),
|
|
4231
4414
|
dataItems: (record.dataItems || []).map((item) => ({
|
|
4232
4415
|
...item,
|
|
4233
|
-
style: this.service.coerceStyleToJsonText(item.style),
|
|
4416
|
+
style: this.service.coerceStyleToJsonText(item.style, 'item'),
|
|
4234
4417
|
})),
|
|
4235
4418
|
badges: (record.badges || []).map((badge) => ({
|
|
4236
4419
|
...badge,
|
|
4237
|
-
style: this.service.coerceStyleToJsonText(badge.style),
|
|
4420
|
+
style: this.service.coerceStyleToJsonText(badge.style, 'badge'),
|
|
4238
4421
|
})),
|
|
4239
4422
|
};
|
|
4240
4423
|
}
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4424
|
+
/**
|
|
4425
|
+
* Parsed styles + API dictionary fields for PUT/POST only.
|
|
4426
|
+
* Keeps `this.record` unchanged so style stays JSON text in inputs if the request fails (avoids "[object Object]").
|
|
4427
|
+
*/
|
|
4428
|
+
buildWidgetRecordForApi() {
|
|
4429
|
+
const dataItems = (this.record.dataItems || []).map((item) => {
|
|
4244
4430
|
const raw = item;
|
|
4245
|
-
const
|
|
4431
|
+
const dictionaryID = raw.dataDictionaryId || raw.dictionaryID || '';
|
|
4432
|
+
const dictionaryItemID = raw.dictionaryItemId || raw.dictionaryItemID || '';
|
|
4433
|
+
const { dataDictionaryId: _dd, dictionaryItemId: _di, ...rest } = raw;
|
|
4246
4434
|
return {
|
|
4247
4435
|
...rest,
|
|
4248
|
-
dictionaryID
|
|
4249
|
-
dictionaryItemID
|
|
4250
|
-
style: this.service.parseStylePayload(raw.style),
|
|
4436
|
+
dictionaryID,
|
|
4437
|
+
dictionaryItemID,
|
|
4438
|
+
style: this.service.parseStylePayload(raw.style, 'item'),
|
|
4251
4439
|
};
|
|
4252
4440
|
});
|
|
4253
|
-
|
|
4254
|
-
|
|
4441
|
+
const badges = this.record.badges && Array.isArray(this.record.badges)
|
|
4442
|
+
? this.record.badges.map((badge) => {
|
|
4255
4443
|
const raw = badge;
|
|
4256
|
-
const
|
|
4444
|
+
const dictionaryID = raw.dataDictionaryId || raw.dictionaryID || '';
|
|
4445
|
+
const dictionaryItemID = raw.dictionaryItemId || raw.dictionaryItemID || '';
|
|
4446
|
+
const { dataDictionaryId: _dd, dictionaryItemId: _di, ...rest } = raw;
|
|
4257
4447
|
return {
|
|
4258
4448
|
...rest,
|
|
4259
|
-
dictionaryID
|
|
4260
|
-
dictionaryItemID
|
|
4261
|
-
style: this.service.parseStylePayload(raw.style),
|
|
4449
|
+
dictionaryID,
|
|
4450
|
+
dictionaryItemID,
|
|
4451
|
+
style: this.service.parseStylePayload(raw.style, 'badge'),
|
|
4262
4452
|
};
|
|
4263
|
-
})
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
this.record
|
|
4267
|
-
|
|
4453
|
+
})
|
|
4454
|
+
: [];
|
|
4455
|
+
return {
|
|
4456
|
+
...this.record,
|
|
4457
|
+
style: this.service.parseStylePayload(this.record.style, 'widget'),
|
|
4458
|
+
dataItems,
|
|
4459
|
+
badges,
|
|
4460
|
+
};
|
|
4461
|
+
}
|
|
4462
|
+
handleSubmit() {
|
|
4268
4463
|
super.handleSubmit();
|
|
4269
4464
|
}
|
|
4465
|
+
handleUpdateRecord() {
|
|
4466
|
+
if (!this.record._id || Object.keys(this.record).length === 0)
|
|
4467
|
+
return;
|
|
4468
|
+
const payload = this.buildWidgetRecordForApi();
|
|
4469
|
+
this.service.update(this.record._id, payload).subscribe({
|
|
4470
|
+
next: (response) => {
|
|
4471
|
+
console.log('Record updated:', response);
|
|
4472
|
+
this.record = {};
|
|
4473
|
+
this.baseStore?.setIsApiValidated(null);
|
|
4474
|
+
this.onFormNavigate.emit(response);
|
|
4475
|
+
},
|
|
4476
|
+
error: (error) => {
|
|
4477
|
+
console.error('Error updating record:', error);
|
|
4478
|
+
},
|
|
4479
|
+
});
|
|
4480
|
+
}
|
|
4481
|
+
handleAddRecord() {
|
|
4482
|
+
if (!this.record || Object.keys(this.record).length === 0)
|
|
4483
|
+
return;
|
|
4484
|
+
const payload = this.buildWidgetRecordForApi();
|
|
4485
|
+
this.service.create(payload).subscribe({
|
|
4486
|
+
next: (response) => {
|
|
4487
|
+
console.log('Record created:', response);
|
|
4488
|
+
this.record = {};
|
|
4489
|
+
this.baseStore?.setIsApiValidated(null);
|
|
4490
|
+
this.onFormNavigate.emit(response);
|
|
4491
|
+
},
|
|
4492
|
+
error: (error) => {
|
|
4493
|
+
console.error('Error creating record:', error);
|
|
4494
|
+
},
|
|
4495
|
+
});
|
|
4496
|
+
}
|
|
4270
4497
|
ngOnDestroy() {
|
|
4271
4498
|
this.record = {};
|
|
4272
4499
|
super.ngOnDestroy();
|