Skip to content

Commit

Permalink
Merge branch 'master' into testsbranch
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinHuang1203 authored Oct 24, 2023
2 parents d765d6c + ef12d24 commit c408dac
Show file tree
Hide file tree
Showing 47 changed files with 1,059 additions and 167 deletions.
29 changes: 29 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,35 @@ _{more aspects and alternatives to be added}_
_{Explain here how the data archiving feature will be implemented}_


### Help feature
#### Steps to trigger
1. User opens the app
2. User keys in `help`
3. Command list is shown and opens user guide in browser
#### Implementation
1. When the user enters the term help. it triggers the help feature in the parser under the switch case.
2. After it is triggered, it will display a short list of possible commands that the user can use.
3. The user guide will also be opened in their browser
#### Notes
1. Help can be called anytime and has no format to follow. The popup screen is disabled to avoid confusion but can be enabled in the future if need be.

### Confirmation + Clear command
#### Steps to trigger
1. User opens the app
2. User enters `clear` (and subsequently sees a message asking to confirm)
3. User enters `yes` to confirm the clear
#### Implementation
1. This features requires the state of the parser to be known.
2. The parser is modified to store the previous taken in command, in this case whether the previous command was a successful clear command.
3. If the previous command is not a clear command, it looks for the keyword clear. Otherwise, it looks for the keyword yes.
4. Hence, the user will first need to call clear, before calling yes to invoke the clear mechanism, ensuring safety of data.
#### Notes
1. If you would like to extend the code for more features that require state, please do change the case condition for this feature.
2. Currently, it follows the default commands if a word other than yes is given. But this will be improved in a future update.
3. The state of the parser, rather than the app is used to reduce the chances of accidental clears.



--------------------------------------------------------------------------------------------------------------------

## **Documentation, logging, testing, configuration, dev-ops**
Expand Down
16 changes: 10 additions & 6 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,22 +133,26 @@ UI mockup:

Adds a new interview to an applicant.

Format: `addi INDEX t/TYPE`
Format: `addi INDEX t/TYPE [r/RATING]`

Examples:
* `addi 1 t/technical` adds a Technical interview to the 1st person in the displayed applicant list.
* `addi 3 t/screening`
* `addi 1 t/technical r/8.6` adds a Technical interview with rating 8.6 to the 1st person in the displayed applicant list.
* `addi 3 t/screening` adds a Screening interview without rating to the 3rd person in the displayed applicant list.

---
### `editi` : Editing an interview of an applicant

Edits an interview of an applicant.

Format: `editi INDEX i/INTERVIEW_INDEX t/TYPE`
Format: `editi INDEX i/INTERVIEW_INDEX [t/TYPE] [r/RATING]`
* Edits the person at the specified `INDEX`. The index refers to the index number shown in the displayed person list.
* At least one of the optional fields must be provided.
* Existing values will be updated by the input values.

Examples:
* `editi 1 i/1 t/technical` edits the 1st interview of the 1st person in the displayed applicant list to a technical interview.
* `editi 3 i/2 t/screening`
* `editi 1 i/1 t/technical r/7.8` edits the 1st interview of the 1st person in the displayed applicant list to a technical interview with rating 7.8.
* `editi 3 i/2 t/screening` edits the 2nd interview type of the 3rd person in the displayed applicant list to a screening interview.
* `editi 2 i/1 r/8.9` edits the 1st interview rating of the 2nd person in the displayed applicant list to 8.9.

