Skip to content

Commit

Permalink
Added test cases, added confirmation modal, cleaned up the code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
ransome1 committed Jun 18, 2021
1 parent 22b2095 commit 9c127f5
Show file tree
Hide file tree
Showing 33 changed files with 536 additions and 305 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ A prioritized backlog of new features and known issues can be found <a href="htt
* <a href="https://github.com/ransome1/sleek/wiki/Keyboard-shortcuts">Keyboard shortcuts following todotxt.net</a>
* Tabindex available
* <a href="https://github.com/ransome1/sleek/wiki/Hidden-todos">A todo can be hidden but its attributes will be available in the filter drawer and autocomplete function</a>
* Alarms will be shown when a todo is due tomorrow or today
* Due dates trigger alarms and appear as badges in sleeks icon
* Dark and light mode can be toggled
* A compact view is available
* Completed todos can be bulk archived to a separate done.txt ([name of todo file]_done.txt) file
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sleek",
"productName": "sleek",
"version": "1.0.6",
"version": "1.0.6-1",
"description": "Todo app based on todo.txt for Linux, Windows and MacOS, free and open-source",
"synopsis": "Todo app based on todo.txt for Linux, Windows and MacOS, free and open-source",
"category": "ProjectManagement",
Expand Down Expand Up @@ -47,7 +47,6 @@
"deb",
"freebsd",
"rpm",
"pacman",
"AppImage"
]
},
Expand Down Expand Up @@ -104,8 +103,8 @@
"build:appimage": "electron-builder -l AppImage --publish never",
"pack": "electron-builder --dir",
"lint": "eslint --ext .js, src --ext .mjs, src",
"test": "mocha --timeout 5000",
"test1": "mocha ./test/settings.js --timeout 5000",
"test": "mocha --timeout 10000",
"test1": "mocha ./test/createTodos.js --timeout 10000",
"sass": "sass -w src/scss/:src/css/",
"start": "yarn sass & electron ."
},
Expand Down
22 changes: 17 additions & 5 deletions src/css/style.css

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

2 changes: 1 addition & 1 deletion src/css/style.css.map

Large diffs are not rendered by default.

32 changes: 22 additions & 10 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<ul>
<li class="logo">sleek</li>
<li id="navBtnAddTodo"><a href="#" tabindex="0"><i class="fas fa-plus"></i></a></li>
<li id="navBtnFilter"><a href="#" tabindex="0"><i class="fas fa-filter"></i></a></li>
<li id="navBtnView"><a href="#" tabindex="0"><i class="fas fa-sliders-h"></i></a></li>
<li id="navBtnFilter" class="drawer" data-drawer="filterDrawer"><a href="#" tabindex="0"><i class="fas fa-filter"></i></a></li>
<li id="navBtnView" class="drawer" data-drawer="viewDrawer"><a href="#" tabindex="0"><i class="fas fa-sliders-h"></i></a></li>
<li id="btnOpenTodoFile"><a href="#" tabindex="-1"><i class="fas fa-folder-open"></i></a></li>
<li id="btnTheme"><a href="#" tabindex="-1"><i class="fas fa-adjust"></i></a></li>
</ul>
Expand Down Expand Up @@ -304,11 +304,7 @@ <h1 id="noResultContainerHeadline" class="title is-1"></h1>
</div>
<div id="recurrencePicker" class="field">
<div class="control has-icons-left">
<<<<<<< HEAD
<input id="recurrencePickerInput" class="input" tabindex="0" readonly>
=======
<input id="recurrencePickerInput" class="input" readonly tabindex="-1">
>>>>>>> develop
<a href="#" class="icon is-left" tabindex="-1">
<i class="fas fa-redo"></i>
</a>
Expand Down Expand Up @@ -691,11 +687,11 @@ <h3 class="title is-3" id="helpTabRecurrencesTitle1"></h3>
</div>
</div>

