-
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
Add view all loans command #81
Add view all loans command #81
Conversation
Currently results in infinite recursion due to storage.
Loans are now sorted by return date. Loans with earlier return dates are shown higher.
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.
Changes look good to me. The app seems to behave as expected.
Just one or two minor nits to fix and should be gtg!
public Loan(int id, float value, Date startDate, Date returnDate) { | ||
requireAllNonNull(id, value, startDate, returnDate); | ||
public Loan(int id, float value, Date startDate, Date returnDate, Person assignee) { | ||
requireAllNonNull(id, value, startDate, returnDate, assignee); |
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.
Good defensive coding
@@ -44,7 +43,8 @@ public ModelManager(ReadOnlyAddressBook addressBook, ReadOnlyUserPrefs userPrefs | |||
this.addressBook = new AddressBook(addressBook); | |||
this.userPrefs = new UserPrefs(userPrefs); | |||
filteredPersons = new FilteredList<>(this.addressBook.getPersonList()); | |||
currLoanList = FXCollections.observableList(new ArrayList<>()); | |||
filteredLoans = new FilteredList<>(this.addressBook.getLoanList()); | |||
sortedLoans = new SortedList<>(filteredLoans, Loan::compareTo); |
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.
Making use of the behaviour of SortedList
is really nice here. Removes the need for implicit sorting through functions at every change. 👍
public CommandResult execute(Model model) { | ||
requireNonNull(model); | ||
model.updateFilteredLoanList(PREDICATE_SHOW_ALL_ACTIVE_LOANS); | ||
return new CommandResult(MESSAGE_SUCCESS, false, false, true); |
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.
return new CommandResult(MESSAGE_SUCCESS, false, false, true); | |
model.updateFilteredPersonList(unused -> false); | |
return new CommandResult(MESSAGE_SUCCESS, false, false, true); |
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.
This is just for cosmetic purposes and not really important. But when we call viewloans
targeting all active loans, we should not show any particular contact's name at the top.
The UI will show a blank space at the top after this change. We will leave it to be fixed as an issue later on as this task is more suitable for another issue and PR on its own.
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.
I agree. In the "view all loans" GUI, the name of the loanee should also be shown for each loan,
5c1b43b
into
AY2324S2-CS2103T-W13-1:master
Fixes #55 and #32.
Refactor
LoanRecords
asUniqueLoanList
UniquePersonList
as a model in implementing methods.Extract individual loan lists to global loan lists
UniqueLoanList
is now a field ofAddressBook
as opposed individual persons.Loan
now holds the assigneePerson
as a field.Refactor the display of loans
Class changes:
ModelManager
now holds asortedLoanList
of loans wrapped around afilteredLoanList
.filteredLoanList
, in turn, wraps around theuniqueLoanList
of the AddressBook, analogous tofilteredPersonList
.Implementation changes:
filteredLoanList
controls which loans are shown. Currently there are two options: show all active loans or show active loans attached to a person.sortedLoanList
controls the order of loans. Currently it is hardcoded that loans due earlier are placed higher.Add new command
viewloans
list
. It displays all active loansRefactor
viewloan
commandLoanRecords
, this command now simply updates the predicate onfilteredLoanList
, similar tofilter
command.Refactor
deleteloan
andmarkloan
commanddeleteloan/markloan INDEX
whereINDEX
is the index of the loan in the last shown loan list.Refactor storage
Change generic data
addressbook.json
does not exist is changed to reflect the above changes.Bugs and issues
The following are essential changes that are not covered in this PR:
deleteloan
andmarkloan
to reflect the change of parameters.deleteloan
andmarkloan
methods.Person
,Loan
andLoanRecords
.Analytics
in this new implementation.EditCommand
related objects to reflect the deletion ofLoanRecords
fromPerson
.