import { Component, HostBinding, OnInit } from '@angular/core'; 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'; const WIP_LIMIT_INPROGRESS = 12; const WIP_LIMIT_VERIFICATION = 8; @Component({ selector: 'app-kanban-board', templateUrl: './kanban-board.component.html', styleUrls: ['./kanban-board.component.css'], animations: [slideInOutAnimation] }) export class KanbanBoardComponent implements OnInit { @HostBinding('@slideInOutAnimation') slideIn = true; constructor(private titleService: Title, private route: ActivatedRoute, private kanbanService: KanbanService) { } /** * Set page title, and handle preloaded kanbanBoard data */ ngOnInit() { this.titleService.setTitle('TaurusXFT : Kanban board'); 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 WIP_LIMIT_INPROGRESS; } 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 > WIP_LIMIT_INPROGRESS, }; } get verificationWipLimit(): number { return WIP_LIMIT_VERIFICATION; } 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 > WIP_LIMIT_VERIFICATION, }; } }