Skip to content

Commit

Permalink
Disable clicking Tags and Notes fields while in save confirmation alert
Browse files Browse the repository at this point in the history
Tags and notes are clickable when the window is showing save confirmation alert, which is causing UI issues.
Disable clicking these fields when the message is being shown.
  • Loading branch information
brandon-nam committed Nov 9, 2023
1 parent 68388fb commit d11fa30
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/main/java/seedu/address/ui/PersonProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,8 @@ public boolean isStillEditing() {
public void setIsInConfirmationDialog(boolean isInConfirmationDialog) {
uiElements.values().stream()
.forEach(field -> field.setIsInConfirmationDialog(isInConfirmationDialog));
tagUI.setIsInConfirmationDialog(isInConfirmationDialog);
noteUI.setIsInConfirmationDialog(isInConfirmationDialog);
}

Check warning on line 486 in src/main/java/seedu/address/ui/PersonProfile.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/ui/PersonProfile.java#L482-L486

Added lines #L482 - L486 were not covered by tests

/**
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/seedu/address/ui/PersonProfileNote.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class PersonProfileNote extends UiPart<SplitPane> {
private final PersonProfile personProfile;
private String value;
private State state;
private boolean isInConfirmationDialog;

// endregion

// region Enums
Expand Down Expand Up @@ -184,14 +186,20 @@ private void handleLoseFocus() {

@FXML
void setFocus() {
personProfile.triggerEvent(PersonProfile.Event.BEFORE_START_EDIT);
updateState(State.EDITING);
if (!isInConfirmationDialog) {
personProfile.triggerEvent(PersonProfile.Event.BEFORE_START_EDIT);
updateState(State.EDITING);

Check warning on line 191 in src/main/java/seedu/address/ui/PersonProfileNote.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/ui/PersonProfileNote.java#L190-L191

Added lines #L190 - L191 were not covered by tests
}
}

boolean isEditing() {
return state == State.EDITING;
}

public void setIsInConfirmationDialog(boolean isInConfirmationDialog) {
this.isInConfirmationDialog = isInConfirmationDialog;
}

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

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/ui/PersonProfileNote.java#L200-L201

Added lines #L200 - L201 were not covered by tests

// endregion

}
11 changes: 9 additions & 2 deletions src/main/java/seedu/address/ui/PersonProfileTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class PersonProfileTags extends UiPart<SplitPane> {
private final PersonProfile personProfile;
private Set<Tag> tags;
private State state;
private boolean isInConfirmationDialog;
// endregion

// region Enums
Expand Down Expand Up @@ -228,14 +229,20 @@ private void handleLoseFocus() {

@FXML
void setFocus() {
personProfile.triggerEvent(PersonProfile.Event.BEFORE_START_EDIT);
updateState(State.EDITING);
if (!isInConfirmationDialog) {
personProfile.triggerEvent(PersonProfile.Event.BEFORE_START_EDIT);
updateState(State.EDITING);

Check warning on line 234 in src/main/java/seedu/address/ui/PersonProfileTags.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/ui/PersonProfileTags.java#L233-L234

Added lines #L233 - L234 were not covered by tests
}
}

boolean isEditing() {
return state == State.EDITING;
}

public void setIsInConfirmationDialog(boolean isInConfirmationDialog) {
this.isInConfirmationDialog = isInConfirmationDialog;
}

Check warning on line 244 in src/main/java/seedu/address/ui/PersonProfileTags.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/ui/PersonProfileTags.java#L243-L244

Added lines #L243 - L244 were not covered by tests

// endregion

}
1 change: 0 additions & 1 deletion src/main/java/seedu/address/ui/UiPart.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,4 @@ private static URL getFxmlFileUrl(String fxmlFileName) {
URL fxmlFileUrl = MainApp.class.getResource(fxmlFileNameWithFolder);
return requireNonNull(fxmlFileUrl);
}

}

0 comments on commit d11fa30

Please sign in to comment.