Skip to content
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 command #114

Conversation

iamdiluxedbutcooler
Copy link

closes #104

Screenshot 2567-10-22 at 05 18 28

This command allows users to see detailed information about a specific person in the address book using the following syntax: view <INDEX>

Copy link

@FionaQY FionaQY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Good job! The Ui looks pretty good

Comment on lines +75 to +78
tierLabel.getStyleClass().add(tier + "-tier");

// Add the label to the FlowPane
assignedTier.getChildren().add(tierLabel);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. the issue now is that for those with no tier, there is now an awkward gap where Tier originally was.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To add on, I think you can use a conditional to render and add the label only if the tier != "NA"

Copy link
Author

@iamdiluxedbutcooler iamdiluxedbutcooler Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for feedback guys @FionaQY @ZShunRen . Quite a significant change for it as conditional UI rendering is related to .fxml and .css :( Have opened a new issue and picked up: #119

Copy link

@ZShunRen ZShunRen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Terrific work pleng! I really like the new UI changes with view. Although close command has yet to be added, the tests you have added are also very comprehensive!

*/
private void ensureSelectedPersonIsValid(ListChangeListener.Change<? extends Person> change) {
while (change.next()) {
if (selectedPerson.getValue() == null) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps you can use getSelectedPerson method here to improve maintainability.

Comment on lines +190 to +209
private void handleViewCommand(String commandText) {
if (!splitPane.getItems().contains(personDetailsPanelPlaceholder)) {
splitPane.getItems().add(personDetailsPanelPlaceholder);
placeholderImage.setVisible(false);
splitPane.setDividerPositions(0.6);
}

String[] commandParts = commandText.split("\\s+");
if (commandParts.length > 1) {
try {
int index = Integer.parseInt(commandParts[1]) - 1; // Assuming 1-based indexing in UI
Person personToView = logic.getFilteredPersonList().get(index);
personDetailPanel.setPersonDetails(personToView);
} catch (NumberFormatException | IndexOutOfBoundsException e) {
// Handle invalid index
resultDisplay.setFeedbackToUser("Invalid person index.");
}
} else {
resultDisplay.setFeedbackToUser("Please provide a person index to view.");
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nicely done!

Comment on lines +75 to +78
tierLabel.getStyleClass().add(tier + "-tier");

// Add the label to the FlowPane
assignedTier.getChildren().add(tierLabel);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To add on, I think you can use a conditional to render and add the label only if the tier != "NA"

Copy link

@itsme-zeix itsme-zeix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work - super clean code and looks great!

We should discuss whether a user image is necessary since there is no function to change it at the moment but we can just merge anyways, we can deal with it later.

Comment on lines 135 to 137
if (person != null && !filteredPersons.contains(person)) {
throw new PersonNotFoundException();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (person != null && !filteredPersons.contains(person)) {
throw new PersonNotFoundException();
}
requireNonNull(person);
if (!filteredPersons.contains(person)) {
throw new PersonNotFoundException();
}

Could consider doing this to match what the module did, but I have no issues with the current implementation either.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing out!

src/main/java/seedu/address/model/ModelManager.java Outdated Show resolved Hide resolved
src/main/java/seedu/address/model/ModelManager.java Outdated Show resolved Hide resolved
resultDisplay.setFeedbackToUser(commandResult.getFeedbackToUser());

if (commandText.trim().toLowerCase().startsWith("view")) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth refactoring the predicate condition to a isViewCommand() method, similar to the isShowHelp() method.

@iamdiluxedbutcooler iamdiluxedbutcooler merged commit 8ca6273 into AY2425S1-CS2103T-T14-4:master Oct 22, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

View command with UI change
4 participants