More Userstory cleanuo
This commit is contained in:
parent
bec66aa69d
commit
3f6682fd8a
@ -24,26 +24,20 @@ export class UserstoryInnerTableComponent extends TableComponentBase<ScrumUserst
|
|||||||
public status: ScrumStatus[] = [];
|
public status: ScrumStatus[] = [];
|
||||||
public categories: ScrumCategory[] = [];
|
public categories: ScrumCategory[] = [];
|
||||||
|
|
||||||
@Input() public items: ScrumUserstory[] = [];
|
|
||||||
|
|
||||||
public get filteredItems() {
|
|
||||||
return this.items.filter(
|
|
||||||
(task) =>
|
|
||||||
this.filterPriority === null || task.priority === this.filterPriority
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private backendService: BackendService,
|
private backendService: BackendService,
|
||||||
private modalService: NgbModal,
|
private modalService: NgbModal,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router
|
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.applyFilterParameters(this.route.snapshot.paramMap);
|
backendService.getUserstories().subscribe((response) => {
|
||||||
this.route.paramMap.subscribe((map) => this.applyFilterParameters(map));
|
if (response.status > 399) {
|
||||||
|
alert('Fehler');
|
||||||
|
} else {
|
||||||
|
this.items.push(...response.body);
|
||||||
|
}
|
||||||
|
});
|
||||||
backendService.getTasks().subscribe((response) => {
|
backendService.getTasks().subscribe((response) => {
|
||||||
if (response.status > 399) {
|
if (response.status > 399) {
|
||||||
alert('Fehler');
|
alert('Fehler');
|
||||||
@ -67,57 +61,16 @@ export class UserstoryInnerTableComponent extends TableComponentBase<ScrumUserst
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private applyFilterParameters(params: ParamMap) {
|
//#region getters
|
||||||
if (params.has('id')) {
|
public get filteredItems() {
|
||||||
this.highlightId = parseInt(params.get('id'));
|
if(this.filterPriority == null){return this.items;}
|
||||||
}
|
return this.items.filter(t => t.priority == this.filterPriority);
|
||||||
}
|
|
||||||
|
|
||||||
public deleteUserstory(userstory: ScrumUserstory) {
|
|
||||||
this.backendService.deleteUserstory(userstory).subscribe((response) => {
|
|
||||||
if (response.status > 399) {
|
|
||||||
alert('Fehler');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const index = this.items.indexOf(userstory);
|
|
||||||
if (index !== -1) {
|
|
||||||
this.items.splice(index, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public openUserstoryForm(editUserstory?: ScrumUserstory) {
|
|
||||||
const modalRef = this.modalService.open(UserstoryFormComponent, {
|
|
||||||
backdrop: 'static',
|
|
||||||
keyboard: true,
|
|
||||||
size: "lg",
|
|
||||||
});
|
|
||||||
if (editUserstory === null) {
|
|
||||||
modalRef.result.then((result) => {
|
|
||||||
this.items.push(result);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
modalRef.componentInstance.userstory = editUserstory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getNumberOfTasks(userstory: ScrumUserstory) {
|
public getNumberOfTasks(userstory: ScrumUserstory) {
|
||||||
return this.tasks.filter((t) => t.userstoryid === userstory.id).length;
|
return this.tasks.filter((t) => t.userstoryid === userstory.id).length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public sortByPrio() {
|
|
||||||
this.doNumericSort('priority', (us) => getNumberForPriority(us.priority));
|
|
||||||
}
|
|
||||||
|
|
||||||
public sortByTasks() {
|
|
||||||
this.doNumericSort('tasks', (us) => this.getNumberOfTasks(us));
|
|
||||||
}
|
|
||||||
|
|
||||||
sortByStatus() {
|
|
||||||
this.doNumericSort('statusid', (us) => us.statusid);
|
|
||||||
}
|
|
||||||
sortByCategory() {
|
|
||||||
this.doNumericSort('categoryid', (us) => us.categoryid);
|
|
||||||
}
|
|
||||||
|
|
||||||
getStatusTitleById(id) {
|
getStatusTitleById(id) {
|
||||||
var status = this.status.find((x) => x.id === id);
|
var status = this.status.find((x) => x.id === id);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
@ -133,4 +86,59 @@ export class UserstoryInnerTableComponent extends TableComponentBase<ScrumUserst
|
|||||||
}
|
}
|
||||||
return category.title;
|
return category.title;
|
||||||
}
|
}
|
||||||
|
//#endregion getters
|
||||||
|
|
||||||
|
//#region userstoryTableFunctions
|
||||||
|
private applyFilterParameters(params: ParamMap) {
|
||||||
|
if (params.has('id')) {
|
||||||
|
this.highlightId = parseInt(params.get('id'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public deleteUserstory(userstory: ScrumUserstory) {
|
||||||
|
this.backendService.deleteUserstory(userstory).subscribe((response) => {
|
||||||
|
if (response.status > 399) {
|
||||||
|
alert('Fehler');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const index = this.items.indexOf(userstory);
|
||||||
|
if (index !== -1) {
|
||||||
|
this.items.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//#endregion userstoryTableFunctions
|
||||||
|
|
||||||
|
//#region sorters
|
||||||
|
public sortByPrio() {
|
||||||
|
this.doNumericSort('priority', (us) => getNumberForPriority(us.priority));
|
||||||
|
}
|
||||||
|
|
||||||
|
public sortByTasks() {
|
||||||
|
this.doNumericSort('tasks', (us) => this.getNumberOfTasks(us));
|
||||||
|
}
|
||||||
|
|
||||||
|
public sortByStatus() {
|
||||||
|
this.doNumericSort('statusid', (us) => us.statusid);
|
||||||
|
}
|
||||||
|
public sortByCategory() {
|
||||||
|
this.doNumericSort('categoryid', (us) => us.categoryid);
|
||||||
|
}
|
||||||
|
//#endregion sorters
|
||||||
|
|
||||||
|
//#region modals
|
||||||
|
public openUserstoryForm(editUserstory?: ScrumUserstory) {
|
||||||
|
const modalRef = this.modalService.open(UserstoryFormComponent, {
|
||||||
|
backdrop: 'static',
|
||||||
|
keyboard: true,
|
||||||
|
size: "lg",
|
||||||
|
});
|
||||||
|
if (editUserstory === null) {
|
||||||
|
modalRef.result.then((result) => {
|
||||||
|
this.items.push(result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
modalRef.componentInstance.userstory = editUserstory;
|
||||||
|
}
|
||||||
|
//#endregion modals
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user