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

Add logics for editing and moving tasks, Update UI for tasks and Implement Import/Export #116

Merged
merged 12 commits into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ src/main/resources/docs/
/config.json
/preferences.json
/*.log.*
*.json

# Test sandbox files
src/test/data/sandbox/
Expand Down
2 changes: 0 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,3 @@ Technical interviews are hard. Unless you are extraordinarily gifted, you will l

* We would like to acknowledge the original source of the code, AddressBook-Level3 project created by SE-EDU initiative at https://se-education.org
* Libraries used: https://openjfx.io/[JavaFX], https://github.com/FasterXML/jackson[Jackson], https://github.com/junit-team/junit5[JUnit5]

== Licence : link:LICENSE[MIT]
155 changes: 141 additions & 14 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,20 @@ the task management feature.

==== Current Implementation

The task management feature mainly involves four main behaviours:
The task management feature mainly involves six main behaviours:

* `AlgoBase#addTask()` - create a new task for a problem and add it to a specified plan.
* `AlgoBase#deleteTask()` - delete an existing task from a specified plan.
* `AlgoBase#doneTask()` - mark a task as done in a specified plan.
* `AlgoBase#editTask()` - edit the due date of a task in a specified plan.
* `AlgoBase#moveTask()` - move a task from one plan to another.
* `AlgoBase#undoneTask()` - mark a task as undone in a specified plan.

Given below is an example usage scenario and how the mechanism for adding tasks behaves at each step.

The following activity diagram summarizes what happens when a user executes the `AddTask` command:

.Activity Diagram for the Execution of `AddTask` Command
.Activity Diagram for the Execution of `AddTaskCommand`
image::task/AddTaskCommandActivityDiagram.png[]

Step 1. The user launches the application.
Expand All @@ -208,23 +210,42 @@ Step 2. AlgoBase displays a list of existing problems and plans in the UI.

Step 3. The user executes `addtask plan/1 prob/1` to add the problem with index 1 in the list to the plan with index 1.
The `AddTask` command calls `Plan#updateTasks` to create a new plan from the original plan with this additional task.
After that, `Model#setPlan()` is called to replace the original plan with the updated plan in the `PlanList`.
After that, `Model#setPlan` is called to replace the original plan with the updated plan in the `PlanList`
stored in `AlgoBase`.

The following sequence diagram shows how the `addtask` operation works:

.Sequence Diagram for the Execution of `AddTask` Command
.Sequence Diagram for the Execution of `AddTaskCommand`
image::task/AddTaskSequenceDiagram.png[]

==== Design Considerations

===== Aspect: Data structure to support the task commands.

* Alternative 1 (current choice): Use a `HashSet` in current AlgoBase to save all tasks in a plan.
** Pros: Users can manage the tasks conveniently.
** Cons: Harder to implement for relational storage.
* Alternative 2: Simply keep tasks as a part of a plan.
** Pros: No need to save the task separately in the storage, all tasks are under plans.
** Cons: Does not keep track of relations between tasks and plans.
* Alternative 1 (current choice): Use a `HashSet` to store tasks in a plan.
** Pros: Duplicate tasks can be checked easily.
** Cons: Harder to identify tasks by index.
* Alternative 2: Use an `ArrayList` to store tasks in a plan.
** Pros: Tasks can be identified by index easily.
** Cons: Harder to check for duplicates.

===== Aspect: How to store problem details within tasks to support the task commands.

* Alternative 1 (current choice): Store a problem object in each task.
** Pros: Changes in problem details will be reflected in the relevant tasks as well.
** Cons: Relational storage is required to keep track of this relationship.
* Alternative 2: Copy all problem details and store as separate fields in each task.
** Pros: No need to implement relational storage. There will be less coupling between problems and tasks as well.
** Cons: Changes in problem details will not be reflected in the relevant tasks.

===== Aspect: Relational storage to support the task commands.

* Alternative 1 (current choice): Use an additional `id` field to identify problems and tasks.
** Pros: Id is immutable over time.
** Cons: An additional field is needed for the models.
* Alternative 2: Use object hash to identify problems and tasks.
** Pros: No need to store another additional field in the models.
** Cons: Object hash can change over time.

// end::task[]
//@@author
Expand All @@ -250,6 +271,7 @@ Step 2. The user executes `addtag t/easy` to add a tag named [easy] which have n

The following sequence diagram shows how the `deletetag` operation works:

.Sequence Diagram for `AddTagCommand`
image::AddTagSequenceDiagram.png[]

Step 3. The user decides to execute the command `listtag` to show a tag list in the GUI of algobase. The `listtag` command calls Model#listtag(), causing the taglist shows the current components of uniqueTagList. Commands that do not modify the address book, such as `listtag`, will not call `Model#addTag()`, `Model#deleteTag()` or `Model#editTag()`. Thus the `uniqueTagList` remains unchanged.
Expand All @@ -262,6 +284,7 @@ Step 5. The user executes `deletetag t/hard` to delete the current tag [easy] in

The following activity diagram summarizes what happens when a user executes a new tag modifying command

.Activity Diagram for tag commands
image::TagActivityDiagram.png[]

==== Design considerations
Expand Down Expand Up @@ -624,11 +647,15 @@ Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (un

|`* * *` |user |add tasks to a plan |better prepare for interview

|`* * *` |user |mark tasks as complete/incomplete within plans |better prepare for interview
|`* * *` |user |mark tasks as done/undone within plans |keep track of progress within each plan

|`* * *` |user |edit due dates of tasks |better manage progress for each plan

|`* * *` |user |move tasks among plans |better manage progress for each plan

|`* * *` |user |import database from <<json,JSON>> files |easily transfer data from one computer to another

|`* * *` |user |export data into JSON format |easily transfer data from one computer to another
|`* * *` |user |export data into <<json,JSON>> format |easily transfer data from one computer to another

|`* *` |advanced user |export data into CSV format |do some manipulation/processing on the data

Expand Down Expand Up @@ -908,7 +935,67 @@ Use case ends.
Use case ends.

[discrete]
=== Use Case 11: Switch between View of Items
=== Use Case 11: Edit Due Dates of Tasks

*MSS*

1. User requests to edit due date of an existing task
by entering the index of the plan, index of the task and new due date.
2. AlgoBase edits the due date of the specified task in the specified plan.
3. AlgoBase indicates that the existing task is edited successfully.
4. AlgoBase displays details of the task updated.
+
Use case ends.

*Extensions*
[none]
* 2a. AlgoBase detects that the index of plan is out of bounds.
+
[none]
** 2a1. AlgoBase informs user that the update is unsuccessful because the index of plan is out of bounds.
+
Use case ends.

[none]
* 2b. AlgoBase detects that the index of task is out of bounds.
+
[none]
** 2b1. AlgoBase informs user that the update is unsuccessful because the index of task is out of bounds.
+
Use case ends.

[discrete]
=== Use Case 12: Move Tasks between Plans

*MSS*

1. User requests to move an existing task from one plan to another
by entering the index of the task and the indices of the plans involved.
2. AlgoBase moves the specified task from the specified "from" plan to the "to" plan.
3. AlgoBase indicates that the existing task is moved successfully.
4. AlgoBase displays list of tasks of the "to" plan updated.
+
Use case ends.

*Extensions*
[none]
* 2a. AlgoBase detects that the index of either plan is out of bounds.
+
[none]
** 2a1. AlgoBase informs user that the update is unsuccessful because the index of plan is out of bounds.
+
Use case ends.

[none]
* 2b. AlgoBase detects that the index of task is out of bounds.
+
[none]
** 2b1. AlgoBase informs user that the update is unsuccessful because the index of task is out of bounds.
+
Use case ends.

[discrete]
=== Use Case 13: Switch between View of Items

*MSS*

Expand All @@ -927,7 +1014,7 @@ Use case ends.
Use case ends.

[discrete]
=== Use Case 12: See details of an item
=== Use Case 14: See details of an item

*MSS*

Expand All @@ -936,6 +1023,46 @@ Use case ends.
+
Use case ends.

[discrete]
=== Use Case 15: Export AlgoBase data

*MSS*

1. User requests to export AlgoBase data to a specified path.
2. AlgoBase exports AlgoBase data to a file name `algobase.json` in the specified location.
3. AlgoBase indicates that AlgoBase data are exported successfully.
+
Use case ends.

*Extensions*
[none]
* 2a. AlgoBase detects that the specified path is invalid.
+
[none]
** 2a1. AlgoBase informs user that the export is unsuccessful because the path is invalid.
+
Use case ends.

[discrete]
=== Use Case 16: Import AlgoBase data

*MSS*

1. User requests to import data from a specified file into AlgoBase.
2. AlgoBase imports data from the specified file into AlgoBase.
3. AlgoBase indicates that the data are imported into AlgoBase successfully.
+
Use case ends.

*Extensions*
[none]
* 2a. AlgoBase detects that the specified file does not exist.
+
[none]
** 2a1. AlgoBase informs user that the import is unsuccessful because the file path is invalid.
+
Use case ends.

[appendix]
== Non Functional Requirements

Expand Down
58 changes: 40 additions & 18 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,15 @@ Examples:

* `donetask plan/1 task/1`

==== Editing due date of a task from a plan: `edittask`

Edits the due date of a specified task from a specified plan. +
Format: `edittask plan/PLAN_INDEX task/TASK_INDEX due/DUE_DATE`

Examples:

* `edittask plan/1 task/1 due/2019-12-12`

==== Marking a task as undone: `undonetask`

Marks a specified task in a specified plan as undone. +
Expand All @@ -323,6 +332,15 @@ Examples:

* `undonetask plan/1 task/1`

==== Moving a task from one plan to another: `movetask`

Moves a specified task from a specified plan to another. +
Format: `movetask task/TASK_INDEX from/PLAN_INDEX to/PLAN_INDEX`

Examples:

* `movetask task/1 from/1 to/2`

=== Tabs

==== Switching Tabs: `switchtab`
Expand Down Expand Up @@ -365,31 +383,27 @@ Examples:

==== Importing data: `import`

Imports external data of a specified format (e.g. CSV, JSON) into local storage. +
Format: `import f/FORMAT p/PATH`
Imports external data of a specified format (e.g. JSON) into local storage. +
Format: `import format/FORMAT path/FILE_PATH`

* Format can be ‘CSV’ or ‘JSON.
* Directory refers to the full path of the output file.
* Format can only be `JSON`.
* File path refers to the relative path of the input file.

Examples:

* `import t/plan p/./steven_halim_secret.json`
* `import format/json path/./steven_halim_secret.json`

==== Exporting data: `export`

Exports data into a specified format (e.g. CSV, JSON). +
Format: `export f/FORMAT p/DIRECTORY`
Exports data into a specified format (e.g. JSON). +
Format: `export format/FORMAT path/DIRECTORY_PATH`

* Format can be ‘CSV’ or ‘JSON.
* Directory refers to the full path of the output file.
* Format can only be `JSON`.
* Directory path refers to the relative path of the directory to store the output file.

Examples:

* `export f/csv p/./`

=== Encryption

==== Encrypting data files `[coming in v2.0]`
* `export format/json path/.`

=== Miscellaneous

Expand Down Expand Up @@ -432,6 +446,10 @@ Format: `exit`
AlgoBase data is saved in the hard disk automatically after any command that changes the data. +
There is no need to save manually.

=== Encryption

==== Encrypting data files `[coming in v2.0]`

== FAQ

*Q*: How do I transfer my data to another Computer? +
Expand Down Expand Up @@ -475,15 +493,19 @@ e.g. `find training set`
e.g. `addtask plan/1 prob/2`
* *Delete Task from Training Plan* : `deletetask plan/PLAN_INDEX task/TASK_INDEX` +
e.g. `deletetask plan/1 task/2`
* *Edit Due Date of Task* : `edittask plan/PLAN_INDEX task/TASK_INDEX due/DUE_DATE` +
e.g. `edittask plan/1 task/2 due/2019-12-12`
* *Mark Task as done* : `donetask plan/PLAN_INDEX task/TASK_INDEX` +
e.g. `donetask plan/1 task/2`
* *Mark Task as undone* : `undonetask plan/PLAN_INDEX task/TASK_INDEX` +
e.g. `undonetask plan/1 task/2`
* *Move Tasks among Plans* : `movetask task/TASK_INDEX from/PLAN_INDEX to/PLAN_TASK` +
e.g. `movetask task/1 from/1 to/2`

* *Importing data* : `import f/FORMAT p/PATH` +
e.g. `import t/plan p/./steven_halim_secret.json`
* *Exporting data* : `export f/FORMAT p/DIRECTORY` +
e.g. `export f/csv p/./`
* *Exporting data* : `export format/FORMAT path/DIRECTORY_PATH` +
e.g. `export format/json path/.`
* *Importing data* : `import format/FORMAT path/FILE_PATH` +
e.g. `import format/json path/./steven_halim_secret.json`

* *Help* : `help`
* *Clear* : `clear`
Expand Down
6 changes: 3 additions & 3 deletions docs/diagrams/task/AddTaskCommandActivityDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

start

:User executes an AddTask command;
:User executes an AddTaskCommand;

if () then ([command is valid])
:Instantiate an AddTaskCommand with a corresponding predicate;
:Instantiate an AddTaskCommand with a corresponding AddTaskDescriptor;
:Execute AddTaskCommand;
:Update UI with filtered task list;
:Update UI with current plan with corresponding task list;
else ([else])
:Throw an exception;
:Update UI to notify the user;
Expand Down
Loading