Skip to content

Commit 5c31d0d

Browse files
Merge branch 'master' of https://github.com/AY2324S2-CS2103T-F13-1/tp into 157-update-command-history-in-ug
* 'master' of https://github.com/AY2324S2-CS2103T-F13-1/tp: (26 commits) Update docs/UserGuide.md Fix wrong command examples Fix wrong command examples Explain why there is no text wrapping Include info on tags format Add note to addstu behavior in user guide Improve format for addstu command user guide Improve wording for addstu command user guide Improve addstu command user guide documentation Allow keyFormat to support icon Update docs/UserGuide.md Update docs/UserGuide.md Fix example of addstu that used `add` instead of `addstu` Fix typo Add Navigating GUI section and hyperlinks to sections Add Titus' suggestions Update docs/UserGuide.md Update docs/UserGuide.md Add Useful Notations and Glossary section Add hyperlinks ... # Conflicts: # docs/UserGuide.md
2 parents 57f0965 + cb5ff55 commit 5c31d0d

File tree

13 files changed

+370
-59
lines changed

13 files changed

+370
-59
lines changed

docs/UserGuide.md

Lines changed: 241 additions & 50 deletions
Large diffs are not rendered by default.

docs/_markbind/_macros.nj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@
1212
</box>
1313

1414
{% endmacro %}
15+
16+
17+
18+
{# Keyboard key formatting #}
19+
{% macro keyFormat(name, icon='') %}<span class="badge bg-light text-dark border">{% if icon %}{{ icon }} {% endif %}{{ name | upper }}</span>{% endmacro %}

docs/images/TAProLogo.jpg

43.6 KB
Loading

src/main/java/seedu/address/logic/LogicManager.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@
1212
import seedu.address.logic.autocomplete.AutoComplete;
1313
import seedu.address.logic.autocomplete.AutoCompleteCommand;
1414
import seedu.address.logic.autocomplete.AutoCompleteResult;
15-
import seedu.address.logic.commands.AddPersonCommand;
16-
import seedu.address.logic.commands.ClearCommand;
1715
import seedu.address.logic.commands.Command;
1816
import seedu.address.logic.commands.CommandResult;
19-
import seedu.address.logic.commands.DeletePersonCommand;
20-
import seedu.address.logic.commands.EditPersonCommand;
2117
import seedu.address.logic.commands.exceptions.CommandException;
2218
import seedu.address.logic.parser.AddressBookParser;
2319
import seedu.address.logic.parser.exceptions.ParseException;
@@ -59,10 +55,7 @@ public CommandResult execute(String commandText) throws CommandException, ParseE
5955
CommandResult commandResult = command.execute(model);
6056

6157
// Update the attributes value generation for prefix autocompletion.
62-
if (command instanceof AddPersonCommand
63-
|| command instanceof DeletePersonCommand
64-
|| command instanceof EditPersonCommand
65-
|| command instanceof ClearCommand) {
58+
if (command.isModification()) {
6659
AttributeValueGeneratorManager.updateAddressBook(getAddressBook());
6760
}
6861

src/main/java/seedu/address/logic/commands/AddPersonCommand.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ public CommandResult execute(Model model) throws CommandException {
6767
return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(toAdd)));
6868
}
6969

70+
@Override
71+
public boolean isModification() {
72+
return true;
73+
}
74+
7075
@Override
7176
public boolean equals(Object other) {
7277
if (other == this) {

src/main/java/seedu/address/logic/commands/ClearCommand.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,9 @@ public CommandResult execute(Model model) {
2626
model.setAddressBook(new AddressBook());
2727
return new CommandResult(MESSAGE_SUCCESS);
2828
}
29+
30+
@Override
31+
public boolean isModification() {
32+
return true;
33+
}
2934
}

src/main/java/seedu/address/logic/commands/Command.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,12 @@ public abstract class Command {
1717
*/
1818
public abstract CommandResult execute(Model model) throws CommandException;
1919

20+
/**
21+
* Returns true if the command potentially modifies the model in a way that should be saved to storage.
22+
*
23+
* @return True if the command potentially modifies the model, otherwise false.
24+
*/
25+
public boolean isModification() {
26+
return false;
27+
}
2028
}

src/main/java/seedu/address/logic/commands/DeletePersonCommand.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ public CommandResult execute(Model model) throws CommandException {
5858
return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(personToDelete)));
5959
}
6060

61+
@Override
62+
public boolean isModification() {
63+
return true;
64+
}
65+
6166
@Override
6267
public boolean equals(Object other) {
6368
if (other == this) {

src/main/java/seedu/address/logic/commands/EditPersonCommand.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ public CommandResult execute(Model model) throws CommandException {
9393
return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)));
9494
}
9595

