Skip to content

Commit

Permalink
Implement dual panel view tab switching
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-ny committed Apr 4, 2024
1 parent 9716f32 commit 64ab6f7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public CommandResult execute(Model model) {
} else {
model.updateFilteredLoanList(PREDICATE_SHOW_ALL_ACTIVE_LOANS);
}
model.setIsLoansTab(true);

Check warning on line 31 in src/main/java/seedu/address/logic/commands/ViewLoansCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/ViewLoansCommand.java#L31

Added line #L31 was not covered by tests
return new CommandResult(MESSAGE_SUCCESS, false, false, true);
}
}
7 changes: 7 additions & 0 deletions src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ public BooleanProperty getIsLoansTab() {

@Override
public void setIsLoansTab(Boolean isLoansTab) {
System.out.println("Method setIsLoansTab called inside ModelManager");

Check warning on line 224 in src/main/java/seedu/address/model/ModelManager.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/ModelManager.java#L224

Added line #L224 was not covered by tests
if (isLoansTab) {
this.isAnalyticsTab.setValue(false);
this.isPersonTab.setValue(false);

Check warning on line 227 in src/main/java/seedu/address/model/ModelManager.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/ModelManager.java#L227

Added line #L227 was not covered by tests
}
this.isLoansTab.setValue(isLoansTab);
}
Expand All @@ -234,14 +236,17 @@ public BooleanProperty getIsAnalyticsTab() {

@Override
public void setToPersonTab() {
System.out.println("Method setToPersonTab called inside ModelManager");
this.isLoansTab.setValue(false);
this.isAnalyticsTab.setValue(false);
this.setIsPersonTab(true);
}

@Override
public void setIsAnalyticsTab(Boolean isAnalyticsTab) {
if (isAnalyticsTab) {
this.isLoansTab.setValue(false);
this.isPersonTab.setValue(false);

Check warning on line 249 in src/main/java/seedu/address/model/ModelManager.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/ModelManager.java#L249

Added line #L249 was not covered by tests
}
this.isAnalyticsTab.setValue(isAnalyticsTab);
}
Expand All @@ -265,6 +270,7 @@ public BooleanProperty getIsPersonTab() {

@Override
public void setIsPersonTab(Boolean isPersonTab) {
System.out.println("Method setIsPersonTab called inside ModelManager");
if (isPersonTab) {
this.isLoansTab.setValue(false);
this.isAnalyticsTab.setValue(false);
Expand All @@ -274,6 +280,7 @@ public void setIsPersonTab(Boolean isPersonTab) {

@Override
public void setDualPanel() {
System.out.println("Method setDualPanel called inside ModelManager");
this.isLoansTab.setValue(true);
this.isPersonTab.setValue(true);
this.isAnalyticsTab.setValue(false);
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/seedu/address/ui/LoanListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ public LoanListPanel(ObservableList<Loan> loanList, ObservableList<Person> perso
super(FXML);
loanListView.setItems(loanList);
loanListView.setCellFactory(listView -> new LoanListViewCell());
// personListView.setItems(personList);
// personListView.setCellFactory(listView -> new PersonListViewCell());
}

/**
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,8 @@ private void initializeLocalListeners() {
}

private void toggleTabs() {
// At most one can be active at a time
// assert (!(this.isLoansTab.getValue() && this.isAnalyticsTab.getValue()));

// At most one of these can be active at a time
assert (!(this.isLoansTab.getValue() && this.isAnalyticsTab.getValue()));
if (isPersonTab.getValue() && isLoansTab.getValue()) {
// Default to person list panel
clearAllPlaceholders();
Expand All @@ -198,19 +197,24 @@ private void toggleTabs() {
VBox.setVgrow(loanList, Priority.ALWAYS);
loanListPanelPlaceholder.getChildren().add(loanListPanel.getRoot());
VBox.setVgrow(analytics, Priority.NEVER);
personListPanelPlaceholder.setMaxHeight(240);
System.out.println("Both tabs are active");

Check warning on line 201 in src/main/java/seedu/address/ui/MainWindow.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/ui/MainWindow.java#L192-L201

Added lines #L192 - L201 were not covered by tests
} else if (isPersonTab.getValue()) {
// Default to person list panel
clearAllPlaceholders();
personListPanelPlaceholder.setMaxHeight(Double.POSITIVE_INFINITY);

Check warning on line 205 in src/main/java/seedu/address/ui/MainWindow.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/ui/MainWindow.java#L205

Added line #L205 was not covered by tests
VBox.setVgrow(personList, Priority.ALWAYS);
VBox.setVgrow(loanList, Priority.NEVER);
VBox.setVgrow(analytics, Priority.NEVER);
personListPanelPlaceholder.getChildren().add(personListPanel.getRoot());
System.out.println("Only person tab is active");

Check warning on line 210 in src/main/java/seedu/address/ui/MainWindow.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/ui/MainWindow.java#L210

Added line #L210 was not covered by tests
} else if (this.isLoansTab.getValue()) {
clearAllPlaceholders();
VBox.setVgrow(loanList, Priority.ALWAYS);
VBox.setVgrow(personList, Priority.NEVER);
VBox.setVgrow(analytics, Priority.NEVER);
loanListPanelPlaceholder.getChildren().add(loanListPanel.getRoot());
System.out.println("Only loans tab is active");

Check warning on line 217 in src/main/java/seedu/address/ui/MainWindow.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/ui/MainWindow.java#L217

Added line #L217 was not covered by tests
} else {
clearAllPlaceholders();
VBox.setVgrow(analytics, Priority.ALWAYS);
Expand Down Expand Up @@ -293,7 +297,7 @@ private CommandResult executeCommand(String commandText) throws CommandException
handleExit();
}
// Enable/Disable the loan tab based on whether command is loan related
logic.setIsLoansTab(commandResult.isLoanRelated());
// logic.setIsLoansTab(commandResult.isLoanRelated());

return commandResult;
} catch (CommandException | ParseException e) {
Expand Down
15 changes: 15 additions & 0 deletions src/test/java/seedu/address/logic/commands/AddCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,21 @@ public ObjectProperty<DashboardData> getDashboardData() {
throw new AssertionError("This method should not be called.");
}

@Override
public BooleanProperty getIsPersonTab() {
throw new AssertionError("This method should not be called.");
}

@Override
public void setIsPersonTab(Boolean isPersonTab) {
throw new AssertionError("This method should not be called.");
}

@Override
public void setDualPanel() {
throw new AssertionError("This method should not be called.");
}

@Override
public void deleteLoan(Loan loan) {
throw new AssertionError("This method should not be called.");
Expand Down

0 comments on commit 64ab6f7

Please sign in to comment.