---
### `clear` : Clearing all applicant entries
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/seedu/staffsnap/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
public class MainApp extends Application {

public static final Version VERSION = new Version(0, 2, 2, true);
public static final Version VERSION = new Version(1, 2, 0, false);

private static final Logger logger = LogsCenter.getLogger(MainApp.class);

Expand Down Expand Up @@ -82,7 +82,7 @@ private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) {
try {
applicantBookOptional = storage.readApplicantBook();
if (!applicantBookOptional.isPresent()) {
logger.info("No applicant book found at file path. A new data file will be created at"
logger.info("No applicant book found at file path. A new data file will be created at "
+ storage.getApplicantBookFilePath()
+ " populated with a sample ApplicantBook.");
}
Expand Down Expand Up @@ -173,7 +173,7 @@ protected UserPrefs initPrefs(UserPrefsStorage storage) {

@Override
public void start(Stage primaryStage) {
logger.info("Starting ApplicantBook " + MainApp.VERSION);
logger.info("Starting Staff-Snap " + MainApp.VERSION);
ui.start(primaryStage);
}

Expand Down
8 changes: 7 additions & 1 deletion src/main/java/seedu/staffsnap/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ public static String format(Applicant applicant) {
.append("; Position: ")
.append(applicant.getPosition())
.append("; Interviews: ");
applicant.getInterviews().forEach(builder::append);
applicant.getInterviews().forEach(interview ->
builder.append(interview.getType())
.append("(")
.append(interview.getRating())
.append("); "));
builder.append("; Status: ")
.append(applicant.getStatus());
return builder.toString();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package seedu.staffsnap.logic.commands;

import static java.util.Objects.requireNonNull;
import static seedu.staffsnap.logic.parser.CliSyntax.PREFIX_RATING;
import static seedu.staffsnap.logic.parser.CliSyntax.PREFIX_TYPE;
import static seedu.staffsnap.model.Model.PREDICATE_HIDE_ALL_APPLICANTS;
import static seedu.staffsnap.model.Model.PREDICATE_SHOW_ALL_APPLICANTS;
Expand All @@ -25,9 +26,12 @@ public class AddInterviewCommand extends Command {
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds an interview to an applicant identified "
+ "by the index number used in the displayed applicant list. "
+ "Parameters: INDEX (must be a positive integer)\n"
+ PREFIX_TYPE + "TYPE\n"
+ PREFIX_TYPE + "TYPE" + " "
+ "[" + PREFIX_RATING + "RATING]...\n"
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_TYPE + "technical";
+ "1 "
+ PREFIX_TYPE + "technical" + " "
+ PREFIX_RATING + "8.0";

public static final String MESSAGE_SUCCESS = "New interview added to applicant: %1$s";
public static final String MESSAGE_DUPLICATE_INTERVIEW = "This interview already exists for this applicant";
Expand Down Expand Up @@ -56,7 +60,8 @@ public CommandResult execute(Model model) throws CommandException {

Applicant applicantToEdit = lastShownList.get(index.getZeroBased());

if (applicantToEdit.getInterviews().contains(interviewToAdd)) {
if (applicantToEdit.getInterviews().contains(interviewToAdd)
|| interviewToAdd.isContainedIn(applicantToEdit.getInterviews())) {
throw new CommandException(MESSAGE_DUPLICATE_INTERVIEW);
}

Expand Down
34 changes: 26 additions & 8 deletions src/main/java/seedu/staffsnap/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import seedu.staffsnap.model.applicant.Name;
import seedu.staffsnap.model.applicant.Phone;
import seedu.staffsnap.model.applicant.Position;
import seedu.staffsnap.model.applicant.Status;
import seedu.staffsnap.model.interview.Interview;

/**
Expand Down Expand Up @@ -53,7 +54,7 @@ public class EditCommand extends Command {
private final EditApplicantDescriptor editApplicantDescriptor;

/**
* @param index of the applicant in the filtered applicant list to edit
* @param index of the applicant in the filtered applicant list to edit
* @param editApplicantDescriptor details to edit the applicant with
*/
public EditCommand(Index index, EditApplicantDescriptor editApplicantDescriptor) {
Expand Down Expand Up @@ -96,17 +97,19 @@ public CommandResult execute(Model model) throws CommandException {
* Creates and returns a {@code Applicant} with the details of {@code applicantToEdit}
* edited with {@code editApplicantDescriptor}.
*/
private static Applicant createEditedApplicant(
Applicant applicantToEdit, EditApplicantDescriptor editApplicantDescriptor) {
private static Applicant createEditedApplicant(Applicant applicantToEdit,
EditApplicantDescriptor editApplicantDescriptor) {
assert applicantToEdit != null;

Name updatedName = editApplicantDescriptor.getName().orElse(applicantToEdit.getName());
Phone updatedPhone = editApplicantDescriptor.getPhone().orElse(applicantToEdit.getPhone());
Email updatedEmail = editApplicantDescriptor.getEmail().orElse(applicantToEdit.getEmail());
Position updatedPosition = editApplicantDescriptor.getPosition().orElse(applicantToEdit.getPosition());
List<Interview> updatedInterviews = applicantToEdit.getInterviews();
Status updatedStatus = editApplicantDescriptor.getStatus().orElse(applicantToEdit.getStatus());

return new Applicant(updatedName, updatedPhone, updatedEmail, updatedPosition, updatedInterviews);
return new Applicant(updatedName, updatedPhone, updatedEmail, updatedPosition,
updatedInterviews, updatedStatus);
}

@Override
Expand All @@ -129,8 +132,7 @@ public boolean equals(Object other) {
public String toString() {
return new ToStringBuilder(this)
.add("index", index)
.add("editApplicantDescriptor", editApplicantDescriptor)
.toString();
.add("editApplicantDescriptor", editApplicantDescriptor).toString();
}

/**
Expand All @@ -144,7 +146,11 @@ public static class EditApplicantDescriptor {
private Position position;
private List<Interview> interviews;

public EditApplicantDescriptor() {}

private Status status;

public EditApplicantDescriptor() {
}

/**
* Copy constructor.
Expand All @@ -156,6 +162,7 @@ public EditApplicantDescriptor(EditApplicantDescriptor toCopy) {
setEmail(toCopy.email);
setPosition(toCopy.position);
setInterviews(toCopy.interviews);
setStatus(toCopy.status);
}

/**
Expand Down Expand Up @@ -214,6 +221,15 @@ public Optional<List<Interview>> getInterviews() {
return (interviews != null) ? Optional.of(Collections.unmodifiableList(interviews)) : Optional.empty();
}

public void setStatus(Status status) {
this.status = status;
}

public Optional<Status> getStatus() {
return Optional.ofNullable(status);
}


@Override
public boolean equals(Object other) {
if (other == this) {
Expand All @@ -229,7 +245,8 @@ public boolean equals(Object other) {
return Objects.equals(name, otherEditApplicantDescriptor.name)
&& Objects.equals(phone, otherEditApplicantDescriptor.phone)
&& Objects.equals(email, otherEditApplicantDescriptor.email)
&& Objects.equals(position, otherEditApplicantDescriptor.position);
&& Objects.equals(position, otherEditApplicantDescriptor.position)
&& Objects.equals(status, otherEditApplicantDescriptor.status);
}

@Override
Expand All @@ -239,6 +256,7 @@ public String toString() {
.add("phone", phone)
.add("email", email)
.add("position", position)
.add("status", status).toString()
.toString();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static java.util.Objects.requireNonNull;
import static seedu.staffsnap.logic.parser.CliSyntax.PREFIX_INTERVIEW;
import static seedu.staffsnap.logic.parser.CliSyntax.PREFIX_RATING;
import static seedu.staffsnap.logic.parser.CliSyntax.PREFIX_TYPE;
import static seedu.staffsnap.model.Model.PREDICATE_HIDE_ALL_APPLICANTS;
import static seedu.staffsnap.model.Model.PREDICATE_SHOW_ALL_APPLICANTS;
Expand All @@ -18,6 +19,7 @@
import seedu.staffsnap.model.Model;
import seedu.staffsnap.model.applicant.Applicant;
import seedu.staffsnap.model.interview.Interview;
import seedu.staffsnap.model.interview.Rating;

/**
* Edits the details of an existing interview of an applicant.
Expand All @@ -32,10 +34,12 @@ public class EditInterviewCommand extends Command {
+ "Existing values will be overwritten by the input values.\n"
+ "Parameters: INDEX (must be a positive integer) "
+ PREFIX_INTERVIEW + "INTERVIEW_INDEX "
+ PREFIX_TYPE + "TYPE\n"
+ "[" + PREFIX_TYPE + "TYPE] \n"
+ "[" + PREFIX_RATING + "RATING] \n"
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_INTERVIEW + "2 "
+ PREFIX_TYPE + "Behavioral";
+ PREFIX_TYPE + "Behavioral "
+ PREFIX_RATING + "8.0";

public static final String MESSAGE_EDIT_INTERVIEW_SUCCESS = "Edited interview of Applicant: %1$s";
public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided.";
Expand Down Expand Up @@ -79,7 +83,8 @@ public CommandResult execute(Model model) throws CommandException {
Interview interviewToEdit = applicantToEdit.getInterviews().get(interviewIndex.getZeroBased());
Interview editedInterview = createEditedInterview(interviewToEdit, editInterviewDescriptor);

if (!interviewToEdit.equals(editedInterview) && applicantToEdit.getInterviews().contains(editedInterview)) {
if (!interviewToEdit.getType().equals(editedInterview.getType())
&& editedInterview.isContainedIn(applicantToEdit.getInterviews())) {
throw new CommandException(MESSAGE_DUPLICATE_INTERVIEW);
}

Expand All @@ -100,8 +105,9 @@ private static Interview createEditedInterview(
assert interviewToEdit != null;

String updatedType = editInterviewDescriptor.getType().orElse(interviewToEdit.getType());
Rating updatedRating = editInterviewDescriptor.getRating().orElse(interviewToEdit.getRating());

return new Interview(updatedType);
return new Interview(updatedType, updatedRating);
}

@Override
Expand Down Expand Up @@ -136,6 +142,7 @@ public String toString() {
*/
public static class EditInterviewDescriptor {
private String type;
private Rating rating;

public EditInterviewDescriptor() {}

Expand All @@ -145,13 +152,14 @@ public EditInterviewDescriptor() {}
*/
public EditInterviewDescriptor(EditInterviewDescriptor toCopy) {
setType(toCopy.type);
setRating(toCopy.rating);
}

/**
* Returns true if at least one field is edited.
*/
public boolean isAnyFieldEdited() {
return CollectionUtil.isAnyNonNull(type);
return CollectionUtil.isAnyNonNull(type, rating);
}

public void setType(String type) {
Expand All @@ -162,6 +170,14 @@ public Optional<String> getType() {
return Optional.ofNullable(type);
}

public void setRating(Rating rating) {
this.rating = rating;
}

public Optional<Rating> getRating() {
return Optional.ofNullable(rating);
}

@Override
public boolean equals(Object other) {
if (other == this) {
Expand All @@ -174,13 +190,15 @@ public boolean equals(Object other) {
}

EditInterviewDescriptor otherEditInterviewDescriptor = (EditInterviewDescriptor) other;
return Objects.equals(type, otherEditInterviewDescriptor.type);
return Objects.equals(type, otherEditInterviewDescriptor.type)
&& Objects.equals(rating, otherEditInterviewDescriptor.rating);
}

@Override
public String toString() {
return new ToStringBuilder(this)
.add("type", type)
.add("rating", rating)
.toString();
}
}
Expand Down
13 changes: 1 addition & 12 deletions src/main/java/seedu/staffsnap/logic/commands/SortCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import static java.util.Objects.requireNonNull;
import static seedu.staffsnap.logic.parser.CliSyntax.PREFIX_DESCRIPTOR;
import static seedu.staffsnap.model.Model.PREDICATE_HIDE_ALL_APPLICANTS;
import static seedu.staffsnap.model.Model.PREDICATE_SHOW_ALL_APPLICANTS;

import seedu.staffsnap.logic.commands.exceptions.CommandException;
import seedu.staffsnap.model.Model;
Expand Down Expand Up @@ -36,16 +34,7 @@ public SortCommand(Descriptor descriptor) {
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
model.updateSortedApplicantList(descriptor);
/*
This is a workaround to javaFX not updating the list shown to the user unless the predicate is changed
Possible fix in the future is to read the current predicate, then store it to be reused
Might be an issue when implementing filter()
TODO:
store current predicate in temp variable
use stored predicate when refreshing the filtered list
*/
model.updateFilteredApplicantList(PREDICATE_HIDE_ALL_APPLICANTS);
model.updateFilteredApplicantList(PREDICATE_SHOW_ALL_APPLICANTS);
model.refreshApplicantList();
return new CommandResult(MESSAGE_SUCCESS);
}
}
Loading

0 comments on commit c408dac

Please sign in to comment.