96+
@Override
97+
public boolean isModification() {
98+
return true;
99+
}
100+
96101
/**
97102
* Creates and returns a {@code Person} with the details of {@code personToEdit}
98103
* edited with {@code editPersonDescriptor}.

src/main/java/seedu/address/logic/commands/MarkAttendanceCommand.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ public CommandResult execute(Model model) throws CommandException {
8080
return new CommandResult(formattedMessage);
8181
}
8282

83+
@Override
84+
public boolean isModification() {
85+
return true;
86+
}
87+
8388
@Override
8489
public boolean equals(Object other) {
8590
if (other == this) {

src/main/java/seedu/address/logic/commands/SetCourseCommand.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ public CommandResult execute(Model model) throws CommandException {
5353
return new CommandResult(MESSAGE_SUCCESS);
5454
}
5555

56+
@Override
57+
public boolean isModification() {
58+
return true;
59+
}
60+
5661
@Override
5762
public boolean equals(Object other) {
5863
if (other == this) {

src/main/java/seedu/address/logic/commands/UnmarkAttendanceCommand.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class UnmarkAttendanceCommand extends Command {
2929
public static final String MESSAGE_USAGE = generateMessageUsage(
3030
COMMAND_WORD,
3131
"Unmarks the attendance of the student identified by their NUSNet ID "
32-
+ "by removing the specified week to their attendance set. ",
32+
+ "by removing the specified week from their attendance set. ",
3333
PARAMETER_NUSNET, PARAMETER_WEEK);
3434

3535
public static final String MESSAGE_UNMARKED_ATTENDANCE_SUCCESS = "Unmarked attendance for student: ";
@@ -82,7 +82,11 @@ public CommandResult execute(Model model) throws CommandException {
8282
updatedPerson.getName(), updatedPerson.getNusNet(), weekNumber);
8383

8484
return new CommandResult(formattedMessage);
85+
}
8586

87+
@Override
88+
public boolean isModification() {
89+
return true;
8690
}
8791

8892
@Override
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package seedu.address.logic.commands;
2+
3+
import static org.junit.jupiter.api.Assertions.assertFalse;
4+
import static org.junit.jupiter.api.Assertions.assertTrue;
5+
import static seedu.address.testutil.TypicalPersons.ALICE;
6+
7+
import java.util.ArrayList;
8+
9+
import org.junit.jupiter.api.Test;
10+
11+
import seedu.address.commons.core.index.Index;
12+
import seedu.address.model.course.Course;
13+
import seedu.address.model.person.NameContainsKeywordsPredicate;
14+
import seedu.address.model.person.NusNet;
15+
import seedu.address.model.weeknumber.WeekNumber;
16+
17+
class CommandTest {
18+
19+
@Test
20+
void isModification() {
21+
NusNet genericNusNet = new NusNet("E1234567");
22+
WeekNumber genericWeekNumber = new WeekNumber("1");
23+
Course genericCourse = new Course("CS2103T");
24+
25+
// EP: AddPersonCommand
26+
Command addCommand = new AddPersonCommand(ALICE);
27+
assertTrue(addCommand.isModification());
28+
29+
// EP: ClearCommand
30+
Command clearCommand = new ClearCommand();
31+
assertTrue(clearCommand.isModification());
32+
33+
// EP: DeletePersonCommand
34+
Command deleteCommand = new DeletePersonCommand(genericNusNet);
35+
assertTrue(deleteCommand.isModification());
36+
37+
// EP: EditPersonCommand
38+
Command editCommand = new EditPersonCommand(
39+
Index.fromOneBased(1),
40+
new EditPersonCommand.EditPersonDescriptor()
41+
);
42+
assertTrue(editCommand.isModification());
43+
44+
// EP: FindPersonCommand
45+
Command findCommand = new FindPersonCommand(
46+
new NameContainsKeywordsPredicate(new ArrayList<>())
47+
);
48+
assertFalse(findCommand.isModification());
49+
50+
// EP: ListPersonCommand
51+
Command listCommand = new ListPersonCommand();
52+
assertFalse(listCommand.isModification());
53+
54+
// EP: MarkAttendanceCommand
55+
Command markAttendanceCommand = new MarkAttendanceCommand(
56+
genericNusNet,
57+
genericWeekNumber
58+
);
59+
assertTrue(markAttendanceCommand.isModification());
60+
61+
// EP: UnmarkAttendanceCommand
62+
Command unmarkAttendanceCommand = new UnmarkAttendanceCommand(
63+
genericNusNet,
64+
genericWeekNumber
65+
);
66+
assertTrue(unmarkAttendanceCommand.isModification());
67+
68+
// EP: HelpCommand
69+
Command helpCommand = new HelpCommand();
70+
assertFalse(helpCommand.isModification());
71+
72+
// EP: ExitCommand
73+
Command exitCommand = new ExitCommand();
74+
assertFalse(exitCommand.isModification());
75+
76+
// EP: SetCourseCommand
77+
Command setCourseCommand = new SetCourseCommand(genericCourse);
78+
assertTrue(setCourseCommand.isModification());
79+
}
80+
}

0 commit comments

Comments
 (0)