A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
feat: add tag/color renaming
thecodrr1117d16e725d
diff --git a/packages/core/__tests__/tags.test.js b/packages/core/__tests__/tags.test.jsindex 9949f3b17..9d9988875 100644--- a/packages/core/__tests__/tags.test.js+++ b/packages/core/__tests__/tags.test.js@@ -18,7 +18,7 @@ describe.each([])("%s", (action, unaction, filter, value) => {let check = action === "tag" ? checkTagValue : checkColorValue;let collection = action === "tag" ? "tags" : "colors";- let key = action === "tag" ? "tags" : "color";+ // let key = action === "tag" ? "tags" : "color";test(`${action} a note`, () =>noteTest().then(async ({ db, id }) => {@@ -68,4 +68,14 @@ describe.each([const filteredNotes = db.notes[filter](tag.id);check(db.notes.note(filteredNotes[0]), value);}));++ test(`rename a ${action}`, () =>+ noteTest().then(async ({ db, id }) => {+ let note = db.notes.note(id);+ await note[action](value);+ let tag = db[collection].tag(value);+ await db[collection].rename(tag.id, value + "-new");+ tag = db[collection].tag(tag.id);+ expect(tag.alias).toBe(value + "-new");+ }));});diff --git a/packages/core/collections/tags.js b/packages/core/collections/tags.jsindex b60c87053..87f967b8a 100644--- a/packages/core/collections/tags.js+++ b/packages/core/collections/tags.js@@ -30,6 +30,7 @@ export default class Tags extends Collection {tag = {type: "tag",+ alias: tag.title,id,title: tag.title,noteIds: [...notes, noteId],@@ -39,6 +40,16 @@ export default class Tags extends Collection {return tag;}+ async rename(tagId, newName) {+ let tag = this.all.find((t) => t.id === tagId);+ if (!tag) {+ console.error(`No such tag found. Tag id:`, tagId);+ return;+ }+ tag.alias = newName;+ await this._collection.updateItem(tag);+ }+get raw() {return this._collection.getRaw();}