bugfixes drag & drop
This commit is contained in:
parent
4dc7e9900d
commit
cf508534fa
5 changed files with 72 additions and 49 deletions
|
|
@ -44,17 +44,17 @@
|
|||
onclick="openAddTaskPage('todo')"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
id="content-todo"
|
||||
<div id="content-todo">
|
||||
<ng-container *ngIf="!isTaskRendered('todo')">
|
||||
<app-task [index]="undefined"></app-task>
|
||||
</ng-container>
|
||||
<ng-container
|
||||
*ngFor="let task of firebaseService.allTasks; index as i"
|
||||
>
|
||||
<app-task
|
||||
*ngIf="firebaseService.allTasks[i].status === 'todo'"
|
||||
[index]="i"
|
||||
></app-task>
|
||||
<ng-template [ngIf]="firebaseService.allTasks[i].status === ''">
|
||||
empthy
|
||||
</ng-template>
|
||||
<ng-container *ngIf="task.status === 'todo'">
|
||||
<app-task [index]="i"></app-task>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
|
|
@ -70,17 +70,19 @@
|
|||
onclick="openAddTaskPage('inprogress')"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
id="content-inprogress"
|
||||
<div id="content-inprogress">
|
||||
<ng-container *ngIf="!isTaskRendered('inprogress')">
|
||||
<app-task [index]="undefined"></app-task>
|
||||
</ng-container>
|
||||
<ng-container
|
||||
*ngFor="let task of firebaseService.allTasks; index as i"
|
||||
>
|
||||
<app-task
|
||||
*ngIf="firebaseService.allTasks[i].status === 'inprogress'"
|
||||
[index]="i"
|
||||
></app-task>
|
||||
<ng-container *ngIf="task.status === 'inprogress'">
|
||||
<app-task [index]="i"></app-task>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="content-column"
|
||||
(dragover)="dragDropService.allowDrop($event)"
|
||||
|
|
@ -94,17 +96,19 @@
|
|||
onclick="openAddTaskPage('awaitfeedback')"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
id="content-awaitfeedback"
|
||||
<div id="content-awaitfeedback">
|
||||
<ng-container *ngIf="!isTaskRendered('awaitfeedback')">
|
||||
<app-task [index]="undefined"></app-task>
|
||||
</ng-container>
|
||||
<ng-container
|
||||
*ngFor="let task of firebaseService.allTasks; index as i"
|
||||
>
|
||||
<app-task
|
||||
*ngIf="firebaseService.allTasks[i].status === 'awaitfeedback'"
|
||||
[index]="i"
|
||||
></app-task>
|
||||
<ng-container *ngIf="task.status === 'awaitfeedback'">
|
||||
<app-task [index]="i"></app-task>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="content-column"
|
||||
(dragover)="dragDropService.allowDrop($event)"
|
||||
|
|
@ -118,14 +122,17 @@
|
|||
onclick="openAddTaskPage('done')"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
id="content-done"
|
||||
<div id="content-done">
|
||||
<ng-container *ngIf="!isTaskRendered('done')">
|
||||
<app-task [index]="undefined"></app-task>
|
||||
</ng-container>
|
||||
<ng-container
|
||||
*ngFor="let task of firebaseService.allTasks; index as i"
|
||||
>
|
||||
<app-task
|
||||
*ngIf="firebaseService.allTasks[i].status === 'done'"
|
||||
[index]="i"
|
||||
></app-task>
|
||||
<ng-container *ngIf="task.status === 'done'">
|
||||
<app-task [index]="i"></app-task>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -15,17 +15,27 @@ export class BoardComponent {
|
|||
constructor(
|
||||
public dragDropService: DragDropService,
|
||||
public firebaseService: FirebaseService
|
||||
) {
|
||||
this.dragDropService.itemDropped.subscribe(({ index, status }) => {
|
||||
this.firebaseService.allTasks[index].status = status;
|
||||
this.firebaseService.updateTask(
|
||||
this.firebaseService.allTasks[index].id,
|
||||
index
|
||||
);
|
||||
});
|
||||
}
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.firebaseService.updateAllTasks();
|
||||
this.dragDropService.itemDropped.subscribe(({ index, status }) => {
|
||||
this.handleItemDropped(index, status);
|
||||
});
|
||||
}
|
||||
|
||||
handleItemDropped(index: number, status: string): void {
|
||||
let firebaseId = this.firebaseService.allTasks[index].id;
|
||||
this.firebaseService.allTasks[index].status = status;
|
||||
this.firebaseService.updateTask(firebaseId, index);
|
||||
}
|
||||
|
||||
isTaskRendered(taskColumn: string): boolean {
|
||||
for (let task of this.firebaseService.allTasks) {
|
||||
if (task.status === taskColumn) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
<section>
|
||||
<section *ngIf="index !== undefined">
|
||||
<div
|
||||
class="content"
|
||||
draggable="true"
|
||||
*ngIf="index !== undefined"
|
||||
(dragstart)="dragDropService.startDragging($event, index)"
|
||||
>
|
||||
<div
|
||||
|
|
@ -22,3 +21,5 @@
|
|||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div *ngIf="index === undefined" class="empty-task">No tasks</div>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
section {
|
||||
width: 246px;
|
||||
height: 100%;
|
||||
margin: 15.5px 0;
|
||||
}
|
||||
|
||||
|
|
@ -18,6 +17,8 @@ section {
|
|||
font-size: 16px;
|
||||
font-weight: 400;
|
||||
color: var(--gray);
|
||||
width: 246px;
|
||||
margin: 15.5px 0;
|
||||
}
|
||||
|
||||
.content {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@
|
|||
white-space: normal;
|
||||
}
|
||||
|
||||
.d-none {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/*------------- SCROLLBAR -------------*/
|
||||
|
||||
*::-webkit-scrollbar {
|
||||
|
|
|
|||
Loading…
Reference in a new issue