From a796a9d179685bf0346b2bcdb1963e50d78a4f34 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 28 Jun 2019 05:46:55 -0700 Subject: [PATCH] API: Support is_todo property to allow making a note a todo (#1688) --- CliClient/tests/services_rest_Api.js | 35 +++++++++++++++++++++- ReactNativeClient/lib/services/rest/Api.js | 3 +- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/CliClient/tests/services_rest_Api.js b/CliClient/tests/services_rest_Api.js index 815d6f08e..27ce5814a 100644 --- a/CliClient/tests/services_rest_Api.js +++ b/CliClient/tests/services_rest_Api.js @@ -189,6 +189,39 @@ describe('services_rest_Api', function() { done(); }); + it('should create todos', async (done) => { + let response = null; + const f = await Folder.save({ title: "stuff to do" }); + + response = await api.route('POST', 'notes', null, JSON.stringify({ + title: 'testing', + parent_id: f.id, + is_todo: 1 + })); + expect(response.is_todo).toBe(1); + + response = await api.route('POST', 'notes', null, JSON.stringify({ + title: 'testing 2', + parent_id: f.id, + is_todo: 0 + })); + expect(response.is_todo).toBe(0); + + response = await api.route('POST', 'notes', null, JSON.stringify({ + title: 'testing 3', + parent_id: f.id, + })); + expect(response.is_todo).toBeUndefined(); + + response = await api.route('POST', 'notes', null, JSON.stringify({ + title: 'testing 4', + parent_id: f.id, + is_todo: '1' + })); + expect(response.is_todo).toBe(1); + done(); + }); + it('should create folders with supplied ID', async (done) => { const response = await api.route('POST', 'folders', null, JSON.stringify({ id: '12345678123456781234567812345678', @@ -316,4 +349,4 @@ describe('services_rest_Api', function() { done(); }); -}); \ No newline at end of file +}); diff --git a/ReactNativeClient/lib/services/rest/Api.js b/ReactNativeClient/lib/services/rest/Api.js index b27cdbe20..0de139809 100644 --- a/ReactNativeClient/lib/services/rest/Api.js +++ b/ReactNativeClient/lib/services/rest/Api.js @@ -456,6 +456,7 @@ class Api { if ('author' in requestNote) output.author = requestNote.author; if ('user_updated_time' in requestNote) output.user_updated_time = Database.formatValue(Database.TYPE_INT, requestNote.user_updated_time); if ('user_created_time' in requestNote) output.user_created_time = Database.formatValue(Database.TYPE_INT, requestNote.user_created_time); + if ('is_todo' in requestNote) output.is_todo = Database.formatValue(Database.TYPE_INT, requestNote.is_todo); return output; } @@ -590,4 +591,4 @@ class Api { } -module.exports = Api; \ No newline at end of file +module.exports = Api;