cat-qw-lib 2.6.35 → 2.6.37

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.
Files changed (148) hide show
  1. package/cat-qw-lib.d.ts.map +1 -0
  2. package/fesm2022/cat-qw-lib.mjs +241 -31
  3. package/fesm2022/cat-qw-lib.mjs.map +1 -1
  4. package/lib/admin/action-admin/action-admin.module.d.ts.map +1 -0
  5. package/lib/admin/action-admin/components/admin-action-form/admin-action-form.component.d.ts.map +1 -0
  6. package/lib/admin/action-admin/components/admin-action-list/admin-action-list.component.d.ts.map +1 -0
  7. package/lib/admin/action-admin/models/admin-action.model.d.ts.map +1 -0
  8. package/lib/admin/action-admin/state/admin-action.service.d.ts.map +1 -0
  9. package/lib/admin/action-admin/state/admin-action.store.d.ts.map +1 -0
  10. package/lib/admin/api-admin/api-admin.module.d.ts.map +1 -0
  11. package/lib/admin/api-admin/components/api-admin-form/api-admin-form.component.d.ts.map +1 -0
  12. package/lib/admin/api-admin/components/api-admin-list/api-admin-list.component.d.ts.map +1 -0
  13. package/lib/admin/api-admin/models/api-config.model.d.ts.map +1 -0
  14. package/lib/admin/api-admin/state/api-admin.service.d.ts.map +1 -0
  15. package/lib/admin/api-admin/state/api-admin.store.d.ts.map +1 -0
  16. package/lib/admin/dd-admin/components/dd-admin-form/dd-admin-form.component.d.ts.map +1 -0
  17. package/lib/admin/dd-admin/components/dd-admin-item-form/dd-admin-item-form.component.d.ts.map +1 -0
  18. package/lib/admin/dd-admin/components/dd-admin-list/dd-admin-list.component.d.ts.map +1 -0
  19. package/lib/admin/dd-admin/dd-admin.module.d.ts.map +1 -0
  20. package/lib/admin/dd-admin/models/api-property.model.d.ts.map +1 -0
  21. package/lib/admin/dd-admin/models/dd-attribute-sidebar-view.model.d.ts.map +1 -0
  22. package/lib/admin/dd-admin/models/dictionary.model.d.ts.map +1 -0
  23. package/lib/admin/dd-admin/state/dictionary.query.d.ts.map +1 -0
  24. package/lib/admin/dd-admin/state/dictionary.service.d.ts.map +1 -0
  25. package/lib/admin/dd-admin/state/dictionary.store.d.ts.map +1 -0
  26. package/lib/admin/queue-admin/components/queue-admin-form/queue-admin-form.component.d.ts.map +1 -0
  27. package/lib/admin/queue-admin/components/queue-admin-list/queue-admin-list.component.d.ts.map +1 -0
  28. package/lib/admin/queue-admin/components/queue-application-list/queue-application-list.component.d.ts.map +1 -0
  29. package/lib/admin/queue-admin/models/queue.model.d.ts.map +1 -0
  30. package/lib/admin/queue-admin/queue-admin-routing.module.d.ts.map +1 -0
  31. package/lib/admin/queue-admin/queue-admin.module.d.ts.map +1 -0
  32. package/lib/admin/queue-admin/state/queue.query.d.ts.map +1 -0
  33. package/lib/admin/queue-admin/state/queue.service.d.ts.map +1 -0
  34. package/lib/admin/queue-admin/state/queue.state.d.ts.map +1 -0
  35. package/lib/admin/queue-admin/state/queue.store.d.ts.map +1 -0
  36. package/lib/admin/template-admin/components/template-admin-form/template-admin-form.component.d.ts.map +1 -0
  37. package/lib/admin/template-admin/components/template-admin-list/template-admin-list.component.d.ts.map +1 -0
  38. package/lib/admin/template-admin/models/template.model.d.ts.map +1 -0
  39. package/lib/admin/template-admin/state/template-admin.query.d.ts.map +1 -0
  40. package/lib/admin/template-admin/state/template-admin.service.d.ts.map +1 -0
  41. package/lib/admin/template-admin/state/template-admin.store.d.ts.map +1 -0
  42. package/lib/admin/template-admin/template-admin.module.d.ts.map +1 -0
  43. package/lib/admin/widget-admin/components/widget-admin-form/widget-admin-form.component.d.ts +7 -0
  44. package/lib/admin/widget-admin/components/widget-admin-form/widget-admin-form.component.d.ts.map +1 -0
  45. package/lib/admin/widget-admin/components/widget-admin-list/widget-admin-list.component.d.ts.map +1 -0
  46. package/lib/admin/widget-admin/models/widget.model.d.ts.map +1 -0
  47. package/lib/admin/widget-admin/state/widget-admin.query.d.ts.map +1 -0
  48. package/lib/admin/widget-admin/state/widget-admin.service.d.ts +24 -5
  49. package/lib/admin/widget-admin/state/widget-admin.service.d.ts.map +1 -0
  50. package/lib/admin/widget-admin/state/widget-admin.store.d.ts.map +1 -0
  51. package/lib/admin/widget-admin/widget-admin.module.d.ts.map +1 -0
  52. package/lib/queue/components/queue-container/queue-container.component.d.ts.map +1 -0
  53. package/lib/queue/components/queue-filter-dropdown/queue-filter-dropdown.component.d.ts.map +1 -0
  54. package/lib/queue/components/queue-item/queue-item.component.d.ts.map +1 -0
  55. package/lib/queue/components/queue-list/queue-list.component.d.ts.map +1 -0
  56. package/lib/queue/components/queue-record-table/queue-record-table.component.d.ts.map +1 -0
  57. package/lib/queue/components/queue-search/queue-search.component.d.ts.map +1 -0
  58. package/lib/queue/models/queue.model.d.ts.map +1 -0
  59. package/lib/queue/queue-routing.module.d.ts.map +1 -0
  60. package/lib/queue/queue.module.d.ts.map +1 -0
  61. package/lib/queue/services/queue-business.service.d.ts.map +1 -0
  62. package/lib/queue/services/queue-filter-dropdown.service.d.ts.map +1 -0
  63. package/lib/queue/services/queue-record-table-builder.service.d.ts.map +1 -0
  64. package/lib/queue/state/queue.query.d.ts.map +1 -0
  65. package/lib/queue/state/queue.service.d.ts.map +1 -0
  66. package/lib/queue/state/queue.state.d.ts.map +1 -0
  67. package/lib/queue/state/queue.store.d.ts.map +1 -0
  68. package/lib/shared/_base/base-container/base-container.component.d.ts.map +1 -0
  69. package/lib/shared/_base/base-control/base-control.component.d.ts.map +1 -0
  70. package/lib/shared/_base/base-form/base-form.component.d.ts.map +1 -0
  71. package/lib/shared/_base/base-list/base-list.component.d.ts.map +1 -0
  72. package/lib/shared/components/form-container/form-container.component.d.ts.map +1 -0
  73. package/lib/shared/components/list/block-list.component.d.ts.map +1 -0
  74. package/lib/shared/components/queue-search-customer/queue-search-customer.component.d.ts.map +1 -0
  75. package/lib/shared/components/sidebar/sidebar.component.d.ts.map +1 -0
  76. package/lib/shared/components/skeleton/skeleton.component.d.ts.map +1 -0
  77. package/lib/shared/constant/CSS.d.ts.map +1 -0
  78. package/lib/shared/constant/DATASOURCES.d.ts.map +1 -0
  79. package/lib/shared/constant/ERROR.d.ts.map +1 -0
  80. package/lib/shared/constant/HEADERS.d.ts.map +1 -0
  81. package/lib/shared/constant/LIST-CONFIG.d.ts.map +1 -0
  82. package/lib/shared/constant/LOOKUPS.d.ts.map +1 -0
  83. package/lib/shared/constant/MESSAGES.d.ts.map +1 -0
  84. package/lib/shared/constant/PERMISSION.d.ts.map +1 -0
  85. package/lib/shared/constant/ROUTES.d.ts.map +1 -0
  86. package/lib/shared/constant/SHARED.d.ts.map +1 -0
  87. package/lib/shared/constant/URLS.d.ts.map +1 -0
  88. package/lib/shared/controls/button/button.component.d.ts.map +1 -0
  89. package/lib/shared/controls/check-box/check-box.component.d.ts.map +1 -0
  90. package/lib/shared/controls/date/date.component.d.ts.map +1 -0
  91. package/lib/shared/controls/dropdown/dropdown.component.d.ts.map +1 -0
  92. package/lib/shared/controls/file-upload/file-upload.component.d.ts.map +1 -0
  93. package/lib/shared/controls/password/password.component.d.ts.map +1 -0
  94. package/lib/shared/controls/text-area/text-area.component.d.ts.map +1 -0
  95. package/lib/shared/controls/text-box/text-box.component.d.ts.map +1 -0
  96. package/lib/shared/controls/username/username.component.d.ts.map +1 -0
  97. package/lib/shared/directives/permission.directive.d.ts.map +1 -0
  98. package/lib/shared/index.d.ts.map +1 -0
  99. package/lib/shared/models/attribute.model.d.ts.map +1 -0
  100. package/lib/shared/models/base.model.d.ts.map +1 -0
  101. package/lib/shared/models/custom-widget.model.d.ts.map +1 -0
  102. package/lib/shared/models/list.model.d.ts.map +1 -0
  103. package/lib/shared/models/meta-data.model.d.ts.map +1 -0
  104. package/lib/shared/pipe/capitalize-words.pipe.d.ts.map +1 -0
  105. package/lib/shared/services/app-config.service.d.ts.map +1 -0
  106. package/lib/shared/services/auth/auth.guard.d.ts.map +1 -0
  107. package/lib/shared/services/custom-widget.service.d.ts.map +1 -0
  108. package/lib/shared/services/data-transformer.service.d.ts.map +1 -0
  109. package/lib/shared/services/date-parser.service.d.ts.map +1 -0
  110. package/lib/shared/services/form-state.service.d.ts.map +1 -0
  111. package/lib/shared/services/list.service.d.ts.map +1 -0
  112. package/lib/shared/services/session.service.d.ts.map +1 -0
  113. package/lib/shared/services/style-builder.service.d.ts.map +1 -0
  114. package/lib/shared/services/table.builder.d.ts.map +1 -0
  115. package/lib/shared/services/validator.service.d.ts.map +1 -0
  116. package/lib/shared/shared.module.d.ts.map +1 -0
  117. package/lib/shared/state/base.query.d.ts.map +1 -0
  118. package/lib/shared/state/base.service.d.ts.map +1 -0
  119. package/lib/shared/state/base.state.d.ts.map +1 -0
  120. package/lib/shared/state/base.store.d.ts.map +1 -0
  121. package/lib/shared/table-primary/components/table-primary.component.d.ts.map +1 -0
  122. package/lib/shared/table-primary/models/table-primary-header.model.d.ts.map +1 -0
  123. package/lib/shared/table-primary/models/table-primary.model.d.ts.map +1 -0
  124. package/lib/shared/table-secondary/components/table-secondary.component.d.ts.map +1 -0
  125. package/lib/shared/table-secondary/models/table-secondary-header.model.d.ts.map +1 -0
  126. package/lib/shared/table-secondary/models/table-secondary.model.d.ts.map +1 -0
  127. package/lib/widget/components/custom-widget/custom-widget.component.d.ts.map +1 -0
  128. package/lib/widget/components/widget-body/widget-body.component.d.ts.map +1 -0
  129. package/lib/widget/components/widget-container/widget-container.component.d.ts.map +1 -0
  130. package/lib/widget/components/widget-footer/widget-footer.component.d.ts.map +1 -0
  131. package/lib/widget/components/widget-header/widget-header.component.d.ts.map +1 -0
  132. package/lib/widget/components/widget-item/widget-item.component.d.ts.map +1 -0
  133. package/lib/widget/components/widget-main/widget-main.component.d.ts.map +1 -0
  134. package/lib/widget/components/widget-menu/widget-menu.component.d.ts.map +1 -0
  135. package/lib/widget/components/widget-menu-body/widget-menu-body.component.d.ts.map +1 -0
  136. package/lib/widget/components/widget-menu-container/widget-menu-container.component.d.ts.map +1 -0
  137. package/lib/widget/components/widget-menu-header/widget-menu-header.component.d.ts.map +1 -0
  138. package/lib/widget/components/widget-menu-item/widget-menu-item.component.d.ts.map +1 -0
  139. package/lib/widget/components/widget-row-tile/widget-row-tile.component.d.ts.map +1 -0
  140. package/lib/widget/models/custom-widget.model.d.ts.map +1 -0
  141. package/lib/widget/models/progress-chart.model.d.ts.map +1 -0
  142. package/lib/widget/models/widget.model.d.ts.map +1 -0
  143. package/lib/widget/state/widget.query.d.ts.map +1 -0
  144. package/lib/widget/state/widget.service.d.ts.map +1 -0
  145. package/lib/widget/state/widget.store.d.ts.map +1 -0
  146. package/lib/widget/widget.module.d.ts.map +1 -0
  147. package/package.json +1 -1
  148. 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"}
