Replace task-list/userstory-list with task-table/userstory-table
This commit is contained in:
@@ -9,7 +9,7 @@ export class BackendService {
|
||||
|
||||
constructor(private httpClient: HttpClient) {}
|
||||
|
||||
|
||||
|
||||
// Tasks
|
||||
public getTasks(): Observable<HttpResponse<ScrumTask[]>> {
|
||||
const url = `${environment.apiUrl}/tasks`;
|
||||
@@ -117,7 +117,7 @@ export class BackendService {
|
||||
return this.httpClient.delete(url, { observe: 'response' });
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Status
|
||||
public getAllStatus(): Observable<HttpResponse<ScrumStatus[]>> {
|
||||
const url = `${environment.apiUrl}/status`;
|
||||
@@ -143,8 +143,8 @@ export class BackendService {
|
||||
const url = `${environment.apiUrl}/status/${status.id}`;
|
||||
return this.httpClient.delete(url, { observe: 'response' });
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Users
|
||||
public getUsers(): Observable<HttpResponse<ScrumUser[]>> {
|
||||
const url = `${environment.apiUrl}/users`;
|
||||
@@ -171,7 +171,7 @@ export class BackendService {
|
||||
return this.httpClient.delete(url, { observe: 'response' });
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Projects
|
||||
public getProjects(): Observable<HttpResponse<ScrumProject[]>> {
|
||||
const url = `${environment.apiUrl}/projects`;
|
||||
@@ -209,12 +209,12 @@ export interface ScrumTask {
|
||||
id?: number;
|
||||
title: string;
|
||||
content?: string;
|
||||
status?: number;
|
||||
category?: number;
|
||||
assignedto?: number;
|
||||
sprint?: number;
|
||||
project?: number;
|
||||
userstory?: number;
|
||||
statusid?: number;
|
||||
categoryid?: number;
|
||||
assignedtoid?: number;
|
||||
sprintid?: number;
|
||||
projectid?: number;
|
||||
userstoryid?: number;
|
||||
priority?: Priority;
|
||||
}
|
||||
|
||||
@@ -223,10 +223,10 @@ export interface ScrumUserstory {
|
||||
title: string;
|
||||
content?: string;
|
||||
priority?: Priority;
|
||||
status?: number;
|
||||
category?: number;
|
||||
createdby?: number;
|
||||
project?: number;
|
||||
statusid?: number;
|
||||
categoryid?: number;
|
||||
createdbyid?: number;
|
||||
projectid?: number;
|
||||
}
|
||||
|
||||
export interface ScrumSprint{
|
||||
@@ -262,4 +262,4 @@ export interface ScrumProject {
|
||||
id?: number;
|
||||
title: string;
|
||||
isprivate: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
20
src/app/services/sorting.service.ts
Normal file
20
src/app/services/sorting.service.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import {Priority} from './backend.service';
|
||||
|
||||
export function sortByNumberAscending<T>(items: T[], key: (T) => number) {
|
||||
return items.sort((a, b) => key(a) - key(b));
|
||||
}
|
||||
|
||||
export function sortByStringAscending<T>(items: T[], key: (T) => string) {
|
||||
return items.sort((a, b) => key(a).localeCompare(key(b)));
|
||||
}
|
||||
|
||||
export function getNumberForPriority(priority: Priority): number {
|
||||
switch (priority) {
|
||||
case Priority.High:
|
||||
return 2;
|
||||
case Priority.Medium:
|
||||
return 1;
|
||||
case Priority.Low:
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
33
src/app/services/table-component.base.ts
Normal file
33
src/app/services/table-component.base.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import {sortByNumberAscending, sortByStringAscending} from './sorting.service';
|
||||
|
||||
export abstract class TableComponentBase<T> {
|
||||
public sortBy: string;
|
||||
public sortDescending = false;
|
||||
public items: T[] = [];
|
||||
|
||||
protected doNumericSort(by: string, key: (ScrumTask) => number) {
|
||||
if (this.sortBy === by) {
|
||||
this.sortDescending = !this.sortDescending;
|
||||
} else {
|
||||
this.sortBy = by;
|
||||
}
|
||||
|
||||
this.items = sortByNumberAscending(this.items, key);
|
||||
if (this.sortDescending) {
|
||||
this.items = this.items.reverse();
|
||||
}
|
||||
}
|
||||
|
||||
protected doStringSort(by: string, key: (ScrumTask) => string) {
|
||||
if (this.sortBy === by) {
|
||||
this.sortDescending = !this.sortDescending;
|
||||
} else {
|
||||
this.sortBy = by;
|
||||
}
|
||||
|
||||
this.items = sortByStringAscending(this.items, key);
|
||||
if (this.sortDescending) {
|
||||
this.items = this.items.reverse();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user