Skip to content

Commit e88765c

Browse files
committed
fix groups
1 parent 1b6188a commit e88765c

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@node-projects/svghmi.webcomponent",
3-
"version": "1.5.0",
3+
"version": "1.6.0",
44
"description": "a svghmi webcomponent.",
55
"type": "module",
66
"main": "./dist/index.js",

src/designer/SvgHmiPropertiesService.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default class SvgHmiPropertiesService extends AbstractPolymerLikeProperti
1111
}
1212

1313
public override async getProperties(designItem: IDesignItem): Promise<IProperty[] | IPropertyGroup[]> {
14-
return [{
14+
const properties: IProperty[] = [{
1515
name: 'src',
1616
type: 'string',
1717
service: this,
@@ -26,5 +26,30 @@ export default class SvgHmiPropertiesService extends AbstractPolymerLikeProperti
2626
group: x[1].group,
2727
description: x[1].description
2828
}))];
29+
30+
if (!properties.some(x => x.group))
31+
return properties;
32+
33+
const ungroupedProperties = properties.filter(x => !x.group);
34+
const groupedProperties = new Map<string, IProperty[]>();
35+
36+
for (const property of properties) {
37+
if (!property.group)
38+
continue;
39+
40+
let group = groupedProperties.get(property.group);
41+
if (group == null) {
42+
group = [];
43+
groupedProperties.set(property.group, group);
44+
}
45+
group.push(property);
46+
}
47+
48+
const groups: IPropertyGroup[] = [...groupedProperties].map(([name, grouped]) => ({
49+
name,
50+
properties: grouped
51+
}));
52+
53+
return [...ungroupedProperties, ...groups] as IProperty[];
2954
}
3055
}

0 commit comments

Comments
 (0)