Skip to content

Commit

Permalink
feat: make logic works for kanban for #54
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Apr 13, 2020
1 parent 59458ef commit 9a39a3b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<div class="board">

<div class="board-bar">
<p class="board-name">{{ board.name }}</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnInit } from '@angular/core';
import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';
import { LedgeListItem } from '../model/ledge-chart.model';
import { CdkDragDrop, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop';
import { Column } from './model/column';
Expand All @@ -9,45 +9,38 @@ import { Board } from './model/board';
templateUrl: './ledge-kanban.component.html',
styleUrls: ['./ledge-kanban.component.scss']
})
export class LedgeKanbanComponent implements OnInit {
export class LedgeKanbanComponent implements OnInit, OnChanges {
@Input()
data: LedgeListItem[];

@Input()
config: any;

board: Board = new Board('Test Board', [
new Column('Ideas', [
'Some random idea',
'This is another random idea',
'build an awesome application'
]),
new Column('Research', [
'Lorem ipsum',
'foo',
'This was in the \'Research\' column'
]),
new Column('Todo', [
'Get to work',
'Pick up groceries',
'Go home',
'Fall asleep'
]),
new Column('Done', [
'Get up',
'Brush teeth',
'Take a shower',
'Check e-mail',
'Walk dog'
])
]);
board: Board = new Board('', []);

constructor() {
}

ngOnInit(): void {
}

ngOnChanges(changes: SimpleChanges): void {
this.updateKanbanData();
}

private updateKanbanData() {
const kanbanData = this.data[0];

this.board = new Board(kanbanData.name, []);
for (const column of kanbanData.children) {
const col = new Column(column.name, []);
for (const cell of column.children) {
col.tasks.push(cell.name);
}
this.board.columns.push(col);
}
}

drop(event: CdkDragDrop<string[]>) {
if (event.previousContainer === event.container) {
moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
Expand All @@ -58,5 +51,4 @@ export class LedgeKanbanComponent implements OnInit {
event.currentIndex);
}
}

}

0 comments on commit 9a39a3b

Please sign in to comment.