From ea05a470863c3ada1187283ba2e7fc903350bb37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Danyi?= Date: Thu, 6 Sep 2018 15:38:50 +0200 Subject: [PATCH] * team customized labels added * team editor interface minor redesign --- .../team-editor/team-editor.component.html | 57 ++++++++++++++---- .../team-editor/team-editor.component.ts | 59 ++++++++++++++++++- .../kanban-entry-item.component.html | 6 +- .../kanban-entry-item.component.ts | 54 ++++++++--------- .../slide-iframe/slide-iframe.component.css | 1 + src/app/display/slide-show.service.ts | 12 ++-- src/app/shared/label.ts | 4 ++ src/app/shared/team.ts | 6 +- 8 files changed, 144 insertions(+), 55 deletions(-) mode change 100644 => 100755 src/app/admin/team-editor/team-editor.component.html mode change 100644 => 100755 src/app/admin/team-editor/team-editor.component.ts create mode 100755 src/app/shared/label.ts mode change 100644 => 100755 src/app/shared/team.ts diff --git a/src/app/admin/team-editor/team-editor.component.html b/src/app/admin/team-editor/team-editor.component.html old mode 100644 new mode 100755 index 0a30e27..2631e7a --- a/src/app/admin/team-editor/team-editor.component.html +++ b/src/app/admin/team-editor/team-editor.component.html @@ -11,22 +11,33 @@ -
1st column
+
+ +
+ + +
+
+ +

Column configuration

+
+
+
-
2nd column
-
3rd column
-
4th column
-
- -
- - +

Labels

+
+
+
+
+ +
+ + {{option}} + + + + +
+
+ {{label.name}}

Team members

@@ -106,6 +142,7 @@ [(ngModel)]="member.name">
+

