feat: add task priority constants and labels for task management
This commit is contained in:
parent
2df0ba517f
commit
87a25ac66a
7 changed files with 115 additions and 87 deletions
|
|
@ -25,6 +25,7 @@
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<div class="left-side">
|
<div class="left-side">
|
||||||
|
<!-- Title -->
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<div class="headline">
|
<div class="headline">
|
||||||
{{ "addTask.title" | translate }}<span class="red-dot">*</span>
|
{{ "addTask.title" | translate }}<span class="red-dot">*</span>
|
||||||
|
|
@ -49,6 +50,8 @@
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Description -->
|
||||||
<div class="description">
|
<div class="description">
|
||||||
<div class="headline">
|
<div class="headline">
|
||||||
{{ "addTask.description" | translate
|
{{ "addTask.description" | translate
|
||||||
|
|
@ -75,14 +78,19 @@
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Assignees -->
|
||||||
<app-assigned
|
<app-assigned
|
||||||
[taskCreator]="taskData.creator"
|
[taskCreator]="taskData.creator"
|
||||||
[currentAssignees]="taskData.assignees"
|
[currentAssignees]="taskData.assignees"
|
||||||
(assignedChange)="receiveAssigned($event)"
|
(assignedChange)="receiveAssigned($event)"
|
||||||
></app-assigned>
|
></app-assigned>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="middle-spacer"><div class="line"></div></div>
|
<div class="middle-spacer"><div class="line"></div></div>
|
||||||
|
|
||||||
<div class="right-side">
|
<div class="right-side">
|
||||||
|
<!-- Date -->
|
||||||
<div
|
<div
|
||||||
class="date"
|
class="date"
|
||||||
[ngStyle]="{
|
[ngStyle]="{
|
||||||
|
|
@ -111,62 +119,39 @@
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Priority -->
|
||||||
<div class="priority">
|
<div class="priority">
|
||||||
<div class="headline">{{ "addTask.priority" | translate }}</div>
|
<div class="headline">{{ "addTask.priority" | translate }}</div>
|
||||||
<div class="btns">
|
<div class="btns">
|
||||||
|
@for (priority of PRIORITIES; track priority) {
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="btn"
|
class="btn"
|
||||||
[ngClass]="{
|
[ngClass]="{
|
||||||
'btn-active': taskData.priority == 'urgent'
|
'btn-active': taskData.priority === priority
|
||||||
}"
|
}"
|
||||||
[ngStyle]="{
|
[ngStyle]="{
|
||||||
'background-color':
|
'background-color':
|
||||||
taskData.priority == 'urgent' ? 'red' : 'white'
|
taskData.priority === priority
|
||||||
|
? getPriorityColor(priority)
|
||||||
|
: 'white'
|
||||||
}"
|
}"
|
||||||
(click)="togglePriority('urgent')"
|
(click)="togglePriority(priority)"
|
||||||
>
|
>
|
||||||
<div class="btn-text">
|
<div class="btn-text">
|
||||||
<span>{{ "addTask.urgent" | translate }}</span>
|
<span>{{ PRIORITY_LABELS[priority] | translate }}</span>
|
||||||
<img src="./../../../assets/img/urgent.svg" alt="" />
|
<img
|
||||||
</div>
|
[src]="getPriorityIcon(priority)"
|
||||||
</button>
|
[alt]="priority + ' icon'"
|
||||||
<button
|
/>
|
||||||
type="button"
|
|
||||||
class="btn"
|
|
||||||
[ngClass]="{
|
|
||||||
'btn-active': taskData.priority == 'medium'
|
|
||||||
}"
|
|
||||||
[ngStyle]="{
|
|
||||||
'background-color':
|
|
||||||
taskData.priority == 'medium' ? 'orange' : 'white'
|
|
||||||
}"
|
|
||||||
(click)="togglePriority('medium')"
|
|
||||||
>
|
|
||||||
<div class="btn-text">
|
|
||||||
<span>{{ "addTask.medium" | translate }}</span>
|
|
||||||
<img src="./../../../assets/img/medium.svg" alt="" />
|
|
||||||
</div>
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="btn"
|
|
||||||
[ngClass]="{
|
|
||||||
'btn-active': taskData.priority == 'low'
|
|
||||||
}"
|
|
||||||
[ngStyle]="{
|
|
||||||
'background-color':
|
|
||||||
taskData.priority == 'low' ? 'green' : 'white'
|
|
||||||
}"
|
|
||||||
(click)="togglePriority('low')"
|
|
||||||
>
|
|
||||||
<div class="btn-text">
|
|
||||||
<span>{{ "addTask.low" | translate }}</span>
|
|
||||||
<img src="./../../../assets/img/low.svg" alt="" />
|
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Category -->
|
||||||
<div class="category">
|
<div class="category">
|
||||||
<div class="headline">
|
<div class="headline">
|
||||||
{{ "addTask.category" | translate }}<span class="red-dot">*</span>
|
{{ "addTask.category" | translate }}<span class="red-dot">*</span>
|
||||||
|
|
@ -195,6 +180,8 @@
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Subtasks -->
|
||||||
<div class="subtask">
|
<div class="subtask">
|
||||||
<div class="headline">{{ "addTask.subtask" | translate }}</div>
|
<div class="headline">{{ "addTask.subtask" | translate }}</div>
|
||||||
<input
|
<input
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,13 @@ import { CommonModule } from '@angular/common';
|
||||||
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
|
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { FormsModule, NgForm } from '@angular/forms';
|
import { FormsModule, NgForm } from '@angular/forms';
|
||||||
import { AssignedComponent } from './assigned/assigned.component';
|
import { AssignedComponent } from './assigned/assigned.component';
|
||||||
import { Subtask, Task, TaskStatus } from '../../interfaces/task.interface';
|
import {
|
||||||
|
Subtask,
|
||||||
|
Task,
|
||||||
|
TaskCategory,
|
||||||
|
TaskPriority,
|
||||||
|
TaskStatus,
|
||||||
|
} from '../../interfaces/task.interface';
|
||||||
import { OverlayService } from '../../services/overlay.service';
|
import { OverlayService } from '../../services/overlay.service';
|
||||||
import { FormBtnComponent } from '../../shared/components/buttons/form-btn/form-btn.component';
|
import { FormBtnComponent } from '../../shared/components/buttons/form-btn/form-btn.component';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
|
@ -14,6 +20,10 @@ import { ApiService } from '../../services/api.service';
|
||||||
import { UpdateNotifierService } from '../../services/update-notifier.service';
|
import { UpdateNotifierService } from '../../services/update-notifier.service';
|
||||||
import { ToastNotificationService } from '../../services/toast-notification.service';
|
import { ToastNotificationService } from '../../services/toast-notification.service';
|
||||||
import { HeadlineComponent } from '../../shared/components/headline/headline.component';
|
import { HeadlineComponent } from '../../shared/components/headline/headline.component';
|
||||||
|
import {
|
||||||
|
PRIORITIES,
|
||||||
|
PRIORITY_LABELS,
|
||||||
|
} from '../../constants/task-priority.constants';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-add-task',
|
selector: 'app-add-task',
|
||||||
|
|
@ -34,6 +44,9 @@ export class AddTaskComponent implements OnInit, OnDestroy {
|
||||||
@Input() overlayType: string = '';
|
@Input() overlayType: string = '';
|
||||||
@Input() overlayMobile: boolean = false;
|
@Input() overlayMobile: boolean = false;
|
||||||
|
|
||||||
|
readonly PRIORITIES = PRIORITIES;
|
||||||
|
readonly PRIORITY_LABELS = PRIORITY_LABELS;
|
||||||
|
|
||||||
currentDate: string = new Date().toISOString().split('T')[0];
|
currentDate: string = new Date().toISOString().split('T')[0];
|
||||||
dateInPast: boolean = false;
|
dateInPast: boolean = false;
|
||||||
subtaskValue: string = '';
|
subtaskValue: string = '';
|
||||||
|
|
@ -54,9 +67,9 @@ export class AddTaskComponent implements OnInit, OnDestroy {
|
||||||
taskData: Task = {
|
taskData: Task = {
|
||||||
title: '',
|
title: '',
|
||||||
description: '',
|
description: '',
|
||||||
category: '',
|
category: TaskCategory.USER_STORY,
|
||||||
status: this.taskService.getStatuses()[0],
|
status: TaskStatus.TODO,
|
||||||
priority: this.taskService.getPriorities()[0],
|
priority: TaskPriority.LOW,
|
||||||
subtasks: [],
|
subtasks: [],
|
||||||
assignees: [],
|
assignees: [],
|
||||||
userData: [],
|
userData: [],
|
||||||
|
|
@ -128,11 +141,35 @@ export class AddTaskComponent implements OnInit, OnDestroy {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
getPriorityColor(priority: TaskPriority): string {
|
||||||
* Loads any existing task data from local storage and assigns it to the taskData object.
|
switch (priority) {
|
||||||
* If no task data is present in local storage, this method saves the current taskData object to local storage.
|
case TaskPriority.URGENT:
|
||||||
* @returns {void}
|
return 'red';
|
||||||
*/
|
case TaskPriority.MEDIUM:
|
||||||
|
return 'orange';
|
||||||
|
case TaskPriority.LOW:
|
||||||
|
return 'green';
|
||||||
|
default:
|
||||||
|
return 'white';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getPriorityIcon(priority: TaskPriority): string {
|
||||||
|
switch (priority) {
|
||||||
|
case TaskPriority.URGENT:
|
||||||
|
return './../../../assets/img/urgent.svg';
|
||||||
|
case TaskPriority.MEDIUM:
|
||||||
|
return './../../../assets/img/medium.svg';
|
||||||
|
case TaskPriority.LOW:
|
||||||
|
return './../../../assets/img/low.svg';
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
togglePriority(priority: TaskPriority): void {
|
||||||
|
this.taskData.priority = priority;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the task data from the Firebase service for the given task id.
|
* Gets the task data from the Firebase service for the given task id.
|
||||||
|
|
@ -194,19 +231,6 @@ export class AddTaskComponent implements OnInit, OnDestroy {
|
||||||
: (this.dateInPast = false);
|
: (this.dateInPast = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Toggles the priority of the task between the given priority and the current priority.
|
|
||||||
* If the given priority is different from the current priority, it sets the priority to the given priority,
|
|
||||||
* otherwise it keeps the current priority.
|
|
||||||
* After setting the priority, it saves the task data.
|
|
||||||
* @param priority the priority to toggle to
|
|
||||||
*/
|
|
||||||
togglePriority(priority: string) {
|
|
||||||
this.taskData.priority !== priority
|
|
||||||
? (this.taskData.priority = priority)
|
|
||||||
: this.taskData.priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the task data from local storage and resets the form and form data.
|
* Removes the task data from local storage and resets the form and form data.
|
||||||
* @param form the form to reset
|
* @param form the form to reset
|
||||||
|
|
@ -246,7 +270,7 @@ export class AddTaskComponent implements OnInit, OnDestroy {
|
||||||
*/
|
*/
|
||||||
clearFormData() {
|
clearFormData() {
|
||||||
this.taskData.date = this.currentDate;
|
this.taskData.date = this.currentDate;
|
||||||
this.taskData.category = '';
|
this.taskData.category = TaskCategory.USER_STORY;
|
||||||
this.taskData.assignees = [];
|
this.taskData.assignees = [];
|
||||||
this.taskData.subtasks = [];
|
this.taskData.subtasks = [];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
13
src/app/constants/task-priority.constants.ts
Normal file
13
src/app/constants/task-priority.constants.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { TaskPriority } from '../interfaces/task.interface';
|
||||||
|
|
||||||
|
export const PRIORITIES: TaskPriority[] = [
|
||||||
|
TaskPriority.LOW,
|
||||||
|
TaskPriority.MEDIUM,
|
||||||
|
TaskPriority.URGENT,
|
||||||
|
];
|
||||||
|
|
||||||
|
export const PRIORITY_LABELS: Record<TaskPriority, string> = {
|
||||||
|
[TaskPriority.LOW]: 'taskPriority.low',
|
||||||
|
[TaskPriority.MEDIUM]: 'taskPriority.medium',
|
||||||
|
[TaskPriority.URGENT]: 'taskPriority.urgent',
|
||||||
|
};
|
||||||
|
|
@ -9,15 +9,26 @@ export enum TaskStatus {
|
||||||
DONE = 'done',
|
DONE = 'done',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum TaskPriority {
|
||||||
|
LOW = 'low',
|
||||||
|
MEDIUM = 'medium',
|
||||||
|
URGENT = 'urgent',
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum TaskCategory {
|
||||||
|
USER_STORY = 'User Story',
|
||||||
|
TECHNICAL_TASK = 'Technical Task',
|
||||||
|
}
|
||||||
|
|
||||||
// Interfaces
|
// Interfaces
|
||||||
|
|
||||||
export interface Task {
|
export interface Task {
|
||||||
id?: string;
|
id?: string;
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
category: string;
|
category: TaskCategory;
|
||||||
status: TaskStatus;
|
status: TaskStatus;
|
||||||
priority: string;
|
priority: TaskPriority;
|
||||||
subtasks: Subtask[];
|
subtasks: Subtask[];
|
||||||
assignees: Assignee[];
|
assignees: Assignee[];
|
||||||
userData: UserSummary[];
|
userData: UserSummary[];
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,19 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable, of } from 'rxjs';
|
import { Observable, of } from 'rxjs';
|
||||||
import { ApiService } from './api.service';
|
import { ApiService } from './api.service';
|
||||||
import { Task, TaskStatus } from '../interfaces/task.interface';
|
import {
|
||||||
|
Task,
|
||||||
|
TaskCategory,
|
||||||
|
TaskPriority,
|
||||||
|
TaskStatus,
|
||||||
|
} from '../interfaces/task.interface';
|
||||||
import { catchError, map, switchMap } from 'rxjs/operators';
|
import { catchError, map, switchMap } from 'rxjs/operators';
|
||||||
import { UserSummary } from '../interfaces/user.interface';
|
import { UserSummary } from '../interfaces/user.interface';
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class TaskService {
|
export class TaskService {
|
||||||
private readonly statuses: TaskStatus[] = [
|
|
||||||
TaskStatus.TODO,
|
|
||||||
TaskStatus.IN_PROGRESS,
|
|
||||||
TaskStatus.AWAIT_FEEDBACK,
|
|
||||||
TaskStatus.DONE,
|
|
||||||
];
|
|
||||||
private readonly priorities = ['low', 'medium', 'high'];
|
|
||||||
|
|
||||||
constructor(private apiService: ApiService) {}
|
constructor(private apiService: ApiService) {}
|
||||||
|
|
||||||
getStatuses(): TaskStatus[] {
|
|
||||||
return this.statuses;
|
|
||||||
}
|
|
||||||
|
|
||||||
getPriorities(): string[] {
|
|
||||||
return this.priorities;
|
|
||||||
}
|
|
||||||
|
|
||||||
getTasks(): Observable<Task[]> {
|
getTasks(): Observable<Task[]> {
|
||||||
return this.fetchTasks();
|
return this.fetchTasks();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,11 @@
|
||||||
"awaitFeedback": "Warte auf Rückmeldung",
|
"awaitFeedback": "Warte auf Rückmeldung",
|
||||||
"done": "Erledigt"
|
"done": "Erledigt"
|
||||||
},
|
},
|
||||||
|
"taskPriority": {
|
||||||
|
"low": "Niedrig",
|
||||||
|
"medium": "Mittel",
|
||||||
|
"urgent": "Dringend"
|
||||||
|
},
|
||||||
"addTask": {
|
"addTask": {
|
||||||
"headline": "Aufgabe",
|
"headline": "Aufgabe",
|
||||||
"title": "Titel",
|
"title": "Titel",
|
||||||
|
|
@ -140,9 +145,6 @@
|
||||||
"date": "Stichtag",
|
"date": "Stichtag",
|
||||||
"priority": "Priorität",
|
"priority": "Priorität",
|
||||||
"creator": "Ersteller",
|
"creator": "Ersteller",
|
||||||
"urgent": "Dringend",
|
|
||||||
"medium": "Mittel",
|
|
||||||
"low": "Niedrig",
|
|
||||||
"category": "Kategorie",
|
"category": "Kategorie",
|
||||||
"categorySelection": "Kategorie wählen",
|
"categorySelection": "Kategorie wählen",
|
||||||
"subtask": "Unteraufgaben",
|
"subtask": "Unteraufgaben",
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,11 @@
|
||||||
"awaitFeedback": "Await feedback",
|
"awaitFeedback": "Await feedback",
|
||||||
"done": "Done"
|
"done": "Done"
|
||||||
},
|
},
|
||||||
|
"taskPriority": {
|
||||||
|
"urgent": "Urgent",
|
||||||
|
"medium": "Medium",
|
||||||
|
"low": "Low"
|
||||||
|
},
|
||||||
"addTask": {
|
"addTask": {
|
||||||
"headline": "Add Task",
|
"headline": "Add Task",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
|
|
@ -140,9 +145,6 @@
|
||||||
"date": "Due date",
|
"date": "Due date",
|
||||||
"priority": "Priority",
|
"priority": "Priority",
|
||||||
"creator": "Creator",
|
"creator": "Creator",
|
||||||
"urgent": "Urgent",
|
|
||||||
"medium": "Medium",
|
|
||||||
"low": "Low",
|
|
||||||
"category": "Category",
|
"category": "Category",
|
||||||
"categorySelection": "Select task category",
|
"categorySelection": "Select task category",
|
||||||
"subtask": "Subtasks",
|
"subtask": "Subtasks",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue