feat: add task category constants, labels and colors for task management

This commit is contained in:
Chneemann 2025-04-17 04:12:56 +02:00
parent 87a25ac66a
commit e4c8fcb7f0
11 changed files with 65 additions and 29 deletions

View file

@ -166,8 +166,11 @@
<option value="" disabled [selected]="!taskData.category"> <option value="" disabled [selected]="!taskData.category">
{{ "addTask.categorySelection" | translate }} {{ "addTask.categorySelection" | translate }}
</option> </option>
<option value="User Story">User Story</option> @for (category of CATEGORIES; track category) {
<option value="Technical Task">Technical Task</option> <option [value]="category">
{{ CATEGORY_LABELS[category] | translate }}
</option>
}
</select> </select>
<img <img
class="open" class="open"

View file

@ -15,7 +15,6 @@ import { ActivatedRoute, Router } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { AuthService } from '../../services/auth.service'; import { AuthService } from '../../services/auth.service';
import { firstValueFrom, map, Subject, takeUntil } from 'rxjs'; import { firstValueFrom, map, Subject, takeUntil } from 'rxjs';
import { TaskService } from '../../services/task.service';
import { ApiService } from '../../services/api.service'; 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';
@ -24,6 +23,10 @@ import {
PRIORITIES, PRIORITIES,
PRIORITY_LABELS, PRIORITY_LABELS,
} from '../../constants/task-priority.constants'; } from '../../constants/task-priority.constants';
import {
CATEGORIES,
CATEGORY_LABELS,
} from '../../constants/task-category.constants';
@Component({ @Component({
selector: 'app-add-task', selector: 'app-add-task',
@ -46,6 +49,8 @@ export class AddTaskComponent implements OnInit, OnDestroy {
readonly PRIORITIES = PRIORITIES; readonly PRIORITIES = PRIORITIES;
readonly PRIORITY_LABELS = PRIORITY_LABELS; readonly PRIORITY_LABELS = PRIORITY_LABELS;
readonly CATEGORIES = CATEGORIES;
readonly CATEGORY_LABELS = CATEGORY_LABELS;
currentDate: string = new Date().toISOString().split('T')[0]; currentDate: string = new Date().toISOString().split('T')[0];
dateInPast: boolean = false; dateInPast: boolean = false;
@ -55,7 +60,6 @@ export class AddTaskComponent implements OnInit, OnDestroy {
constructor( constructor(
private overlayService: OverlayService, private overlayService: OverlayService,
private taskService: TaskService,
private apiService: ApiService, private apiService: ApiService,
private authService: AuthService, private authService: AuthService,
private updateNotifierService: UpdateNotifierService, private updateNotifierService: UpdateNotifierService,

View file

@ -44,6 +44,7 @@
<div class="content"> <div class="content">
<div class="status"> <div class="status">
<!-- Loop through statuses -->
@for (status of STATUSES; track status) { @for (status of STATUSES; track status) {
<div <div
class="column" class="column"

View file

@ -22,6 +22,10 @@ import { ToastNotificationService } from '../../services/toast-notification.serv
import { ResizeService } from '../../services/resize.service'; import { ResizeService } from '../../services/resize.service';
import { HeadlineComponent } from '../../shared/components/headline/headline.component'; import { HeadlineComponent } from '../../shared/components/headline/headline.component';
import { STATUS_LABELS, STATUSES } from '../../constants/task-status.constants'; import { STATUS_LABELS, STATUSES } from '../../constants/task-status.constants';
import {
CATEGORIES,
CATEGORY_LABELS,
} from '../../constants/task-category.constants';
@Component({ @Component({
selector: 'app-board', selector: 'app-board',

View file

@ -12,9 +12,9 @@
<div class="header"> <div class="header">
<div <div
class="category" class="category"
[style.background-color]="categoryColors.get(task.category)" [style.backgroundColor]="categoryColors[task.category]"
> >
<p>{{ task.category }}</p> <p>{{ CATEGORY_LABELS[task.category] | translate }}</p>
</div> </div>
<!-- If the user is on a mobile device, show the menu button --> <!-- If the user is on a mobile device, show the menu button -->

View file

@ -17,11 +17,16 @@ import { Router } from '@angular/router';
import { TaskMenuComponent } from './task-menu/task-menu.component'; import { TaskMenuComponent } from './task-menu/task-menu.component';
import { ResizeService } from '../../../services/resize.service'; import { ResizeService } from '../../../services/resize.service';
import { take } from 'rxjs'; import { take } from 'rxjs';
import {
CATEGORY_COLORS,
CATEGORY_LABELS,
} from '../../../constants/task-category.constants';
import { TranslateModule } from '@ngx-translate/core';
@Component({ @Component({
selector: 'app-task', selector: 'app-task',
standalone: true, standalone: true,
imports: [CommonModule, TaskMenuComponent], imports: [CommonModule, TranslateModule, TaskMenuComponent],
templateUrl: './task.component.html', templateUrl: './task.component.html',
styleUrl: './task.component.scss', styleUrl: './task.component.scss',
}) })
@ -29,6 +34,8 @@ export class TaskComponent {
@Input() task!: Task; @Input() task!: Task;
@Output() updateStatusEmitter = new EventEmitter<TaskMoveEvent>(); @Output() updateStatusEmitter = new EventEmitter<TaskMoveEvent>();
readonly CATEGORY_LABELS = CATEGORY_LABELS;
readonly categoryColors = CATEGORY_COLORS;
readonly DISABLE_DRAG_BREAKPOINT = 667; readonly DISABLE_DRAG_BREAKPOINT = 667;
readonly DIALOG_OFFSET_X = 25; readonly DIALOG_OFFSET_X = 25;
readonly DIALOG_OFFSET_Y = 10; readonly DIALOG_OFFSET_Y = 10;
@ -36,10 +43,6 @@ export class TaskComponent {
pageViewMedia$ = this.resizeService.pageViewMedia$; pageViewMedia$ = this.resizeService.pageViewMedia$;
assignees: Assignee[] = []; assignees: Assignee[] = [];
categoryColors = new Map<string, string>([
['User Story', '#0038ff'],
['Technical Task', '#20d7c2'],
]);
mobileMenuOpen = false; mobileMenuOpen = false;
disableDrag = false; disableDrag = false;

View file

@ -0,0 +1,16 @@
import { TaskCategory } from '../interfaces/task.interface';
export const CATEGORIES: TaskCategory[] = [
TaskCategory.USER_STORY,
TaskCategory.TECHNICAL_TASK,
];
export const CATEGORY_LABELS: Record<TaskCategory, string> = {
[TaskCategory.USER_STORY]: 'taskCategory.userStory',
[TaskCategory.TECHNICAL_TASK]: 'taskCategory.technicalTask',
};
export const CATEGORY_COLORS: Record<TaskCategory, string> = {
[TaskCategory.USER_STORY]: '#0038ff',
[TaskCategory.TECHNICAL_TASK]: '#20d7c2',
};

View file

@ -8,9 +8,9 @@
<div class="header"> <div class="header">
<div <div
class="category" class="category"
[style.background-color]="categoryColors.get(task.category)" [style.backgroundColor]="categoryColors[task.category]"
> >
{{ task.category }} <p>{{ CATEGORY_LABELS[task.category] | translate }}</p>
</div> </div>
@if (overlayMobile) { @if (overlayMobile) {
<app-btn-back></app-btn-back> <app-btn-back></app-btn-back>
@ -34,7 +34,7 @@
</div> </div>
<div class="priority"> <div class="priority">
<p>{{ "addTask.priority" | translate }}:</p> <p>{{ "addTask.priority" | translate }}:</p>
{{ capitalizeFirstLetter(task.priority) }} {{ PRIORITY_LABELS[task.priority] | translate }}
<div class="priority-bg priority-{{ task.priority }}"></div> <div class="priority-bg priority-{{ task.priority }}"></div>
</div> </div>

View file

@ -19,6 +19,11 @@ import { map, Subject, takeUntil } from 'rxjs';
import { ApiService } from '../../../../services/api.service'; 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 {
CATEGORY_COLORS,
CATEGORY_LABELS,
} from '../../../../constants/task-category.constants';
import { PRIORITY_LABELS } from '../../../../constants/task-priority.constants';
@Component({ @Component({
selector: 'app-task-overlay', selector: 'app-task-overlay',
@ -31,6 +36,10 @@ export class TaskOverlayComponent implements OnInit, OnDestroy {
@Input() overlayData: string = ''; @Input() overlayData: string = '';
@Output() closeDialogEmitter = new EventEmitter<boolean>(); @Output() closeDialogEmitter = new EventEmitter<boolean>();
readonly CATEGORY_LABELS = CATEGORY_LABELS;
readonly PRIORITY_LABELS = PRIORITY_LABELS;
readonly categoryColors = CATEGORY_COLORS;
task: Task | null = null; task: Task | null = null;
overlayMobile: boolean = false; overlayMobile: boolean = false;
currentUserId: string = ''; currentUserId: string = '';
@ -49,11 +58,6 @@ export class TaskOverlayComponent implements OnInit, OnDestroy {
private route: ActivatedRoute private route: ActivatedRoute
) {} ) {}
categoryColors = new Map<string, string>([
['User Story', '#0038ff'],
['Technical Task', '#20d7c2'],
]);
ngOnInit(): void { ngOnInit(): void {
this.setCurrentUserId(); this.setCurrentUserId();
this.setOverlayDataFromRoute(); this.setOverlayDataFromRoute();
@ -175,16 +179,9 @@ export class TaskOverlayComponent implements OnInit, OnDestroy {
); );
} }
/** capitalizeFirstLetter(value: string): string {
* Capitalizes the first letter of a given string. if (!value) return '';
* return value.charAt(0).toUpperCase() + value.slice(1);
* This function takes a string as an argument and returns a new string
* with the first letter capitalized.
* @param data The string to capitalize.
* @returns {string} A new string with the first letter capitalized.
*/
capitalizeFirstLetter(data: string) {
return data.charAt(0).toUpperCase() + data.slice(1);
} }
toggleConfirmDialog() { toggleConfirmDialog() {

View file

@ -134,6 +134,10 @@
"medium": "Mittel", "medium": "Mittel",
"urgent": "Dringend" "urgent": "Dringend"
}, },
"taskCategory": {
"userStory": "Benutzergeschichte",
"technicalTask": "Technischer Auftrag"
},
"addTask": { "addTask": {
"headline": "Aufgabe", "headline": "Aufgabe",
"title": "Titel", "title": "Titel",

View file

@ -134,6 +134,10 @@
"medium": "Medium", "medium": "Medium",
"low": "Low" "low": "Low"
}, },
"taskCategory": {
"userStory": "User Story",
"technicalTask": "Technical Task"
},
"addTask": { "addTask": {
"headline": "Add Task", "headline": "Add Task",
"title": "Title", "title": "Title",