Skip to content

Commit

Permalink
Updates // "projects" code refactor (functions split and clean up)
Browse files Browse the repository at this point in the history
  • Loading branch information
purplehepatica committed Nov 13, 2023
1 parent edfee9b commit 96438dc
Show file tree
Hide file tree
Showing 24 changed files with 184 additions and 296 deletions.
5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/dictionaries/fedora.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 25 additions & 44 deletions app/projekty/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,21 @@
</head>

<body class="container">

<header>
<a href="../">
<hgroup class="center head-link">
<h1>Supreme Pomodoro</h1>
<h2><kbd>your badass productivity app</kbd></h2>
<p>your badass productivity app</p>
</hgroup>
</a>

<section>
<!--<section>
<small class="center"><mark>click on item to enter full-screen mode & hold on item to mark for deletion</mark></small>
</section>
</section>-->

<form id="add-project-form" role="group">
<!--<label>-->
<input name="value" placeholder="Dodaj nowy projekt..." />
<!--</label>-->
<button type="submit" class="primary">
<span class="material-icons">add</span>
</button>
Expand Down Expand Up @@ -62,13 +61,9 @@ <h2>Lista projektów</h2>

<dialog class="task-dialog" data-task-id="">
<article>
<div class="container">
<div class="dialog-top">

<div role="group">
<button aria-current="true" class="subtasks-tab secondary">Zadania</button>

<button class="thoughts-log-tab secondary">Dziennik</button>
</div>
<h3 class="project-title editable"></h3>



Expand All @@ -78,21 +73,26 @@ <h2>Lista projektów</h2>
</div>
<!--<small class="left"><mark>double click on text to edit & hold on item to mark for deletion</mark></small>-->



<h3 class="project-title editable"></h3>




<!--<blockquote class="description editable">
</blockquote>-->
<div class="add-subtasks-container flex row gap bottom">
<div class="task-tabs" role="group">
<button aria-current="true" class="tasks-tab secondary">Zadania</button>

<button class="journals-tab secondary">Dziennik</button>
</div>
<form id="add-project-task-form" role="group">
<input name="value" placeholder="Dodaj nowe zadanie..." />
<button type="submit">
<button type="submit" class="primary">
<span class="material-icons">
add
</span>
</button>
</form>
<form id="add-project-journal-form" class="hide" role="group">
<input name="value" placeholder="Dodaj nowe przemyślenia..." />
<button type="submit" class="primary">
<span class="material-icons">
add
</span>
Expand All @@ -108,19 +108,7 @@ <h3 class="project-title editable"></h3>
</div>-->
</div>

<!--<div class="add-log-container flex row gap bottom">
<input class="log-input-field" placeholder="Dodaj nowe przemyślenia..." />
<button class="add-log-button">
<span class="material-icons">
add
</span>
</button>
</div>-->




<div class="subtasks-tabs container flex" role="group">
<!-- <div class="subtasks-tabs container flex" role="group">
<button aria-current="true" class="active-subtasks-tab secondary">
Aktywne
Expand All @@ -130,21 +118,14 @@ <h3 class="project-title editable"></h3>
Odznaczone
</button>
</div>


<div class=" subtasks">
<div class="active-subtasks">

</div>
<!--<hr />-->
<div class="checked-subtasks hide">
</div>-->

</div>
<hr/>
<div class="tasks-container">
<hr/>
</div>

<div class="hide thoughts">
<hr/>
<div class="hide journals-container">

</div>

Expand Down
27 changes: 9 additions & 18 deletions app/projekty/js/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,21 @@ export const elements = {

addProjectForm: document.querySelector("#add-project-form"),
addProjectTaskForm: document.querySelector("#add-project-task-form"),
addProjectJournalForm: document.querySelector("#add-project-journal-form"),

deleteProjectsData: document.querySelector(".delete-projects-data"),

addSubtaskButton: document.querySelector(".add-subtask-button"),
editTasksButton: document.querySelector(".edit-tasks-button"),
subtaskInputField: document.querySelector(".subtask-input-field"),
projectsContainer: document.querySelector(".projects"),
mainSubtasksContainer: document.querySelector(".subtasks"),
activeSubtasksContainer: document.querySelector(".active-subtasks"),
checkedSubtasksContainer: document.querySelector(".checked-subtasks"),
removeSelectedTasksButton: document.querySelector(".remove-selected-tasks-button"),
removeCheckedSubtasksButton: document.querySelector(".remove-checked-subtasks-button"),

taskDialog: document.querySelector(".task-dialog"),

activeSubtasksTab: document.querySelector(".active-subtasks-tab"),
checkedSubtasksTab: document.querySelector(".checked-subtasks-tab"),
tasksContainer: document.querySelector(".tasks-container"),
journalsContainer: document.querySelector(".journals-container"),


taskTabs: document.querySelector(".task-tabs"),

subtasksTab: document.querySelector(".subtasks-tab"),
subtasksTabs: document.querySelector(".subtasks-tabs"),
thoughtsLogTab: document.querySelector(".thoughts-log-tab"),
thoughtsLogContainer: document.querySelector(".thoughts"),
tasksTab: document.querySelector(".tasks-tab"),
journalsTab: document.querySelector(".journals-tab"),

addLogButton: document.querySelector(".add-log-button"),
logInputField: document.querySelector(".log-input-field"),
addSubtaskContainer: document.querySelector(".add-subtasks-container"),
addLogContainer: document.querySelector(".add-log-container"),
}
103 changes: 4 additions & 99 deletions app/projekty/js/functionalities/addEventListeners.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import {elements} from "../elements.js";
import {saveDataToLocalStorage} from "./localStorage/saveDataToLocalStorage.js";
import {appData} from "../index.js";
import {validateProjectInputData} from "./addProject/validateProjectInputData.js";
import {createProjectEntryInAppData} from "./addProject/createProjectEntryInAppData.js";
import {addProjectTaskElement} from "./addProjectTask/addProjectTaskElement.js";
import {validateProjectTaskType} from "./validateProjectTaskType.js";
import {deleteProjectsDataListener} from "./eventListeners/deleteProjectsDataListener.js";
import {addProjectListener} from "./eventListeners/addProjectListener.js";
import {openAndListProjectInfoListener} from "./eventListeners/openAndListProjectInfoListener.js";
import {closeDialogListener} from "./eventListeners/closeDialogListener.js";
import {addProjectTaskListener} from "./eventListeners/addProjectTaskListener.js";
import {switchProjectTaskTabsListener} from "./eventListeners/switchProjectTaskTabsListener.js";
import {addProjectJournalListener} from "./eventListeners/addProjectJournalListener.js";

