torarnehave1 / todoapp

0 stars 0 forks source link

Search & Filterbar Like the on in Github #7

Open torarnehave1 opened 5 months ago

torarnehave1 commented 5 months ago

Implementing Search and Filters for Tasks Add Search Bar Add a search input to allow searching for tasks:

Add Filter Options Add checkboxes to filter tasks on different criteria like status and date:

Filter Tasks on Search and Filters When search text or filters change, filter the tasks array:

const filterTasks = () => {

const query = searchTasks.value.toLowerCase();

const filters = getFilters(); // active filters

tasks.forEach(task => {

if (task.name.toLowerCase().includes(query) && 

    filters.includes(task.status) &&

    filters.includes(task.date)) {

     // show task

      } else {   

       // hide task

      }

})

}

Update on Input Change Add event listeners to call filterTasks() when search or filters change:

const debounce = (callback, delay) => { // debounce implementation }

searchTasks.addEventListener('input', () => { debounce(filterTasks, 500); });

torarnehave1 commented 5 months ago

Explain what components, elements files, csss Html js will be affected. Creat the full answer into 1 MD formated file so I can copy it and ask ChatGPT to make a flowchart for a totale overview of the new feature and how to implement it.

Here is a Markdown file explaining the components and files that would need to be added/updated to implement search and filtering for the tasks app:

Implementing Search and Filters - Overview New Components Search input

ID: searchTasks Filter checkboxes

ID: filter Updated Files index.html Add search input and filter checkboxes style.css Styling for new components main.js filterTasks() method Get search query and active filters Loop through tasks Show/hide based on search and filters Event listeners Call filterTasks() on input and change events Debouncing for search input Data Model Update tasks to include: status date Other filterable fields Summary New components:

Search input Filter checkboxes Updated files:

index.html - Add components style.css - Style components main.js - Filter logic, event listeners Data model - Add filterable fields This allows adding search and filter functionality similar to GitHub.

torarnehave1 commented 5 months ago

Implementing Search and Filters - Overview

New Components

Search input

Filter checkboxes

Updated Files

index.html

style.css

main.js

Data Model

Summary

This allows adding search and filter functionality similar to GitHub.

torarnehave1 commented 5 months ago

Navnløs