From df7b3ab88fef26a0c490f09fc06c60f535eadae2 Mon Sep 17 00:00:00 2001 From: JackGruber <24863925+JackGruber@users.noreply.github.com> Date: Sat, 2 Dec 2023 09:47:40 +0100 Subject: [PATCH 1/6] Update search url --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bd7baf8..0388169 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ Options that can be specified in the in the code block using YAML syntax. ### search The search filter which will be used to create the overview. -[Documentation of search filters](https://joplinapp.org/help/#search-filters). +[Documentation of search filters](https://joplinapp.org/help/apps/search#search-filters). ```yml search: type:todo From 74612fe17594c6bc7ef2a1024fb2142a726d0ffa Mon Sep 17 00:00:00 2001 From: Andry Yosua Date: Fri, 15 Dec 2023 10:30:12 +0700 Subject: [PATCH 2/6] add settings for note item MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Steps - create a note and todo note - create note-overview ``` ``` ### Actual result note status has same status as todo open status | status | title | | ------ | ------------------------------------------------------- | | ⚠ | [todo overdue](:/722c80cb665549fb94472d4802cfbdc5) | | 🗹 | [todo completed](:/6adfa0f5c5ab4642bc696db08a212baf) | | ☐ | [todo with duedate](:/27de5a7fa4424ad993c6ee251ee88812) | | ☐ | [todo open](:/01bca8a69a9341cabcba59531c0cad8e) | | ☐ | [note 1](:/1809922cc3fa49c1bf8f045cbf6f8e55) | ### Expected result as note do not have status (`overdue`, `open` or `done`), note status should be empty. | status | title | | ------ | ------------------------------------------------------- | | ⚠ | [todo overdue](:/722c80cb665549fb94472d4802cfbdc5) | | 🗹 | [todo completed](:/6adfa0f5c5ab4642bc696db08a212baf) | | ☐ | [todo with duedate](:/27de5a7fa4424ad993c6ee251ee88812) | | ☐ | [todo open](:/01bca8a69a9341cabcba59531c0cad8e) | | | [note 1](:/1809922cc3fa49c1bf8f045cbf6f8e55) | --- README.md | 14 ++++++++++++ __test__/data/options/note_status.yml | 6 +++++ __test__/fields.test.ts | 32 +++++++++++++++++++++++++++ src/noteoverview.ts | 17 +++++++++----- 4 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 __test__/data/options/note_status.yml diff --git a/README.md b/README.md index 0388169..2041001 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ A note overview is created based on the defined search and the specified fields. - [count](#count) - [listview](#listview) - [link](#link) + - [status](#status) - [Examples](#examples) - [ToDo Overview](#todo-overview) - [Show all ToDos with status](#show-all-todos-with-status) @@ -272,6 +273,19 @@ link: html: true ``` +### status + +Customize note status field for a single overview. + +```yml +status: + note: "" + todo: + open: "☐" + done: "🗹" + overdue: "⚠" +``` + ## Examples ### ToDo Overview diff --git a/__test__/data/options/note_status.yml b/__test__/data/options/note_status.yml new file mode 100644 index 0000000..99258d0 --- /dev/null +++ b/__test__/data/options/note_status.yml @@ -0,0 +1,6 @@ +status: + note: "n" + todo: + open: "o" + done: "d" + overdue: "od" diff --git a/__test__/fields.test.ts b/__test__/fields.test.ts index 881a794..45f7441 100644 --- a/__test__/fields.test.ts +++ b/__test__/fields.test.ts @@ -42,3 +42,35 @@ describe("Field function", function () { expect(result).toBe("[Link](" + fields["source_url"] + ")"); }); }); + +describe("note status text", function () { + it(`Status `, async () => { + const options = getOptionsFromFile("note_status"); + const optionsObject = await noteoverview.getOptions(options); + + const now = new Date().getTime(); + const testCases = [ + [0, 0, 0, "n"], + [1, 0, 0, "o"], + [1, 0, now, "d"], + [1, now - 86400, 0, "od"], + [1, now + 86400, now - 86400, "d"], + [1, now - 86400, now + 86400, "d"], + ]; + + for (const t of testCases) { + const fields: Object = { + is_todo: Number(t[0]), + todo_due: Number(t[1]), + todo_completed: Number(t[2]), + }; + const expected = t[3]; + const actual = await noteoverview.getFieldValue( + "status", + fields, + optionsObject + ); + expect(actual).toBe(expected); + } + }); +}); diff --git a/src/noteoverview.ts b/src/noteoverview.ts index c2aa464..9d59fc6 100644 --- a/src/noteoverview.ts +++ b/src/noteoverview.ts @@ -310,6 +310,7 @@ export namespace noteoverview { export async function getDefaultStatusText(): Promise { let status = { + note: "", todo: { overdue: await joplin.settings.value("todoStatusOverdue"), open: await joplin.settings.value("todoStatusOpen"), @@ -912,7 +913,7 @@ export namespace noteoverview { try { queryNotes = await joplin.data.get(["search"], { query: query, - fields: "id, parent_id, " + dbFieldsArray.join(","), + fields: "id, parent_id, is_todo, " + dbFieldsArray.join(","), order_by: options.orderBy, order_dir: options.orderDir.toUpperCase(), limit: 50, @@ -1178,11 +1179,15 @@ export namespace noteoverview { } break; case "status": - const status: string = await noteoverview.getToDoStatus( - fields["todo_due"], - fields["todo_completed"] - ); - value = options.statusText["todo"][status]; + if (!!fields["is_todo"]) { + const status: string = await noteoverview.getToDoStatus( + fields["todo_due"], + fields["todo_completed"] + ); + value = options.statusText["todo"][status]; + } else { + value = options.statusText["note"]; + } break; case "excerpt": value = await noteoverview.getMarkdownExcerpt( From 91de002736610a101780cdcb894aa13598f5f08f Mon Sep 17 00:00:00 2001 From: Andry Yosua Date: Mon, 18 Dec 2023 13:57:04 +0700 Subject: [PATCH 3/6] add adjustments --- README.md | 1 + src/noteoverview.ts | 5 +++-- src/settings.ts | 9 +++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2041001..c822a84 100644 --- a/README.md +++ b/README.md @@ -470,6 +470,7 @@ Settings for the plugin, accessible at `Tools > Options > Note overview`. | `Note count text` | Text for the display of the found notes, `{{count}}` is replace with the number of matched notes. | `Note count: {{count}}` | | `Update interval in minutes` | How often the overview notes should be updated. | `5` | | `Update on Joplin sync` | Update the Noteoverview after a Joplin syncronisation. Independent of the update interval. | `No` | +| `Field status: note` | Text for the `status` field, for note. | | | `Field status: open todo` | Text for the `status` field, when the todo is not completed. | | | `Field status: todo completed` | Text for the `status` field, when the todo is completed. | | | `Field status: todo over due` | Text for the `status` field, when the due date of the todo is exceeded. | | diff --git a/src/noteoverview.ts b/src/noteoverview.ts index 9d59fc6..66639f3 100644 --- a/src/noteoverview.ts +++ b/src/noteoverview.ts @@ -310,7 +310,7 @@ export namespace noteoverview { export async function getDefaultStatusText(): Promise { let status = { - note: "", + note: await joplin.settings.value("noteStatus"), todo: { overdue: await joplin.settings.value("todoStatusOverdue"), open: await joplin.settings.value("todoStatusOpen"), @@ -843,6 +843,7 @@ export namespace noteoverview { if (fields.includes("status")) { additionalFields.push("todo_due"); additionalFields.push("todo_completed"); + additionalFields.push("is_todo"); } // include body @@ -913,7 +914,7 @@ export namespace noteoverview { try { queryNotes = await joplin.data.get(["search"], { query: query, - fields: "id, parent_id, is_todo, " + dbFieldsArray.join(","), + fields: "id, parent_id, " + dbFieldsArray.join(","), order_by: options.orderBy, order_dir: options.orderDir.toUpperCase(), limit: 50, diff --git a/src/settings.ts b/src/settings.ts index 191fda7..046572a 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -57,6 +57,15 @@ export namespace settings { "Text for the display of the found notes, {{count}} is replace with the number of matched notes", }, + noteStatus: { + value: "", + advanced: true, + type: SettingItemType.String, + section: "noteOverviewSection", + public: true, + label: "Field status: note", + description: "Text for the status field, for note.", + }, todoStatusOpen: { value: "", advanced: true, From 6a6939959d8e1c8b0816d8edbbbf5ac3fd019017 Mon Sep 17 00:00:00 2001 From: JackGruber <24863925+JackGruber@users.noreply.github.com> Date: Mon, 18 Dec 2023 17:42:17 +0100 Subject: [PATCH 4/6] Correct YAML --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3571626..d620184 100644 --- a/README.md +++ b/README.md @@ -282,9 +282,9 @@ Customize note status field for a single overview. status: note: "" todo: - open: "☐" - done: "🗹" - overdue: "⚠" + open: ☐ + done: 🗹 + overdue: ⚠ ``` ## Examples From 133e2fed37edddf1caabd733b49669d8ade9236d Mon Sep 17 00:00:00 2001 From: JackGruber <24863925+JackGruber@users.noreply.github.com> Date: Mon, 18 Dec 2023 17:43:58 +0100 Subject: [PATCH 5/6] Add translation --- src/locales/de_DE.json | 4 ++++ src/locales/en_US.json | 4 ++++ src/settings.ts | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/locales/de_DE.json b/src/locales/de_DE.json index e85ef60..4388f2a 100644 --- a/src/locales/de_DE.json +++ b/src/locales/de_DE.json @@ -66,6 +66,10 @@ "label": "Farbe: %s", "description": "HTML Farbe für das Abschlussdatum (%s), wenn die Aufgabe abgeschlossen wurde, aber kein Fälligkeitsdatum gesetzt wurde" }, + "noteStatus": { + "label": "Feld status: %s", + "description": "Text für das Statusfeld wenn es sich um eine Notiz und keine Aufgabe handelt" + }, "fileLogLevel": { "label": "Loglevel", "description": "Einstellung für das Loglevel", diff --git a/src/locales/en_US.json b/src/locales/en_US.json index 19ab491..b932094 100644 --- a/src/locales/en_US.json +++ b/src/locales/en_US.json @@ -65,6 +65,10 @@ "label": "Color: %s", "description": "HTML color for the %s, when the todo was completed but no due date was set" }, + "noteStatus": { + "label": "Field status: %s", + "description": "Text for the status field if it is a note and not a todo" + }, "fileLogLevel": { "label": "Loglevel", "description": "Setting for the Loglevel", diff --git a/src/settings.ts b/src/settings.ts index 7a44da5..2db83af 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -66,8 +66,8 @@ export namespace settings { type: SettingItemType.String, section: "noteOverviewSection", public: true, - label: "Field status: note", - description: "Text for the status field, for note.", + label: i18n.__("settings.noteStatus.label", "note"), + description: i18n.__("settings.noteStatus.description"), }, todoStatusOpen: { value: "", From 4864fc29d8a0ab3651793caff7727f1f5fd2b6d6 Mon Sep 17 00:00:00 2001 From: JackGruber <24863925+JackGruber@users.noreply.github.com> Date: Mon, 18 Dec 2023 17:47:20 +0100 Subject: [PATCH 6/6] Add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c31fc1a..6fdb2eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Add: Translation - Fix: #67 HTML image tags are not recognized for `image` option - Add: Option to disable automatic update of a note overview #57 +- Add: Option to configure the `status` field per note overview #66 @aiosk ## v1.6.0 (2022-12-26)