diff --git a/src/app/admin/team-editor/team-editor.component.ts b/src/app/admin/team-editor/team-editor.component.ts old mode 100644 new mode 100755 index d8d6fcb..36cd34d --- a/src/app/admin/team-editor/team-editor.component.ts +++ b/src/app/admin/team-editor/team-editor.component.ts @@ -1,11 +1,11 @@ -import { Component, ElementRef, HostBinding, OnInit, ViewChild } from '@angular/core'; +import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { Title } from '@angular/platform-browser'; import { TeamService } from '../../shared/service/team.service'; import { Team } from '../../shared/team'; import { Member } from '../../shared/member'; -import { slideInOutAnimation } from '../../shared/slide-in-out-animation'; +import { Label } from '../../shared/label'; @Component({ selector: 'app-team-editor', @@ -13,8 +13,10 @@ import { slideInOutAnimation } from '../../shared/slide-in-out-animation'; styleUrls: ['./team-editor.component.css'] }) export class TeamEditorComponent implements OnInit { + @ViewChild('labelInput') labelInputElement: ElementRef; @ViewChild('signumInput') signumInputElement: ElementRef; public team: Team; + public label: Label = new Label(); public member: Member = new Member(); constructor(private teamService: TeamService, @@ -28,6 +30,57 @@ export class TeamEditorComponent implements OnInit { this.route.data.subscribe((data: { team: Team }) => this.team = data.team ? data.team : new Team()); } + get labelColors(): Array { + return [ + 'red', + 'orange', + 'yellow', + 'olive', + 'green', + 'teal', + 'blue', + 'violet', + 'purple', + 'pink', + 'brown', + 'grey', + 'black', + 'white' + ]; + } + + get canAddLabel(): boolean { + try { + return [this.label.name, this.label.color].every(field => field.length !== 0) + && this.team.labels.every(label => label.name !== this.label.name); + } catch (e) { + return false; + } + } + + public addLabel() { + this.team.labels = this.team.labels + .concat(Object.assign({}, this.label)) + .sort((a: Label, b: Label) => a.name < b.name ? -1 : 1); + this.label = new Label(); + } + + public removeLabel(label: Label) { + this.team.labels = this.team.labels.filter(teamLabel => teamLabel !== label); + } + + public handleLabelEnter(ev: KeyboardEvent) { + ev.preventDefault(); + if (this.canAddLabel) { + this.addLabel(); + this.focusLabelField(); + } + } + + public focusLabelField() { + this.labelInputElement.nativeElement.focus(); + } + get canAddMember(): boolean { try { return [this.member.name, this.member.signum].every(field => field.length !== 0) @@ -66,7 +119,7 @@ export class TeamEditorComponent implements OnInit { return [ this.team.name.trim(), this.team.members - ].every(field => field.length > 0); + ].every(field => field.length > 0) && this.team.filterId > 0; } public saveTeam() { diff --git a/src/app/display/kanban-entry-item/kanban-entry-item.component.html b/src/app/display/kanban-entry-item/kanban-entry-item.component.html index c08d372..6f3b34e 100755 --- a/src/app/display/kanban-entry-item/kanban-entry-item.component.html +++ b/src/app/display/kanban-entry-item/kanban-entry-item.component.html @@ -12,10 +12,8 @@
{{kanbanEntry.epicName}} - - {{label|uppercase|blockedDays:kanbanEntry.daysBlocked}} - + {{label|blockedDays:kanbanEntry.daysBlocked}} {{kanbanEntry.daysBlocked}}D
diff --git a/src/app/display/kanban-entry-item/kanban-entry-item.component.ts b/src/app/display/kanban-entry-item/kanban-entry-item.component.ts index 0702f3c..91e48f5 100755 --- a/src/app/display/kanban-entry-item/kanban-entry-item.component.ts +++ b/src/app/display/kanban-entry-item/kanban-entry-item.component.ts @@ -2,23 +2,11 @@ import { Component, Input } from '@angular/core'; import { environment } from '../../../environments/environment'; import { JiraAssignee, KanbanEntry } from '../shared'; +import { SettingsService } from '../../shared/service/settings.service'; const DEFAULT_AVATAR = '/assets/riddler.png'; const JIRA_BOARD_BASE_HREF = 'https://cc-jira.rnd.ki.sw.ericsson.se/browse/'; -const labelColors = { - TSP: 'teal', - MTAS: 'orange', - INTERNAL: 'yellow', - TEAM: 'yellow', - BLOCKED: 'red', - SPIKE: 'purple', - EXPEDITE: 'pink', - - 'MTAS-GUARDIAN': 'pink', - 'MTAS-GUARDIANACTIVE': 'yellow', -}; - @Component({ selector: 'app-kanban-entry-item,[app-kanban-entry-item]', templateUrl: './kanban-entry-item.component.html', @@ -30,8 +18,7 @@ export class KanbanEntryItemComponent { @Input() wipLimit = 0; @Input() wipCount = 0; - constructor() { - } + constructor(private settingService: SettingsService) {} /** * Returns the full url of the assignee avatar, @@ -41,17 +28,9 @@ export class KanbanEntryItemComponent { * @returns {string} */ public avatarUrl(avatarPath: string): string { - return environment.apiUrl + (avatarPath ? avatarPath : DEFAULT_AVATAR); - } - - /** - * Returns true if issue has any labels attached - * - * @param {KanbanEntry} entry - * @returns {boolean} - */ - public hasLabels(entry: KanbanEntry): boolean { - return entry.labels.length > 0; + return environment.apiUrl + (avatarPath + ? avatarPath + : DEFAULT_AVATAR); } /** @@ -61,11 +40,16 @@ export class KanbanEntryItemComponent { * @returns {string} */ public labelClass(label: string): string { - try { - return labelColors[label.toUpperCase()]; - } catch (e) { - return 'white'; + if (this.settingService.team.labels) { + const color = this.settingService.team.labels.find( + teamLabel => teamLabel.name.toLocaleLowerCase() === label.toLocaleLowerCase() + ).color; + + if (color !== null) { + return color; + } } + return 'white'; } /** @@ -80,6 +64,15 @@ export class KanbanEntryItemComponent { }; } + public filteredLabels(kanbanEntry: KanbanEntry): Array { + if (this.settingService.team.labels) { + return kanbanEntry.labels.filter(entryLabel => this.settingService.team.labels.some( + teamLabel => teamLabel.name.toLocaleLowerCase() === entryLabel.toLocaleLowerCase() + )); + } + return []; + } + /** * Generate jira issue href * @@ -122,4 +115,5 @@ export class KanbanEntryItemComponent { public getAssignees(kanbanEntry: KanbanEntry): Array { return [].concat([kanbanEntry.assignee], kanbanEntry.additionalAssignees); } + } diff --git a/src/app/display/slide-iframe/slide-iframe.component.css b/src/app/display/slide-iframe/slide-iframe.component.css index a982899..7c65fc8 100755 --- a/src/app/display/slide-iframe/slide-iframe.component.css +++ b/src/app/display/slide-iframe/slide-iframe.component.css @@ -12,6 +12,7 @@ :host.preview { position: absolute; z-index: 1; + padding: 30px; } iframe { width: 100%; diff --git a/src/app/display/slide-show.service.ts b/src/app/display/slide-show.service.ts index 7789a8c..4ab57e4 100755 --- a/src/app/display/slide-show.service.ts +++ b/src/app/display/slide-show.service.ts @@ -1,8 +1,8 @@ -import { Injectable } from '@angular/core'; -import { Slide } from '../shared/slide'; -import { SlideService } from '../shared/service/slide.service'; -import { Router } from '@angular/router'; -import { SettingsService } from '../shared/service/settings.service'; +import {Injectable} from '@angular/core'; +import {Slide, SlideVisibility} from '../shared/slide'; +import {SlideService} from '../shared/service/slide.service'; +import {Router} from '@angular/router'; +import {SettingsService} from '../shared/service/settings.service'; @Injectable() export class SlideShowService { @@ -39,7 +39,7 @@ export class SlideShowService { const team = this.settingsService.team; this.slideService.list().subscribe( slides => this.slides = slides.filter( - slide => slide.teams === null || slide.teams.some(s => s.id === team.id) && slide.isVisible + slide => slide.isVisible && (slide.visibility === SlideVisibility.Public || slide.teams.some(s => s.id === team.id)) ) ); } diff --git a/src/app/shared/label.ts b/src/app/shared/label.ts new file mode 100755 index 0000000..607bd67 --- /dev/null +++ b/src/app/shared/label.ts @@ -0,0 +1,4 @@ +export class Label { + name: string; + color: string; +} diff --git a/src/app/shared/team.ts b/src/app/shared/team.ts old mode 100644 new mode 100755 index 72dc8a6..8ac9392 --- a/src/app/shared/team.ts +++ b/src/app/shared/team.ts @@ -1,16 +1,18 @@ import { Member } from './member'; import { KanbanColumn } from './kanban-column'; +import { Label } from './label'; export class Team { id: number = null; name: String = ''; members: Array = []; - filterId: number; + filterId = 0; backlogColumn: KanbanColumn = new KanbanColumn(); inprogressColumn: KanbanColumn = new KanbanColumn(); verificationColumn: KanbanColumn = new KanbanColumn(); doneColumn: KanbanColumn = new KanbanColumn(); - isActive = false; + labels: Array