Skip to content

Commit e027eb1

Browse files
fix typeExpr implementation in CustomShapesWithTemplates
1 parent 610ec0a commit e027eb1

File tree

5 files changed

+37
-8
lines changed

5 files changed

+37
-8
lines changed

apps/demos/Demos/Diagram/CustomShapesWithTemplates/Angular/app/app.component.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,13 @@ export class AppComponent {
4444
});
4545
}
4646

47-
itemTypeExpr(obj) {
48-
return `employee${obj.ID}`;
47+
itemTypeExpr(obj, value) {
48+
if (value) {
49+
obj.type = value;
50+
} else {
51+
return `employee${obj.ID}`;
52+
}
53+
return null;
4954
}
5055

5156
showInfo(employee) {

apps/demos/Demos/Diagram/CustomShapesWithTemplates/React/App.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@ const dataSource = new ArrayStore({
1111
data: employees,
1212
});
1313

14-
function itemTypeExpr(obj: { ID: number; }) {
15-
return `employee${obj.ID}`;
14+
function itemTypeExpr(obj: { ID: number; type: string; }, value: string) {
15+
if (value) {
16+
obj.type = value;
17+
} else {
18+
return `employee${obj.ID}`;
19+
}
20+
return null;
1621
}
1722

1823
export default function App() {

apps/demos/Demos/Diagram/CustomShapesWithTemplates/ReactJs/App.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ const dataSource = new ArrayStore({
1010
key: 'ID',
1111
data: employees,
1212
});
13-
function itemTypeExpr(obj) {
14-
return `employee${obj.ID}`;
13+
function itemTypeExpr(obj, value) {
14+
if (value) {
15+
obj.type = value;
16+
} else {
17+
return `employee${obj.ID}`;
18+
}
19+
return null;
1520
}
1621
export default function App() {
1722
const [currentEmployee, setCurrentEmployee] = useState({});

apps/demos/Demos/Diagram/CustomShapesWithTemplates/Vue/App.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,14 @@ const dataSource = new ArrayStore({
6767
});
6868
const currentEmployee = ref({} as Record<string, any>);
6969
const popupVisible = ref(false);
70-
const itemTypeExpr = ({ ID }: any) => `employee${ID}`;
70+
const itemTypeExpr = (obj: { ID: number; type: string; }, value: string) => {
71+
if (value) {
72+
obj.type = value;
73+
} else {
74+
return `employee${obj.ID}`;
75+
}
76+
return null;
77+
};
7178
7279
function showInfo(employee: any) {
7380
currentEmployee.value = employee;

apps/demos/Demos/Diagram/CustomShapesWithTemplates/jQuery/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@ $(() => {
2929
data: employees,
3030
}),
3131
keyExpr: 'ID',
32-
typeExpr(obj) { return `employee${obj.ID}`; },
32+
typeExpr(obj, value) {
33+
if (value) {
34+
obj.type = value;
35+
} else {
36+
return `employee${obj.ID}`;
37+
}
38+
return null;
39+
},
3340
parentKeyExpr: 'Head_ID',
3441
autoLayout: {
3542
type: 'tree',

0 commit comments

Comments
 (0)