Skip to content

Commit

Permalink
Merge branch 'master' into refactor-remove-person
Browse files Browse the repository at this point in the history
  • Loading branch information
jellywaiyan authored Nov 2, 2023
2 parents f5dae4e + 465b87f commit d2a7ced
Show file tree
Hide file tree
Showing 23 changed files with 756 additions and 196 deletions.
75 changes: 0 additions & 75 deletions .github/workflows/pull-request-artifacts.yml

This file was deleted.

612 changes: 548 additions & 64 deletions docs/UserGuide.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/diagrams/StorageClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ JsonSerializableAddressBook --> "*" JsonAdaptedInternshipTask
JsonAdaptedAssignment --> "*" JsonAdaptedTag
JsonAdaptedInternshipRole --> "*" JsonAdaptedTag
JsonAdaptedInternshipTask --> "*" JsonAdaptedTag
JsonAdaptedInternshipTask --> "1" JsonAdaptedInternshipRole

@enduml
Binary file modified docs/images/StorageClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ public class AddInternshipRoleCommand extends InternshipCommand {

private final InternshipRole toAdd;

/**
* Creates an AddInternshipRole command with the given internship, input cannot be null.
* @param toAdd the internship role to add
*/
public AddInternshipRoleCommand(InternshipRole toAdd) {
requireNonNull(toAdd);
this.toAdd = toAdd;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
public class ParserUtil {
public static final String MESSAGE_INVALID_INDEX = "Index is not a non-zero unsigned integer.";

public static final String MESSAGE_INVALID_DATE = "Enter date in yyyy-mm-dd HH:mm or yyyy-mm-dd "
+ "(default 23:59) format and given date must not be before today's date";
public static final String MESSAGE_INVALID_DATE = "Enter date in yyyy-mm-dd HH:mm or yyyy-mm-dd format. "
+ "Date must be after current date.";

public static final String MESSAGE_INVALID_NAME = "Name cannot be empty";

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/seedu/address/model/AddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,12 @@ public ObservableList<InternshipTask> getInternshipTaskList() {
return internshipTasks.asUnmodifiableObservableList();
}

/**
* Adds an internship task to the list of internship tasks, checking if the role exists first
* @param internshipTask
*/
public void addInternshipTask(InternshipTask internshipTask) {
assert internshipRoles.contains(internshipTask.getInternshipRole());
internshipTasks.add(internshipTask);
}

Expand Down
39 changes: 20 additions & 19 deletions src/main/java/seedu/address/model/fields/IsoDate.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,26 @@
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.format.ResolverStyle;
import java.util.Optional;

/**
* Represents a task's end date.
*/
public class IsoDate extends Date {

public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm";
public static final String DATE_FORMAT_WITHOUT_TIME = "yyyy-MM-dd";
public static final String DATE_FORMAT = "uuuu-MM-dd HH:mm";

public static final String DATE_FORMAT_WITHOUT_TIME = "uuuu-MM-dd";

public static final String MESSAGE_CONSTRAINTS = "Enter date in yyyy-mm-dd HH:mm or yyyy-mm-dd format.";

private static final DateTimeFormatter dfWithTime = DateTimeFormatter.ofPattern(DATE_FORMAT)
.withResolverStyle(ResolverStyle.STRICT);

private static final DateTimeFormatter dfWithoutTime = DateTimeFormatter.ofPattern(DATE_FORMAT_WITHOUT_TIME)
.withResolverStyle(ResolverStyle.STRICT);

public static final String MESSAGE_CONSTRAINTS_LIST =
MESSAGE_CONSTRAINTS + " Start date must be before end date.";

Expand All @@ -41,8 +49,7 @@ public IsoDate(LocalDateTime endDate) {
*/
public static boolean isValidDateNotBeforeToday(String date) {
try {
DateTimeFormatter df = DateTimeFormatter.ofPattern(DATE_FORMAT);
LocalDateTime d = LocalDateTime.parse(date, df);
LocalDateTime d = LocalDateTime.parse(date, dfWithTime);
return !d.isBefore(LocalDateTime.now());
} catch (DateTimeParseException e) {
return false;
Expand All @@ -58,10 +65,8 @@ public static boolean isValidDateNotBeforeToday(String date) {
*/
public static boolean isDateBefore(String startDate, String endDate) {
try {
DateTimeFormatter df = DateTimeFormatter.ofPattern(DATE_FORMAT);
LocalDateTime startDateFilter = LocalDateTime.parse(startDate, df);
LocalDateTime endDateFilter = LocalDateTime.parse(endDate, df);

LocalDateTime startDateFilter = LocalDateTime.parse(startDate, dfWithTime);
LocalDateTime endDateFilter = LocalDateTime.parse(endDate, dfWithTime);
return startDateFilter.isBefore(endDateFilter);
} catch (DateTimeParseException e) {
return false;
Expand All @@ -76,8 +81,7 @@ public static boolean isDateBefore(String startDate, String endDate) {
*/
public static boolean isValidIsoDate(String date) {
try {
DateTimeFormatter df = DateTimeFormatter.ofPattern(DATE_FORMAT);
LocalDate d = LocalDate.parse(date, df);
LocalDateTime d = LocalDateTime.parse(date, dfWithTime);
return true;
} catch (DateTimeParseException e) {
return false;
Expand All @@ -92,8 +96,7 @@ public static boolean isValidIsoDate(String date) {
*/
public static boolean isValidIsoDateWithoutTime(String date) {
try {
DateTimeFormatter df = DateTimeFormatter.ofPattern(DATE_FORMAT_WITHOUT_TIME);
LocalDate d = LocalDate.parse(date, df);
LocalDate d = LocalDate.parse(date, dfWithoutTime);
return true;
} catch (DateTimeParseException e) {
return false;
Expand All @@ -106,8 +109,7 @@ public static boolean isValidIsoDateWithoutTime(String date) {
*/
public static boolean isValidIsoDateWithoutTimeAfterCurrent(String date) {
try {
DateTimeFormatter df = DateTimeFormatter.ofPattern(DATE_FORMAT_WITHOUT_TIME);
LocalDate d = LocalDate.parse(date, df);
LocalDate d = LocalDate.parse(date, dfWithoutTime);
return !d.isBefore(LocalDate.now());
} catch (DateTimeParseException e) {
return false;
Expand All @@ -120,16 +122,15 @@ public static boolean isValidIsoDateWithoutTimeAfterCurrent(String date) {
*/
public static boolean isValidSavedDate(String date) {
try {
DateTimeFormatter df = DateTimeFormatter.ofPattern(DATE_FORMAT);
LocalDateTime.parse(date, df);
LocalDateTime.parse(date, dfWithTime);
return true;
} catch (DateTimeParseException e) {
return false;
}
}

public String toParseString() {
return endDate.format(DateTimeFormatter.ofPattern(DATE_FORMAT));
return endDate.format(dfWithTime);
}

@Override
Expand All @@ -139,7 +140,7 @@ public Optional<LocalDateTime> getDate() {

@Override
public String toString() {
return endDate.format(DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm"));
return endDate.format(dfWithTime);
}

@Override
Expand All @@ -164,7 +165,7 @@ public int hashCode() {

@Override
public String toSaveData() {
return endDate.format(DateTimeFormatter.ofPattern(DATE_FORMAT));
return endDate.format(dfWithTime);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public InternshipTask toModelType() throws IllegalValueException {
final IsoDate modelDeadline = new IsoDate(LocalDateTime.parse(deadline,
DateTimeFormatter.ofPattern(IsoDate.DATE_FORMAT)));


if (outcome == null) {
throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Outcome.class.getSimpleName()));
}
Expand All @@ -107,7 +108,12 @@ public InternshipTask toModelType() throws IllegalValueException {
}
final Status modelStatus = new Status(status);

if (internshipRole == null) {
throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, InternshipRole
.class.getSimpleName()));
}
final InternshipRole modelInternshipRole = internshipRole.toModelType();

final Set<Tag> modelTags = new HashSet<>(internshipTaskTags);

return new InternshipTask(modelInternshipRole, modelName, modelDeadline,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;

import seedu.address.commons.core.LogsCenter;
import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.model.AddressBook;
import seedu.address.model.ReadOnlyAddressBook;
Expand All @@ -27,6 +29,8 @@ class JsonSerializableAddressBook {

public static final String MESSAGE_DUPLICATE_INTERN_TASKS = "InternshipRole list contains duplicate task(s).";

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

private final List<JsonAdaptedAssignment> assignments = new ArrayList<>();

private final List<JsonAdaptedInternshipRole> roles = new ArrayList<>();
Expand Down Expand Up @@ -68,26 +72,42 @@ public JsonSerializableAddressBook(ReadOnlyAddressBook source) {
public AddressBook toModelType() throws IllegalValueException {
AddressBook addressBook = new AddressBook();
for (JsonAdaptedAssignment jsonAdaptedAssignment : assignments) {
Assignment assignment = jsonAdaptedAssignment.toModelType();
if (addressBook.hasAssignment(assignment)) {
throw new IllegalValueException(MESSAGE_DUPLICATE_ASSIGNMENTS);
try {
Assignment assignment = jsonAdaptedAssignment.toModelType();
if (addressBook.hasAssignment(assignment)) {
throw new IllegalValueException(MESSAGE_DUPLICATE_ASSIGNMENTS);
}
addressBook.addAssignment(assignment);
} catch (IllegalValueException e) {
logger.warning("Invalid assignment, will not be added.");
}
addressBook.addAssignment(assignment);
}

for (JsonAdaptedInternshipRole jsonAdaptedInternshipRole : roles) {
InternshipRole role = jsonAdaptedInternshipRole.toModelType();
if (addressBook.hasInternshipRole(role)) {
throw new IllegalValueException(MESSAGE_DUPLICATE_INTERN_ROLES);
try {
InternshipRole role = jsonAdaptedInternshipRole.toModelType();
if (addressBook.hasInternshipRole(role)) {
throw new IllegalValueException(MESSAGE_DUPLICATE_INTERN_ROLES);
}
addressBook.addInternshipRole(role);
} catch (IllegalValueException e) {
logger.warning("Invalid role, will not be added");
}
addressBook.addInternshipRole(role);
}

for (JsonAdaptedInternshipTask jsonAdaptedInternshipTask : internshipTasks) {
InternshipTask internshipTask = jsonAdaptedInternshipTask.toModelType();
if (addressBook.hasInternshipTask(internshipTask)) {
throw new IllegalValueException(MESSAGE_DUPLICATE_INTERN_TASKS);
try {
InternshipTask internshipTask = jsonAdaptedInternshipTask.toModelType();
if (addressBook.hasInternshipTask(internshipTask)) {
throw new IllegalValueException(MESSAGE_DUPLICATE_INTERN_TASKS);
}
if (!addressBook.getInternshipRoleList().contains(internshipTask.getInternshipRole())) {
throw new IllegalValueException("Task does not belong to a valid internship role");
}
addressBook.addInternshipTask(internshipTask);
} catch (IllegalValueException e) {
logger.warning("Invalid task, will not be added");
}
addressBook.addInternshipTask(internshipTask);
}
return addressBook;
}
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/seedu/address/ui/Calendar.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,26 @@ private void addNamesToCell(VBox vbox, LinkedList<String> names) {
vbox.getChildren().add(l);
currCount += 1;
}

if (names.size() > 2) {
Label l = new Label("...");
l.setMaxWidth(500000);
l.setStyle("-fx-text-fill: #ebebeb; -fx-background-color: #262626; "
+ "-fx-background-radius: 0.5em; -fx-max-height: 30;");
vbox.getChildren().add(l);
}
}

/**
* Shifts the current month of the calendar by the given input
* @param monthsToAdd the amount to shift
*/
public void handleCalendarChange(int monthsToAdd) {
// Prevents user from going before year 0
if (selectedCalendarMonth.plusMonths(monthsToAdd).getYear() < 0) {
return;
}

// Reset calendar
calendar.getChildren().clear();

Expand Down Expand Up @@ -208,7 +221,8 @@ private void fillStartOfCurrentMonthToEndOfCalendar() {
day.getStyleClass().add("cal-disabled");
}

if (newMonthDate.equals(LocalDate.now())) {

if (newMonthDate.equals(LocalDate.now()) && !newMonthDate.isAfter(endOfMonthDate)) {
day.setStyle("-fx-text-fill: #BB66FC;");
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/view/DarkTheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -443,5 +443,9 @@
-fx-font-weight: 700;
}

.rounded-container {
-fx-background-radius: 1em;
}



2 changes: 1 addition & 1 deletion src/main/resources/view/InternPanel.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Label HBox.hgrow="ALWAYS" styleClass="h2">Applications</Label>
<Label HBox.hgrow="ALWAYS" maxWidth="Infinity"></Label>
</HBox>
<VBox fx:id="internshipRolePlaceHolder" VBox.vgrow="ALWAYS" />
<VBox fx:id="internshipRolePlaceHolder" VBox.vgrow="ALWAYS"/>
<HBox>
<Label HBox.hgrow="ALWAYS" maxWidth="Infinity"></Label>
<Label HBox.hgrow="ALWAYS" styleClass="h2">Tasks</Label>
Expand Down
Loading

0 comments on commit d2a7ced

Please sign in to comment.