Commit 2877852b authored by ransome1's avatar ransome1
Browse files

Fixed plain-text search bug

parent d1bdca26
{
"name": "sleek",
"productName": "sleek",
"version": "1.2.6",
"version": "1.2.7",
"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",
......@@ -19,7 +19,7 @@
"main": "src/main.js",
"buildResources": "src",
"build": {
"buildVersion": "22",
"buildVersion": "23",
"files": [
"!flatpak-node${/*}",
"!snap${/*}",
......
name: sleek
base: core18
version: "1.2.6"
version: "1.2.7"
summary: todo.txt manager for Linux, free and open-source (FOSS)
description: |
sleek is an open-source (FOSS) todo manager based on the todo.txt syntax. Stripped down to only the most necessary features, and with a clean and simple interface, sleek aims to help you focus on getting things done.
......
......@@ -11528,6 +11528,30 @@ a.button.projects.is-dark.is-hovered {
color: white;
}
a.button.customTags,
a.button.customTags:hover {
background: #ccc;
color: #595959;
}
a.button.customTags span.tag,
a.button.customTags:hover span.tag {
color: white;
background: #404040;
}
a.button.customTags:focus-visible,
a.button.customTags.is-dark:focus-visible {
background: #4d4d4d;
color: white;
}
a.button.customTags.is-dark,
a.button.customTags.is-dark:hover,
a.button.customTags.is-dark.is-hovered {
background: #333333;
color: white;
}
a.button.priority,
a.button.priority:focus,
a.button.priority:focus-visible,
......
This diff is collapsed.
......@@ -47,6 +47,7 @@ autoCompleteContainer.onkeyup = function(event) {
function saveFilter(newFilter, oldFilter, category) {
try {
const l = items.objects.length;
for(let i = 0; i < l; i++) {
if(category !== "priority" && items.objects[i][category]) {
......@@ -64,6 +65,11 @@ function saveFilter(newFilter, oldFilter, category) {
}).catch(error => {
handleError(error);
});
console.log(items.objects)
console.log(items.objects.toString())
return false;
// write the data to the file
// a newline character is added to prevent other todo.txt apps to append new todos to the last line
......@@ -192,11 +198,7 @@ function applySearchInput(queryString) {
// plain-text query.
items.filtered = items.filtered.filter(function(item) {
if(!userData.caseSensitive) {
queryString = queryString.toLowerCase();
item.raw = item.raw;
}
return item.raw.indexOf(queryString) !== -1;
return item.raw.toLowerCase().indexOf(queryString.toLowerCase()) !== -1;
});
}
}
......@@ -278,12 +280,12 @@ function resetFilters(refresh) {
}
function addFilterToInput(filter, autoCompletePrefix) {
try {
try {
const modalFormInput = document.getElementById("modalFormInput");
const caretPosition = getCaretPosition(modalFormInput);
// split string into elements
const inputElements = modalFormInput.value.split(" ");
const inputElements = modalFormInput.value.split(/[^\r\n]+/);
let i;
let x = 0;
for(i = 0; i < inputElements.length; i++) {
......@@ -293,6 +295,7 @@ function addFilterToInput(filter, autoCompletePrefix) {
}
inputElements.splice(i, 1, autoCompletePrefix + filter + " ");
modalFormInput.value = inputElements.join(" ");
// empty autoCompleteValue to prevent multiple inputs using multiple Enter presses
......@@ -413,6 +416,7 @@ function generateCategoryContainer(category, autoCompletePrefix, buttons) {
function generateFilterButtons(category, autoCompletePrefix) {
try {
// create a fragment to collect the filters in
const buttons = document.createDocumentFragment();
......@@ -548,7 +552,6 @@ function generateFilterButtons(category, autoCompletePrefix) {
}
}
function generateFilterData(autoCompleteCategory, autoCompleteValue, autoCompletePrefix) {
try {
......
......@@ -202,12 +202,14 @@ function addInputEvents(element) {
let autoCompleteValue ="";
// TODO: describe
if((inputValue.charAt(caretPosition-2) === " " || inputValue.charAt(caretPosition-2) === "\n") && (inputValue.charAt(caretPosition-1) === "@" || inputValue.charAt(caretPosition-1) === "+")) {
//if((inputValue.charAt(caretPosition-2) === " " || inputValue.charAt(caretPosition-2) === "\n") && (inputValue.charAt(caretPosition-1) === "@" || inputValue.charAt(caretPosition-1) === "+" || inputValue.charAt(caretPosition-1) === "#")) {
if((inputValue.charAt(caretPosition-2) === " " || inputValue.charAt(caretPosition-2) === "\n") && (inputValue.charAt(caretPosition-1) === "@" || inputValue.charAt(caretPosition-1) === "+")) {
autoCompleteValue = inputValue.substr(caretPosition, inputValue.lastIndexOf(" ")).split(" ").shift();
autoCompletePrefix = inputValue.charAt(caretPosition-1);
} else if(inputValue.charAt(caretPosition) === " ") {
autoCompleteValue = inputValue.substr(inputValue.lastIndexOf(" ", caretPosition-1)+2).split(" ").shift();
autoCompletePrefix = inputValue.charAt(inputValue.lastIndexOf(" ", caretPosition-1)+1);
//} else if(inputValue.charAt(inputValue.lastIndexOf(" ", caretPosition)+1) === "@" || inputValue.charAt(inputValue.lastIndexOf(" ", caretPosition)+1) === "+" || inputValue.charAt(inputValue.lastIndexOf(" ", caretPosition)+1) === "#") {
} else if(inputValue.charAt(inputValue.lastIndexOf(" ", caretPosition)+1) === "@" || inputValue.charAt(inputValue.lastIndexOf(" ", caretPosition)+1) === "+") {
autoCompleteValue = inputValue.substr(inputValue.lastIndexOf(" ", caretPosition)+2).split(" ").shift();
autoCompletePrefix = inputValue.charAt(inputValue.lastIndexOf(" ", caretPosition)+1);
......@@ -222,6 +224,8 @@ function addInputEvents(element) {
autoCompleteCategory = "projects";
} else if(autoCompletePrefix === "@") {
autoCompleteCategory = "contexts";
// } else if(autoCompletePrefix === "#") {
// autoCompleteCategory = "customTags";
} else {
// interrupt in case no filter is being asked for
return false;
......
"use strict";
import { createTodoContext, setTodoComplete, archiveTodos, items } from "./todos.mjs";
import { createTodoContext, setTodoComplete, deleteTodo, archiveTodos, items } from "./todos.mjs";
import { getConfirmation } from "./prompt.mjs";
import { pasteItemsToClipboard, setDueDate } from "./helper.mjs";
import { removeFileFromList } from "./files.mjs";
......@@ -206,6 +206,10 @@ export async function registerShortcuts() {
if(!isInputFocused() && !isContextOpen()) {
// if(event.key === "Delete" || event.key === "Backspace") {
// deleteTodo(currentRow);
// }
// move focus down in table list
if(event.key === "ArrowDown") {
......
......@@ -13,7 +13,7 @@ import { generateRecurrence } from "./recurrences.mjs";
import { getActiveFile, getDoneFile, handleError, pasteItemToClipboard, generateGenericNotification, generateTodoNotification, isInViewport } from "./helper.mjs";
import { getConfirmation } from "./prompt.mjs";
import { show } from "./form.mjs";
import { SugarDueExtension, RecExtension, ThresholdExtension, PriExtension } from "./todotxtExtensions.mjs";
import { SugarDueExtension, RecExtension, ThresholdExtension, PriExtension, TagExtension } from "./todotxtExtensions.mjs";
const item = { previous: "" }
const items = { objects: {} }
......@@ -305,7 +305,6 @@ function generateGroupedObjects() {
}
function generateTableRow(todo) {
try {
// create nodes from templates
let todoTableBodyRow = todoTableBodyRowTemplate.cloneNode(true);
let todoTableBodyCellCheckbox = todoTableBodyCellCheckboxTemplate.cloneNode(true);
......@@ -567,6 +566,18 @@ function generateTableRow(todo) {
return Promise.reject(error);
}
}
const deleteTodo = async function(index) {
//send index to main process in order to delete line
window.api.send("writeToFile", [undefined, index, undefined]);
todoContext.classList.remove("is-active");
todoContext.removeAttribute("data-item");
// trigger matomo event
if(userData.matomoEvents) _paq.push(["trackEvent", "Todo-Table-Context", "Click on Delete"]);
}
async function createTodoContext(todoTableRow) {
try {
......@@ -602,17 +613,17 @@ async function createTodoContext(todoTableRow) {
// trigger matomo event
if(userData.matomoEvents) _paq.push(["trackEvent", "Todo-Table-Context", "Click on Copy"]);
}
const deleteTodo = async function() {
// const deleteTodo = async function() {
//send index to main process in order to delete line
window.api.send("writeToFile", [undefined, index, undefined]);
// //send index to main process in order to delete line
// window.api.send("writeToFile", [undefined, index, undefined]);
todoContext.classList.remove("is-active");
todoContext.removeAttribute("data-item");
// todoContext.classList.remove("is-active");
// todoContext.removeAttribute("data-item");
// trigger matomo event
if(userData.matomoEvents) _paq.push(["trackEvent", "Todo-Table-Context", "Click on Delete"]);
}
// // trigger matomo event
// if(userData.matomoEvents) _paq.push(["trackEvent", "Todo-Table-Context", "Click on Delete"]);
// }
const changePriority = function(direction) {
const todo = items.objects[index];
......@@ -907,4 +918,4 @@ async function archiveTodos() {
}
}
export { generateTodoTxtObjects, generateGroupedObjects, generateTable, items, item, setTodoComplete, archiveTodos, addTodo, editTodo, show, createTodoContext, generateTodoTxtObject };
export { generateTodoTxtObjects, generateGroupedObjects, generateTable, items, item, setTodoComplete, deleteTodo, archiveTodos, addTodo, editTodo, show, createTodoContext, generateTodoTxtObject };
......@@ -3,6 +3,35 @@ import "../../node_modules/jstodotxt/jsTodoExtensions.js";
import { convertDate } from "./date.mjs";
import { addIntervalToDate } from "./recurrences.mjs";
function TagExtension() {
this.name = "customTags";
}
TagExtension.prototype = new TodoTxtExtension();
TagExtension.prototype.parsingFunction = function(line) {
//var tagRegex = /(#\w+)/g;
var tagRegex = /(^|\s+)#(\S+)/g;
//var tagRegexReplace = /(^|\s+)#\S+/g;
var matchTag = line.match(tagRegex);
//var matchTagReplace = line.match(tagRegexReplace);
if(matchTag !== null) {
var customTags = [];
for(var i = 0; i < matchTag.length; i++) { customTags.push( matchTag[i].trim().substr( 1 ) ); }
const customTagsToString = "#" + customTags.join(" #");
let textOnly = line.replace(tagRegex, '')
console.log(customTagsToString)
return [customTags, line.replace(tagRegex, ""), customTagsToString];
}
return [null, null, null];
};
function RecExtension() {
this.name = "rec";
}
......@@ -109,4 +138,4 @@ function resolveRelativeDate(relativeDate) {
return addIntervalToDate(today, increment, unit);
}
export { RecExtension, SugarDueExtension, ThresholdExtension, PriExtension };
\ No newline at end of file
export { RecExtension, SugarDueExtension, ThresholdExtension, PriExtension, TagExtension };
\ No newline at end of file
......@@ -99,6 +99,7 @@
"priorities": "Priority",
"priority": "Priorita",
"projects": "Projekty",
"customTags": "Tags",
"printCurrentView": "Tisk aktuálního pohledu",
"reload": "Obnovit",
"resetFilters": "Obnovit filtry a vyhledávání",
......
......@@ -100,6 +100,7 @@
"priorities": "Prioritäten",
"priority": "Priorität",
"projects": "Projekte",
"customTags": "Tags",
"printCurrentView": "Aktuelle Ansicht ausdrucken",
"reload": "Neuladen",
"resetFilters": "Filter und Sucheingabe zurücksetzen",
......
......@@ -99,6 +99,7 @@
"priorities": "Priorities",
"priority": "Priority",
"projects": "Projects",
"customTags": "Tags",
"printCurrentView": "Print current view",
"reload": "Reload",
"resetFilters": "Reset filters and search",
......
......@@ -99,6 +99,7 @@
"priorities": "Prioridades",
"priority": "Prioridad",
"projects": "Proyectos",
"customTags": "Tags",
"printCurrentView": "Imprimir vista actual",
"reload": "Recarga",
"resetFilters": "Eliminar filtros y buscar",
......
......@@ -99,6 +99,7 @@
"priorities": "Priorités",
"priority": "Priorité",
"projects": "Projets",
"customTags": "Tags",
"printCurrentView": "Imprimer la vue actuelle",
"reload": "Recharger",
"resetFilters": "Réinitialiser les filtres et la recherche",
......
......@@ -99,6 +99,7 @@
"priorities": "Tulajdonságok",
"priority": "Prioritás",
"projects": "Projektek",
"customTags": "Tags",
"printCurrentView": "Jelenlegi nézet nyomtatása",
"reload": "Újratöltés",
"resetFilters": "Szűrők és keresés visszaállítása",
......
......@@ -99,6 +99,7 @@
"priorities": "Priorità",
"priority": "Priorità",
"projects": "Progetti",
"customTags": "Tags",
"printCurrentView": "Stampa vista corrente",
"reload": "Ricarica",
"resetFilters": "Elimina filtri e ricerca",
......
......@@ -99,6 +99,7 @@
"priorities": "優先度",
"priority": "優先度",
"projects": "プロジェクト",
"customTags": "Tags",
"printCurrentView": "現在のビューを印刷",
"reload": "リロード",
"resetFilters": "フィルターと検索をリセット",
......
......@@ -98,6 +98,7 @@
"priorities": "Priorytety",
"priority": "Priorytet",
"projects": "Projekty",
"customTags": "Tags",
"printCurrentView": "Wydrukuj aktualny widok",
"reload": "Odśwież",
"resetFilters": "Zresetuj filtry i szukaj",
......
......@@ -99,6 +99,7 @@
"priorities": "Prioridades",
"priority": "Prioridade",
"projects": "Projetos",
"customTags": "Tags",
"printCurrentView": "Imprimir vista atual",
"reload": "Recarregar",
"resetFilters": "Redefinir filtros e pesquisa",
......
......@@ -98,6 +98,7 @@
"priorities": "Приоритеты",
"priority": "Приоритет",
"projects": "Проекты",
"customTags": "Tags",
"printCurrentView": "Распечатать выведенный список",
"reload": "Перезагрузить",
"resetFilters": "Сбросить фильтры и поиск",
......
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