export const addEventListeners = () => {

Expand All @@ -18,97 +13,7 @@ export const addEventListeners = () => {
openAndListProjectInfoListener();
closeDialogListener();
addProjectTaskListener();

/*
elements.removeCheckedSubtasksButton.addEventListener("click", () => {
const projectID = elements.taskDialog.dataset.taskId;
const message = "Czy na pewno chcesz usunąć zaznaczone zadania?";
if (confirm(message)) {
appData.projects[projectID].subtasks.checked = [];
elements.checkedSubtasksContainer.innerHTML = "";
saveDataToLocalStorage();
}
})
elements.checkedSubtasksTab.addEventListener("click", (e) => {
validateProjectTaskType(e);
});
elements.activeSubtasksTab.addEventListener("click", (e) => {
validateProjectTaskType(e);
});
elements.mainSubtasksContainer.addEventListener("click", (e) => {
if (e.target.classList.contains("subtask-checkbox")) {
const content = e.target.closest(".subtask-container").querySelector(".subtask-content").textContent;
const projectID = e.target.closest("dialog").dataset.taskId;
const currentState = e.target.checked
? "active"
: "checked";
const oppositeState = e.target.checked
? "checked"
: "active";
const subtasks = [...appData.projects[projectID].subtasks[currentState]].filter(subtask => subtask !== content);
appData.projects[projectID].subtasks[currentState] = [...subtasks];
appData.projects[projectID].subtasks[oppositeState].push(content);
e.target.closest(".subtask-container").remove();
saveDataToLocalStorage();
}
});
const validateLogTab = (e) => {
if (!e.target.hasAttribute("aria-current")) {
elements.thoughtsLogTab.removeAttribute("aria-current");
elements.subtasksTab.removeAttribute("aria-current");
e.target.setAttribute("aria-current", "true");
elements.subtasksTabs.classList.toggle("hide");
elements.mainSubtasksContainer.classList.toggle("hide");
elements.addLogContainer.classList.toggle("hide");
elements.addSubtaskContainer.classList.toggle("hide");
elements.thoughtsLogContainer.classList.toggle("hide");
loadLogElements(e);
}
};
elements.thoughtsLogTab.addEventListener("click", (e) => {
validateLogTab(e);
});
elements.subtasksTab.addEventListener("click", (e) => {
validateLogTab(e);
});
elements.addLogButton.addEventListener("click", (e) => {
addLogElement(e);
});
elements.logInputField.addEventListener("keypress", (e) => {
if (e.key === "Enter") addLogElement(e)
}
)
*/
addProjectJournalListener();
switchProjectTaskTabsListener();

}
34 changes: 0 additions & 34 deletions app/projekty/js/functionalities/addJournalElement.js

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ export const createProjectEntryInAppData = (value) => {
appData.projects[projectID] = {
name: value,
maxTaskID: 0,
maxJournalID: 0,
tasks: {},
journal: {}
journals: {}
}

saveDataToLocalStorage();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {elements} from "../../elements.js";
import {appData} from "../../index.js";

export const addProjectJournalElement = (id) => {

const projectID = elements.taskDialog.dataset.projectId;
const { name, date} = appData.projects[projectID].journals[id];
console.log(name, date)
const element = document.createElement("blockquote");
element.textContent = name;

const quoteFooter = document.createElement("footer");
quoteFooter.innerHTML = `<cite>${date}</cite>`;

element.append(quoteFooter);


elements.journalsContainer.append(element);
}
Loading

0 comments on commit 96438dc

Please sign in to comment.