Skip to content

Commit

Permalink
Merge branch 'master' into UG-format-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jerremyng authored Apr 10, 2024
2 parents 144c10d + f6e9a9d commit d098114
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 43 deletions.
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}


checkstyle {
toolVersion = '10.2'
}
Expand Down Expand Up @@ -70,7 +71,11 @@ dependencies {
}

shadowJar {
archiveFileName = 'addressbook.jar'
archiveFileName = 'Dook.jar'
}

processResources {
duplicatesStrategy = 'exclude'
}

defaultTasks 'clean', 'test'
Expand Down
48 changes: 32 additions & 16 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,13 @@ Format: `find KEYWORD [MORE_KEYWORDS]`
* Persons matching at least one keyword will be returned (i.e. `OR` search).
e.g. `Hans Bo` will return `Hans Gruber`, `Bo Yang`

<div markdown="block" class="alert alert-info">
:information_source: **Information**

For now, we can only `find` contacts by name - future implementations would include finding by other fields as well,
so stay tuned!
</div>

Examples:
* `find John` returns `john` and `John Doe`
* `find alex david` returns `Alex Yeoh`, `David Li`<br>
Expand Down Expand Up @@ -460,7 +467,7 @@ This command is **irreversible**, the deleted contact information will be lost!
If you want to remind yourself of your consult tomorrow, you can add it to Dook.

```
-n DESCRIPTION -s START_TIME -e END_TIME -note NOTE
book -n DESCRIPTION -s START_TIME -e END_TIME -note NOTE
```
* Duplicate bookings are not allowed! This means that across two bookings, you cannot have all four params to be the exact same.
* For now: start and end time formats must be in `yyyy-mm-d hh:mm` (we are working to expand this!)
Expand All @@ -470,7 +477,7 @@ If you want to remind yourself of your consult tomorrow, you can add it to Dook.
| **DESCRIPTION** | Must be non-null and unique |
| **START_TIME** | Must follow format of `2023-12-31 19:00` |
| **END_TIME** | Must follow format of `2023-12-31 19:00` |
| **NOTE** | Optional |
| **NOTE** | Must be non-null |

