Commit abf595b2 authored by ransome1's avatar ransome1
Browse files

Improved file tabbing, improved print CSS, fixed tray function, fixed h:1 function

parent 6000e80f
......@@ -211,22 +211,20 @@ function modalFormInputEvent(event) {
}
// TODO add try catch
async function resizeInput(input) {
// resizing modalFormInput
if(input.tagName==="TEXTAREA" && input.id==="modalFormInput") {
// reduce height after lines are being deleted
input.style.height = "auto"
// wait until the textarea is rendered
await input.scrollHeight;
input.style.height = input.scrollHeight+"px";
return false;
} else if (input.type==="text" && input.id==="modalFormInput") {
return false;
}
// resizing all other input
let additionalLength = 6;
if(userData.language === "jp" || userData.language === "zh") additionalLength = 11;
if(input.value) {
input.style.width = input.value.length + 6 + "ch";
input.style.width = input.value.length + additionalLength + "ch";
} else if(!input.value && input.placeholder) {
input.style.width = input.placeholder.length + 6 + "ch";
input.style.width = input.placeholder.length + additionalLength + "ch";
}
}
function setPriority(priority) {
......@@ -402,7 +400,7 @@ function submitForm() {
modalFormAlert.parentElement.classList.add("is-active", 'is-warning');
return Promise.resolve("Info: Todo already exists in file, won't write duplicate");
// check if todo text is empty
} else if(!todo.text) {
} else if(!todo.text && !todo.h) {
modalFormAlert.innerHTML = translations.formInfoIncomplete;
modalFormAlert.parentElement.classList.remove("is-active", 'is-danger');
modalFormAlert.parentElement.classList.add("is-active", 'is-warning');
......@@ -424,7 +422,7 @@ function submitForm() {
modalFormAlert.parentElement.classList.add("is-active", 'is-warning');
return Promise.resolve("Info: Todo already exists in file, won't write duplicate");
// check if todo text is empty
} else if(!todo.text) {
} else if(!todo.text && !todo.h) {
modalFormAlert.innerHTML = translations.formInfoIncomplete;
modalFormAlert.parentElement.classList.remove("is-active", 'is-danger');
modalFormAlert.parentElement.classList.add("is-active", 'is-warning');
......
......@@ -116,7 +116,7 @@ function generateItems(content) {
try {
items = { objects: TodoTxt.parse(content, [ new DueExtension(), new HiddenExtension(), new RecExtension(), new ThresholdExtension() ]) }
items.objects = items.objects.filter(function(item) {
if(!item.text) return false;
if(!item.text && !item.h) return false;
return true;
});
items.complete = items.objects.filter(function(item) { return item.complete === true });
......@@ -517,7 +517,7 @@ function addTodo(todo) {
try {
todo = new TodoTxtItem(todo, [ new SugarDueExtension(), new HiddenExtension(), new RecExtension(), new ThresholdExtension() ]);
// abort if there is no text
if(!todo.text) return Promise.resolve("Info: Text is missing, no todo is written");
if(!todo.text && !todo.h) return Promise.resolve("Info: Text is missing, no todo is written");
// we add the current date to the start date attribute of the todo.txt object
todo.date = new Date();
// get index of todo
......
......@@ -433,11 +433,19 @@ const createWindow = async function() {
header: "Header of the Page",
footer: "Footer of the Page"
}
mainWindow.webContents.executeJavaScript("body.classList.remove(\"dark\");");
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");
if(!success) {
console.log(error);
// trigger matomo event
if(userData.data.matomoEvents) _paq.push(["trackEvent", "Print", "Print error", error])
} else {
console.log("Success: Print initiated");
// trigger matomo event
if(userData.data.matomoEvents) _paq.push(["trackEvent", "Print", "Print initiated"])
}
});
}).catch(error => {
console.log(error);
......@@ -754,9 +762,8 @@ const createWindow = async function() {
// ########################################################################################################################
// REFRESH WHEN IN BACKGROUND
// ########################################################################################################################
// every 10 minutes sleek will reload data and send it to renderer if app is not focused
setInterval(() => {
if(!mainWindow.isFocused()) {
if(userData.data.file && !mainWindow.isFocused()) {
getContent(userData.data.file).then(content => {
mainWindow.webContents.send("refresh", [content])
}).catch(error => {
......
......@@ -354,12 +354,12 @@ function registerEvents() {
}
});
btnFiltersResetFilters.onclick = function() {
resetFilters();
resetFilters(true);
// trigger matomo event
if(userData.matomoEvents) matomo._paq.push(["trackEvent", "Filter-Drawer", "Click on reset button"])
}
btnNoResultContainerResetFilters.onclick = function() {
resetFilters();
resetFilters(true);
// trigger matomo event
if(userData.matomoEvents) matomo._paq.push(["trackEvent", "No Result Container", "Click on reset button"])
}
......@@ -397,8 +397,8 @@ function registerKeyboardShortcuts() {
window.addEventListener("keyup", function(event) {
// switch files
const regex=/^[1-9]+$/;
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]);
if(event.key.match(regex) && userData.files.length > 1 && userData.files[event.key-1] && !modalForm.classList.contains("is-active") && (document.activeElement.id!="todoTableSearch" && document.activeElement.id!="filterContextInput" && document.activeElement.id!="modalFormInput")) {
if(userData.files[event.key-1][1]) window.api.send("startFileWatcher", userData.files[event.key-1][1]);
}
// cycle through tabs
if(event.ctrlKey && !event.shiftKey && event.keyCode === 9) {
......@@ -449,7 +449,7 @@ function registerKeyboardShortcuts() {
// abort when onboarding is shown
if(onboarding) return false;
resetFilters().then(function(response) {
resetFilters(true).then(function(response) {
console.info(response);
}).catch(function(error) {
handleError(error);
......@@ -559,7 +559,7 @@ function registerKeyboardShortcuts() {
return Promise.reject(error);
}
}
function resetFilters() {
function resetFilters(refresh) {
try {
// scroll back to top
document.getElementById("todoTableWrapper").scrollTo(0,0);
......@@ -572,7 +572,7 @@ function resetFilters() {
// clear search input
document.getElementById("todoTableSearch").value = null;
// regenerate the data
startBuilding();
if(refresh) startBuilding();
return Promise.resolve("Success: Filters resetted");
} catch(error) {
error.functionName = resetFilters.name;
......
@page {
margin: 0cm !important;
}
html,
body {
filter: grayscale(100%)!important;
color: black!important;
font-size: 9pt!important;
padding: 0!important;
margin: 0!important;
-webkit-print-color-adjust: exact !important;
}
nav #drawerContainer,
nav ul,
header,
header #fileTabBar,
#drawerClose,
#viewDrawer,
#todoContext,
......@@ -34,16 +31,28 @@ header,
overflow-y: visible!important;
}
#todoTable .cell:hover .tags, #todoTable .cell:focus .tags {
#todoTable .cell:hover .tags, #todoTable .cell:focus .tags,
#todoTable .cell.itemDueDate .tags,
#todoTable .cell.itemDueDate .fa-sort-down {
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;
#todoTable .cell span.tag.contexts {
background: black;
color: white;
opacity: 0.7;
}
#todoTable .cell span.tag.projects {
background: $light-grey;
color: black;
}
// 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;
// }
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