1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-18 23:07:45 +02:00

API: Resolves #941: Add support for "tags" property for note PUT request (#2649)

* API: Fix updation of tags when updating a note

* Add test for fix updation of tags

* Rewrite unit test and change variable name

* Use consistent variables and function calls

* Use default function call and change variable

* Handle case when tags is empty string

* Restructure test cases and improve tags check

* Update documentation
This commit is contained in:
Yuvaraj J
2020-03-14 00:14:47 +05:30
committed by GitHub
parent 8e2ba0d963
commit cda837247a
3 changed files with 102 additions and 5 deletions

View File

@ -451,6 +451,22 @@ class Api {
return note;
}
if (request.method === 'PUT') {
const note = await Note.load(id);
if (!note) throw new ErrorNotFound();
let updatedNote = await this.defaultAction_(BaseModel.TYPE_NOTE, request, id, link);
const requestNote = JSON.parse(request.body);
if (requestNote.tags || requestNote.tags === '') {
const tagTitles = requestNote.tags.split(',');
await Tag.setNoteTagsByTitles(id, tagTitles);
}
return updatedNote;
}
return this.defaultAction_(BaseModel.TYPE_NOTE, request, id, link);
}