Skip to content
Open
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 tasklist/src/pages/detailTask/detailTask.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<ion-content>
<ion-card>
<ion-card-content>
<h4>Id: {{task.id}}</h4>
<ion-card-title *ngIf="task.done" color="danger">
{{ task.name }}
</ion-card-title>
Expand Down
9 changes: 8 additions & 1 deletion tasklist/src/pages/listProject/listProject.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@
</ion-header>

<ion-content>
<ion-item>
<ion-searchbar [(ngModel)]="searchTerm" (ionInput)="getDataFromApi()"></ion-searchbar>
</ion-item>
<ion-item>
<ion-label>Id</ion-label>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user don't know the ID and can't read it. You need to put the ID in the list and the detail of the project if you want filter by ID

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the ID to the view

<ion-input [(ngModel)]="searchId" (input)="getDataFromApi()"></ion-input>
</ion-item>
<ion-list inset>

<ion-item-sliding *ngFor="let item of items">
<ion-item (click)="itemTapped($event, item)">
{{item.name}}
#{{item.id}} {{item.name}}
</ion-item>

<ion-item-options side="right">
Expand Down
13 changes: 12 additions & 1 deletion tasklist/src/pages/listProject/listProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { Project } from '../../models/projectModel';

export class ListProject {
items: Array<Project>;
searchTerm: string = '';
searchId: string = '';

constructor(
public navCtrl: NavController,
Expand Down Expand Up @@ -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({
Expand Down
43 changes: 41 additions & 2 deletions tasklist/src/pages/listTask/listTask.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,54 @@
</ion-header>

<ion-content>
<ion-item>
<ion-searchbar [(ngModel)]="searchName" (ionInput)="getDataFromApi()"></ion-searchbar>
</ion-item>
<ion-item>
<button ion-button (click)="this.showFilter=!this.showFilter">{{showFilter ? 'Hide' : 'Show'}} filters</button>
</ion-item>
<ion-item *ngIf="this.showFilter">
<ion-label>Id</ion-label>
<ion-input [(ngModel)]="searchId" (input)="getDataFromApi()"></ion-input>
</ion-item>
<ion-item *ngIf="this.showFilter">
<ion-label>Status</ion-label>
<ion-select [(ngModel)]="searchDone" (ionChange)="getDataFromApi()">
<ion-option value="all" selected="true">All</ion-option>
<ion-option value="done">Open</ion-option>
<ion-option value="notDone">Closed</ion-option>
</ion-select>
</ion-item>
<ion-item *ngIf="this.showFilter">
<ion-label>Priority</ion-label>
<ion-select [(ngModel)]="searchPriority" (ionChange)="getDataFromApi()">
<ion-option value="all" selected="true">All</ion-option>
<ion-option value="0">0</ion-option>
<ion-option value="1">1</ion-option>
<ion-option value="2">2</ion-option>
<ion-option value="3">3</ion-option>
<ion-option value="4">4</ion-option>
<ion-option value="5">5</ion-option>
<ion-option value="6">6</ion-option>
<ion-option value="7">7</ion-option>
<ion-option value="8">8</ion-option>
<ion-option value="9">9</ion-option>
<ion-option value="10">10</ion-option>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works for me but i thinks its better to just able to Sort by in place of filter by for the priority. But it's good no problem with that.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave it as a filter by for now because I cannot think of a way to have the layout allow for an intuitive way to sort by parameter without clogging the UI with lot of junk

</ion-select>
</ion-item>
<ion-item *ngIf="this.showFilter">
<ion-label>Assigned to</ion-label>
<ion-input [(ngModel)]="searchAssigned" (input)="getDataFromApi()"></ion-input>
</ion-item>
<ion-list inset>
<ion-item-sliding *ngFor="let item of items">
<ion-item (click)="itemTapped($event, item)">
<h3 *ngIf="item.done" color="danger">
<ion-icon name="checkmark" color="danger"></ion-icon>
{{item.name}}
#{{item.id}} {{item.name}}
</h3>
<h3 *ngIf="!item.done">
{{item.name}}
#{{item.id}} {{item.name}}
</h3>
<p>{{item.description}}</p>
</ion-item>
Expand Down
46 changes: 44 additions & 2 deletions tasklist/src/pages/listTask/listTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {Project} from '../../models/projectModel';
})
export class PopOverPage {
constructor(private navParams: NavParams) { }

}


Expand All @@ -37,6 +36,13 @@ export class PopOverPage {
export class ListTask {
items: Array<Task>;
project: Project;
searchId: string = '';
searchName: string = '';
searchDone: string = 'all';
searchPriority: string = 'all';
searchAssigned: string = '';
showFilter: boolean = false;
isPriorityFiltered: boolean = false;

constructor(
public navCtrl: NavController,
Expand All @@ -57,7 +63,43 @@ 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;
}
}
if (this.searchAssigned != "")
{
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;
}
}
return item.name.toLowerCase().indexOf(this.searchName.toLowerCase()) > -1;
});
},
err => {
let toast = this.toastCtrl.create({
Expand Down