Skip to content

Commit 43c4798

Browse files
committed
Build fails after refactoring of Widget in lib-admin-ui #1534
1 parent 4b29afd commit 43c4798

File tree

2 files changed

+44
-43
lines changed

2 files changed

+44
-43
lines changed

.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ module.exports = {
1717

1818
// '@typescript-eslint/member-ordering': ['error'],
1919
'@typescript-eslint/member-ordering': ['off'],
20+
'@typescript-eslint/no-use-before-define': 'off',
21+
'@typescript-eslint/no-unsafe-member-access': 'off',
22+
'@typescript-eslint/no-unsafe-call': 'off',
2023
},
2124
'env': {
2225
'browser': true,

src/main/resources/assets/js/home/resource/widget/DashboardWidget.ts

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,40 @@ enum WidgetStyle {
1414
CUSTOM = 'custom'
1515
}
1616

17+
export class DashboardWidget extends Widget<DashboardWidgetBuilder, DashboardWidgetConfig> {
18+
protected createConfig(): DashboardWidgetConfig {
19+
return new DashboardWidgetConfig();
20+
}
21+
22+
static fromJson(json: WidgetDescriptorJson): DashboardWidget {
23+
return new DashboardWidgetBuilder().fromJson(json).build();
24+
}
25+
26+
getHeight(): string {
27+
return this.getConfig().getHeight();
28+
}
29+
30+
getWidth(): string {
31+
return this.getConfig().getWidth();
32+
}
33+
34+
getStyle(): string {
35+
return this.getConfig().getStyle();
36+
}
37+
38+
getOrder(): number {
39+
return this.getConfig().getOrder();
40+
}
41+
42+
hasCustomStyling(): boolean {
43+
return this.getConfig().getStyle() !== WidgetStyle.AUTO.toString();
44+
}
45+
46+
hasHeader(): boolean {
47+
return this.getConfig().hasHeader();
48+
}
49+
}
50+
1751
class DashboardWidgetConfig extends WidgetConfig {
1852
private width: WidgetSize;
1953
private height: WidgetSize;
@@ -52,55 +86,19 @@ class DashboardWidgetConfig extends WidgetConfig {
5286
}
5387
}
5488

55-
class DashboardWidgetBuilder extends WidgetBuilder {
56-
config: DashboardWidgetConfig;
57-
58-
fromJson(json: WidgetDescriptorJson): WidgetBuilder {
59-
const builder = super.fromJson(json);
60-
61-
builder.config = new DashboardWidgetConfig().fromJson(json.config);
89+
class DashboardWidgetBuilder extends WidgetBuilder<DashboardWidgetConfig> {
90+
fromJson(json: WidgetDescriptorJson): DashboardWidgetBuilder {
91+
super.fromJson(json);
6292

6393
return this;
6494
}
6595

66-
/* eslint-disable @typescript-eslint/no-use-before-define */
96+
protected createConfig(json: Record<string, string>): DashboardWidgetConfig {
97+
return new DashboardWidgetConfig().fromJson(json);
98+
}
99+
67100
build(): DashboardWidget {
68101
return new DashboardWidget(this);
69102
}
70103
}
71104

72-
export class DashboardWidget extends Widget {
73-
protected readonly config: DashboardWidgetConfig;
74-
75-
static fromJson(json: WidgetDescriptorJson): DashboardWidget {
76-
return new DashboardWidgetBuilder().fromJson(json).build() as DashboardWidget;
77-
}
78-
79-
public getConfig(): DashboardWidgetConfig {
80-
return this.config;
81-
}
82-
83-
getHeight(): string {
84-
return this.config.getHeight();
85-
}
86-
87-
getWidth(): string {
88-
return this.config.getWidth();
89-
}
90-
91-
getStyle(): string {
92-
return this.config.getStyle();
93-
}
94-
95-
getOrder(): number {
96-
return this.config.getOrder();
97-
}
98-
99-
hasCustomStyling(): boolean {
100-
return this.config.getStyle() !== WidgetStyle.AUTO.toString();
101-
}
102-
103-
hasHeader(): boolean {
104-
return this.config.hasHeader();
105-
}
106-
}

0 commit comments

Comments
 (0)