@@ -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
- * Plain-object values (e.g. key/value/itemStyle saved as subdocuments) become JSON strings
3772
- * so the payload matches API expectations and form text fields stay readable.
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
- normalizeNestedStyleObjects(style) {
3818
+ stringifyStyleJsonKeys(style, keys) {
3775
3819
  const out = { ...style };
3776
- for (const key of Object.keys(out)) {
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.normalizeNestedStyleObjects(parsed);
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.normalizeNestedStyleObjects(value);
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
- try {
3832
- const parsed = JSON.parse(trimmed);
3833
- return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)
3834
- ? parsed
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
- catch {
4002
+ if (!parsedObj) {
3838
4003
  const fallback = this.sanitizeStyleString(trimmed);
3839
- return fallback ?? {};
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' });
@@ -4240,20 +4410,23 @@ class WidgetAdminFormComponent extends BaseFormComponent {
4240
4410
  normalizeLoadedRecordStyles(record) {
4241
4411
  return {
4242
4412
  ...record,
4243
- style: this.service.coerceStyleToJsonText(record.style),
4413
+ style: this.service.coerceStyleToJsonText(record.style, 'widget'),
4244
4414
  dataItems: (record.dataItems || []).map((item) => ({
4245
4415
  ...item,
4246
- style: this.service.coerceStyleToJsonText(item.style),
4416
+ style: this.service.coerceStyleToJsonText(item.style, 'item'),
4247
4417
  })),
4248
4418
  badges: (record.badges || []).map((badge) => ({
4249
4419
  ...badge,
4250
- style: this.service.coerceStyleToJsonText(badge.style),
4420
+ style: this.service.coerceStyleToJsonText(badge.style, 'badge'),
4251
4421
  })),
4252
4422
  };
4253
4423
  }
4254
- handleSubmit() {
4255
- this.record.style = this.service.parseStylePayload(this.record.style);
4256
- this.record.dataItems = this.record.dataItems.map((item) => {
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) => {
4257
4430
  const raw = item;
4258
4431
  const dictionaryID = raw.dataDictionaryId || raw.dictionaryID || '';
4259
4432
  const dictionaryItemID = raw.dictionaryItemId || raw.dictionaryItemID || '';
@@ -4262,11 +4435,11 @@ class WidgetAdminFormComponent extends BaseFormComponent {
4262
4435
  ...rest,
4263
4436
  dictionaryID,
4264
4437
  dictionaryItemID,
4265
- style: this.service.parseStylePayload(raw.style),
4438
+ style: this.service.parseStylePayload(raw.style, 'item'),
4266
4439
  };
4267
4440
  });
4268
- if (this.record.badges && Array.isArray(this.record.badges)) {
4269
- this.record.badges = this.record.badges.map((badge) => {
4441
+ const badges = this.record.badges && Array.isArray(this.record.badges)
4442
+ ? this.record.badges.map((badge) => {
4270
4443
  const raw = badge;
4271
4444
  const dictionaryID = raw.dataDictionaryId || raw.dictionaryID || '';
4272
4445
  const dictionaryItemID = raw.dictionaryItemId || raw.dictionaryItemID || '';
@@ -4275,15 +4448,52 @@ class WidgetAdminFormComponent extends BaseFormComponent {
4275
4448
  ...rest,
4276
4449
  dictionaryID,
4277
4450
  dictionaryItemID,
4278
- style: this.service.parseStylePayload(raw.style),
4451
+ style: this.service.parseStylePayload(raw.style, 'badge'),
4279
4452
  };
4280
- });
4281
- }
4282
- else {
4283
- this.record.badges = [];
4284
- }
4453
+ })
4454
+ : [];
4455
+ return {
4456
+ ...this.record,
4457
+ style: this.service.parseStylePayload(this.record.style, 'widget'),
4458
+ dataItems,
4459
+ badges,
4460
+ };
4461
+ }
4462
+ handleSubmit() {
4285
4463
  super.handleSubmit();
4286
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
+ }
4287
4497
  ngOnDestroy() {
4288
4498
  this.record = {};
4289
4499
  super.ngOnDestroy();