finished code: move task status
This commit is contained in:
parent
f6d4983785
commit
34df5bf449
3 changed files with 25 additions and 5 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { Component, Input } from '@angular/core';
|
||||
import { FirebaseService } from '../../../../services/firebase.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-task-menu',
|
||||
|
|
@ -8,9 +9,24 @@ import { Component, Input } from '@angular/core';
|
|||
styleUrl: './task-menu.component.scss',
|
||||
})
|
||||
export class TaskMenuComponent {
|
||||
@Input() taskId: string = '';
|
||||
@Input() boardTaskStatus: string = '';
|
||||
|
||||
constructor(private firebaseService: FirebaseService) {}
|
||||
|
||||
moveTask(moveTo: string) {
|
||||
console.log(moveTo);
|
||||
const index = this.firebaseService.allTasks.findIndex(
|
||||
(task) => task.id === this.taskId
|
||||
);
|
||||
const filteredIndex = this.firebaseService.filteredTasks.findIndex(
|
||||
(task) => task.id === this.taskId
|
||||
);
|
||||
if (index !== -1) {
|
||||
this.firebaseService.allTasks[index].status = moveTo;
|
||||
if (filteredIndex !== -1) {
|
||||
this.firebaseService.filteredTasks[filteredIndex].status = moveTo;
|
||||
}
|
||||
this.firebaseService.updateTask(this.taskId, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<section>
|
||||
@if (task.id) {
|
||||
<div (click)="handleMenuButtonClick($event, task.id)">
|
||||
<div
|
||||
class="content"
|
||||
|
|
@ -52,6 +53,9 @@
|
|||
</div>
|
||||
</div>
|
||||
@if (isMenuOpen){
|
||||
<app-task-menu [boardTaskStatus]="task.status"></app-task-menu>
|
||||
}
|
||||
<app-task-menu
|
||||
[taskId]="task.id"
|
||||
[boardTaskStatus]="task.status"
|
||||
></app-task-menu>
|
||||
} }
|
||||
</section>
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export class TaskComponent implements OnInit, OnDestroy {
|
|||
this.isPageViewMedia = window.innerWidth <= 650;
|
||||
}
|
||||
|
||||
handleMenuButtonClick(event: MouseEvent, taskId: string | undefined) {
|
||||
handleMenuButtonClick(event: MouseEvent, taskId: string) {
|
||||
event.stopPropagation();
|
||||
const targetElement = event.target as HTMLElement;
|
||||
targetElement.classList.contains('menu-btn') ||
|
||||
|
|
@ -59,7 +59,7 @@ export class TaskComponent implements OnInit, OnDestroy {
|
|||
this.isMenuOpen = !this.isMenuOpen;
|
||||
}
|
||||
|
||||
openTaskDetailsOverlay(taskId: string | undefined) {
|
||||
openTaskDetailsOverlay(taskId: string) {
|
||||
if (this.isMenuOpen) {
|
||||
this.toggleTaskMenu();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue