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

Added basic print function

parent 9c9433a8
{ {
"name": "sleek", "name": "sleek",
"productName": "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", "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", "synopsis": "Todo app based on todo.txt for Linux, Windows and MacOS, free and open-source",
"category": "ProjectManagement", "category": "ProjectManagement",
......
...@@ -2458,6 +2458,47 @@ body.compact #autoCompleteContainer h4 { ...@@ -2458,6 +2458,47 @@ body.compact #autoCompleteContainer h4 {
box-shadow: 0 0 0.25em 0.25em rgba(35, 102, 209, 0.2); 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.io v0.9.2 | MIT License | github.com/jgthms/bulma */
/* Bulma Utilities */ /* Bulma Utilities */
.pagination-previous, .pagination-previous,
......
This diff is collapsed.
...@@ -59,13 +59,13 @@ let ...@@ -59,13 +59,13 @@ let
clusterCounter, clusterCounter,
clusterSize = Math.ceil(window.innerHeight/30), // 35 being the pixel height of one todo in compact mode clusterSize = Math.ceil(window.innerHeight/30), // 35 being the pixel height of one todo in compact mode
clusterThreshold = 0, clusterThreshold = 0,
stopBuilding = false, //stopBuilding = false,
visibleRows = 0; visibleRows = 0;
todoTableWrapper.addEventListener("scroll", function(event) { todoTableWrapper.addEventListener("scroll", function(event) {
if(visibleRows>=items.filtered.length) return false; if(visibleRows>=items.filtered.length) return false;
if(Math.floor(event.target.scrollHeight - event.target.scrollTop) <= event.target.clientHeight) { if(Math.floor(event.target.scrollHeight - event.target.scrollTop) <= event.target.clientHeight) {
stopBuilding = false; //stopBuilding = false;
startBuilding(true); startBuilding(true);
} }
}); });
...@@ -96,14 +96,13 @@ function configureTodoTableTemplate(append) { ...@@ -96,14 +96,13 @@ function configureTodoTableTemplate(append) {
todoTable.innerHTML = ""; todoTable.innerHTML = "";
visibleRows = 0; visibleRows = 0;
clusterThreshold = 0; clusterThreshold = 0;
stopBuilding = false; //stopBuilding = false;
} }
todoTableBodyRowTemplate.setAttribute("class", "todo"); todoTableBodyRowTemplate.setAttribute("class", "todo");
todoTableBodyCellCheckboxTemplate.setAttribute("class", "cell checkbox"); todoTableBodyCellCheckboxTemplate.setAttribute("class", "cell checkbox");
todoTableBodyCellTextTemplate.setAttribute("class", "cell text"); todoTableBodyCellTextTemplate.setAttribute("class", "cell text");
todoTableBodyCellTextTemplate.setAttribute("tabindex", 0); todoTableBodyCellTextTemplate.setAttribute("tabindex", 0);
todoTableBodyCellTextTemplate.setAttribute("href", "#"); todoTableBodyCellTextTemplate.setAttribute("href", "#");
//todoTableBodyCellTextTemplate.setAttribute("title", translations.editTodo);
tableContainerCategoriesTemplate.setAttribute("class", "categories"); tableContainerCategoriesTemplate.setAttribute("class", "categories");
todoTableBodyCellDueDateTemplate.setAttribute("class", "cell itemDueDate"); todoTableBodyCellDueDateTemplate.setAttribute("class", "cell itemDueDate");
todoTableBodyCellRecurrenceTemplate.setAttribute("class", "cell recurrence"); todoTableBodyCellRecurrenceTemplate.setAttribute("class", "cell recurrence");
...@@ -167,7 +166,7 @@ function generateGroups(items) { ...@@ -167,7 +166,7 @@ function generateGroups(items) {
}); });
return Promise.resolve(items) return Promise.resolve(items)
} }
async function generateTable(groups, append) { async function generateTable(groups, append, loadAll) {
try { try {
// configure stats // configure stats
showResultStats(); showResultStats();
...@@ -176,10 +175,10 @@ async function generateTable(groups, append) { ...@@ -176,10 +175,10 @@ async function generateTable(groups, append) {
// reset cluster count for this run // reset cluster count for this run
clusterCounter = 0; clusterCounter = 0;
for (let group in groups) { for (let group in groups) {
if(stopBuilding) { // if(stopBuilding) {
stopBuilding = false; // stopBuilding = false;
break; // break;
} // }
// create a divider row // create a divider row
let dividerRow; let dividerRow;
// completed todos // completed todos
...@@ -207,13 +206,13 @@ async function generateTable(groups, append) { ...@@ -207,13 +206,13 @@ async function generateTable(groups, append) {
if(!append && !document.getElementById(userData.sortBy[0] + groups[group][0]) && dividerRow) tableContainerContent.appendChild(dividerRow); if(!append && !document.getElementById(userData.sortBy[0] + groups[group][0]) && dividerRow) tableContainerContent.appendChild(dividerRow);
for (let item in groups[group][1]) { for (let item in groups[group][1]) {
let todo = groups[group][1][item]; let todo = groups[group][1][item];
// //TODO: Explain this, maybe refactor
if(clusterCounter<clusterThreshold) { if(!loadAll && clusterCounter<clusterThreshold) {
clusterCounter++; clusterCounter++;
continue; continue;
} else if((visibleRows===clusterSize+clusterThreshold) || visibleRows===items.filtered.length ) { } else if(!loadAll && (visibleRows===clusterSize+clusterThreshold) || visibleRows===items.filtered.length ) {
clusterThreshold = visibleRows; clusterThreshold = visibleRows;
stopBuilding = true; //stopBuilding = true;
break; break;
} }
// if this todo is not a recurring one the rec value will be set to null // if this todo is not a recurring one the rec value will be set to null
......
...@@ -212,7 +212,7 @@ const createWindow = async function() { ...@@ -212,7 +212,7 @@ const createWindow = async function() {
fileWatcher fileWatcher
.on("add", function() { .on("add", function() {
getContent(file).then(content => { getContent(file).then(content => {
mainWindow.webContents.send("refresh", content) mainWindow.webContents.send("refresh", [content])
}).catch(error => { }).catch(error => {
console.log(error); console.log(error);
}); });
...@@ -230,7 +230,7 @@ const createWindow = async function() { ...@@ -230,7 +230,7 @@ const createWindow = async function() {
// wait 10ms before rereading in case the file is being updated with a delay // wait 10ms before rereading in case the file is being updated with a delay
setTimeout(function() { setTimeout(function() {
getContent(file).then(content => { getContent(file).then(content => {
mainWindow.webContents.send("refresh", content) mainWindow.webContents.send("refresh", [content])
}).catch(error => { }).catch(error => {
console.log(error); console.log(error);
}); });
...@@ -413,6 +413,37 @@ const createWindow = async function() { ...@@ -413,6 +413,37 @@ const createWindow = async function() {
} }
}, },
{ type: "separator" }, { 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", role: "close",
label: translations.close label: translations.close
...@@ -721,7 +752,7 @@ const createWindow = async function() { ...@@ -721,7 +752,7 @@ const createWindow = async function() {
setInterval(() => { setInterval(() => {
if(!mainWindow.isFocused()) { if(!mainWindow.isFocused()) {
getContent(userData.data.file).then(content => { getContent(userData.data.file).then(content => {
mainWindow.webContents.send("refresh", content) mainWindow.webContents.send("refresh", [content])
}).catch(error => { }).catch(error => {
console.error(error); console.error(error);
}); });
......
...@@ -388,7 +388,7 @@ function registerKeyboardShortcuts() { ...@@ -388,7 +388,7 @@ function registerKeyboardShortcuts() {
window.addEventListener("keyup", function(event) { window.addEventListener("keyup", function(event) {
// switch files // switch files
const regex=/^[1-9]+$/; 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]); window.api.send("startFileWatcher", userData.files[event.key-1][1]);
} }
// open settings // open settings
...@@ -706,7 +706,7 @@ function getBadgeCount() { ...@@ -706,7 +706,7 @@ function getBadgeCount() {
}); });
return count; return count;
} }
async function startBuilding(append) { async function startBuilding(append, loadAll) {
try { try {
t0 = performance.now(); t0 = performance.now();
...@@ -719,7 +719,7 @@ async function startBuilding(append) { ...@@ -719,7 +719,7 @@ async function startBuilding(append) {
userData = await getUserData(); userData = await getUserData();
await todos.generateTable(groups, append); await todos.generateTable(groups, append, loadAll);
configureMainView(); configureMainView();
...@@ -865,9 +865,9 @@ window.api.receive("triggerFunction", (name, args) => { ...@@ -865,9 +865,9 @@ window.api.receive("triggerFunction", (name, args) => {
return Promise.reject(error); return Promise.reject(error);
} }
}); });
window.api.receive("refresh", async function(content) { window.api.receive("refresh", async (args) => {
todos.generateItems(content).then(function() { todos.generateItems(args[0]).then(function() {
startBuilding(); startBuilding(args[1], args[2]);
}).catch(function(error) { }).catch(function(error) {
handleError(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 { ...@@ -427,4 +427,7 @@ code, pre {
@import "todoTable.scss"; @import "todoTable.scss";
@import "toggle.scss"; @import "toggle.scss";
@import "datepicker.scss"; @import "datepicker.scss";
@media print {
@import "print.scss";
}
@import "../../node_modules/bulma/bulma.sass"; @import "../../node_modules/bulma/bulma.sass";
...@@ -5,3 +5,4 @@ x 2021-06-18 2021-06-18 test todo ...@@ -5,3 +5,4 @@ x 2021-06-18 2021-06-18 test todo
x 2021-06-19 2021-06-19 test todo x 2021-06-19 2021-06-19 test todo
x 2021-07-05 2021-07-05 test todo x 2021-07-05 2021-07-05 test todo
x 2021-07-15 2021-07-15 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} {"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 \ 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} {"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 \ 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} {"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 \ No newline at end of file
Supports Markdown
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