From 039a97d2d9edbcc0dfb919801f347a8b648ee30d Mon Sep 17 00:00:00 2001 From: Ramveer Date: Wed, 31 Aug 2022 16:40:27 +0530 Subject: [PATCH 1/2] feat: Holiday office multiselect replaced with multiselect --- .../create-holiday/checklist-db.class.ts | 46 ++++ .../create-holiday.component.html | 26 ++- .../create-holiday.component.ts | 215 +++++++++++++++++- .../create-holiday/create-holiday.service.ts | 17 ++ .../create-holiday/todo-flat-item.class.ts | 10 + .../create-holiday/todo-item.class.ts | 9 + src/app/organization/organization.module.ts | 14 ++ 7 files changed, 326 insertions(+), 11 deletions(-) create mode 100644 src/app/organization/holidays/create-holiday/checklist-db.class.ts create mode 100644 src/app/organization/holidays/create-holiday/create-holiday.service.ts create mode 100644 src/app/organization/holidays/create-holiday/todo-flat-item.class.ts create mode 100644 src/app/organization/holidays/create-holiday/todo-item.class.ts diff --git a/src/app/organization/holidays/create-holiday/checklist-db.class.ts b/src/app/organization/holidays/create-holiday/checklist-db.class.ts new file mode 100644 index 000000000..fe641ac40 --- /dev/null +++ b/src/app/organization/holidays/create-holiday/checklist-db.class.ts @@ -0,0 +1,46 @@ +import { BehaviorSubject } from 'rxjs'; +import { Injectable } from '@angular/core'; +import { TodoItemNode } from './todo-item.class'; + +@Injectable({ + providedIn: 'root' +}) +export class ChecklistDatabase { + + + // rxjs functionality to update DOM via subscribe + dataChange = new BehaviorSubject([]); + get data(): TodoItemNode[] { + return this.dataChange.value; + } + TREE_DATA = {}; + + constructor() { + } + + // called every time the data in route changes + initialize(trie: any) { + this.TREE_DATA = trie; + const data = this.buildFileTree(this.TREE_DATA, 0); + this.dataChange.next(data); + } + + // builds hierarchical tree of TodoItemNodes + buildFileTree(obj: { [key: string]: any }, level: number): TodoItemNode[] { + return Object.keys(obj).reduce((accumulator, key) => { + const value = obj[key]; + const node = new TodoItemNode(); + node.item = key; + + if (value != null) { + if (typeof value === 'object') { + node.children = this.buildFileTree(value, level + 1); + } else { + node.item = value; + } + } + + return accumulator.concat(node); + }, []); + } +} diff --git a/src/app/organization/holidays/create-holiday/create-holiday.component.html b/src/app/organization/holidays/create-holiday/create-holiday.component.html index bbba20675..ecc07418a 100644 --- a/src/app/organization/holidays/create-holiday/create-holiday.component.html +++ b/src/app/organization/holidays/create-holiday/create-holiday.component.html @@ -64,7 +64,7 @@ - + + + + + + + + {{officesDict[node.item].name}} + + + + + {{ officesDict[node.item].name }} + + diff --git a/src/app/organization/holidays/create-holiday/create-holiday.component.ts b/src/app/organization/holidays/create-holiday/create-holiday.component.ts index c72250f39..4a1152356 100644 --- a/src/app/organization/holidays/create-holiday/create-holiday.component.ts +++ b/src/app/organization/holidays/create-holiday/create-holiday.component.ts @@ -1,12 +1,19 @@ /** Angular Imports. */ -import { Component, OnInit, ViewChild } from '@angular/core'; +import { SelectionModel } from '@angular/cdk/collections'; +import { Component, OnInit, ViewChild, Injectable } from '@angular/core'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; import { Dates } from 'app/core/utils/dates'; +import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree'; +import { FlatTreeControl } from '@angular/cdk/tree'; /** Custom Services. */ import { OrganizationService } from 'app/organization/organization.service'; import { SettingsService } from 'app/settings/settings.service'; +import { TodoItemNode } from './todo-item.class'; +import { TodoItemFlatNode } from './todo-flat-item.class'; +import { ChecklistDatabase } from './checklist-db.class'; +import { CreateHoliday } from './create-holiday.service'; /** * Create Holiday component. @@ -29,6 +36,35 @@ export class CreateHolidayComponent implements OnInit { minDate = new Date(2000, 0, 1); /** Maximum Date allowed. */ maxDate = new Date(2100, 0, 1); + // Stores office data in a trie-like structure + officesTrie: any; + // Stores office data for access from DOM via Office ID + officesDict = {}; + + // Angular Material Tree Configuration start ------------ + + /** Map from flat node to nested node. This helps us finding the nested node to be modified */ + flatNodeMap = new Map(); + + /** Map from nested node to flattened node. This helps us to keep the same object for selection */ + nestedNodeMap = new Map(); + + /** A selected parent node to be inserted */ + selectedParent: TodoItemFlatNode | null = null; + + /** The new item's name */ + newItemName = ''; + + treeControl: FlatTreeControl; + + treeFlattener: MatTreeFlattener; + + dataSource: MatTreeFlatDataSource; + + /** The selection for checklist */ + checklistSelection = new SelectionModel(true /* multiple */); + + // Angular Material Tree Configuration end ------------ /** * Get offices and holiday template from `Resolver`. @@ -43,12 +79,173 @@ export class CreateHolidayComponent implements OnInit { private dateUtils: Dates, private organizationService: OrganizationService, private settings: SettingsService, - private router: Router ) { + private router: Router, + private _database: ChecklistDatabase, + private createHoliday: CreateHoliday ) { this.route.data.subscribe((data: { offices: any, holidayTemplate: any }) => { this.officesData = data.offices; this.repaymentSchedulingTypes = data.holidayTemplate; + // Constructs trie everytime data changes + this.constructOfficeHierarchy(); + // Updates data in the CheckListDatabase + _database.initialize(this.officesTrie); + }); + this.treeFlattener = new MatTreeFlattener(this.transformer, this.getLevel, this.isExpandable, this.getChildren); + this.treeControl = new FlatTreeControl(this.getLevel, this.isExpandable); + this.dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); + + // Listens for changes in CheckListDatabase + this._database.dataChange.subscribe((data) => { + this.dataSource.data = data; }); } + constructOfficeHierarchy() { + const trie = {}; + // Iterates over all the offices + this.officesData.forEach((office: any) => { + this.officesDict[office.id] = office; + + let hierarchy = office.hierarchy.split('.'); + + // Removes empty strings + hierarchy = hierarchy.filter((stage: any) => { + return stage.length > 0; + }); + + // Temporary variable to store current object + + let root = trie; + + if (hierarchy.length === 0) { + root[office.id] = {}; + } else { + // Sets root as the first object + root = trie[Object.keys(trie)[0]]; + // Construction of hierarchy via Depth First Search + hierarchy.forEach((stage: string) => { + if (!(stage in root)) { + root[stage] = {}; + } + root = root[stage]; + }); + } + }); + + // Sets leaf offices to null as per the requirement of Angular Material + this.createHoliday.setEmptyObjectsToNull(trie); + + this.officesTrie = trie; + } + + // angular material tree config start ---------------------- + + getLevel = (node: TodoItemFlatNode) => node.level; + + isExpandable = (node: TodoItemFlatNode) => node.expandable; + + getChildren = (node: TodoItemNode): TodoItemNode[] => node.children; + + hasChild = (_: number, _nodeData: TodoItemFlatNode) => _nodeData.expandable; + + hasNoContent = (_: number, _nodeData: TodoItemFlatNode) => _nodeData.item === ''; + + /** + * Transformer to convert nested node to flat node. Record the nodes in maps for later use. + */ + transformer = (node: TodoItemNode, level: number) => { + const existingNode = this.nestedNodeMap.get(node); + const flatNode = existingNode && existingNode.item === node.item ? existingNode : new TodoItemFlatNode(); + flatNode.item = node.item; + flatNode.level = level; + flatNode.expandable = !!node.children?.length; + this.flatNodeMap.set(flatNode, node); + this.nestedNodeMap.set(node, flatNode); + return flatNode; + } + + /** Whether all the descendants of the node are selected. */ + descendantsAllSelected(node: TodoItemFlatNode): boolean { + return this.checklistSelection.isSelected(node); + } + + /** Whether part of the descendants are selected */ + descendantsPartiallySelected(node: TodoItemFlatNode): boolean { + const descendants = this.treeControl.getDescendants(node); + const result = descendants.some((child) => this.checklistSelection.isSelected(child)); + return result && !this.descendantsAllSelected(node); + } + + setSelectedOffices() { + this.holidayForm.patchValue({ + offices: this.checklistSelection.selected.map((item) => item.item), + }); + } + + /** Toggle the to-do item selection. Select/deselect all the descendants node */ + todoItemSelectionToggle(node: TodoItemFlatNode): void { + this.checklistSelection.toggle(node); + const descendants = this.treeControl.getDescendants(node); + this.checklistSelection.isSelected(node) + ? this.checklistSelection.select(...descendants) + : this.checklistSelection.deselect(...descendants); + + // Force update for the parent + descendants.forEach((child) => this.checklistSelection.isSelected(child)); + this.setSelectedOffices(); + } + + /** Toggle a leaf to-do item selection. Check all the parents to see if they changed */ + todoLeafItemSelectionToggle(node: TodoItemFlatNode): void { + this.checklistSelection.toggle(node); + this.setSelectedOffices(); + } + + /* Checks all the parents when a leaf node is selected/unselected */ + checkAllParentsSelection(node: TodoItemFlatNode): void { + let parent: TodoItemFlatNode | null = this.getParentNode(node); + while (parent) { + this.checkRootNodeSelection(parent); + parent = this.getParentNode(parent); + } + } + + /** Check root node checked state and change it accordingly */ + checkRootNodeSelection(node: TodoItemFlatNode): void { + const nodeSelected = this.checklistSelection.isSelected(node); + const descendants = this.treeControl.getDescendants(node); + const descAllSelected = + descendants.length > 0 && + descendants.every((child) => { + return this.checklistSelection.isSelected(child); + }); + if (nodeSelected && !descAllSelected) { + this.checklistSelection.deselect(node); + } else if (!nodeSelected && descAllSelected) { + this.checklistSelection.select(node); + } + } + + /* Get the parent node of a node */ + getParentNode(node: TodoItemFlatNode): TodoItemFlatNode | null { + const currentLevel = this.getLevel(node); + + if (currentLevel < 1) { + return null; + } + + const startIndex = this.treeControl.dataNodes.indexOf(node) - 1; + + for (let i = startIndex; i >= 0; i--) { + const currentNode = this.treeControl.dataNodes[i]; + + if (this.getLevel(currentNode) < currentLevel) { + return currentNode; + } + } + return null; + } + + // angular material tree config end ---------------------- ngOnInit() { this.setHolidayForm(); @@ -91,20 +288,20 @@ export class CreateHolidayComponent implements OnInit { const locale = this.settings.language.code; const prevFromDate: Date = this.holidayForm.value.fromDate; const prevToDate: Date = this.holidayForm.value.toDate; - if (holidayFormData.closureDate instanceof Date) { - holidayFormData.fromDate = this.dateUtils.formatDate(prevFromDate, dateFormat); - } - if (holidayFormData.closureDate instanceof Date) { - holidayFormData.toDate = this.dateUtils.formatDate(prevToDate, dateFormat); - } + holidayFormData.fromDate = this.dateUtils.formatDate(prevFromDate, dateFormat); + holidayFormData.toDate = this.dateUtils.formatDate(prevToDate, dateFormat); if (this.holidayForm.contains('repaymentsRescheduledTo')) { const prevRepaymentsRescheduledTo: Date = this.holidayForm.value.repaymentsRescheduledTo; holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDate(prevRepaymentsRescheduledTo, dateFormat); } + const offices = this.holidayForm.value.offices.map((office: string) => { + return {'officeId': Number.parseInt(office, 10)}; + }); const data = { ...holidayFormData, dateFormat, - locale + locale, + offices }; this.organizationService.createHoliday(data).subscribe((response: any) => { this.router.navigate(['../', response.resourceId], { relativeTo: this.route }); diff --git a/src/app/organization/holidays/create-holiday/create-holiday.service.ts b/src/app/organization/holidays/create-holiday/create-holiday.service.ts new file mode 100644 index 000000000..6cebbd079 --- /dev/null +++ b/src/app/organization/holidays/create-holiday/create-holiday.service.ts @@ -0,0 +1,17 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class CreateHoliday { + setEmptyObjectsToNull(root: any) { + Object.keys(root).forEach((key) => { + if (Object.keys(root[key]).length === 0) { + root[key] = null; + } else { + this.setEmptyObjectsToNull(root[key]); + } + }); + } + +} diff --git a/src/app/organization/holidays/create-holiday/todo-flat-item.class.ts b/src/app/organization/holidays/create-holiday/todo-flat-item.class.ts new file mode 100644 index 000000000..3b2e458b0 --- /dev/null +++ b/src/app/organization/holidays/create-holiday/todo-flat-item.class.ts @@ -0,0 +1,10 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class TodoItemFlatNode { + item: string; + level: number; + expandable: boolean; + } diff --git a/src/app/organization/holidays/create-holiday/todo-item.class.ts b/src/app/organization/holidays/create-holiday/todo-item.class.ts new file mode 100644 index 000000000..882836471 --- /dev/null +++ b/src/app/organization/holidays/create-holiday/todo-item.class.ts @@ -0,0 +1,9 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class TodoItemNode { + children: TodoItemNode[]; + item: string; +} diff --git a/src/app/organization/organization.module.ts b/src/app/organization/organization.module.ts index 92215dc2a..2ac73521c 100644 --- a/src/app/organization/organization.module.ts +++ b/src/app/organization/organization.module.ts @@ -70,6 +70,14 @@ import { StandingInstructionsHistoryComponent } from './standing-instructions-hi import { FundMappingComponent } from './fund-mapping/fund-mapping.component'; import { CreateHolidayComponent } from './holidays/create-holiday/create-holiday.component'; + +/** Custom Service */ +import { TodoItemNode } from './holidays/create-holiday/todo-item.class'; +import { TodoItemFlatNode } from './holidays/create-holiday/todo-flat-item.class'; +import { ChecklistDatabase } from './holidays/create-holiday/checklist-db.class'; +import { CreateHoliday } from './holidays/create-holiday/create-holiday.service'; + + /** * Organization Module * @@ -144,6 +152,12 @@ import { CreateHolidayComponent } from './holidays/create-holiday/create-holiday StandingInstructionsHistoryComponent, FundMappingComponent, CreateHolidayComponent, + ], + providers: [ + CreateHoliday, + ChecklistDatabase, + TodoItemFlatNode, + TodoItemNode ] }) export class OrganizationModule { } From 14a80bb65bfe3d0f0a835b564ffcc39f8826e34c Mon Sep 17 00:00:00 2001 From: Ramveer Date: Wed, 31 Aug 2022 18:01:21 +0530 Subject: [PATCH 2/2] fix: updated changes --- .../create-holiday/checklist-db.class.ts | 14 ++--- .../create-holiday.component.html | 17 +------ .../create-holiday.component.ts | 51 +++++++++---------- ...tem.class.ts => office-flat-item.class.ts} | 2 +- ...odo-item.class.ts => office-item.class.ts} | 4 +- src/app/organization/organization.module.ts | 8 +-- 6 files changed, 41 insertions(+), 55 deletions(-) rename src/app/organization/holidays/create-holiday/{todo-flat-item.class.ts => office-flat-item.class.ts} (81%) rename src/app/organization/holidays/create-holiday/{todo-item.class.ts => office-item.class.ts} (62%) diff --git a/src/app/organization/holidays/create-holiday/checklist-db.class.ts b/src/app/organization/holidays/create-holiday/checklist-db.class.ts index fe641ac40..de1bf2db4 100644 --- a/src/app/organization/holidays/create-holiday/checklist-db.class.ts +++ b/src/app/organization/holidays/create-holiday/checklist-db.class.ts @@ -1,6 +1,6 @@ import { BehaviorSubject } from 'rxjs'; import { Injectable } from '@angular/core'; -import { TodoItemNode } from './todo-item.class'; +import { OfficeItemNode } from './office-item.class'; @Injectable({ providedIn: 'root' @@ -9,8 +9,8 @@ export class ChecklistDatabase { // rxjs functionality to update DOM via subscribe - dataChange = new BehaviorSubject([]); - get data(): TodoItemNode[] { + dataChange = new BehaviorSubject([]); + get data(): OfficeItemNode[] { return this.dataChange.value; } TREE_DATA = {}; @@ -25,11 +25,11 @@ export class ChecklistDatabase { this.dataChange.next(data); } - // builds hierarchical tree of TodoItemNodes - buildFileTree(obj: { [key: string]: any }, level: number): TodoItemNode[] { - return Object.keys(obj).reduce((accumulator, key) => { + // builds hierarchical tree of officeItemNodes + buildFileTree(obj: { [key: string]: any }, level: number): OfficeItemNode[] { + return Object.keys(obj).reduce((accumulator, key) => { const value = obj[key]; - const node = new TodoItemNode(); + const node = new OfficeItemNode(); node.item = key; if (value != null) { diff --git a/src/app/organization/holidays/create-holiday/create-holiday.component.html b/src/app/organization/holidays/create-holiday/create-holiday.component.html index ecc07418a..79c94dad9 100644 --- a/src/app/organization/holidays/create-holiday/create-holiday.component.html +++ b/src/app/organization/holidays/create-holiday/create-holiday.component.html @@ -63,19 +63,6 @@ - - - @@ -83,7 +70,7 @@ {{officesDict[node.item].name}} + (change)="officeLeafItemSelectionToggle(node);">{{officesDict[node.item].name}} @@ -94,7 +81,7 @@ {{ officesDict[node.item].name }} + (change)="officeItemSelectionToggle(node)">{{ officesDict[node.item].name }} diff --git a/src/app/organization/holidays/create-holiday/create-holiday.component.ts b/src/app/organization/holidays/create-holiday/create-holiday.component.ts index 4a1152356..dd3b26de2 100644 --- a/src/app/organization/holidays/create-holiday/create-holiday.component.ts +++ b/src/app/organization/holidays/create-holiday/create-holiday.component.ts @@ -10,14 +10,13 @@ import { FlatTreeControl } from '@angular/cdk/tree'; /** Custom Services. */ import { OrganizationService } from 'app/organization/organization.service'; import { SettingsService } from 'app/settings/settings.service'; -import { TodoItemNode } from './todo-item.class'; -import { TodoItemFlatNode } from './todo-flat-item.class'; +import { OfficeItemNode } from './office-item.class'; +import { OfficeItemFlatNode } from './office-flat-item.class'; import { ChecklistDatabase } from './checklist-db.class'; import { CreateHoliday } from './create-holiday.service'; /** * Create Holiday component. - * TODO: Develop a custom angular checkbox tree and replace offices select. */ @Component({ selector: 'mifosx-create-holiday', @@ -44,25 +43,25 @@ export class CreateHolidayComponent implements OnInit { // Angular Material Tree Configuration start ------------ /** Map from flat node to nested node. This helps us finding the nested node to be modified */ - flatNodeMap = new Map(); + flatNodeMap = new Map(); /** Map from nested node to flattened node. This helps us to keep the same object for selection */ - nestedNodeMap = new Map(); + nestedNodeMap = new Map(); /** A selected parent node to be inserted */ - selectedParent: TodoItemFlatNode | null = null; + selectedParent: OfficeItemFlatNode | null = null; /** The new item's name */ newItemName = ''; - treeControl: FlatTreeControl; + treeControl: FlatTreeControl; - treeFlattener: MatTreeFlattener; + treeFlattener: MatTreeFlattener; - dataSource: MatTreeFlatDataSource; + dataSource: MatTreeFlatDataSource; /** The selection for checklist */ - checklistSelection = new SelectionModel(true /* multiple */); + checklistSelection = new SelectionModel(true /* multiple */); // Angular Material Tree Configuration end ------------ @@ -91,7 +90,7 @@ export class CreateHolidayComponent implements OnInit { _database.initialize(this.officesTrie); }); this.treeFlattener = new MatTreeFlattener(this.transformer, this.getLevel, this.isExpandable, this.getChildren); - this.treeControl = new FlatTreeControl(this.getLevel, this.isExpandable); + this.treeControl = new FlatTreeControl(this.getLevel, this.isExpandable); this.dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); // Listens for changes in CheckListDatabase @@ -139,22 +138,22 @@ export class CreateHolidayComponent implements OnInit { // angular material tree config start ---------------------- - getLevel = (node: TodoItemFlatNode) => node.level; + getLevel = (node: OfficeItemFlatNode) => node.level; - isExpandable = (node: TodoItemFlatNode) => node.expandable; + isExpandable = (node: OfficeItemFlatNode) => node.expandable; - getChildren = (node: TodoItemNode): TodoItemNode[] => node.children; + getChildren = (node: OfficeItemNode): OfficeItemNode[] => node.children; - hasChild = (_: number, _nodeData: TodoItemFlatNode) => _nodeData.expandable; + hasChild = (_: number, _nodeData: OfficeItemFlatNode) => _nodeData.expandable; - hasNoContent = (_: number, _nodeData: TodoItemFlatNode) => _nodeData.item === ''; + hasNoContent = (_: number, _nodeData: OfficeItemFlatNode) => _nodeData.item === ''; /** * Transformer to convert nested node to flat node. Record the nodes in maps for later use. */ - transformer = (node: TodoItemNode, level: number) => { + transformer = (node: OfficeItemNode, level: number) => { const existingNode = this.nestedNodeMap.get(node); - const flatNode = existingNode && existingNode.item === node.item ? existingNode : new TodoItemFlatNode(); + const flatNode = existingNode && existingNode.item === node.item ? existingNode : new OfficeItemFlatNode(); flatNode.item = node.item; flatNode.level = level; flatNode.expandable = !!node.children?.length; @@ -164,12 +163,12 @@ export class CreateHolidayComponent implements OnInit { } /** Whether all the descendants of the node are selected. */ - descendantsAllSelected(node: TodoItemFlatNode): boolean { + descendantsAllSelected(node: OfficeItemFlatNode): boolean { return this.checklistSelection.isSelected(node); } /** Whether part of the descendants are selected */ - descendantsPartiallySelected(node: TodoItemFlatNode): boolean { + descendantsPartiallySelected(node: OfficeItemFlatNode): boolean { const descendants = this.treeControl.getDescendants(node); const result = descendants.some((child) => this.checklistSelection.isSelected(child)); return result && !this.descendantsAllSelected(node); @@ -182,7 +181,7 @@ export class CreateHolidayComponent implements OnInit { } /** Toggle the to-do item selection. Select/deselect all the descendants node */ - todoItemSelectionToggle(node: TodoItemFlatNode): void { + officeItemSelectionToggle(node: OfficeItemFlatNode): void { this.checklistSelection.toggle(node); const descendants = this.treeControl.getDescendants(node); this.checklistSelection.isSelected(node) @@ -195,14 +194,14 @@ export class CreateHolidayComponent implements OnInit { } /** Toggle a leaf to-do item selection. Check all the parents to see if they changed */ - todoLeafItemSelectionToggle(node: TodoItemFlatNode): void { + officeLeafItemSelectionToggle(node: OfficeItemFlatNode): void { this.checklistSelection.toggle(node); this.setSelectedOffices(); } /* Checks all the parents when a leaf node is selected/unselected */ - checkAllParentsSelection(node: TodoItemFlatNode): void { - let parent: TodoItemFlatNode | null = this.getParentNode(node); + checkAllParentsSelection(node: OfficeItemFlatNode): void { + let parent: OfficeItemFlatNode | null = this.getParentNode(node); while (parent) { this.checkRootNodeSelection(parent); parent = this.getParentNode(parent); @@ -210,7 +209,7 @@ export class CreateHolidayComponent implements OnInit { } /** Check root node checked state and change it accordingly */ - checkRootNodeSelection(node: TodoItemFlatNode): void { + checkRootNodeSelection(node: OfficeItemFlatNode): void { const nodeSelected = this.checklistSelection.isSelected(node); const descendants = this.treeControl.getDescendants(node); const descAllSelected = @@ -226,7 +225,7 @@ export class CreateHolidayComponent implements OnInit { } /* Get the parent node of a node */ - getParentNode(node: TodoItemFlatNode): TodoItemFlatNode | null { + getParentNode(node: OfficeItemFlatNode): OfficeItemFlatNode | null { const currentLevel = this.getLevel(node); if (currentLevel < 1) { diff --git a/src/app/organization/holidays/create-holiday/todo-flat-item.class.ts b/src/app/organization/holidays/create-holiday/office-flat-item.class.ts similarity index 81% rename from src/app/organization/holidays/create-holiday/todo-flat-item.class.ts rename to src/app/organization/holidays/create-holiday/office-flat-item.class.ts index 3b2e458b0..159991061 100644 --- a/src/app/organization/holidays/create-holiday/todo-flat-item.class.ts +++ b/src/app/organization/holidays/create-holiday/office-flat-item.class.ts @@ -3,7 +3,7 @@ import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root' }) -export class TodoItemFlatNode { +export class OfficeItemFlatNode { item: string; level: number; expandable: boolean; diff --git a/src/app/organization/holidays/create-holiday/todo-item.class.ts b/src/app/organization/holidays/create-holiday/office-item.class.ts similarity index 62% rename from src/app/organization/holidays/create-holiday/todo-item.class.ts rename to src/app/organization/holidays/create-holiday/office-item.class.ts index 882836471..33add8f69 100644 --- a/src/app/organization/holidays/create-holiday/todo-item.class.ts +++ b/src/app/organization/holidays/create-holiday/office-item.class.ts @@ -3,7 +3,7 @@ import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root' }) -export class TodoItemNode { - children: TodoItemNode[]; +export class OfficeItemNode { + children: OfficeItemNode[]; item: string; } diff --git a/src/app/organization/organization.module.ts b/src/app/organization/organization.module.ts index 2ac73521c..6b2c0945e 100644 --- a/src/app/organization/organization.module.ts +++ b/src/app/organization/organization.module.ts @@ -72,8 +72,8 @@ import { CreateHolidayComponent } from './holidays/create-holiday/create-holiday /** Custom Service */ -import { TodoItemNode } from './holidays/create-holiday/todo-item.class'; -import { TodoItemFlatNode } from './holidays/create-holiday/todo-flat-item.class'; +import { OfficeItemNode } from './holidays/create-holiday/office-item.class'; +import { OfficeItemFlatNode } from './holidays/create-holiday/office-flat-item.class'; import { ChecklistDatabase } from './holidays/create-holiday/checklist-db.class'; import { CreateHoliday } from './holidays/create-holiday/create-holiday.service'; @@ -156,8 +156,8 @@ import { CreateHoliday } from './holidays/create-holiday/create-holiday.service' providers: [ CreateHoliday, ChecklistDatabase, - TodoItemFlatNode, - TodoItemNode + OfficeItemFlatNode, + OfficeItemNode ] }) export class OrganizationModule { }