Commit 3c223e28 authored by ransome1's avatar ransome1
Browse files

Added basic print function

parent 9c9433a8
{
"name": "sleek",
"productName": "sleek",
"version": "1.1.0",
"version": "1.1.0-rc.2",
"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",
......
......@@ -2458,6 +2458,47 @@ body.compact #autoCompleteContainer h4 {
box-shadow: 0 0 0.25em 0.25em rgba(35, 102, 209, 0.2);
}
@media print {
@page {
margin: 0cm !important;
}
html,
body {
font-size: 9pt !important;
padding: 0 !important;
margin: 0 !important;
-webkit-print-color-adjust: exact !important;
}
nav ul,
header,
#btnFiltersResetFilters {
display: none !important;
}
.columns.is-mobile {
display: block !important;
}
.columns #todoTableWrapper {
overflow-x: visible !important;
overflow-y: visible !important;
}
#todoTable .cell:hover .tags, #todoTable .cell:focus .tags {
display: block !important;
}
nav #drawerContainer,
nav #drawerContainer section#filterDrawer {
width: 100% !important;
--resizeable-width: 100%!important;
--max-width: 100%!important;
--min-width: 100%!important;
float: left;
display: block !important;
}
}
/*! bulma.io v0.9.2 | MIT License | github.com/jgthms/bulma */
/* Bulma Utilities */
.pagination-previous,
......
This diff is collapsed.
......@@ -59,13 +59,13 @@ let
clusterCounter,
clusterSize = Math.ceil(window.innerHeight/30), // 35 being the pixel height of one todo in compact mode
clusterThreshold = 0,
stopBuilding = false,
//stopBuilding = false,
visibleRows = 0;
todoTableWrapper.addEventListener("scroll", function(event) {
if(visibleRows>=items.filtered.length) return false;
if(Math.floor(event.target.scrollHeight - event.target.scrollTop) <= event.target.clientHeight) {
stopBuilding = false;
//stopBuilding = false;
startBuilding(true);
}
});
......@@ -96,14 +96,13 @@ function configureTodoTableTemplate(append) {
todoTable.innerHTML = "";
visibleRows = 0;
clusterThreshold = 0;
stopBuilding = false;
//stopBuilding = false;
}
todoTableBodyRowTemplate.setAttribute("class", "todo");
todoTableBodyCellCheckboxTemplate.setAttribute("class", "cell checkbox");
todoTableBodyCellTextTemplate.setAttribute("class", "cell text");
todoTableBodyCellTextTemplate.setAttribute("tabindex", 0);
todoTableBodyCellTextTemplate.setAttribute("href", "#");
//todoTableBodyCellTextTemplate.setAttribute("title", translations.editTodo);
tableContainerCategoriesTemplate.setAttribute("class", "categories");
todoTableBodyCellDueDateTemplate.setAttribute("class", "cell itemDueDate");
todoTableBodyCellRecurrenceTemplate.setAttribute("class", "cell recurrence");
......@@ -167,7 +166,7 @@ function generateGroups(items) {
});
return Promise.resolve(items)
}
async function generateTable(groups, append) {
async function generateTable(groups, append, loadAll) {
try {
// configure stats
showResultStats();
......@@ -176,10 +175,10 @@ async function generateTable(groups, append) {
// reset cluster count for this run
clusterCounter = 0;
for (let group in groups) {
if(stopBuilding) {
stopBuilding = false;
break;
}
// if(stopBuilding) {
// stopBuilding = false;
// break;
// }
// create a divider row
let dividerRow;
// completed todos
......@@ -207,13 +206,13 @@ async function generateTable(groups, append) {
if(!append && !document.getElementById(userData.sortBy[0] + groups[group][0]) && dividerRow) tableContainerContent.appendChild(dividerRow);
for (let item in groups[group][1]) {
let todo = groups[group][1][item];
//
if(clusterCounter<clusterThreshold) {
//TODO: Explain this, maybe refactor
if(!loadAll && clusterCounter<clusterThreshold) {
clusterCounter++;
continue;
} else if((visibleRows===clusterSize+clusterThreshold) || visibleRows===items.filtered.length ) {
} else if(!loadAll && (visibleRows===clusterSize+clusterThreshold) || visibleRows===items.filtered.length ) {
clusterThreshold = visibleRows;
stopBuilding = true;
//stopBuilding = true;
break;
}
// if this todo is not a recurring one the rec value will be set to null
......
......@@ -212,7 +212,7 @@ const createWindow = async function() {
fileWatcher
.on("add", function() {
getContent(file).then(content => {
mainWindow.webContents.send("refresh", content)
mainWindow.webContents.send("refresh", [content])
}).catch(error => {
console.log(error);
});
......@@ -230,7 +230,7 @@ const createWindow = async function() {
// wait 10ms before rereading in case the file is being updated with a delay
setTimeout(function() {
getContent(file).then(content => {
mainWindow.webContents.send("refresh", content)
mainWindow.webContents.send("refresh", [content])
}).catch(error => {
console.log(error);
});
......@@ -413,6 +413,37 @@ const createWindow = async function() {
}
},
{ type: "separator" },
{
role: "print",
accelerator: "CmdOrCtrl+P",
label: "Print",
click: function() {
const options = {
silent: false,
printBackground: true,
color: true,
margin: {
marginType: "printableArea"
},
landscape: false,
pagesPerSheet: 1,
collate: false,
copies: 1,
header: "Header of the Page",
footer: "Footer of the Page"
}
getContent(userData.data.file).then(content => {
mainWindow.webContents.send("refresh", [content, false, true]);
mainWindow.webContents.print(options, (success, error) => {
if(!success) console.log(error);
console.log("Success: Print Initiated");
});
}).catch(error => {
console.log(error);
});
}
},
{ type: "separator" },
{
role: "close",
label: translations.close
......@@ -721,7 +752,7 @@ const createWindow = async function() {
setInterval(() => {
if(!mainWindow.isFocused()) {
getContent(userData.data.file).then(content => {
mainWindow.webContents.send("refresh", content)
mainWindow.webContents.send("refresh", [content])
}).catch(error => {
console.error(error);
});
......
......@@ -388,7 +388,7 @@ function registerKeyboardShortcuts() {
window.addEventListener("keyup", function(event) {
// switch files
const regex=/^[1-9]+$/;
if(event.key.match(regex) && !modalForm.classList.contains("is-active") && (document.activeElement.id!="todoTableSearch" && document.activeElement.id!="filterContextInput" && document.activeElement.id!="modalFormInput")) {
if(event.key.match(regex) && userData.files.length > 1 && !modalForm.classList.contains("is-active") && (document.activeElement.id!="todoTableSearch" && document.activeElement.id!="filterContextInput" && document.activeElement.id!="modalFormInput")) {
window.api.send("startFileWatcher", userData.files[event.key-1][1]);
}
// open settings
......@@ -706,7 +706,7 @@ function getBadgeCount() {
});
return count;
}
async function startBuilding(append) {
async function startBuilding(append, loadAll) {
try {
t0 = performance.now();
......@@ -719,7 +719,7 @@ async function startBuilding(append) {
userData = await getUserData();
await todos.generateTable(groups, append);
await todos.generateTable(groups, append, loadAll);
configureMainView();
......@@ -865,9 +865,9 @@ window.api.receive("triggerFunction", (name, args) => {
return Promise.reject(error);
}
});
window.api.receive("refresh", async function(content) {
todos.generateItems(content).then(function() {
startBuilding();
window.api.receive("refresh", async (args) => {
todos.generateItems(args[0]).then(function() {
startBuilding(args[1], args[2]);
}).catch(function(error) {
handleError(error);
});
......
@page {
margin: 0cm !important;
}
html,
body {
font-size: 9pt!important;
padding: 0!important;
margin: 0!important;
-webkit-print-color-adjust: exact !important;
}
nav ul,
header,
#btnFiltersResetFilters {
display: none!important;
}
.columns.is-mobile {
display: block!important;
}
.columns #todoTableWrapper {
overflow-x: visible!important;
overflow-y: visible!important;
}
#todoTable .cell:hover .tags, #todoTable .cell:focus .tags {
display: block!important;
}
nav #drawerContainer,
nav #drawerContainer section#filterDrawer {
width: 100%!important;
--resizeable-width: 100%!important;
--max-width: 100%!important;
--min-width: 100%!important;
float: left;
display: block!important;
}
......@@ -427,4 +427,7 @@ code, pre {
@import "todoTable.scss";
@import "toggle.scss";
@import "datepicker.scss";
@media print {
@import "print.scss";
}
@import "../../node_modules/bulma/bulma.sass";
......@@ -5,3 +5,4 @@ x 2021-06-18 2021-06-18 test todo
x 2021-06-19 2021-06-19 test todo
x 2021-07-05 2021-07-05 test todo
x 2021-07-15 2021-07-15 test todo
x 2021-07-17 2021-07-17 test todo
{"theme":"light","width":1538,"height":863,"horizontal":2450,"vertical":164,"maximizeWindow":false,"notifications":true,"useTextarea":false,"compactView":false,"matomoEvents":false,"drawerWidth":"500","showDueIsPast":true,"showDueIsFuture":true,"showDueIsToday":true,"showHidden":false,"showCompleted":true,"sortCompletedLast":false,"sortBy":["priority","dueString","contexts","projects"],"zoom":"100","tray":false,"showEmptyFilters":true,"dismissedNotifications":[-1319247018],"dismissedMessages":[],"hideFilterCategories":[],"language":"en","uid":"TESTING","path":"test/preferences_empty/todo.txt","files":[[1,"test/preferences_empty/todo.txt"]],"file":"test/preferences_empty/todo.txt","filterDrawer":false,"selectedFilters":[],"viewDrawer":false,"sortByLevel":["priority","dueString","contexts","projects"],"deferredTodos":true}
\ No newline at end of file
{"theme":"light","width":1538,"height":863,"horizontal":2450,"vertical":280,"maximizeWindow":false,"notifications":true,"useTextarea":false,"compactView":false,"matomoEvents":false,"drawerWidth":"500","showDueIsPast":true,"showDueIsFuture":true,"showDueIsToday":true,"showHidden":false,"showCompleted":true,"sortCompletedLast":false,"sortBy":["priority","dueString","contexts","projects"],"zoom":"100","tray":false,"showEmptyFilters":true,"dismissedNotifications":[-1319247018],"dismissedMessages":[],"hideFilterCategories":[],"language":"en","uid":"TESTING","path":"test/preferences_empty/todo.txt","files":[[1,"test/preferences_empty/todo.txt"]],"file":"test/preferences_empty/todo.txt","filterDrawer":false,"selectedFilters":[],"viewDrawer":false,"sortByLevel":["priority","dueString","contexts","projects"],"deferredTodos":true,"fileTabs":true}
\ No newline at end of file
{"theme":"light","width":1538,"height":863,"horizontal":2181,"vertical":577,"maximizeWindow":false,"notifications":true,"useTextarea":false,"compactView":false,"matomoEvents":false,"drawerWidth":"500","showDueIsPast":true,"showDueIsFuture":true,"showDueIsToday":true,"showHidden":false,"showCompleted":true,"sortCompletedLast":false,"sortBy":["priority","dueString","contexts","projects"],"zoom":"100","tray":false,"showEmptyFilters":true,"dismissedNotifications":[-1319247018],"dismissedMessages":[],"hideFilterCategories":[],"language":"en","uid":"TESTING","path":"test/preferences_existent/todo.txt","files":[[1,"test/preferences_existent/todo.txt"]],"file":"test/preferences_existent/todo.txt","filterDrawer":false,"selectedFilters":[],"viewDrawer":false,"sortByLevel":["priority","dueString","contexts","projects"],"deferredTodos":true}
\ No newline at end of file
{"theme":"light","width":1538,"height":863,"horizontal":2181,"vertical":577,"maximizeWindow":false,"notifications":true,"useTextarea":false,"compactView":false,"matomoEvents":false,"drawerWidth":"500","showDueIsPast":true,"showDueIsFuture":true,"showDueIsToday":true,"showHidden":false,"showCompleted":true,"sortCompletedLast":false,"sortBy":["priority","dueString","contexts","projects"],"zoom":"100","tray":false,"showEmptyFilters":true,"dismissedNotifications":[-1319247018],"dismissedMessages":[],"hideFilterCategories":[],"language":"en","uid":"TESTING","path":"test/preferences_existent/todo.txt","files":[[1,"test/preferences_existent/todo.txt"]],"file":"test/preferences_existent/todo.txt","filterDrawer":false,"selectedFilters":[],"viewDrawer":false,"sortByLevel":["priority","dueString","contexts","projects"],"deferredTodos":true,"fileTabs":true}
\ No newline at end of file
{"theme":"light","width":1100,"height":700,"horizontal":129,"vertical":740,"maximizeWindow":false,"notifications":true,"useTextarea":false,"compactView":false,"matomoEvents":false,"drawerWidth":"500","showDueIsPast":true,"showDueIsFuture":true,"showDueIsToday":true,"showHidden":false,"showCompleted":true,"sortCompletedLast":false,"sortBy":["priority","dueString","contexts","projects"],"zoom":"100","tray":false,"showEmptyFilters":true,"hideFilterCategories":[],"language":"en","dismissedNotifications":[],"dismissedMessages":[],"sortByLevel":["priority","dueString","contexts","projects"],"deferredTodos":true}
\ No newline at end of file
{"theme":"light","width":1100,"height":700,"horizontal":129,"vertical":740,"maximizeWindow":false,"notifications":true,"useTextarea":false,"compactView":false,"matomoEvents":false,"drawerWidth":"500","showDueIsPast":true,"showDueIsFuture":true,"showDueIsToday":true,"showHidden":false,"showCompleted":true,"sortCompletedLast":false,"sortBy":["priority","dueString","contexts","projects"],"zoom":"100","tray":false,"showEmptyFilters":true,"hideFilterCategories":[],"language":"en","dismissedNotifications":[],"dismissedMessages":[],"sortByLevel":["priority","dueString","contexts","projects"],"deferredTodos":true,"fileTabs":true}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment