Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation #188

Merged
merged 15 commits into from
Nov 11, 2018
4 changes: 2 additions & 2 deletions docs/AboutUs.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ Responsibilities: Archive (Archive, Restore)

'''

=== Jian Yu
=== Kok Jian Yu
image::kokjianyu.png[width="150", align="left"]
{empty}[http://github.com/KokJianYu[github]]
{empty}[http://github.com/KokJianYu[github]][http://github.com/CS2103-AY1819S1-F10-1/main/blob/master/docs/team/kokjianyu.adoc[portfolio]]

Role: Developer +
Responsibilities: Permissions (Adding, Removing, Ensuring user has valid permissions)
Expand Down
128 changes: 116 additions & 12 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,46 @@ image::UndoRedoActivityDiagram.png[width="650"]
** Cons: Requires dealing with commands that have already been undone: We must remember to skip these commands. Violates Single Responsibility Principle and Separation of Concerns as `HistoryManager` now needs to do two different things.
// end::undoredo[]

// tag::permission
//tag::commandautocomplete[]
=== Command Auto Complete

When user type in the command box, OASIS will predict what commands the user is going to run, and display a drop down list containing all suggestions.

==== Current Implementation

Auto complete functionality in OASIS is supported by both `org.controlsfx.control.textfield.TextFields` API and `AutoCompleteCommandHelper` class.

When text is typed into the Command Box (`commandTextField` object), it will display a drop down list of possible commands, that is retrieved from `AutoCompleteCommandHelper` class.

* `org.controlsfx.control.textfield.TextFields` API is utilised to display the drop down list.

* `AutoCompleteCommandHelper` class is used to generate the `Set` of possible commands with the input given in `CommandBox`.


===== Aspect: Logic & UI
When `CommandBox` class is being constructed, `bindAutoCompletion` method provided by `TextFields` API will be utilised to create an auto-completion binding between the `commandTextField` object and `AutoCompleteCommandHelper#autoCompleteWord` method.

With this binding, whenever `commandTextField` is updated, it will display a drop down list of possible commands retrieved from `AutoCompleteCommandHelper#autoCompleteWord` if it exist.

===== Design Considerations

* Alternative 1 (Current Implementation): Make use of `TextFields` API

** Pros: Easy to implement.

** Pros: Can view ALL possible commands.

** Cons: There is a slight delay before the drop down list appear. Can potentially slow down users who type fast.

* Alternative 2: Immediately place predicted command as text into `commandTextField`.

** Pros: No delay, predicted command is immediately displayed.

** Cons: Only able to view 1 possible command.

//end::commandautocomplete[]

// tag::permission[]
=== Permission System
There are several commands in OASIS that should not be executable by every user. E.g. Add and Delete commands should only be usable by user with the power to hire and dismiss other employees.
Permission system is used to ensure that each user are only able to perform commands that they are authorised to when using OASIS.
Expand All @@ -348,13 +387,24 @@ Permission system is used to ensure that each user are only able to perform comm
===== Aspect: Model
Model of a person have been changed to reflect the permission that each user possesses.

The following diagram highlights the class added to reflect the changes to the model for `Person`.
The class highlighted in Red in the following diagram represents the class that have been created to support the Permission system.

image::permissionPersonModel.png[width="750"]

image::permissionPersonModel.png[width="350"]
* `Permission` class contains the all possible Permissions that are available to a Person.

* All values in `PermissionSet` must be from `Permission` class.

* `PresetPermission` is a enumeration class that resides in `PermissionSet`. `PresetPermission` is utilised by `PermissionSet` class to generate a `PermissionSet` object that represents the set of permission that a certain type of User will possess.

[NOTE]
As of v1.4, `PresetPermission` only contains the following preset: `Admin`, `Manager` and `Employee`.

===== Aspect: Storage
Permission have to be stored in the addressbook where the information for `Person` is stored. This is achieved through creation of `XmlAdaptedPermission`, which was utilised by `XmlAdaptedPerson` to store the information in an xml file.

The class highlighted in Red in the following diagram represents the class that have been created to support the Permission system.

image::permissionStorage.png[width="350]

===== Aspect: Logic
Expand All @@ -367,18 +417,23 @@ The following is an example on how to assign permission to a Command.
----
public AddCommand(Person person) {
requireNonNull(person);
requiredPermission.addPermissions(Permission.ADD_EMPLOYEE);
requiredPermission.addPermissions(Permission.ADD_EMPLOYEE); <1>
toAdd = person;
}
----
<1> The method to assign permission to a command

The code to ensure that each command is only executed by user with the correct permission is located in `Command#execute`.

When any command executes, the command will first check if the logged in user possess the correct authorization by comparing `requiredPermission` with the user's `permissionSet` object, before performing the command.

Given below is an example scenario of how commands will be executed.

Step 1. The user enters a command `Delete 1` into the CLI.
Step 1. The user enters a command `delete 1` into the CLI.

Step 2. The system retrieves current user's `PermissionSet`

Step 3. The system compares user's `PermissionSet` with `Delete` command's `requiredPermission`.
Step 3. The system compares user's `PermissionSet` with `DeleteCommand` 's `requiredPermission`.

* Two different cases

Expand All @@ -405,9 +460,9 @@ The commands executable by the user will depend on their class.

** Cons: Commands cannot be freely assigned to users as it is now dependent on which subclass the user is. E.g. we cannot create an `Employee` with a subset of the commands available to `Manager`.

=== Supporting features for Permission System
=== Supporting commands for Permission System

The following are features that have been implemented to support the Permission System.
The following are commands that have been implemented to support the Permission System.

==== Modify Permissions of employee

Expand All @@ -423,18 +478,37 @@ This feature allows the user to indicate what permission to add and remove based
* `-a PERMISSION_TO_ADD` to add permission
* `-r PERMISSION_TO_REMOVE` to remove permission

To implement this new command syntax, `ModifyPermissionCommandParser` utilises `ArgumentTokenizer#tokenize` to generate a `ArgumentMultiMap`. The `ArgumentMultiMap` 's `key` contains the prefix, and `value` contains the list of keywords that succeeded the prefix. There will also be a `preamble` which can be used to retrieve the `index` of the targeted employee.
====== Aspect: Logic

The list of keywords is then used to create `permissionToAdd:Set<Permission>` and `permissionToRemove:Set<Permission>`, depending on their prefix. The 2 sets, together with the index, will be then be used to create `ModifyPermissionCommand`.
To implement this new command syntax, `ModifyPermissionCommandParser` utilises `ArgumentTokenizer#tokenize` to generate a `ArgumentMultiMap`. The `ArgumentMultiMap` 's `key` contains the prefix, and `value` contains the list of keywords that succeeded the prefix. There will also be a `preamble` which is used to retrieve the `index` of the targeted employee.

Might want to insert code snippet here
All the keywords is then added to either `permissionToAdd:Set<Permission>` or `permissionToRemove:Set<Permission>` depending on their prefix. The 2 sets, together with the index, will be then be used to create `ModifyPermissionCommand`.

[NOTE]
A ParseException will be thrown if any of the permission names are invalid.

When `ModifyPermissionCommand` is executed, it will then modify the permission of targeted employee, adding permission in `permissionToAdd` and removing permissions in `permissionToRemove`.

[NOTE]
The command will be executed successfully if at least one permission is added or removed.

The following is a sequence diagram that visualizes how this operation works.

image::modifyPermissionSequenceDiagram.png[width="350]

===== Design Considerations

* Alternative 1 (Current Implementation): Allow both adding and removing of multiple permissions with one command with the use of prefixes.

** Pros: Only need to learn how to use 1 command. Can perform both adding and removing of permissions with a single command.

** Cons: Harder to implement then other alternatives.

* Alternative 2: Create 2 separate commands to handle adding and removing of permission. (E.g. `AddPermissionCommand` and `RemovePermissionCommand`)

** Pros: Easy to implement.

** Cons: User will have to remember 2 commands. In addition to this, User also have to execute at least 2 commands if they wish to both add and remove permission.

==== View Permissions of employee

Expand All @@ -443,8 +517,38 @@ This feature allows the user to view the permissions that have been allocated to
[NOTE]
This feature can only be performed by users that have `ASSIGN_PERMISSION` permission.

===== Current Implementation
To use this command, the user only have to give an `INDEX` parameter.

====== Aspect: Logic

To process this command, `ViewPermissionCommandParser` simply utilise `ParserUtil#parseIndex` to parse the argument into the `index` of the target employee.

The index will then be used to create a `ViewPermissionCommand`.

When `ViewPermissionCommand` is executed, it will retrieve the targeted employee from the `Model`, and print out the list of permission that the employee possesses.

The following is a sequence diagram that visualizes how this operation works.

image::viewPermissionSequenceDiagram.png[width="350]

===== Design Considerations

* Alternative 1 (Current Implementation): Display permissions in the command box result text field.

** Pros: Easy to implement.

** Cons: Can only view permissions of a single employee at a time.

* Alternative 2: Display all permissions in the Person card.

** Pros: Able to view all permissions, of all employee in one go.

** Pros: No commands required.

** Cons: Person card can get very cluttered if employee have many permissions.

// end::permission
// end::permission[]


// tag::keyboardshortcuts[]
Expand Down
39 changes: 35 additions & 4 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,29 @@ e.g. typing help and pressing Enter will open the help window.
* Items in square brackets are optional e.g `-n NAME [-t TAG]` can be used as `-n John Doe -t friend` or as `-n John Doe`.
* Items with `…`​ after them can be used multiple times including zero times e.g. `-t TAG...` can be used as `{nbsp}` (i.e. 0 times), `-t friend`, `-t friend -t family` etc.
* Parameters can be in any order e.g. if the command specifies `-n NAME -p PHONE_NUMBER`, `-p PHONE_NUMBER -n NAME` is also acceptable.

// tag::autocomplete[]
*Command Auto Complete*

OASIS has provided you with a command auto complete feature to aid you with the usage of commands. With this functionality, you no longer have to memorise any commands!

When you type commands into the command box, a drop down list of possible commands will appear, as shown in the screenshot below.

image::autoCompleteDropDownList.png[width=300]

When the drop down list is shown, you can do the following:

* Use `↑` and `↓` to navigate through the list
* Press kbd:[Enter] to select the highlighted option

After selecting the command, you will see that the command will be displayed in the command box.

image::autoCompleteFinished.png[width=150]

If you wish to see a list of all commands, simply type kbd:[Space] into an empty command box. You should see the list as shown in the screenshot.

image::autoCompleteDropDownListAllCommand.png[width=300]
// end::autocomplete[]
====

=== Viewing help : `help`
Expand Down Expand Up @@ -120,6 +143,7 @@ Examples:
Shows a list of all employees in the system. +
Format: `list`

//tag::viewpermission[]
=== View all the permissions that an employee has : `viewpermission`

Displays all the permissions that an employee has been assigned.
Expand All @@ -133,7 +157,7 @@ Format: viewpermission INDEX
Examples:

* viewpermission 2

//end::viewpermission[]
=== Removing an employee from my department: `delete`

Removes an employee from the system.
Expand Down Expand Up @@ -342,9 +366,11 @@ Examples:
* `edit 1 -p 91234567 -e johndoe@example.com`
* `edit 2 -n James`

//tag::modifypermission[]

=== Modify permissions of an emplyee : `modifypermission`

Modifies the permissions of an employee.
This command allows you to modify the permissions of an employee.

Format : `modifypermission INDEX [-a PERMISSION_TO_ADD]... [-r PERMISSION_TO_REMOVE]...`

Expand All @@ -358,7 +384,7 @@ The following is the list of Permissions available.
|ADD_EMPLOYEE|Allows the user to add employee
|DELETE_EMPLOYEE|Allows the user to delete employee
|EDIT_EMPLOYEE|Allows the user to edit information of an employee
|VIEW_EMPLOYEE_LEAVE|Allows user to view all applications for leave
|VIEW_EMPLOYEE_LEAVE|Allows user to view other employee's applications for leave
|APPROVE_LEAVE|Allows user to approve and reject leave application
|ADD_ASSIGNMENT|Allows user to add assignments into OASIS
|DELETE_ASSIGNMENT|Allows user to delete assignments
Expand All @@ -376,6 +402,7 @@ Examples:

* modifypermission 1 -a ADD_EMPLOYEE
* modifypermission 2 -a DELETE_EMPLOYEE -r ADD_EMPLOYEE
//end::modifypermission[]

// tag::passwd[]
=== Change password : `passwd`
Expand Down Expand Up @@ -554,7 +581,7 @@ Format: `summary`

*Q*: Is it possible for me to change my username? +
*A*: No, the username assigned to you is fixed.

//tag::commandsummary[]
== Command Summary

=== Commands that do not require permissions
Expand Down Expand Up @@ -605,10 +632,14 @@ Format: `summary`
|Edit an assignment|EDIT_ASSIGNMENT|editassignment INDEX [-an ASSIGNMENT NAME] [-au AUTHOR] [-de DESCRIPTION]| editassignment 1 -an OASIS v2.0 -au MARY GOSLOW
|=========================================================

//end::commandsummary[]


== Keyboard Shortcuts

[width="100%",options="header"]
|=========================================================
|Command|Key
|
|=========================================================

Binary file added docs/images/autoCompleteDropDownList.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/autoCompleteFinished.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/introToOASIS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/modifyPermissionSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/permissionPersonModel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/permissionStorage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/viewPermissionSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading