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

Mobile: Added duplicate option when selecting notes. (#1969)

* Adding duplicate button on screen-header.js when selecting notes; Adding 'duplicateMultipleNotes' function on Note.js;

* Using for-loop like the rest of the code does

* changing from 'uniqueTitle' to 'ensureUniqueTitle'
This commit is contained in:
Alan Martins Silva
2019-10-11 23:37:16 +01:00
committed by Laurent Cozic
parent b0a4a10dcc
commit d3e9ffcaea
2 changed files with 47 additions and 0 deletions

View File

@ -481,6 +481,25 @@ class Note extends BaseItem {
return note;
}
static async duplicateMultipleNotes(noteIds, options = null){
/*
if options.uniqueTitle is true, a unique title for the duplicated file will be assigned.
*/
const ensureUniqueTitle = options && options.ensureUniqueTitle;
for(const noteId of noteIds){
const noteOptions = {};
//If ensureUniqueTitle is truthy, set the original note's name as root for the unique title.
if(ensureUniqueTitle){
const originalNote = await Note.load(noteId);
noteOptions.uniqueTitle = originalNote.title;
}
await Note.duplicate(noteId, noteOptions);
}
}
static async duplicate(noteId, options = null) {
const changes = options && options.changes;
const uniqueTitle = options && options.uniqueTitle;