Skip to content

Commit

Permalink
Implement filter function
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusdeap committed Jan 4, 2022
1 parent 6d244f5 commit 3d4f11c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/assets/javascripts/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,22 @@ window.addEventListener("load", () => {
});
});
});

const filterStories = () => {
const searchTerm = document.getElementById("title_contains").value.toLowerCase().trim();
if (searchTerm.length == 0) {
$("#stories").sortable("enable");
} else {
$("#stories").sortable("disable");
}

document.querySelectorAll("#stories tr").forEach(function(element) {
const cl = element.classList
const storyTitle = element.querySelector("td:first-child").innerText.toLowerCase()
if (storyTitle.includes(searchTerm)) {
cl.remove("hidden")
} else {
cl.add("hidden")
}
})
};

0 comments on commit 3d4f11c

Please sign in to comment.