Skip to content

Commit

Permalink
Fix no card drop issue when the list is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
parwatcodes committed Jul 4, 2023
1 parent 66eff29 commit 8fdf99d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions pages/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export function loadTask(searchTerm) {
if (searchTerm) {
taskList = filterFromData(taskList, searchTerm);
document.querySelectorAll(".card").forEach(el => {
el.remove()
el.remove();
});
} else {
document.querySelectorAll(".card").forEach(el => {
el.remove()
el.remove();
});
}

Expand All @@ -32,9 +32,7 @@ export function loadTask(searchTerm) {
let cardType = ['cardToDo', 'cardInProgress', 'cardInReview', 'cardInDone'];

[inToDoTask, inProgressTask, inReviewTask, inDoneTask].forEach((taskArr, idx) => {
if (taskArr?.length) {
appendToList(taskArr, cardType[idx], listType[idx]);
}
appendToList(taskArr, cardType[idx], listType[idx]);
});
}

Expand All @@ -43,9 +41,9 @@ function appendToList(data, cardContainerType, listType) {
cardContainer.ondrop = (event) => dropTo(event, cardContainerType);
cardContainer.ondragover = (event) => event.preventDefault();

document.getElementById(`total${cardContainerType}`).innerText = data?.length;
document.getElementById(`total${cardContainerType}`).innerText = data?.length || 0;

data.forEach(item => {
data?.forEach(item => {
const card = document.createElement('div');
card.className = 'card';
card.id = item.id;
Expand Down

0 comments on commit 8fdf99d

Please sign in to comment.