Commit e620531e authored by ransome1's avatar ransome1
Browse files

WIP: Making sleek less strict on touching todos, that have not been changed by users

parent 7e3e68a6
{
"name": "sleek",
"productName": "sleek",
"version": "1.2.2-rc.2",
"version": "1.2.2-rc.4",
"description": "todo.txt manager for Linux, Windows and MacOS, free and open-source (FOSS)",
"synopsis": "todo.txt manager for Linux, Windows and MacOS, free and open-source (FOSS)",
"category": "ProjectManagement",
......
......@@ -871,7 +871,7 @@
<button class="delete" role="cancel" data-message="support"></button>
</div>
<div class="message-body">
<p>Please submit bug reports on <i class="fab fa-github"></i>&nbsp;<a href="https://github.com/ransome1/sleek/issues\" target="_blank">Github</a> and support this little project by writing a review on:
<p>Return the love! Submit bug reports on <i class="fab fa-github"></i>&nbsp;<a href="https://github.com/ransome1/sleek/issues\" target="_blank">Github</a> and support this project by writing a review:
<table>
<tr>
<td><a href="https://apps.apple.com/us/app/sleek-todo-manager/id1614704209" target="_blank"><i class="fa-brands fa-apple"></i><br>Mac App Store</a></td>
......
......@@ -75,7 +75,7 @@ modalFormInputResize.onclick = function() {
modalForm.onsubmit = async function(event) {
try {
event.preventDefault();
event.preventDefault();
const modalFormInput = document.getElementById("modalFormInput");
......@@ -96,10 +96,10 @@ modalForm.onsubmit = async function(event) {
let index;
// get the index for EDITING
if(dataItem) {
index = items.objects.map(function(item) { return item.toString(); }).indexOf(dataItem);
index = items.objects.map(function(object) { return object.raw; }).indexOf(dataItem);
// get the index for checking for duplicates
} else {
index = items.objects.map(function(item) { return item.toString(); }).indexOf(todo.toString());
index = items.objects.map(function(object) { return object.raw; }).indexOf(todo.raw);
}
// handle warnings in case of false user input
......@@ -120,14 +120,15 @@ modalForm.onsubmit = async function(event) {
// adding: append a new item to array
// edit: use index to replace the existing item
(index === -1 && !dataItem) ? items.objects.push(todo) : items.objects.splice(index, 1, todo);
//(index === -1 && !dataItem) ? items.objects.push(todo) : items.objects.splice(index, 1, todo);
// mark the todo for anchor jump after next reload
item.previous = todo;
// send file to main process to save it
//window.api.send("writeToFile", [items.objects.join("\n").toString() + "\n"]);
window.api.send("writeToFile", [todo.toString(), index]);
//window.api.send("writeToFile", [todo.toString(), index]);
window.api.send("writeToFile", [inputValue, index]);
// close and clean up the modal
resetForm().then(function(response) {
......@@ -471,7 +472,8 @@ async function show(todo, templated) {
// only show the complete button on open items
(todo.complete) ? btnItemStatus.innerHTML = translations.inProgress : btnItemStatus.innerHTML = translations.done;
const value = todo.toString();
//const value = todo.toString();
const value = todo.raw;
// pass todo string to form data item
modalForm.setAttribute("data-item", value);
......@@ -485,7 +487,7 @@ async function show(todo, templated) {
if(todo.rec) setInput(todo.rec)
// if so we paste it into the input field
if(todo.due || todo.t) fillDatePickerInput(todo)
//if(todo.due || todo.t) fillDatePickerInput(todo)
}
// resize all necessary input elements
......
......@@ -78,7 +78,7 @@ export function jumpToItem(item) {
export async function pasteItemToClipboard(item) {
try {
window.api.send("copyToClipboard", [item.text]);
window.api.send("copyToClipboard", [item.raw]);
showGenericMessage(translations.todoCopiedToClipboard, 3);
return Promise.resolve("Success: Todo text pasted to clipboard: " + item.text);
......
......@@ -89,7 +89,23 @@ async function generateTodoTxtObjects(fileContent) {
try {
// create todo.txt objects
if(fileContent !== undefined) items.objects = await TodoTxt.parse(fileContent, [ new SugarDueExtension(), new HiddenExtension(), new RecExtension(), new ThresholdExtension(), new PriExtension() ])
//if(fileContent !== undefined) items.objects = await TodoTxt.parse(fileContent, [ new SugarDueExtension(), new HiddenExtension(), new RecExtension(), new ThresholdExtension(), new PriExtension() ])
if(fileContent !== undefined) {
items.objects = new Array;
const todoArray = fileContent.split(/\r?\n/);
// create todo.txt objects
let l = todoArray.length;
for(let i = 0; i < l; i++) {
const todoObject = await generateTodoTxtObject(todoArray[i]);
//todoObject.raw = todoArray[i];
// push objects into array
items.objects.push(todoObject);
}
}
// empty lines will be filtered
items.objects = items.objects.filter(function(item) { return item.toString() !== "" });
......@@ -104,6 +120,7 @@ async function generateTodoTxtObjects(fileContent) {
function generateTodoTxtObject(string) {
try {
const todo = new TodoTxtItem(string, [ new SugarDueExtension(), new HiddenExtension(), new RecExtension(), new ThresholdExtension(), new PriExtension() ]);
todo.raw = string;
return Promise.resolve(todo);
} catch(error) {
error.functionName = editTodo.name;
......@@ -319,7 +336,8 @@ function generateTableRow(todo) {
if(todo.complete) todoTableBodyRow.setAttribute("class", "todo completed")
// add todo string to data-item attribute
todoTableBodyRow.setAttribute("data-item", todo.toString());
//todoTableBodyRow.setAttribute("data-item", todo.toString());
todoTableBodyRow.setAttribute("data-item", todo.raw);
// add the priority marker or a white spacer
if(todo.priority && (sortBy === "priority" && !userData.sortByFile)) {
......@@ -560,7 +578,7 @@ async function createTodoContext(todoTableRow) {
try {
// get index of todo
let index = await items.objects.map(function(object) {return object.toString(); }).indexOf(todoTableRow.getAttribute("data-item"));
let index = await items.objects.map(function(object) {return object.raw; }).indexOf(todoTableRow.getAttribute("data-item"));
// retrieve todo object
const todo = items.objects[index]
......@@ -578,6 +596,7 @@ async function createTodoContext(todoTableRow) {
if(userData.matomoEvents) _paq.push(["trackEvent", "Todo-Table-Context", "Click on Use as template"]);
}
const copyTodo = async function() {
pasteItemToClipboard(todo).then(response => {
console.log(response);
}).catch(error => {
......@@ -811,8 +830,9 @@ async function addTodo(todo) {
const index = items.objects.map(function(item) { return item.toString(); }).indexOf(todo.toString());
if(index === -1) {
//write the data to the file
window.api.send("writeToFile", [todo.toString(), index]);
window.api.send("writeToFile", [todo.raw, index]);
return Promise.resolve("Success: New todo added to file: " + getActiveFile());
......@@ -867,6 +887,10 @@ async function archiveTodos() {
completeTodos = completeTodos.filter(function(element) { return element });
}
console.log(incompleteTodos);
return false;
//write completed items to done file
window.api.send("replaceFileContent", [completeTodos.join("\n").toString(), doneFile]);
......
......@@ -2,6 +2,7 @@
let
appData,
events,
fileContent,
filters,
helper,
keyboard,
......@@ -22,7 +23,9 @@ async function setUserData(key, value) {
return Promise.reject(error);
}
}
async function buildTable(fileContent, loadAll) {
async function buildTable(raw, loadAll) {
fileContent = raw;
// start timer for table
const t0 = performance.now();
......@@ -163,4 +166,4 @@ window.onload = async function() {
}
}
export { setUserData, buildTable, userData, appData, translations };
export { setUserData, fileContent, buildTable, userData, appData, translations };
......@@ -25,4 +25,5 @@ x 2022-04-07 This is a test todo that needs to be archived
x 2022-04-08 This is a test todo that needs to be archived
x 2022-04-12 This is a test todo that needs to be archived
x 2022-06-13 This is a test todo that needs to be archived
x 2022-07-01 This is a test todo that needs to be archived
\ No newline at end of file
x 2022-07-01 This is a test todo that needs to be archived
x 2022-09-29 This is a test todo that needs to be archived
\ No newline at end of file
This diff is collapsed.
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