From 859ee6f688f33e3abba6d5fa89a8959c82bc1720 Mon Sep 17 00:00:00 2001 From: snaplemouton Date: Wed, 29 Mar 2017 12:51:53 -0400 Subject: [PATCH 1/3] Added filter for projects and tasks --- .../src/pages/listProject/listProject.html | 7 ++++ tasklist/src/pages/listProject/listProject.ts | 13 +++++++- tasklist/src/pages/listTask/listTask.html | 32 +++++++++++++++++++ tasklist/src/pages/listTask/listTask.ts | 27 +++++++++++++++- 4 files changed, 77 insertions(+), 2 deletions(-) diff --git a/tasklist/src/pages/listProject/listProject.html b/tasklist/src/pages/listProject/listProject.html index ddf1e62..03d0f62 100644 --- a/tasklist/src/pages/listProject/listProject.html +++ b/tasklist/src/pages/listProject/listProject.html @@ -15,6 +15,13 @@ + + + + + Id + + diff --git a/tasklist/src/pages/listProject/listProject.ts b/tasklist/src/pages/listProject/listProject.ts index 1889eb1..c3fb7cc 100644 --- a/tasklist/src/pages/listProject/listProject.ts +++ b/tasklist/src/pages/listProject/listProject.ts @@ -15,6 +15,8 @@ import { Project } from '../../models/projectModel'; export class ListProject { items: Array; + searchTerm: string = ''; + searchId: string = ''; constructor( public navCtrl: NavController, @@ -68,7 +70,16 @@ export class ListProject { getDataFromApi() { this.projectService.listProjects().subscribe( response => { - this.items = response.json().map(p => new Project(p) ); + this.items = response.json().map(p => new Project(p) ).filter((item) => { + if (this.searchId != "") + { + if(item.id != this.searchId) + { + return false; + } + } + return item.name.toLowerCase().indexOf(this.searchTerm.toLowerCase()) > -1; + });; }, err => { let toast = this.toastCtrl.create({ diff --git a/tasklist/src/pages/listTask/listTask.html b/tasklist/src/pages/listTask/listTask.html index c875bc3..779a525 100644 --- a/tasklist/src/pages/listTask/listTask.html +++ b/tasklist/src/pages/listTask/listTask.html @@ -18,6 +18,38 @@ + + + + + Id + + + + Status + + All + Done + Not done + + + + Priority + + All + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + diff --git a/tasklist/src/pages/listTask/listTask.ts b/tasklist/src/pages/listTask/listTask.ts index ff2fea9..3f0e819 100644 --- a/tasklist/src/pages/listTask/listTask.ts +++ b/tasklist/src/pages/listTask/listTask.ts @@ -37,6 +37,11 @@ export class PopOverPage { export class ListTask { items: Array; project: Project; + searchId: string = ''; + searchName: string = ''; + searchDone: string = 'all'; + searchPriority: string = 'all'; + isPriorityFiltered: boolean = false; constructor( public navCtrl: NavController, @@ -57,7 +62,27 @@ export class ListTask { getDataFromApi(){ this.taskService.getTasksByProject(this.project.id).subscribe( response => { - this.items = response.json().map(t => new Task(t)); + this.items = response.json().map(t => new Task(t)).filter((item) => { + if (this.searchPriority != "all") { + if (item.priority != this.searchPriority) { + return false; + } + } + if (this.searchDone == "done" && item.done != true) { + return false; + } + else if (this.searchDone == "notDone" && item.done != false) { + return false; + } + if (this.searchId != "") + { + if(item.id != this.searchId) + { + return false; + } + } + return item.name.toLowerCase().indexOf(this.searchName.toLowerCase()) > -1; + }); }, err => { let toast = this.toastCtrl.create({ From b416b373b73c53b2502931b37df1330652313620 Mon Sep 17 00:00:00 2001 From: snaplemouton Date: Thu, 30 Mar 2017 02:27:02 -0400 Subject: [PATCH 2/3] Added filter by assigned, changed labels for Status filter, added IDs in views --- tasklist/src/pages/detailTask/detailTask.html | 1 + tasklist/src/pages/listProject/listProject.html | 1 + tasklist/src/pages/listTask/listTask.html | 16 ++++++++++++---- tasklist/src/pages/listTask/listTask.ts | 9 +++++++++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/tasklist/src/pages/detailTask/detailTask.html b/tasklist/src/pages/detailTask/detailTask.html index 87457a6..0865eda 100644 --- a/tasklist/src/pages/detailTask/detailTask.html +++ b/tasklist/src/pages/detailTask/detailTask.html @@ -17,6 +17,7 @@ +

Id: {{task.id}}

{{ task.name }} diff --git a/tasklist/src/pages/listProject/listProject.html b/tasklist/src/pages/listProject/listProject.html index 03d0f62..853ce2e 100644 --- a/tasklist/src/pages/listProject/listProject.html +++ b/tasklist/src/pages/listProject/listProject.html @@ -26,6 +26,7 @@ +

Id: {{item.id}}

{{item.name}}
diff --git a/tasklist/src/pages/listTask/listTask.html b/tasklist/src/pages/listTask/listTask.html index 779a525..47d9d77 100644 --- a/tasklist/src/pages/listTask/listTask.html +++ b/tasklist/src/pages/listTask/listTask.html @@ -22,18 +22,21 @@
+ + + Id - + Status All - Done - Not done + Open + Closed - + Priority All @@ -50,9 +53,14 @@ 10 + + Assigned to + + +

Id: {{item.id}}

{{item.name}} diff --git a/tasklist/src/pages/listTask/listTask.ts b/tasklist/src/pages/listTask/listTask.ts index 3f0e819..5acb2f1 100644 --- a/tasklist/src/pages/listTask/listTask.ts +++ b/tasklist/src/pages/listTask/listTask.ts @@ -41,6 +41,8 @@ export class ListTask { searchName: string = ''; searchDone: string = 'all'; searchPriority: string = 'all'; + searchAssigned: string = ''; + showFilter: boolean = false; isPriorityFiltered: boolean = false; constructor( @@ -81,6 +83,13 @@ export class ListTask { return false; } } + if (this.searchAssigned != "") + { + if(item.assigned.username.toLowerCase().indexOf(this.searchAssigned.toLowerCase()) == -1) + { + return false; + } + } return item.name.toLowerCase().indexOf(this.searchName.toLowerCase()) > -1; }); }, From e21a987b92489326bd3ddb9e51a99c9f6bd4a11e Mon Sep 17 00:00:00 2001 From: snaplemouton Date: Thu, 30 Mar 2017 15:13:46 -0400 Subject: [PATCH 3/3] Fix undefined bug. Changed UI to show ID in front of name for projects and tasks. --- tasklist/src/pages/listProject/listProject.html | 3 +-- tasklist/src/pages/listTask/listTask.html | 5 ++--- tasklist/src/pages/listTask/listTask.ts | 12 ++++++++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tasklist/src/pages/listProject/listProject.html b/tasklist/src/pages/listProject/listProject.html index 853ce2e..f6451c7 100644 --- a/tasklist/src/pages/listProject/listProject.html +++ b/tasklist/src/pages/listProject/listProject.html @@ -26,8 +26,7 @@ -

Id: {{item.id}}

- {{item.name}} + #{{item.id}} {{item.name}}
diff --git a/tasklist/src/pages/listTask/listTask.html b/tasklist/src/pages/listTask/listTask.html index 47d9d77..64aff33 100644 --- a/tasklist/src/pages/listTask/listTask.html +++ b/tasklist/src/pages/listTask/listTask.html @@ -60,13 +60,12 @@ -

Id: {{item.id}}

- {{item.name}} + #{{item.id}} {{item.name}}

- {{item.name}} + #{{item.id}} {{item.name}}

{{item.description}}

diff --git a/tasklist/src/pages/listTask/listTask.ts b/tasklist/src/pages/listTask/listTask.ts index 5acb2f1..e40e4ae 100644 --- a/tasklist/src/pages/listTask/listTask.ts +++ b/tasklist/src/pages/listTask/listTask.ts @@ -25,7 +25,6 @@ import {Project} from '../../models/projectModel'; }) export class PopOverPage { constructor(private navParams: NavParams) { } - } @@ -85,7 +84,16 @@ export class ListTask { } if (this.searchAssigned != "") { - if(item.assigned.username.toLowerCase().indexOf(this.searchAssigned.toLowerCase()) == -1) + console.log(typeof item.assigned); + console.log(typeof item.assigned.username); + if("undefined" != typeof item.assigned.username) + { + if(item.assigned.username.toLowerCase().indexOf(this.searchAssigned.toLowerCase()) == -1) + { + return false; + } + } + else { return false; }