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

Electron: Resolves #751: Allow switching between todo and note when multiple notes are selected

This commit is contained in:
Laurent Cozic
2018-10-04 18:34:30 +01:00
parent 79b6f64bd0
commit f6c5620682
3 changed files with 58 additions and 9 deletions

View File

@ -424,17 +424,25 @@ class Note extends BaseItem {
return Note.save(modifiedNote, { autoTimestamp: false });
}
static toggleIsTodo(note) {
static changeNoteType(note, type) {
if (!('is_todo' in note)) throw new Error('Missing "is_todo" property');
let output = Object.assign({}, note);
output.is_todo = output.is_todo ? 0 : 1;
const newIsTodo = type === 'todo' ? 1 : 0;
if (Number(note.is_todo) === newIsTodo) return note;
const output = Object.assign({}, note);
output.is_todo = newIsTodo;
output.todo_due = 0;
output.todo_completed = 0;
return output;
}
static toggleIsTodo(note) {
return this.changeNoteType(note, !!note.is_todo ? 'note' : 'todo');
}
static async duplicate(noteId, options = null) {
const changes = options && options.changes;
const uniqueTitle = options && options.uniqueTitle;