mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2024-12-25 22:10:43 -05:00
style: formatting with prettier
This commit is contained in:
parent
b357ad8ecc
commit
7eb4f96f3a
3 changed files with 28 additions and 27 deletions
|
@ -2,7 +2,8 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"es2021": true
|
"es2021": true,
|
||||||
|
node: true
|
||||||
},
|
},
|
||||||
"extends": "eslint:recommended",
|
"extends": "eslint:recommended",
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { format, compareAsc } from "date-fns";
|
||||||
|
|
||||||
function createTodo(title, description, dueDate, pomodoros) {
|
function createTodo(title, description, dueDate, pomodoros) {
|
||||||
dueDate = dueDate.replaceAll('-', '/');
|
dueDate = dueDate.replaceAll('-', '/');
|
||||||
|
|
||||||
const newTodo = {
|
const newTodo = {
|
||||||
title: title,
|
title: title,
|
||||||
description: description,
|
description: description,
|
||||||
|
@ -25,7 +25,7 @@ function createProject(name) {
|
||||||
|
|
||||||
class todoHandler {
|
class todoHandler {
|
||||||
// Create default project during construction
|
// Create default project during construction
|
||||||
constructor(projects=null) {
|
constructor(projects = null) {
|
||||||
if (projects) {
|
if (projects) {
|
||||||
this.projects = projects;
|
this.projects = projects;
|
||||||
} else if (!this.projects) {
|
} else if (!this.projects) {
|
||||||
|
@ -38,24 +38,24 @@ class todoHandler {
|
||||||
|
|
||||||
getTodos() {
|
getTodos() {
|
||||||
return this.projects.map(item => item.todos);
|
return this.projects.map(item => item.todos);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTodosFromProject(project) {
|
getTodosFromProject(project) {
|
||||||
return this.projects.find((item) => item.name === project).todos;
|
return this.projects.find((item) => item.name === project).todos;
|
||||||
}
|
}
|
||||||
|
|
||||||
addTodo(project = 'default', title, description, dueDate, pomodoros) {
|
addTodo(project = 'default', title, description, dueDate, pomodoros) {
|
||||||
let index = this.projects.findIndex(x => x.name === project);
|
let index = this.projects.findIndex(x => x.name === project);
|
||||||
let _titleExists = this.titleExists(title, this.projects[index].todos);
|
let _titleExists = this.titleExists(title, this.projects[index].todos);
|
||||||
|
|
||||||
if (!_titleExists) {
|
if (!_titleExists) {
|
||||||
this.projects[index].todos.push(new createTodo(title, description, dueDate, pomodoros));
|
this.projects[index].todos.push(new createTodo(title, description, dueDate, pomodoros));
|
||||||
this.projects[index].todos.sort((a,b) => {
|
this.projects[index].todos.sort((a, b) => {
|
||||||
|
|
||||||
return compareAsc(new Date(a.dueDate), new Date(b.dueDate));
|
return compareAsc(new Date(a.dueDate), new Date(b.dueDate));
|
||||||
});
|
});
|
||||||
// console.log(this.projects[index]);
|
// console.log(this.projects[index]);
|
||||||
//(itemA, itemB) => {return itemA.dueDate - itemB.dueDate})
|
//(itemA, itemB) => {return itemA.dueDate - itemB.dueDate})
|
||||||
} else {
|
} else {
|
||||||
alert('unable to create duplicate note');
|
alert('unable to create duplicate note');
|
||||||
return
|
return
|
||||||
|
@ -68,7 +68,7 @@ class todoHandler {
|
||||||
let projectIndex = this.projects.findIndex(x => x.name === project);
|
let projectIndex = this.projects.findIndex(x => x.name === project);
|
||||||
let todo = this.projects[projectIndex].todos.find(t => t.title === title)
|
let todo = this.projects[projectIndex].todos.find(t => t.title === title)
|
||||||
|
|
||||||
if (todo){
|
if (todo) {
|
||||||
todo.completed = !todo.completed;
|
todo.completed = !todo.completed;
|
||||||
// if(description) todo.description = description;
|
// if(description) todo.description = description;
|
||||||
// if(dueDate) todo.dueDate = dueDate;
|
// if(dueDate) todo.dueDate = dueDate;
|
||||||
|
@ -79,9 +79,9 @@ class todoHandler {
|
||||||
deleteTodo(project, title) {
|
deleteTodo(project, title) {
|
||||||
let projectIndex = this.projects.findIndex(x => x.name === project);
|
let projectIndex = this.projects.findIndex(x => x.name === project);
|
||||||
let tempArr = this.projects[projectIndex].todos.filter(item => {
|
let tempArr = this.projects[projectIndex].todos.filter(item => {
|
||||||
if (item.title !== title){
|
if (item.title !== title) {
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
this.projects[projectIndex].todos = tempArr;
|
this.projects[projectIndex].todos = tempArr;
|
||||||
}
|
}
|
||||||
|
@ -98,24 +98,24 @@ class todoHandler {
|
||||||
}
|
}
|
||||||
alert(`Project ${name} already exists!`);
|
alert(`Project ${name} already exists!`);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getProjects () {
|
getProjects() {
|
||||||
return this.projects;
|
return this.projects;
|
||||||
}
|
}
|
||||||
|
|
||||||
delProject(name) {
|
delProject(name) {
|
||||||
let index = this.projects.findIndex(proj => proj.name === name);
|
let index = this.projects.findIndex(proj => proj.name === name);
|
||||||
let tempArr = this.projects.filter(item => {
|
let tempArr = this.projects.filter(item => {
|
||||||
if (item !== this.projects[index] || name === 'default' ){
|
if (item !== this.projects[index] || name === 'default') {
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
this.projects = tempArr;
|
this.projects = tempArr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return { getTodos, addTodo, editTodo, deleteTodo, addProject, getProjects, delProject }
|
// return { getTodos, addTodo, editTodo, deleteTodo, addProject, getProjects, delProject }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { todoHandler };
|
export { todoHandler };
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import {
|
import {
|
||||||
addTodo,
|
addTodo,
|
||||||
deleteTodo,
|
deleteTodo,
|
||||||
addProject,
|
addProject,
|
||||||
deleteProject,
|
deleteProject,
|
||||||
projectComponent,
|
projectComponent,
|
||||||
todoTableComponent,
|
todoTableComponent,
|
||||||
getTodoFromActiveProject,
|
getTodoFromActiveProject,
|
||||||
addTodoComponent,
|
addTodoComponent,
|
||||||
handleCompletedTodo
|
handleCompletedTodo
|
||||||
} from "./components/todoComponent";
|
} from "./components/todoComponent";
|
||||||
import { navbar } from "./components/navbar";
|
import { navbar } from "./components/navbar";
|
||||||
import { save, load } from "./components/storage";
|
import { save, load } from "./components/storage";
|
||||||
import './style.css';
|
import './style.css';
|
||||||
|
@ -22,7 +22,7 @@ todos = data ? new todoManager(JSON.parse(data)) : new todoManager();
|
||||||
let activeProject = 'default';
|
let activeProject = 'default';
|
||||||
|
|
||||||
function setActiveProject(value) {
|
function setActiveProject(value) {
|
||||||
activeProject = value;
|
activeProject = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getActiveProject() {
|
function getActiveProject() {
|
||||||
|
@ -47,9 +47,9 @@ function website() {
|
||||||
function updateDisplay() {
|
function updateDisplay() {
|
||||||
const div = document.querySelector('.container');
|
const div = document.querySelector('.container');
|
||||||
if (div) div.innerHTML = '';
|
if (div) div.innerHTML = '';
|
||||||
|
|
||||||
// ensure grabbing latest projects
|
// ensure grabbing latest projects
|
||||||
let projects = todos.getProjects();
|
let projects = todos.getProjects();
|
||||||
let currentActiveProject = activeProject;
|
let currentActiveProject = activeProject;
|
||||||
let todosToRender = todos.getTodosFromProject(currentActiveProject);
|
let todosToRender = todos.getTodosFromProject(currentActiveProject);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue