Skip to content

Commit

Permalink
Added multi line text field support, multi line text field is persist…
Browse files Browse the repository at this point in the history
…ed, changed "Save" button to "Add" and "Update" depending on the context, added translations for this
  • Loading branch information
ransome1 committed Oct 20, 2023
1 parent a555be9 commit 2f75ea2
Show file tree
Hide file tree
Showing 35 changed files with 503 additions and 410 deletions.
584 changes: 297 additions & 287 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
"applicationId": "RobinAhle.sleektodomanager"
},
"linux": {
"icon": "assets/icons/sleek.png",
"icon": "assets/icons/sleek.ico",
"category": "ProjectManagement",
"target": [
"deb",
Expand Down
2 changes: 1 addition & 1 deletion release/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sleek",
"version": "2.0.0-dev16",
"version": "2.0.0-dev17",
"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)",
"keywords": [
Expand Down
16 changes: 8 additions & 8 deletions src/__tests__/__mock__/recurrence.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

2023-10-15 Line 1 rec:1d due:2023-10-16
2023-10-15 Line 1 rec:w due:2023-10-22
2023-10-15 Line 1 rec:2m due:2023-12-15
2023-10-15 Line 1 rec:+1d due:2023-10-17
2023-10-15 Line 1 rec:7w due:2023-12-03
2023-10-20 Line 1 rec:1d due:2023-10-21
2023-10-20 Line 1 rec:w due:2023-10-27
2023-10-20 Line 1 rec:2m due:2023-12-20
2023-10-20 Line 1 rec:+1d due:2023-10-22
2023-10-20 Line 1 rec:7w due:2023-12-08
2023-07-21 Line 1 due:2023-07-24 rec:+1b
2021-01-01 taxes are due in one year t:2022-03-30 due:2022-04-30 rec:+1y
2023-10-15 Water plants @home +quick due:2023-10-22 t:2023-10-12 rec:1w
2023-10-15 Line 1 rec:+1d t:2023-09-20 due:2023-10-16
(A) 2023-10-15 Line 1 rec:1d pri:A due:2023-10-16
2023-10-20 Water plants @home +quick due:2023-10-27 t:2023-10-17 rec:1w
2023-10-20 Line 1 rec:+1d t:2023-09-20 due:2023-10-21
(A) 2023-10-20 Line 1 rec:1d pri:A due:2023-10-21
2 changes: 1 addition & 1 deletion src/__tests__/__mock__/test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Line 1
Edited line
New line
2023-10-15 New line with creation date
2023-10-20 New line with creation date
New line with relative threshold date t:June 3rd, 2005
3 changes: 2 additions & 1 deletion src/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"splashscreen.noTodosVisible.text": "Žádné výsledky nejsou viditelné.",
"splashscreen.noTodosVisible.reset": "Obnovit filtry a hledání",
"search.visibleTodos": "Viditelné úkoly: ",
"todoDialog.footer.save": "Uložit",
"todoDialog.footer.add": "Přidat",
"todoDialog.footer.update": "Aktualizovat",
"todoDialog.footer.cancel": "Zrušit",
"todoDialog.snackbar.emptyInput": "Zadejte prosím něco do textového pole",
"todoDialog.priorityPicker.label": "Priorita",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"splashscreen.noTodosVisible.text": "Keine sichtbaren Ergebnisse.",
"splashscreen.noTodosVisible.reset": "Filter und Suche zurücksetzen",
"search.visibleTodos": "Sichtbare Aufgaben: ",
"todoDialog.footer.save": "Speichern",
"todoDialog.footer.add": "Hinzufügen",
"todoDialog.footer.update": "Aktualisieren",
"todoDialog.footer.cancel": "Abbrechen",
"todoDialog.snackbar.emptyInput": "Bitte geben Sie etwas in das Textfeld ein",
"todoDialog.priorityPicker.label": "Priorität",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en-gb.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"splashscreen.noTodosVisible.text": "No results visible.",
"splashscreen.noTodosVisible.reset": "Reset filters and search",
"search.visibleTodos": "Visible todos: ",
"todoDialog.footer.save": "Save",
"todoDialog.footer.add": "Add",
"todoDialog.footer.update": "Update",
"todoDialog.footer.cancel": "Cancel",
"todoDialog.snackbar.emptyInput": "Please enter something into the text field",
"todoDialog.priorityPicker.label": "Priority",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"splashscreen.noTodosVisible.text": "No results visible.",
"splashscreen.noTodosVisible.reset": "Reset filters and search",
"search.visibleTodos": "Visible todos: ",
"todoDialog.footer.save": "Save",
"todoDialog.footer.add": "Add",
"todoDialog.footer.update": "Update",
"todoDialog.footer.cancel": "Cancel",
"todoDialog.snackbar.emptyInput": "Please enter something into the text field",
"todoDialog.priorityPicker.label": "Priority",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"splashscreen.noTodosVisible.text": "No se ven resultados.",
"splashscreen.noTodosVisible.reset": "Restablecer filtros y búsqueda",
"search.visibleTodos": "Tareas visibles: ",
"todoDialog.footer.save": "Guardar",
"todoDialog.footer.add": "Agregar",
"todoDialog.footer.update": "Actualizar",
"todoDialog.footer.cancel": "Cancelar",
"todoDialog.snackbar.emptyInput": "Por favor, ingrese algo en el campo de texto",
"todoDialog.priorityPicker.label": "Prioridad",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"splashscreen.noTodosVisible.text": "Aucun résultat visible.",
"splashscreen.noTodosVisible.reset": "Réinitialiser les filtres et la recherche",
"search.visibleTodos": "Tâches visibles : ",
"todoDialog.footer.save": "Enregistrer",
"todoDialog.footer.add": "Ajouter",
"todoDialog.footer.update": "Mettre à jour",
"todoDialog.footer.cancel": "Annuler",
"todoDialog.snackbar.emptyInput": "Veuillez entrer quelque chose dans le champ de texte",
"todoDialog.priorityPicker.label": "Priorité",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"splashscreen.noTodosVisible.text": "कोई दिखाई देने वाला परिणाम नहीं है।",
"splashscreen.noTodosVisible.reset": "फ़िल्टर और खोज को रीसेट करें",
"search.visibleTodos": "दिखाई देने वाले कार्य: ",
"todoDialog.footer.save": "सहेजें",
"todoDialog.footer.add": "जोड़ें",
"todoDialog.footer.update": "अपडेट करें",
"todoDialog.footer.cancel": "रद्द करें",
"todoDialog.snackbar.emptyInput": "कृपया पाठ फ़ील्ड में कुछ डालें",
"todoDialog.priorityPicker.label": "प्राथमिकता",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"splashscreen.noTodosVisible.text": "Nincs látható eredmény.",
"splashscreen.noTodosVisible.reset": "Szűrők és keresés visszaállítása",
"search.visibleTodos": "Látható feladatok: ",
"todoDialog.footer.save": "Mentés",
"todoDialog.footer.add": "Hozzáadás",
"todoDialog.footer.update": "Frissítés",
"todoDialog.footer.cancel": "Mégse",
"todoDialog.snackbar.emptyInput": "Kérjük, írjon be valamit a szövegmezőbe",
"todoDialog.priorityPicker.label": "Prioritás",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"splashscreen.noTodosVisible.text": "Nessun risultato visibile.",
"splashscreen.noTodosVisible.reset": "Reimposta filtri e ricerca",
"search.visibleTodos": "Compiti visibili: ",
"todoDialog.footer.save": "Salva",
"todoDialog.footer.add": "Aggiungi",
"todoDialog.footer.update": "Aggiorna",
"todoDialog.footer.cancel": "Annulla",
"todoDialog.snackbar.emptyInput": "Inserisci qualcosa nel campo di testo, per favore",
"todoDialog.priorityPicker.label": "Priorità",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"splashscreen.noTodosVisible.text": "表示できる結果はありません。",
"splashscreen.noTodosVisible.reset": "フィルターと検索をリセット",
"search.visibleTodos": "表示されるタスク:",
"todoDialog.footer.save": "保存",
"todoDialog.footer.add": "追加",
"todoDialog.footer.update": "更新",
"todoDialog.footer.cancel": "キャンセル",
"todoDialog.snackbar.emptyInput": "テキストフィールドに何かを入力してください",
"todoDialog.priorityPicker.label": "優先度",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"splashscreen.noTodosVisible.text": "표시할 결과 없음.",
"splashscreen.noTodosVisible.reset": "필터 및 검색 재설정",
"search.visibleTodos": "표시된 작업: ",
"todoDialog.footer.save": "저장",
"todoDialog.footer.add": "추가",
"todoDialog.footer.update": "업데이트",
"todoDialog.footer.cancel": "취소",
"todoDialog.snackbar.emptyInput": "텍스트 필드에 내용을 입력하세요",
"todoDialog.priorityPicker.label": "우선 순위",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"splashscreen.noTodosVisible.text": "Brak widocznych wyników.",
"splashscreen.noTodosVisible.reset": "Resetuj filtry i wyszukiwanie",
"search.visibleTodos": "Widoczne zadania: ",
"todoDialog.footer.save": "Zapisz",
"todoDialog.footer.add": "Dodaj",
"todoDialog.footer.update": "Aktualizuj",
"todoDialog.footer.cancel": "Anuluj",
"todoDialog.snackbar.emptyInput": "Proszę wprowadzić coś do pola tekstowego",
"todoDialog.priorityPicker.label": "Priorytet",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"splashscreen.noTodosVisible.text": "Sem resultados visíveis.",
"splashscreen.noTodosVisible.reset": "Repor filtros e pesquisa",
"search.visibleTodos": "Tarefas visíveis: ",
"todoDialog.footer.save": "Guardar",
"todoDialog.footer.add": "Adicionar",
"todoDialog.footer.update": "Atualizar",
"todoDialog.footer.cancel": "Cancelar",
"todoDialog.snackbar.emptyInput": "Por favor, insira algo no campo de texto",
"todoDialog.priorityPicker.label": "Prioridade",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"splashscreen.noTodosVisible.text": "Нет видимых результатов.",
"splashscreen.noTodosVisible.reset": "Сбросить фильтры и поиск",
"search.visibleTodos": "Видимые задачи: ",
"todoDialog.footer.save": "Сохранить",
"todoDialog.footer.add": "Добавить",
"todoDialog.footer.update": "Обновить",
"todoDialog.footer.cancel": "Отменить",
"todoDialog.snackbar.emptyInput": "Пожалуйста, введите что-то в текстовое поле",
"todoDialog.priorityPicker.label": "Приоритет",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"splashscreen.noTodosVisible.text": "Görünen sonuç yok.",
"splashscreen.noTodosVisible.reset": "Filtreleri ve aramayı sıfırla",
"search.visibleTodos": "Görünür görevler: ",
"todoDialog.footer.save": "Kaydet",
"todoDialog.footer.add": "Ekle",
"todoDialog.footer.update": "Güncelle",
"todoDialog.footer.cancel": "İptal",
"todoDialog.snackbar.emptyInput": "Lütfen metin alanına bir şeyler yazın",
"todoDialog.priorityPicker.label": "Öncelik",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"splashscreen.noTodosVisible.text": "没有可见的结果。",
"splashscreen.noTodosVisible.reset": "重置过滤器和搜索",
"search.visibleTodos": "可见任务:",
"todoDialog.footer.save": "保存",
"todoDialog.footer.add": "添加",
"todoDialog.footer.update": "更新",
"todoDialog.footer.cancel": "取消",
"todoDialog.snackbar.emptyInput": "请在文本字段中输入内容",
"todoDialog.priorityPicker.label": "优先级",
Expand Down
1 change: 1 addition & 0 deletions src/main/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const defaultConfigData = {
customStylesPath: customStylesPath,
tray: false,
zoom: 100,
multilineTextField: false,
};

const configPath = path.join(userDataDirectory, 'config.json');
Expand Down
2 changes: 2 additions & 0 deletions src/main/modules/Filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function applyFilters(todoObjects: TodoObject[], filters: Filters | null): TodoO

const hasMatchingValue = attributeValues.includes(value);

console.log(hasMatchingValue)

return exclude ? !hasMatchingValue : hasMatchingValue;
});
});
Expand Down
8 changes: 4 additions & 4 deletions src/main/modules/TodoObject/CreateTodoObjects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ function createTodoObjects(fileContent: string): TodoObject[] {
const todoObjects: TodoObject[] = lines
.map((line, i) => {
try {
const JsTodoTxtObject = new Item(line);
const updatedLine = line.replaceAll(String.fromCharCode(16), ` `)

const JsTodoTxtObject = new Item(updatedLine);
const body = JsTodoTxtObject.body();
if (!body) {
return null;
Expand Down Expand Up @@ -49,17 +51,15 @@ function createTodoObjects(fileContent: string): TodoObject[] {
rec,
hidden,
pm,
string: JsTodoTxtObject.toString(),
string: line,
};

return todoObject as TodoObject;
} catch (error) {
console.log(error);
return null;
}
})
.filter((todoObject): todoObject is TodoObject => todoObject !== null);

return todoObjects;
}

Expand Down
32 changes: 16 additions & 16 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const App = () => {
const [todoObject, setTodoObject] = useState(null);
const [headers, setHeaders] = useState<object>(null);
const [filters, setFilters] = useState<object>({});
const [attributes, setAttributes] = useState<object>({});
const [attributes, setAttributes] = useState<object>({});
const [sorting, setSorting] = useState<Sorting>(store.get('sorting') || null);
const [zoom, setZoom] = useState<number>(store.get('zoom') || 100);
const searchFieldRef = useRef(null);
Expand Down Expand Up @@ -169,7 +169,6 @@ const App = () => {
document.body.style.fontSize = `${adjustedFontSize}px`;
}, [zoom]);


useEffect(() => {
ipcRenderer.on('requestData', handleRequestedData);
ipcRenderer.on('updateFiles', handleUpdateFiles);
Expand All @@ -183,20 +182,20 @@ const App = () => {
ipcRenderer.on('writeTodoToFile', handleWriteTodoToFile);
window.addEventListener('drop', handleDrop);
window.addEventListener('dragover', handleDragOver);
return () => {
ipcRenderer.removeListener('requestData', handleRequestedData);
ipcRenderer.removeListener('updateFiles', handleUpdateFiles);
ipcRenderer.removeListener('updateSorting', handleUpdateSorting);
ipcRenderer.removeListener('setIsSearchOpen', handleSetIsSearchOpen);
ipcRenderer.removeListener('setIsNavigationOpen', handleSetIsNavigationOpen);
ipcRenderer.removeListener('setShouldUseDarkColors', handleSetShouldUseDarkColors);
ipcRenderer.removeListener('setShowFileTabs', handleSetShowFileTabs);
ipcRenderer.removeListener('setIsDrawerOpen', handleSetIsDrawerOpen);
ipcRenderer.removeListener('setIsSettingsOpen', handleSetIsSettingsOpen);
ipcRenderer.removeListener('writeTodoToFile', handleWriteTodoToFile);
window.removeEventListener('drop', handleDrop);
window.removeEventListener('dragover', handleDragOver);
};
// return () => {
// ipcRenderer.removeListener('requestData', handleRequestedData);
// ipcRenderer.removeListener('updateFiles', handleUpdateFiles);
// ipcRenderer.removeListener('updateSorting', handleUpdateSorting);
// ipcRenderer.removeListener('setIsSearchOpen', handleSetIsSearchOpen);
// ipcRenderer.removeListener('setIsNavigationOpen', handleSetIsNavigationOpen);
// ipcRenderer.removeListener('setShouldUseDarkColors', handleSetShouldUseDarkColors);
// ipcRenderer.removeListener('setShowFileTabs', handleSetShowFileTabs);
// ipcRenderer.removeListener('setIsDrawerOpen', handleSetIsDrawerOpen);
// ipcRenderer.removeListener('setIsSettingsOpen', handleSetIsSettingsOpen);
// ipcRenderer.removeListener('writeTodoToFile', handleWriteTodoToFile);
// window.removeEventListener('drop', handleDrop);
// window.removeEventListener('dragover', handleDragOver);
// };
}, []);

return (
Expand Down Expand Up @@ -266,6 +265,7 @@ const App = () => {
setContextMenuPosition={setContextMenuPosition}
contextMenuItems={contextMenuItems}
setContextMenuItems={setContextMenuItems}
setTextFieldValue={setTextFieldValue}
/>
<SplashScreen
screen={splashScreen}
Expand Down
9 changes: 8 additions & 1 deletion src/renderer/DataGrid/DatePickerInline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ import dayjs from 'dayjs';

const { ipcRenderer, store } = window.api;

const DatePickerInline: React.FC<DatePicker> = ({
interface DatePickerInlineProps {
type: string,
todoObject: TodoObject,
date: date,
filters
}

const DatePickerInline: React.FC<DatePickerInlineProps> = ({
type,
todoObject,
date,
Expand Down
16 changes: 7 additions & 9 deletions src/renderer/DataGrid/Elements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const Elements: React.FC<ElementsProps> = ({ todoObject, filters, handleButtonCl
{ pattern: /rec:([^ ]+)/, type: 'rec', key: 'rec:' },
];

let body = todoObject.body;
let body = todoObject.body.replaceAll(String.fromCharCode(16), ' ');
let substrings = [];
let index = 0;

Expand All @@ -81,15 +81,14 @@ const Elements: React.FC<ElementsProps> = ({ todoObject, filters, handleButtonCl
let matched = false;

for (const expression of expressions) {

const regex = new RegExp(`^(${expression.pattern.source})`);
const match = body.match(regex);

if (match) {
matched = true;

const value = match[0].substr(expression.key.length);

substrings.push({ type: expression.type, value: value, key: expression.key, index: index });
const value = match[0].substr(expression.key?.length);
if(value) substrings.push({ type: expression.type, value: value, key: expression.key, index: index });
body = body.substring(match[0].length);
break;
}
Expand All @@ -98,11 +97,10 @@ const Elements: React.FC<ElementsProps> = ({ todoObject, filters, handleButtonCl
if (!matched) {
const nextSpaceIndex = body.indexOf(' ');
const endOfWordIndex = nextSpaceIndex !== -1 ? nextSpaceIndex : body.length;

substrings.push({ type: null, value: body.substring(0, endOfWordIndex), index: index });
const value = body.substring(0, endOfWordIndex);
if(value !== '') substrings.push({ type: null, value: value, index: index });
body = body.substring(endOfWordIndex + 1);
}

index++;
}
}
Expand Down Expand Up @@ -130,4 +128,4 @@ const Elements: React.FC<ElementsProps> = ({ todoObject, filters, handleButtonCl
return <>{elements}</>;
};

export default Elements;
export default Elements;
2 changes: 1 addition & 1 deletion src/renderer/DataGrid/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const Row: React.FC<DataGridRowProps> = ({
setTodoObject(row);
setDialogOpen(true);
}
//setTextFieldValue(row.string);
setTextFieldValue(row.string);
}
}
};
Expand Down
Loading

0 comments on commit 2f75ea2

Please sign in to comment.