2023-08-11 13:14:58 +02:00
|
|
|
|
/*Your ‘todos’ are going to be objects that you’ll want to dynamically create,
|
|
|
|
|
which means either using factories or constructors/classes to generate them.*/
|
|
|
|
|
|
|
|
|
|
/* Brainstorm what kind of properties your todo-items are going to have. At a minimum they should have a title,
|
|
|
|
|
description, dueDate and priority. You might also want to include notes or even a checklist.*/
|
|
|
|
|
|
|
|
|
|
/*Your todo list should have projects or separate lists of todos.
|
|
|
|
|
When a user first opens the app, there should be some sort of ‘default’ project to which all of their todos are put.
|
|
|
|
|
Users should be able to create new projects and choose which project their todos go into.*/
|
|
|
|
|
|
|
|
|
|
/*You should separate your application logic (i.e. creating new todos, setting todos as complete, changing todo priority etc.)
|
|
|
|
|
from the DOM-related stuff, so keep all of those things in separate modules.*/
|
|
|
|
|
|
|
|
|
|
/*The look of the User Interface is up to you, but it should be able to do the following:
|
|
|
|
|
view all projects
|
|
|
|
|
view all todos in each project (probably just the title and duedate… perhaps changing color for different priorities)
|
|
|
|
|
expand a single todo to see/edit its details
|
|
|
|
|
delete a todo*/
|
|
|
|
|
|
|
|
|
|
const projectInput = document.querySelector(".show");
|
|
|
|
|
|
|
|
|
|
projectInput.addEventListener("click",()=>{
|
|
|
|
|
const form = document.querySelector(".form");
|
2023-08-16 14:01:21 +02:00
|
|
|
|
Display.toggleShow(form);
|
2023-08-11 13:14:58 +02:00
|
|
|
|
});
|
|
|
|
|
|
2023-08-16 14:01:21 +02:00
|
|
|
|
const add = document.getElementById("addP");
|
2023-08-11 13:14:58 +02:00
|
|
|
|
|
2023-08-16 14:01:21 +02:00
|
|
|
|
add.addEventListener("click", () =>{
|
2023-08-11 13:14:58 +02:00
|
|
|
|
const projectName = document.querySelector(".nameP");
|
|
|
|
|
const newProject = Project();
|
2023-08-16 14:01:21 +02:00
|
|
|
|
newProject.addName(projectName.value);
|
2023-08-11 13:14:58 +02:00
|
|
|
|
});
|
|
|
|
|
|
2023-08-16 14:01:21 +02:00
|
|
|
|
const Display = (() =>{
|
|
|
|
|
const toggleShow = (name) => {
|
|
|
|
|
if (name.style.display === "block") {
|
|
|
|
|
name.style.display = "none";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
name.style.display = "block";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const appendList = (node, array) => {
|
|
|
|
|
array.forEach(element => {
|
|
|
|
|
let child = node.appendChild(element);
|
|
|
|
|
return child;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
const delNode = (node)=> {
|
|
|
|
|
console.log("Remove!");
|
|
|
|
|
|
|
|
|
|
node.remove();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {toggleShow, appendList, delNode};
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
const Storage = (() =>{
|
|
|
|
|
const setItems = (name) => {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
const removeItems = () =>{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
const clearStorage = () =>{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {setItems, removeItems, clearStorage};
|
|
|
|
|
})();
|
|
|
|
|
|
2023-08-11 13:14:58 +02:00
|
|
|
|
const Project = (name) =>{
|
|
|
|
|
const getName = () => name;
|
|
|
|
|
|
|
|
|
|
const addName = (name) => {
|
2023-08-16 14:01:21 +02:00
|
|
|
|
const projectList = document.querySelector(".projectList");
|
|
|
|
|
const project = document.createElement("li");
|
|
|
|
|
|
|
|
|
|
const link = document.createElement("a");
|
|
|
|
|
link.setAttribute("href", "project.html");
|
|
|
|
|
link.innerText = `${name}`;
|
|
|
|
|
|
|
|
|
|
const btnDel = document.createElement("button");
|
|
|
|
|
btnDel.innerText = "-";
|
|
|
|
|
|
|
|
|
|
btnDel.addEventListener("click", ()=>{
|
|
|
|
|
Display.delNode(project);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let list = [link, btnDel];
|
|
|
|
|
Display.appendList(project,list);
|
2023-08-11 13:14:58 +02:00
|
|
|
|
projectList.appendChild(project);
|
2023-08-16 14:01:21 +02:00
|
|
|
|
|
|
|
|
|
console.log(pjctNames);
|
2023-08-11 13:14:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {getName, addName};
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-16 14:01:21 +02:00
|
|
|
|
const TodoList = (name) =>{
|
|
|
|
|
const getName = () => name;
|
|
|
|
|
const addList = () =>{
|
|
|
|
|
|
|
|
|
|
}
|
2023-08-11 13:14:58 +02:00
|
|
|
|
}
|
|
|
|
|
const TodoItems = (title, description, dueDate, priority) =>{
|
|
|
|
|
const getTitle = () => title;
|
|
|
|
|
const getDescription = () => description;
|
|
|
|
|
const getDueDate = () => dueDate;
|
|
|
|
|
const getPriority = () => priority;
|
|
|
|
|
|
|
|
|
|
return {getTitle, getDescription, getDueDate, getPriority};
|
|
|
|
|
|
|
|
|
|
}
|