<div id="todoContext" class="dropdown-menu" role="menu">
<div id="todoContext" class="dropdown-menu" role="menu" tabindex="0">
<div class="dropdown-content">
<a id="todoContextUseAsTemplate" class="dropdown-item"></a>
<a id="todoContextEdit" href="#" class="dropdown-item"></a>
<a id="todoContextDelete" class="dropdown-item"></a>
<a id="todoContextUseAsTemplate" class="dropdown-item" tabindex="0"></a>
<a id="todoContextEdit" href="#" class="dropdown-item" tabindex="0"></a>
<a id="todoContextDelete" class="dropdown-item" tabindex="0"></a>
</div>
</div>

Expand Down Expand Up @@ -730,7 +726,21 @@ <h3 class="title is-3" id="helpTabRecurrencesTitle1"></h3>
</div>
</div>

<div id="modalPrompt" class="modal">
<div class="modal-background"></div>
<div class="modal-content">
<div class="card">
<div id="modalPromptContent" class="card-content"></div>
<footer class="card-footer">
<a href="#" id="modalPromptConfirm" class="card-footer-item" tabindex="0">Confirm</a>
<a href="#" id="modalPromptCancel" class="card-footer-item" tabindex="0">Cancel</a>
</footer>
</div>
</div>
</div>

<section id="messages">

<article class="message fixed" data="logging">
<div class="message-header">
<p><span id="messageLoggingTitle"></span></p>
Expand All @@ -741,6 +751,7 @@ <h3 class="title is-3" id="helpTabRecurrencesTitle1"></h3>
<p><button id="btnMessageLogging" class="button" tabindex="0"><i class="fas fa-cog"></i>&nbsp;<span id="messageLoggingButton"></span></button></p>
</div>
</article>

<article class="message fixed" data="share">
<div class="message-header">
<p><span id="messageShareTitle"></span></p>
Expand All @@ -755,6 +766,7 @@ <h3 class="title is-3" id="helpTabRecurrencesTitle1"></h3>
</p>
</div>
</article>

<article id="errorContainer" class="notification is-danger" data="error" style="position: relative">
<button id="errorContainerClose" class="delete" aria-label="delete" data-message="error"></button>
<p id="errorMessage"></p>
Expand Down
45 changes: 23 additions & 22 deletions src/js/content.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict";
import { modal, userData, appData, setUserData, translations, handleError, setTheme } from "../render.js";
import { modal, userData, appData, setUserData, translations, handleError, setTheme, getConfirmation } from "../render.js";
import { _paq } from "./matomo.mjs";
import { createModalJail } from "../configs/modal.config.mjs";

