-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refractor refresh #218
Refractor refresh #218
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,8 +190,6 @@ public void addEmployee(Employee employee) { | |
public void setEmployee(Employee target, Employee editedEmployee) { | ||
requireNonNull(editedEmployee); | ||
employees.setEmployee(target, editedEmployee); | ||
refreshDepartments(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. defensive prog aside, just wondering where's the logic for edit employee command? Where is the new refresh method called for edit employee command? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be no need to add in logic for edit employee since we are currently just tracking the number of employees in each leaves/department, editing employee has no effect There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh right. Normal edits to employee (eg name) will be updated because rendering logic handled diffly. |
||
refreshLeaves(); | ||
} | ||
|
||
/** | ||
|
@@ -200,8 +198,6 @@ public void setEmployee(Employee target, Employee editedEmployee) { | |
*/ | ||
public void removeEmployee(Employee key) { | ||
employees.remove(key); | ||
refreshDepartments(); | ||
refreshLeaves(); | ||
} | ||
|
||
// =========== Department-Level Operations | ||
|
@@ -262,7 +258,6 @@ public void removeDepartment(Department key) { | |
public void addEmployeeToDepartment(Employee p, Department d) { | ||
requireAllNonNull(p, d); | ||
d.addEmployee(p); | ||
refreshDepartments(); | ||
} | ||
|
||
/** | ||
|
@@ -274,20 +269,8 @@ public void addEmployeeToDepartment(Employee p, Department d) { | |
public void removeEmployeeFromDepartment(Employee p, Department d) { | ||
requireAllNonNull(p, d); | ||
d.removeEmployee(p); | ||
refreshDepartments(); | ||
} | ||
|
||
/** | ||
* Refreshes the department list. | ||
*/ | ||
public void refreshDepartments() { | ||
UniqueDepartmentList currList = new UniqueDepartmentList(); | ||
for (Department d : departments) { | ||
currList.add(d); | ||
} | ||
departments.setDepartments(new UniqueDepartmentList()); | ||
departments.setDepartments(currList); | ||
} | ||
|
||
/** | ||
* Gets the number of employees in the specified department. | ||
|
@@ -312,8 +295,6 @@ public void cascadeDeleteEmployeeToDepartments(Employee employeeToDelete) { | |
dept.removeEmployee(employeeToDelete); | ||
} | ||
} | ||
refreshDepartments(); // defensive programming | ||
refreshLeaves(); // defensive programming | ||
} | ||
|
||
/** | ||
|
@@ -329,8 +310,6 @@ public void cascadeEditEmployeeToDepartments(Employee employeeToEdit, Employee e | |
dept.setEmployee(employeeToEdit, editedEmployee); | ||
} | ||
} | ||
refreshDepartments(); // defensive programming | ||
refreshLeaves(); // defensive programming | ||
} | ||
|
||
// =========== Leave-Level Operations | ||
|
@@ -377,8 +356,6 @@ public void addLeave(Leave leave) { | |
*/ | ||
public void deleteLeave(Leave leave) { | ||
leaves.remove(leave); | ||
refreshDepartments(); | ||
refreshLeaves(); | ||
} | ||
|
||
/** | ||
|
@@ -412,7 +389,7 @@ public boolean hasEmployeeOnLeave(LeaveDate date, Employee employee) { | |
public void addEmployeeToLeave(Leave leave, Employee employee) { | ||
requireAllNonNull(leave, employee); | ||
leave.addEmployee(employee); | ||
refreshLeaves(); | ||
|
||
} | ||
|
||
/** | ||
|
@@ -421,19 +398,6 @@ public void addEmployeeToLeave(Leave leave, Employee employee) { | |
public void deleteEmployeeFromLeave(Leave leave, Employee employee) { | ||
requireAllNonNull(leave, employee); | ||
leave.deleteEmployee(employee); | ||
refreshLeaves(); | ||
} | ||
|
||
/** | ||
* Refreshes the leave list | ||
*/ | ||
public void refreshLeaves() { | ||
UniqueLeaveList currList = new UniqueLeaveList(); | ||
for (Leave l : leaves) { | ||
currList.addLeave(l); | ||
} | ||
leaves.setLeaves(new UniqueLeaveList()); | ||
leaves.setLeaves(currList); | ||
} | ||
|
||
/** | ||
|
@@ -457,8 +421,6 @@ public void cascadeUpdateUserInLeaves(Employee employeeToEdit, Employee editedEm | |
leave.setEmployee(employeeToEdit, editedEmployee); | ||
} | ||
} | ||
refreshDepartments(); | ||
refreshLeaves(); | ||
} | ||
|
||
/** | ||
|
@@ -471,8 +433,6 @@ public void cascadeDeleteUserInLeaves(Employee employeeToDelete) { | |
leave.deleteEmployee(employeeToDelete); | ||
} | ||
} | ||
refreshDepartments(); | ||
refreshLeaves(); | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just double confirm, setting predicate here to be true / false of an already filtered list will not introduce new unnecessary behaviour right? it wont remove all entires or display all entries right