Examples:
* `book -n CS2101 Consult -s 2023-12-31 19:00 -e 2023-12-31 23:00 -note DO HOMEWORK`
Expand Down Expand Up @@ -538,12 +545,12 @@ Done searching for your bookings with your favourite professor? Lets display all
view
```

#### Clearing all bookings entries : `clear`
#### Clearing all bookings entries : `cancel -a`

Want a fresh start? Quickly clears all your bookings with:

```
clear
cancel -a
```

<div markdown="block" class="alert alert-danger">
Expand All @@ -561,22 +568,30 @@ Please use this command with caution!

Dook comes preinstalled with a light and dark theme.

![Dark Theme](images/darktheme.png)

![Light Theme](images/lighttheme.png)
Format: `theme -bg light/dark`

Format: `-bg THEME(light/dark)`
* changes the current theme to either dark/light
* dark theme is the *default* on a new launch
* Dook remembers your preferences!, it loads the most recent selected theme on launch.
* Changes the current theme to either dark/light
* Dark theme is the *default* on a new launch
* Dook remembers your preferences, it loads the most recent selected theme on launch.

Examples:
* `theme -bg light`

Any unknown theme will be met with an error message
Below shows the application before executing `theme -bg light`:

![Dark Theme](images/darktheme.png)

Below shows the application after executing `theme -bg light`:

![Light Theme](images/lighttheme.png)

Below shows the error message upon executing an invalid theme:

![Theme_Command_Failure](images/themefailure.png)


<div markdown="block" class="alert alert-info">:information_source: **Information**

New themes are currently being added.

#### Adding aliases in Dook : `alias`
Expand All @@ -600,6 +615,7 @@ This feature is still in beta, note:
* Aliases must be for the entire command (i.e. cannot replace `add -n` with `addn`)
</div>


#### Exiting the program : `exit`

Exits the program.
Expand All @@ -612,7 +628,7 @@ AddressBook data are saved automatically after any command that changes the data

#### Editing the data file

AddressBook data are saved automatically as a JSON file `[JAR file location]/data/addressbook.json`. Advanced users are welcome to update data directly by editing that data file.
AddressBook data are saved automatically as a JSON file:<br> `[JAR file location]/data/addressbook.json`. <br>Advanced users are welcome to update data directly by editing that data file.

<div markdown="span" class="alert alert-warning">:exclamation: **Caution:**
If your changes to the data file makes its format invalid, AddressBook will discard all data and start with an empty data file at the next run. Hence, it is recommended to take a backup of the file before editing it.<br>
Expand All @@ -623,17 +639,17 @@ Furthermore, certain edits can cause the AddressBook to behave in unexpected way

## FAQ

**Q**: How do I install Java 11?
**Q**: How do I install Java 11?<br>
**A**: Follow this [link](https://docs.oracle.com/en/java/javase/11/install/overview-jdk-installation.html#GUID-8677A77F-231A-40F7-98B9-1FD0B48C346A) for steps to download Java 11.

**Q**: How do I transfer my data to another Computer?<br>
**A**: Go to the application's home directory and copy the `data/addressbook.json` file containing your data into the empty
data folder created by Dook on the other computer.

**Q**: Oh no! I have accidentally closed Dook without using the `exit` command? Do I lose all my data?
**Q**: Oh no! I have accidentally closed Dook without using the `exit` command? Do I lose all my data?<br>
**A**: Not to worry! Dook automatically saves all data after every change, so no data will be lost!

**Q**: Do I need Internet connection to use Dook?
**Q**: Do I need Internet connection to use Dook?<br>
**A**: Nope! Dook works fully offline and online!

--------------------------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/commons/util/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static boolean isFileExists(Path file) {
}

/**
* Returns true if {@code path} can be converted into a {@code Path} via {@link Paths#get(String)},
* Returns true if {@code path} can be converted into a {@code Path},
* otherwise returns false.
* @param path A string representing the file path. Cannot be null.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class BookCommand extends Command {
+ PREFIX_START_TIME + "2023-12-31 19:00 "
+ PREFIX_END_TIME + "2023-12-31 23:00 "
+ PREFIX_NOTES + "Bring cake";
public static final String MESSAGE_NOTE_MISSING = "Error: Please fill in a non-empty note!";
private final Booking toAdd;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public CommandResult execute(Model model) throws CommandException {

model.setBooking(bookingToUpdate, updatedBooking);
model.updateFilteredBookingList(PREDICATE_SHOW_ALL_BOOKINGS);
return new CommandResult(String.format(MESSAGE_UPDATE_BOOKING_SUCCESS, Messages.format(updatedBooking)));
return new CommandResult(String.format(MESSAGE_UPDATE_BOOKING_SUCCESS, Messages.format(bookingToUpdate)));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public BookCommand parse(String args) throws ParseException {

argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_DESCRIPTION, PREFIX_START_TIME, PREFIX_END_TIME, PREFIX_NOTES);

// If note field is empty
if (argMultimap.getValue(PREFIX_NOTES).isEmpty()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, BookCommand.MESSAGE_NOTE_MISSING));
}

Description description = ParserUtil.parseBookingName(argMultimap.getValue(PREFIX_DESCRIPTION).get());
StartTime start = ParserUtil.parseStartTime(argMultimap.getValue(PREFIX_START_TIME).get());
EndTime end = ParserUtil.parseEndTime(argMultimap.getValue(PREFIX_END_TIME).get());
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/address/model/booking/EndTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;

/**
* Represents a Booking's end time in the address book.
* Guarantees: immutable; is valid as declared in {@link #isValidEndTime(String)}
Expand All @@ -13,7 +14,7 @@ public class EndTime {

public static final String MESSAGE_CONSTRAINTS = "End times must be in the format of YYYY-MM-DD HH:MM "
+ "(ISO_LOCAL_DATE_TIME).";
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-M-d HH:mm");
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");

public final String endTimeString;
public final LocalDateTime endTime;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/address/model/booking/StartTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;

/**
* Represents a Booking's start time in the address book.
* Guarantees: immutable; is valid as declared in {@link #isValidStartTime(String)}
Expand All @@ -13,7 +14,7 @@ public class StartTime {

public static final String MESSAGE_CONSTRAINTS = "Start times must be in the format of YYYY-MM-DD HH:MM "
+ "(ISO_LOCAL_DATE_TIME).";
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-M-d HH:mm");
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");

public final String startTimeString;
public final LocalDateTime startTime;
Expand Down
28 changes: 16 additions & 12 deletions src/test/java/seedu/address/logic/commands/UpdateCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,18 @@ public class UpdateCommandTest {

@Test
public void execute_allFieldsSpecifiedUnfilteredList_success() {
Booking originalBooking = model.getFilteredBookingList().get(0);
Booking updatedBooking = new BookingBuilder().build();
UpdateBookingDescriptor descriptor = new UpdateBookingDescriptorBuilder(updatedBooking).build();
UpdateCommand updateCommand = new UpdateCommand(INDEX_FIRST_BOOKING, descriptor);

String expectedMessage = String.format(UpdateCommand.MESSAGE_UPDATE_BOOKING_SUCCESS,
Messages.format(updatedBooking));
Messages.format(originalBooking));

Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()),
new ProfData(model.getProfData()),
new UserPrefs());
expectedModel.setBooking(model.getFilteredBookingList().get(0), updatedBooking);
new ProfData(model.getProfData()),
new UserPrefs());
expectedModel.setBooking(originalBooking, updatedBooking);

assertCommandSuccess(updateCommand, model, expectedMessage, expectedModel);
}
Expand All @@ -69,16 +70,17 @@ public void execute_someFieldsSpecifiedUnfilteredList_success() {
UpdateCommand updateCommand = new UpdateCommand(indexLastBooking, descriptor);

String expectedMessage = String.format(UpdateCommand.MESSAGE_UPDATE_BOOKING_SUCCESS,
Messages.format(updatedBooking));
Messages.format(lastBooking));

Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()),
new ProfData(model.getProfData()),
new UserPrefs());
new ProfData(model.getProfData()),
new UserPrefs());
expectedModel.setBooking(lastBooking, updatedBooking);

assertCommandSuccess(updateCommand, model, expectedMessage, expectedModel);
}


@Test
public void execute_noFieldSpecifiedUnfilteredList_success() {
UpdateCommand updateCommand = new UpdateCommand(INDEX_FIRST_BOOKING, new UpdateBookingDescriptor());
Expand All @@ -102,19 +104,21 @@ public void execute_filteredList_success() {
Booking updatedBooking =
new BookingBuilder(bookingInFilteredList).withDescription(VALID_BOOKING_DESCRIPTION).build();
UpdateCommand updateCommand = new UpdateCommand(INDEX_FIRST_BOOKING,
new UpdateBookingDescriptorBuilder().withDescription(VALID_BOOKING_DESCRIPTION).build());
new UpdateBookingDescriptorBuilder()
.withDescription(VALID_BOOKING_DESCRIPTION).build());

String expectedMessage = String.format(UpdateCommand.MESSAGE_UPDATE_BOOKING_SUCCESS,
Messages.format(updatedBooking));
Messages.format(bookingInFilteredList));

Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()),
new ProfData(model.getProfData()),
new UserPrefs());
expectedModel.setBooking(model.getFilteredBookingList().get(0), updatedBooking);
new ProfData(model.getProfData()),
new UserPrefs());
expectedModel.setBooking(bookingInFilteredList, updatedBooking);

assertCommandSuccess(updateCommand, model, expectedMessage, expectedModel);
}


@Test
public void execute_duplicateBookingUnfilteredList_failure() {
Booking firstBooking = model.getFilteredBookingList().get(INDEX_FIRST_BOOKING.getZeroBased());
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/seedu/address/testutil/BookingBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
public class BookingBuilder {

public static final String DEFAULT_DESCRIPTION = "Default booking description";
public static final String DEFAULT_START_TIME = "2023-12-31 19:00";
public static final String DEFAULT_END_TIME = "2023-12-31 21:00";
public static final String DEFAULT_START_TIME = "2023-12-22 19:00";
public static final String DEFAULT_END_TIME = "2023-12-22 21:00";
public static final String DEFAULT_NOTE = "Hello World!";

private Description description;
Expand Down
16 changes: 8 additions & 8 deletions src/test/java/seedu/address/testutil/TypicalBookings.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@ public class TypicalBookings {

public static final Booking CAREER_ADVISORY = new BookingBuilder()
.withDescription("Career advisory consult")
.withStartTime("2024-1-31 11:00")
.withEndTime("2024-1-31 12:00")
.withStartTime("2024-01-12 11:00")
.withEndTime("2024-01-12 12:00")
.build();

public static final Booking CS2103T_CONSULT = new BookingBuilder()
.withDescription("CS2103T consult")
.withStartTime("2024-3-31 14:00")
.withEndTime("2024-3-31 16:00")
.withStartTime("2024-03-09 14:00")
.withEndTime("2024-03-09 16:00")
.build();

public static final Booking CS2101_CONSULT = new BookingBuilder()
.withDescription("CS2101 consult")
.withStartTime("2024-3-24 14:00")
.withEndTime("2024-3-24 16:00")
.withStartTime("2024-03-24 14:00")
.withEndTime("2024-03-24 16:00")
.build();

public static final Booking CS2109S_CONSULT = new BookingBuilder()
.withDescription("CS2109 consult")
.withStartTime("2024-2-22 11:00")
.withEndTime("2024-2-22 13:00")
.withStartTime("2024-05-22 11:00")
.withEndTime("2024-05-22 13:00")
.build();

public static final Booking GENERIC_BOOKING = new BookingBuilder()
Expand Down

0 comments on commit d098114

Please sign in to comment.