cat-qw-lib 0.59.2 → 0.59.4
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 +56 -9
- 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 +2 -2
- package/lib/admin/widget-admin/state/widget-admin.service.d.ts +6 -0
- package/lib/shared/services/style-builder.service.d.ts +3 -0
- package/lib/widget/components/widget-body/widget-body.component.d.ts +6 -0
- package/lib/widget/models/widget.model.d.ts +8 -16
- package/package.json +1 -1
- package/src/assets/config/api.config.json +22 -0
package/fesm2022/cat-qw-lib.mjs
CHANGED
|
@@ -2539,6 +2539,22 @@ class WidgetAdminService extends BaseService {
|
|
|
2539
2539
|
listLabelProperty: "name",
|
|
2540
2540
|
},
|
|
2541
2541
|
];
|
|
2542
|
+
/**
|
|
2543
|
+
* Cleans and parses a malformed style JSON string
|
|
2544
|
+
* @param {string} rawStyleStr - The raw style string from API or DB
|
|
2545
|
+
* @returns {Record<string, any> | null} - Parsed style object or null if parsing fails
|
|
2546
|
+
*/
|
|
2547
|
+
sanitizeStyleString(rawStyleStr) {
|
|
2548
|
+
try {
|
|
2549
|
+
rawStyleStr = rawStyleStr.replace(/""/g, '"');
|
|
2550
|
+
rawStyleStr = rawStyleStr.replace(/([{,]\s*)([a-zA-Z0-9_]+)\s*:/g, '$1"$2":');
|
|
2551
|
+
return JSON.parse(rawStyleStr);
|
|
2552
|
+
}
|
|
2553
|
+
catch (err) {
|
|
2554
|
+
console.error('Failed to sanitize/parse style JSON:', err);
|
|
2555
|
+
return null;
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2542
2558
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.4", ngImport: i0, type: WidgetAdminService, deps: [{ token: i1$1.HttpClient }, { token: WidgetAdminStore }, { token: AppConfigService }, { token: ListService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2543
2559
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.4", ngImport: i0, type: WidgetAdminService, providedIn: 'root' });
|
|
2544
2560
|
}
|
|
@@ -2714,6 +2730,15 @@ class WidgetAdminFormComponent extends BaseFormComponent {
|
|
|
2714
2730
|
console.error(ERROR.INVALID_INDEX, index);
|
|
2715
2731
|
}
|
|
2716
2732
|
}
|
|
2733
|
+
handleSubmit() {
|
|
2734
|
+
this.record.style = this.service.sanitizeStyleString(typeof this.record.style === 'string' ? this.record.style : SHARED.EMPTY);
|
|
2735
|
+
this.record.dataItems = this.record.dataItems.map((item) => {
|
|
2736
|
+
item.style = this.service.sanitizeStyleString(typeof item.style === 'string' ? item.style : SHARED.EMPTY);
|
|
2737
|
+
return item;
|
|
2738
|
+
});
|
|
2739
|
+
console.log(this.record);
|
|
2740
|
+
super.handleSubmit();
|
|
2741
|
+
}
|
|
2717
2742
|
ngOnDestroy() {
|
|
2718
2743
|
this.record = {};
|
|
2719
2744
|
super.ngOnDestroy();
|
|
@@ -4157,6 +4182,17 @@ class StyleBuilderService {
|
|
|
4157
4182
|
...this.normalizeStyleObject(styleExpression),
|
|
4158
4183
|
};
|
|
4159
4184
|
}
|
|
4185
|
+
parseStyleObject(styleStr) {
|
|
4186
|
+
if (!styleStr)
|
|
4187
|
+
return {};
|
|
4188
|
+
try {
|
|
4189
|
+
return JSON.parse(styleStr);
|
|
4190
|
+
}
|
|
4191
|
+
catch (e) {
|
|
4192
|
+
console.warn('Failed to parse style:', styleStr);
|
|
4193
|
+
return {};
|
|
4194
|
+
}
|
|
4195
|
+
}
|
|
4160
4196
|
normalizeStyleObject(obj) {
|
|
4161
4197
|
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
4162
4198
|
if (value !== undefined && value !== '') {
|
|
@@ -4336,29 +4372,40 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.4", ngImpor
|
|
|
4336
4372
|
}] } });
|
|
4337
4373
|
|
|
4338
4374
|
class WidgetBodyComponent {
|
|
4375
|
+
styleBulderService;
|
|
4376
|
+
constructor(styleBulderService) {
|
|
4377
|
+
this.styleBulderService = styleBulderService;
|
|
4378
|
+
}
|
|
4339
4379
|
widget;
|
|
4340
4380
|
ngOnChanges(changes) {
|
|
4341
4381
|
this.computeStylesForAll();
|
|
4342
4382
|
}
|
|
4383
|
+
parseStyleObject(styleStr) {
|
|
4384
|
+
if (!styleStr)
|
|
4385
|
+
return {};
|
|
4386
|
+
try {
|
|
4387
|
+
return JSON.parse(styleStr);
|
|
4388
|
+
}
|
|
4389
|
+
catch (e) {
|
|
4390
|
+
return {};
|
|
4391
|
+
}
|
|
4392
|
+
}
|
|
4343
4393
|
computeStylesForAll() {
|
|
4344
4394
|
if (!this.widget?.dataItems)
|
|
4345
4395
|
return;
|
|
4346
4396
|
this.widget.dataItems.forEach((item) => {
|
|
4347
|
-
|
|
4348
|
-
const
|
|
4349
|
-
console.log(base);
|
|
4350
|
-
const expr = item.style?.styleExpression || {};
|
|
4351
|
-
console.log(expr);
|
|
4397
|
+
const base = this.styleBulderService.parseStyleObject(typeof item.style.itemStyle === 'string' ? item.style.itemStyle : undefined);
|
|
4398
|
+
const expr = this.styleBulderService.parseStyleObject(typeof item.style.styleExpression === 'string' ? item.style.styleExpression : undefined);
|
|
4352
4399
|
item.style.computedStyle = { ...base, ...expr };
|
|
4353
4400
|
});
|
|
4354
4401
|
}
|
|
4355
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.4", ngImport: i0, type: WidgetBodyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4356
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.4", type: WidgetBodyComponent, isStandalone: false, selector: "lib-widget-body", inputs: { widget: "widget" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"widget-body-container grid m-0\">\r\n <div *ngFor=\"let dataItem of widget?.dataItems || []; let i = index\" [ngClass]=\"widget.style.width\">\r\n @if(!dataItem.isHidden){\r\n <div [ngStyle]=\"dataItem.style.computedStyle\"
|
|
4402
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.4", ngImport: i0, type: WidgetBodyComponent, deps: [{ token: StyleBuilderService }], target: i0.ɵɵFactoryTarget.Component });
|
|
4403
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.4", type: WidgetBodyComponent, isStandalone: false, selector: "lib-widget-body", inputs: { widget: "widget" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"widget-body-container grid m-0\">\r\n <div *ngFor=\"let dataItem of widget?.dataItems || []; let i = index\" [ngClass]=\"widget.style.width\">\r\n @if(!dataItem.isHidden){\r\n <div [ngStyle]=\"dataItem.style.computedStyle\"\r\n [ngClass]=\"{'widget-item-wrapper': (i !== ((widget.dataItems || []).length - 1)) && dataItem.style?.hasSeparator}\">\r\n <div [ngClass]=\"\r\n dataItem?.key === 'Vulnerability' && widget.predefinedName === 'ApplicantWidget'\r\n ? 'vulnerability-title-wrapper'\r\n : ( i !== ((widget.dataItems || []).length - 1) ? 'widget-wrapper' : 'widget-last-wrapper' )\r\n \" class=\"px-3\">\r\n <lib-widget-item [widgetItem]=\"dataItem\" [widget]=\"widget\"></lib-widget-item>\r\n </div>\r\n </div>\r\n }\r\n </div>\r\n</div>", styles: [".widget-item-wrapper{border-bottom:1px solid rgba(68,72,109,.1)}.widget-wrapper{padding:10px 0}.widget-last-wrapper{padding:10px 0 0}.vulnerability-title-wrapper{background:#fb392d36}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: WidgetItemComponent, selector: "lib-widget-item", inputs: ["widgetItem", "widget", "application"] }] });
|
|
4357
4404
|
}
|
|
4358
4405
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.4", ngImport: i0, type: WidgetBodyComponent, decorators: [{
|
|
4359
4406
|
type: Component,
|
|
4360
|
-
args: [{ selector: 'lib-widget-body', standalone: false, template: "<div class=\"widget-body-container grid m-0\">\r\n <div *ngFor=\"let dataItem of widget?.dataItems || []; let i = index\" [ngClass]=\"widget.style.width\">\r\n @if(!dataItem.isHidden){\r\n <div [ngStyle]=\"dataItem.style.computedStyle\"
|
|
4361
|
-
}], propDecorators: { widget: [{
|
|
4407
|
+
args: [{ selector: 'lib-widget-body', standalone: false, template: "<div class=\"widget-body-container grid m-0\">\r\n <div *ngFor=\"let dataItem of widget?.dataItems || []; let i = index\" [ngClass]=\"widget.style.width\">\r\n @if(!dataItem.isHidden){\r\n <div [ngStyle]=\"dataItem.style.computedStyle\"\r\n [ngClass]=\"{'widget-item-wrapper': (i !== ((widget.dataItems || []).length - 1)) && dataItem.style?.hasSeparator}\">\r\n <div [ngClass]=\"\r\n dataItem?.key === 'Vulnerability' && widget.predefinedName === 'ApplicantWidget'\r\n ? 'vulnerability-title-wrapper'\r\n : ( i !== ((widget.dataItems || []).length - 1) ? 'widget-wrapper' : 'widget-last-wrapper' )\r\n \" class=\"px-3\">\r\n <lib-widget-item [widgetItem]=\"dataItem\" [widget]=\"widget\"></lib-widget-item>\r\n </div>\r\n </div>\r\n }\r\n </div>\r\n</div>", styles: [".widget-item-wrapper{border-bottom:1px solid rgba(68,72,109,.1)}.widget-wrapper{padding:10px 0}.widget-last-wrapper{padding:10px 0 0}.vulnerability-title-wrapper{background:#fb392d36}\n"] }]
|
|
4408
|
+
}], ctorParameters: () => [{ type: StyleBuilderService }], propDecorators: { widget: [{
|
|
4362
4409
|
type: Input
|
|
4363
4410
|
}] } });
|
|
4364
4411
|
|