mtas-tv-frontend/src/app/display/kanban-board/kanban-board.component.ts

110 lines
3.0 KiB
TypeScript
Raw Normal View History

import { Component, HostBinding, OnInit } from '@angular/core';
2018-04-21 15:23:43 +02:00
import { Title } from '@angular/platform-browser';
import { ActivatedRoute } from '@angular/router';
import { KanbanBoard, KanbanEntry, KanbanService, } from '../shared';
import { slideInOutAnimation } from '../../shared/slide-in-out-animation';
import { SettingsService } from '../../shared/service/settings.service';
2018-04-21 15:23:43 +02:00
@Component({
selector: 'app-kanban-board',
templateUrl: './kanban-board.component.html',
styleUrls: ['./kanban-board.component.css'],
animations: [slideInOutAnimation]
2018-04-21 15:23:43 +02:00
})
export class KanbanBoardComponent implements OnInit {
@HostBinding('@slideInOutAnimation')
slideIn = true;
2018-04-21 15:23:43 +02:00
constructor(private titleService: Title,
private route: ActivatedRoute,
private kanbanService: KanbanService,
private settingService: SettingsService) {
2018-04-21 15:23:43 +02:00
}
/**
* Set page title, and handle preloaded kanbanBoard data
*/
ngOnInit() {
2018-09-11 16:10:47 +02:00
this.titleService.setTitle(`${this.settingService.team.name} : Kanban board`);
2018-04-21 15:23:43 +02:00
this.route.data.subscribe((data: {
kanbanBoard: KanbanBoard,
}) => {
this.kanbanBoard = data.kanbanBoard;
});
}
get kanbanBoard(): KanbanBoard {
return this.kanbanService.kanbanBoard;
}
set kanbanBoard(kanbanBoard: KanbanBoard) {
this.kanbanService.kanbanBoard = kanbanBoard;
}
get inprogressWipLimit(): number {
return this.settingService.team.inprogressColumn.wipLimit;
2018-04-21 15:23:43 +02:00
}
get inprogressWipCount(): number {
return this.kanbanBoard.inProgress.filter(
(entry: KanbanEntry) => entry.labels.every(
label => label.toUpperCase() !== 'BLOCKED'
)
).length;
}
/**
* Set 'over-wip' class on inprogress row if its over the wip limit
* This excludes issues marked as BLOCKED with labels
*
* @returns {{over-wip: boolean}}
*/
get inprogressWipClass() {
return {
'over-wip': this.inprogressWipCount > this.settingService.team.inprogressColumn.wipLimit,
2018-04-21 15:23:43 +02:00
};
}
get verificationWipLimit(): number {
return this.settingService.team.verificationColumn.wipLimit;
2018-04-21 15:23:43 +02:00
}
get verificationWipCount(): number {
return this.kanbanBoard.verification.filter(
(entry: KanbanEntry) => entry.labels.every(
label => label.toUpperCase() !== 'BLOCKED'
)
).length;
}
/**
* Set 'over-wip' class on verification row if its over the wip limit
* This excludes issues marked as BLOCKED with labels
*
* @returns {{over-wip: boolean}}
*/
get verificationWipClass() {
return {
'over-wip': this.verificationWipCount > this.settingService.team.verificationColumn.wipLimit,
2018-04-21 15:23:43 +02:00
};
}
get backlogLabel(): string {
return this.settingService.team.backlogColumn.label;
}
get inProgressLabel(): string {
return this.settingService.team.inprogressColumn.label;
}
get verificationLabel(): string {
return this.settingService.team.verificationColumn.label;
}
get doneLabel(): string {
return this.settingService.team.doneColumn.label;
}
2018-04-21 15:23:43 +02:00
}