diff --git a/src/main/java/seedu/address/commons/events/ui/HideStaffPanelEvent.java b/src/main/java/seedu/address/commons/events/ui/HideStaffPanelEvent.java
new file mode 100644
index 000000000000..25c8815f99bc
--- /dev/null
+++ b/src/main/java/seedu/address/commons/events/ui/HideStaffPanelEvent.java
@@ -0,0 +1,14 @@
+package seedu.address.commons.events.ui;
+
+import seedu.address.commons.events.BaseEvent;
+
+/**
+ * A UI event class that is used to hide the {@code StaffPanel}
+ */
+public class HideStaffPanelEvent extends BaseEvent {
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName();
+ }
+}
diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java
index a20e9d49eac7..e144a9ef6f16 100644
--- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java
+++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java
@@ -4,8 +4,10 @@
import java.util.List;
+import seedu.address.commons.core.EventsCenter;
import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
+import seedu.address.commons.events.ui.HideStaffPanelEvent;
import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
@@ -43,6 +45,11 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
Person personToDelete = lastShownList.get(targetIndex.getZeroBased());
model.deletePerson(personToDelete);
model.commitAddressBook();
+
+ if (lastShownList.isEmpty()) {
+ EventsCenter.getInstance().post(new HideStaffPanelEvent());
+ }
+
return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, personToDelete));
}
diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java
index 3a38cae960a3..1f28ab0bbed4 100644
--- a/src/main/java/seedu/address/logic/commands/EditCommand.java
+++ b/src/main/java/seedu/address/logic/commands/EditCommand.java
@@ -20,8 +20,10 @@
import java.util.Optional;
import java.util.Set;
+import seedu.address.commons.core.EventsCenter;
import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
+import seedu.address.commons.events.ui.JumpToListRequestEvent;
import seedu.address.commons.util.CollectionUtil;
import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.exceptions.CommandException;
@@ -105,6 +107,10 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
model.updatePerson(personToEdit, editedPerson);
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
model.commitAddressBook();
+
+ Index indexEdited = Index.fromZeroBased(model.getFilteredPersonList().indexOf(editedPerson));
+ EventsCenter.getInstance().post(new JumpToListRequestEvent(indexEdited));
+
return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, editedPerson));
}
diff --git a/src/main/java/seedu/address/logic/commands/FeedbackCommand.java b/src/main/java/seedu/address/logic/commands/FeedbackCommand.java
index 6a4dc3ec7335..7c791e7b521b 100644
--- a/src/main/java/seedu/address/logic/commands/FeedbackCommand.java
+++ b/src/main/java/seedu/address/logic/commands/FeedbackCommand.java
@@ -6,8 +6,10 @@
import java.util.List;
+import seedu.address.commons.core.EventsCenter;
import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
+import seedu.address.commons.events.ui.JumpToListRequestEvent;
import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
@@ -64,6 +66,10 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
model.updatePerson(personToEdit, editedPerson);
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
model.commitAddressBook();
+
+ Index indexEdited = Index.fromZeroBased(model.getFilteredPersonList().indexOf(editedPerson));
+ EventsCenter.getInstance().post(new JumpToListRequestEvent(indexEdited));
+
return new CommandResult(String.format(MESSAGE_FEEDBACK_PERSON_SUCCESS, editedPerson));
}
diff --git a/src/main/java/seedu/address/logic/commands/PrivacyCommand.java b/src/main/java/seedu/address/logic/commands/PrivacyCommand.java
index a42c58728a6b..b5bd202991d9 100644
--- a/src/main/java/seedu/address/logic/commands/PrivacyCommand.java
+++ b/src/main/java/seedu/address/logic/commands/PrivacyCommand.java
@@ -11,8 +11,10 @@
import java.util.Optional;
import java.util.Set;
+import seedu.address.commons.core.EventsCenter;
import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
+import seedu.address.commons.events.ui.JumpToListRequestEvent;
import seedu.address.commons.util.CollectionUtil;
import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.exceptions.CommandException;
@@ -79,6 +81,10 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
model.updatePerson(personToEdit, editedPerson);
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
model.commitAddressBook();
+
+ Index indexEdited = Index.fromZeroBased(model.getFilteredPersonList().indexOf(editedPerson));
+ EventsCenter.getInstance().post(new JumpToListRequestEvent(indexEdited));
+
return new CommandResult(String.format(MESSAGE_EDIT_PRIVACY_SUCCESS, editedPerson));
}
diff --git a/src/main/java/seedu/address/logic/commands/RateCommand.java b/src/main/java/seedu/address/logic/commands/RateCommand.java
index 09ebcbd30f8a..70728a8642ba 100644
--- a/src/main/java/seedu/address/logic/commands/RateCommand.java
+++ b/src/main/java/seedu/address/logic/commands/RateCommand.java
@@ -6,8 +6,10 @@
import java.util.List;
+import seedu.address.commons.core.EventsCenter;
import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
+import seedu.address.commons.events.ui.JumpToListRequestEvent;
import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
@@ -70,6 +72,10 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
model.updatePerson(personToEdit, editedPerson);
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
model.commitAddressBook();
+
+ Index indexEdited = Index.fromZeroBased(model.getFilteredPersonList().indexOf(editedPerson));
+ EventsCenter.getInstance().post(new JumpToListRequestEvent(indexEdited));
+
return new CommandResult(String.format(MESSAGE_RATING_PERSON_SUCCESS, editedPerson));
}
diff --git a/src/main/java/seedu/address/logic/commands/RedoCommand.java b/src/main/java/seedu/address/logic/commands/RedoCommand.java
index 227771a4eef6..3fe85d8b8fd7 100644
--- a/src/main/java/seedu/address/logic/commands/RedoCommand.java
+++ b/src/main/java/seedu/address/logic/commands/RedoCommand.java
@@ -3,6 +3,8 @@
import static java.util.Objects.requireNonNull;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS;
+import seedu.address.commons.core.EventsCenter;
+import seedu.address.commons.events.ui.HideStaffPanelEvent;
import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
@@ -13,7 +15,8 @@
public class RedoCommand extends Command {
public static final String COMMAND_WORD = "redo";
- public static final String MESSAGE_SUCCESS = "Redo success!";
+ public static final String MESSAGE_SUCCESS = "Redo success!" + "\n"
+ + "Any staff panel previously selected will now be unselected";
public static final String MESSAGE_FAILURE = "No more commands to redo!";
@Override
@@ -26,6 +29,8 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
model.redoAddressBook();
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
+
+ EventsCenter.getInstance().post(new HideStaffPanelEvent());
return new CommandResult(MESSAGE_SUCCESS);
}
}
diff --git a/src/main/java/seedu/address/logic/commands/UndoCommand.java b/src/main/java/seedu/address/logic/commands/UndoCommand.java
index 40441264f346..2b440db6c2c5 100644
--- a/src/main/java/seedu/address/logic/commands/UndoCommand.java
+++ b/src/main/java/seedu/address/logic/commands/UndoCommand.java
@@ -3,6 +3,8 @@
import static java.util.Objects.requireNonNull;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS;
+import seedu.address.commons.core.EventsCenter;
+import seedu.address.commons.events.ui.HideStaffPanelEvent;
import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
@@ -13,7 +15,8 @@
public class UndoCommand extends Command {
public static final String COMMAND_WORD = "undo";
- public static final String MESSAGE_SUCCESS = "Undo success!";
+ public static final String MESSAGE_SUCCESS = "Undo success!" + "\n"
+ + "Any staff panel previously selected will now be unselected";
public static final String MESSAGE_FAILURE = "No more commands to undo!";
@Override
@@ -26,6 +29,8 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
model.undoAddressBook();
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
+
+ EventsCenter.getInstance().post(new HideStaffPanelEvent());
return new CommandResult(MESSAGE_SUCCESS);
}
}
diff --git a/src/main/java/seedu/address/model/person/Manager.java b/src/main/java/seedu/address/model/person/Manager.java
index 1252dfc2cd26..c90cb1d0373b 100644
--- a/src/main/java/seedu/address/model/person/Manager.java
+++ b/src/main/java/seedu/address/model/person/Manager.java
@@ -10,13 +10,13 @@
public class Manager {
public static final String MESSAGE_CONSTRAINTS =
- "Managers should only contain alphanumeric characters and spaces, and it should not be blank";
+ "Managers should only contain alphabetical characters and spaces, and it should not be blank";
/**
* The first character of the manager must not be a whitespace,
* otherwise " " (a blank string) becomes a valid input.
*/
- public static final String VALIDATION_REGEX = "[\\p{Alnum}][\\p{Alnum} ]*";
+ public static final String VALIDATION_REGEX = "[\\p{Alpha}][\\p{Alpha} ]*";
public final String fullName;
diff --git a/src/main/java/seedu/address/model/person/Name.java b/src/main/java/seedu/address/model/person/Name.java
index 79244d71cf73..f26d1dab2fb1 100644
--- a/src/main/java/seedu/address/model/person/Name.java
+++ b/src/main/java/seedu/address/model/person/Name.java
@@ -10,13 +10,13 @@
public class Name {
public static final String MESSAGE_CONSTRAINTS =
- "Names should only contain alphanumeric characters and spaces, and it should not be blank";
+ "Names should only contain alphabetical characters and spaces, and it should not be blank";
/*
* The first character of the address must not be a whitespace,
* otherwise " " (a blank string) becomes a valid input.
*/
- public static final String VALIDATION_REGEX = "[\\p{Alnum}][\\p{Alnum} ]*";
+ public static final String VALIDATION_REGEX = "[\\p{Alpha}][\\p{Alpha} ]*";
public final String fullName;
diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java
index 505c6db1ff06..0600251994b2 100644
--- a/src/main/java/seedu/address/ui/MainWindow.java
+++ b/src/main/java/seedu/address/ui/MainWindow.java
@@ -16,6 +16,7 @@
import seedu.address.commons.core.GuiSettings;
import seedu.address.commons.core.LogsCenter;
import seedu.address.commons.events.ui.ExitAppRequestEvent;
+import seedu.address.commons.events.ui.HideStaffPanelEvent;
import seedu.address.commons.events.ui.PersonPanelSelectionChangedEvent;
import seedu.address.commons.events.ui.ShowHelpRequestEvent;
import seedu.address.logic.Logic;
@@ -209,4 +210,10 @@ private void handlePersonPanelSelectionChangedEvent(PersonPanelSelectionChangedE
logger.info(LogsCenter.getEventHandlingLogMessage(event));
enableStaffPanel();
}
+
+ @Subscribe
+ private void handleHideStaffPanelEvent(HideStaffPanelEvent event) {
+ logger.info(LogsCenter.getEventHandlingLogMessage(event));
+ staffPlaceholder.setVisible(false);
+ }
}
diff --git a/src/main/resources/view/PersonListCard.fxml b/src/main/resources/view/PersonListCard.fxml
index 4515438606c5..81a7e1f948f2 100644
--- a/src/main/resources/view/PersonListCard.fxml
+++ b/src/main/resources/view/PersonListCard.fxml
@@ -32,12 +32,12 @@
-
-
+
+
-
-
+
+
diff --git a/src/test/java/seedu/address/model/person/ManagerTest.java b/src/test/java/seedu/address/model/person/ManagerTest.java
index 5465294b33ef..b449c770c43c 100644
--- a/src/test/java/seedu/address/model/person/ManagerTest.java
+++ b/src/test/java/seedu/address/model/person/ManagerTest.java
@@ -30,12 +30,12 @@ public void isValidManager() {
assertFalse(Manager.isValidManager(" ")); // spaces only
assertFalse(Manager.isValidManager("^")); // only non-alphanumeric characters
assertFalse(Manager.isValidManager("peter*")); // contains non-alphanumeric characters
+ assertFalse(Manager.isValidManager("peter the 2nd")); // alphanumeric characters
+ assertFalse(Manager.isValidManager("12345")); // numbers only
// valid manager
assertTrue(Manager.isValidManager("peter jack")); // alphabets only
- assertTrue(Manager.isValidManager("12345")); // numbers only
- assertTrue(Manager.isValidManager("peter the 2nd")); // alphanumeric characters
assertTrue(Manager.isValidManager("Capital Tan")); // with capital letters
- assertTrue(Manager.isValidManager("David Roger Jackson Ray Jr 2nd")); // long names
+ assertTrue(Manager.isValidManager("David Roger Jackson Ray Jr")); // long names
}
}
diff --git a/src/test/java/seedu/address/model/person/NameTest.java b/src/test/java/seedu/address/model/person/NameTest.java
index b4a356b6f011..e2d5feb83693 100644
--- a/src/test/java/seedu/address/model/person/NameTest.java
+++ b/src/test/java/seedu/address/model/person/NameTest.java
@@ -30,12 +30,12 @@ public void isValidName() {
assertFalse(Name.isValidName(" ")); // spaces only
assertFalse(Name.isValidName("^")); // only non-alphanumeric characters
assertFalse(Name.isValidName("peter*")); // contains non-alphanumeric characters
+ assertFalse(Name.isValidName("12345")); // numbers only
+ assertFalse(Name.isValidName("peter the 2nd")); // alphanumeric characters
// valid name
assertTrue(Name.isValidName("peter jack")); // alphabets only
- assertTrue(Name.isValidName("12345")); // numbers only
- assertTrue(Name.isValidName("peter the 2nd")); // alphanumeric characters
assertTrue(Name.isValidName("Capital Tan")); // with capital letters
- assertTrue(Name.isValidName("David Roger Jackson Ray Jr 2nd")); // long names
+ assertTrue(Name.isValidName("David Roger Jackson Ray Jr nd")); // long names
}
}
diff --git a/src/test/java/seedu/address/ui/PersonListPanelTest.java b/src/test/java/seedu/address/ui/PersonListPanelTest.java
index 789a0b1839fb..8c4cdbfb9a5d 100644
--- a/src/test/java/seedu/address/ui/PersonListPanelTest.java
+++ b/src/test/java/seedu/address/ui/PersonListPanelTest.java
@@ -95,7 +95,11 @@ private Path createXmlFileWithPersons(int personCount) throws Exception {
builder.append("\n");
for (int i = 0; i < personCount; i++) {
builder.append("\n");
- builder.append("").append(i).append("a\n");
+ builder.append("");
+ for (int n = 0; n < i; n++) {
+ builder.append("a");
+ }
+ builder.append("a\n");
builder.append("91239090\n");
builder.append("a@aa\n");
builder.append("a\n");