Skip to content

Commit 7228f4e

Browse files
committed
✨ Added item type customisations
1 parent e13ce95 commit 7228f4e

File tree

4 files changed

+48
-7
lines changed

4 files changed

+48
-7
lines changed

src/businessLogic/contracts/types.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ export interface TreeViewItem {
77
parentId?: string
88
}
99

10+
export interface ItemTypeCustomisations {
11+
makeItemsCheckable(types: string[]): void;
12+
typeCustomisations(): {[type: string]: Customisations };
13+
}
14+
15+
export interface TreeViewCreatedEventPayload {
16+
itemCustomisations:
17+
}
18+
19+
export interface Customisations {
20+
isCheckable?: boolean;
21+
}
22+
1023
export interface ItemCheckedChangedEvent {
1124
item: TreeViewItem,
1225
status: CheckedState
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { ItemCustomisations } from "./itemCustomisations";
2+
3+
describe("ItemCustomisation", () => {
4+
const customisations = ItemCustomisations;
5+
6+
it("makeItemsCheckable() should make items checkable", () => {
7+
const expectedTypes = [".docs", ".excel"];
8+
customisations.makeItemsCheckable(expectedTypes);
9+
10+
const customisedTypes = customisations.typeCustomisations();
11+
expectedTypes.forEach(type => {
12+
expect(customisedTypes[type].isCheckable).toBe(true);
13+
})
14+
});
15+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Customisations, ItemTypeCustomisations } from "../contracts/types";
2+
3+
const typeCustomisations: {[type: string]: Customisations } = {};
4+
5+
export const ItemCustomisations: ItemTypeCustomisations = {
6+
makeItemsCheckable(types: string[]): void {
7+
types.forEach(type => {
8+
if (!typeCustomisations[type])
9+
typeCustomisations[type] = {}
10+
11+
typeCustomisations[type].isCheckable = true;
12+
});
13+
},
14+
15+
typeCustomisations(): {[type: string]: Customisations } {
16+
return typeCustomisations;
17+
}
18+
}

src/businessLogic/treviewViewModel/treeViewViewModel.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import { Vue } from 'vue-property-decorator';
21
import { TreeViewItem, CheckedState } from "@/businessLogic/contracts/types";
32
import { eventHub } from "@/businessLogic/eventHub/explorerEventPublisher";
43
import { cascadeStateToDescendants, flattenNodes } from "../hierachyTraversal/hierachyTraversal";
54

6-
export interface TreeViewItemEvents {
7-
checkedStatusChanged(item: TreeViewItem): void;
8-
}
9-
10-
export interface TreeViewViewModel extends TreeViewItemEvents {
5+
let flattenedNodesLookUp: { [id: string]: TreeViewItem } = {};
6+
export interface TreeViewViewModel {
117
loadNodes(nodes: TreeViewItem[]): void;
128
getNodes(): { [id: string]: TreeViewItem };
139
removeTreeViewItem(id: string): boolean;
@@ -17,7 +13,6 @@ export interface TreeViewViewModel extends TreeViewItemEvents {
1713
checkedStatusChanged(item: TreeViewItem): void;
1814
}
1915

20-
let flattenedNodesLookUp: { [id: string]: TreeViewItem } = {};
2116

2217
export const notifyParentOfSelection = (item: TreeViewItem): void => {
2318
const parentId = item.parentId as string;

0 commit comments

Comments
 (0)