Expand All @@ -20,7 +20,6 @@ const helpTabContextsProjectsBody = document.getElementById("helpTabContextsProj
const helpTabContextsProjectsTitle = document.getElementById("helpTabContextsProjectsTitle");
const helpTabDatesBody1 = document.getElementById("helpTabDatesBody1");
const helpTabDatesBody2 = document.getElementById("helpTabDatesBody2");

const helpTabRecurrencesBody1 = document.getElementById("helpTabRecurrencesBody1");
const helpTabDatesTitle1 = document.getElementById("helpTabDatesTitle1");
const helpTabDatesTitle2 = document.getElementById("helpTabDatesTitle2");
Expand Down Expand Up @@ -86,19 +85,14 @@ helpTab2Title.innerHTML = translations.priorities;
helpTab3Title.innerHTML = translations.helpTab3Title;
helpTab4Title.innerHTML = translations.helpTab4Title;
helpTab5Title.innerHTML = translations.helpTab5Title;

helpTabContextsProjectsBody.innerHTML = translations.helpTabContextsProjectsBody;
helpTabContextsProjectsTitle.innerHTML = translations.helpTabContextsProjectsTitle;
helpTabDatesBody1.innerHTML = translations.helpTabDatesBody1;
helpTabDatesBody2.innerHTML = translations.helpTabDatesBody2;

helpTabRecurrencesBody1.innerHTML = translations.helpTabRecurrencesBody1;
helpTabDatesTitle1.innerHTML = translations.helpTabDatesTitle1;
helpTabDatesTitle2.innerHTML = translations.helpTabDatesTitle2;

helpTabRecurrencesTitle1.innerHTML = translations.helpTabRecurrencesTitle1;


helpTabKeyboardTitle.innerHTML = translations.shortcuts;
helpTabKeyboardTR10TD1.innerHTML = translations.helpTabKeyboardTR10TD1;
helpTabKeyboardTR1TD1.innerHTML = translations.addTodo;
Expand Down Expand Up @@ -154,16 +148,12 @@ contentTabs.forEach(tab => tab.addEventListener("click", function() {
// trigger matomo event
if(userData.matomoEvents) _paq.push(["trackEvent", "Content", "Click on " + this.firstElementChild.innerHTML, this.classList[0]]);
}));
settingsLanguage.onchange = function() {
userData.language = this.value;
window.api.send("userData", ["language", userData.language]);
window.api.send("changeLanguage", this.value);
// trigger matomo event
if(userData.matomoEvents) _paq.push(["trackEvent", "Settings", "Language changed to: " + this.value]);

settingsLanguage.onchange = function(event) {
getConfirmation(setLanguage, translations.restartPrompt, this.value);
}
toggleNotifications.onclick = function() {
//notifications = this.checked;
setUserData('notifications', this.checked);
setUserData("notifications", this.checked);
// trigger matomo event
if(userData.matomoEvents) _paq.push(["trackEvent", "Setting", "Click on Notifications", this.checked])
}
Expand All @@ -172,17 +162,28 @@ toggleDarkmode.onclick = function() {
// trigger matomo event
if(userData.matomoEvents) _paq.push(["trackEvent", "Setting", "Click on Dark mode", this.checked])
}
toggleTray.onclick = function() {
setUserData("tray", this.checked);
// trigger matomo event
if(userData.matomoEvents) _paq.push(["trackEvent", "Setting", "Click on Tray", this.checked])
// restart
window.api.send("restart");
toggleTray.onclick = function(event) {
event.preventDefault();
getConfirmation(setTray, translations.restartPrompt, this.checked);
}

toggleNotifications.checked = userData.notifications;


function setTray(setting) {
setUserData("tray", setting);
// trigger matomo event
if(userData.matomoEvents) _paq.push(["trackEvent", "Settings", "Tray changed to: " + setting]);
window.api.send("restart");
return Promise.resolve("Info: Tray changed to: " + setting);
}
function setLanguage(language) {
if(appData.environment==="testing") return false;
userData.language = language;
window.api.send("userData", ["language", userData.language]);
window.api.send("changeLanguage", language);
// trigger matomo event
if(userData.matomoEvents) _paq.push(["trackEvent", "Settings", "Language changed to: " + language]);
}
function showTab(tab) {
contentTabsCards.forEach(function(el) {
el.classList.remove("is-active");
Expand Down
91 changes: 30 additions & 61 deletions src/js/drawer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ import { setUserData, userData, handleError } from "../render.js";
import { _paq } from "./matomo.mjs";
import { getHandleElement, startDragging } from "./drawer_handle.mjs";

const viewDrawer = document.getElementById("viewDrawer");
const filterDrawer = document.getElementById("filterDrawer");
const drawerContainer = document.getElementById("drawerContainer");
const todoTable = document.getElementById("todoTable");
const todoTableSearchContainer = document.getElementById("todoTableSearchContainer");
const navBtnFilter = document.getElementById("navBtnFilter");
const navBtnView = document.getElementById("navBtnView");
const drawers = document.querySelectorAll(".drawer");
const drawers = document.querySelectorAll("nav ul li.drawer");

document.getElementById("drawerClose").onclick = function() {
showDrawer(false).then(function(result) {
showDrawer(null, null, true).then(function(result) {
console.log(result);
}).catch(function(error) {
handleError(error);
Expand Down Expand Up @@ -41,9 +39,7 @@ document.getElementById("viewDrawer").addEventListener ("keydown", function () {
});
getHandleElement.addEventListener("mousedown", startDragging);
navBtnFilter.onclick = function() {
let toggle = true;
if(document.getElementById("drawerContainer").classList.contains("is-active")) toggle = false;
showDrawer(toggle, "navBtnFilter", "filterDrawer").then(function(result) {
showDrawer(this, this.getAttribute("data-drawer")).then(function(result) {
console.log(result);
}).catch(function(error) {
handleError(error);
Expand All @@ -52,73 +48,46 @@ navBtnFilter.onclick = function() {
if(userData.matomoEvents) _paq.push(["trackEvent", "Menu", "Click on filter"]);
}
navBtnView.onclick = function() {
let toggle = true;
if(document.getElementById("drawerContainer").classList.contains("is-active")) toggle = false;
showDrawer(toggle, this.id, viewDrawer.id).then(function(result) {
showDrawer(this, this.getAttribute("data-drawer")).then(function(result) {
console.log(result);
}).catch(function(error) {
handleError(error);
});
// trigger matomo event
if(userData.matomoEvents) _paq.push(["trackEvent", "Menu", "Click on view"]);
}
// open filter drawer if it has been persisted
showDrawer(userData.filterDrawer, "navBtnFilter", "filterDrawer").then(function(result) {
console.log(result);
}).catch(function(error) {
handleError(error);
});
export function showDrawer(variable, buttonId, drawerId) {
try {

if(!variable && !buttonId && !drawerId) {
export function showDrawer(button, drawer, close) {
try {
// close drawers and the container and persist it
if(close) {
drawerContainer.classList.remove("is-active");
filterDrawer.classList.remove("is-active");
viewDrawer.classList.remove("is-active");
navBtnFilter.classList.remove("is-highlighted");
navBtnView.classList.remove("is-highlighted");
setUserData("filterDrawer", false);
drawers.forEach((item) => {
item.classList.remove("is-highlighted");
document.getElementById(item.getAttribute("data-drawer")).classList.remove("is-active");
setUserData(item.getAttribute("data-drawer"), false);
});
return Promise.resolve("Success: Drawer closed");
}
switch (drawerId) {
case "viewDrawer":
// highlight persisted selection in dropdown
Array.from(document.getElementById("viewSelectSortBy").options).forEach(function(item) {
if(item.value===userData.sortBy) item.selected = true
});
break;
}
buttonId = document.getElementById(buttonId);
drawerId = document.getElementById(drawerId);
// always hide the drawer container first
drawerContainer.classList.remove("is-active");
// next show or hide the single drawers
switch(variable) {
case true:
buttonId.classList.add("is-highlighted");
drawerId.classList.add("is-active");
drawerContainer.classList.add("is-active");
break;
case false:
drawers.forEach(function(drawer) {
drawer.classList.remove("is-active");
});
buttonId.classList.remove("is-highlighted");
drawerContainer.classList.remove("is-active");
break;
}
setUserData(drawerId.id, variable);
// persist filter drawer state
if(drawerId && drawerId.classList.contains("is-active")) {
// if the drawer is open the table needs a fixed width to overlap the viewport
todoTable.style.minWidth = "45em";
todoTableSearchContainer.style.minWidth = "45em";
// close open drawers, open the new one and persist it
drawer = document.getElementById(drawer);
if(drawer.classList.contains("is-active")) {
drawerContainer.classList.remove("is-active");
drawer.classList.remove("is-active");
button.classList.remove("is-highlighted");
setUserData(drawer.id, false);
return Promise.resolve("Success: Drawer closed");
} else {
// undo what has been done
todoTable.style.minWidth = "auto";
todoTableSearchContainer.style.minWidth = "auto";
drawerContainer.classList.add("is-active");
drawers.forEach((item) => {
item.classList.remove("is-highlighted");
document.getElementById(item.getAttribute("data-drawer")).classList.remove("is-active");
});
drawer.classList.add("is-active");
button.classList.add("is-highlighted");
setUserData(drawer.id, true);
return Promise.resolve("Success: Drawer opened");
}
return Promise.resolve("Success: Drawer toggled");
} catch(error) {
error.functionName = showDrawer.name;
return Promise.reject(error);
Expand Down
Loading

0 comments on commit 9c127f5

Please sign in to comment.