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

mv folder in cli

This commit is contained in:
Laurent Cozic
2017-07-17 19:19:01 +00:00
parent b124aabe2b
commit 63772629cf
5 changed files with 47 additions and 20 deletions

View File

@ -66,10 +66,7 @@ class FolderScreenComponent extends BaseScreenComponent {
let folder = Object.assign({}, this.state.folder);
try {
folder = await Folder.save(folder, {
duplicateCheck: true,
reservedTitleCheck: true,
});
folder = await Folder.save(folder, { userSideValidation: true });
reg.scheduleSync();
} catch (error) {

View File

@ -114,15 +114,29 @@ class Folder extends BaseItem {
// These "duplicateCheck" and "reservedTitleCheck" should only be done when a user is
// manually creating a folder. They shouldn't be done for example when the folders
// are being synced to avoid any strange side-effect. Technically it's possible to
// have folders and notes with duplicate titles (or no title), or with reserved words,
// are being synced to avoid any strange side-effects. Technically it's possible to
// have folders and notes with duplicate titles (or no title), or with reserved words.
static async save(o, options = null) {
if (options && options.duplicateCheck === true && o.title) {
if (!options) options = {};
if (options.userSideValidation === true) {
if (!('duplicateCheck' in options)) options.duplicateCheck = true;
if (!('reservedTitleCheck' in options)) options.reservedTitleCheck = true;
if (!('stripLeftSlashes' in options)) options.stripLeftSlashes = true;
}
if (options.stripLeftSlashes === true && o.title) {
while (o.title.length && (o.title[0] == '/' || o.title[0] == "\\")) {
o.title = o.title.substr(1);
}
}
if (options.duplicateCheck === true && o.title) {
let existingFolder = await Folder.loadByTitle(o.title);
if (existingFolder && existingFolder.id != o.id) throw new Error(_('A notebook with this title already exists: "%s"', o.title));
}
if (options && options.reservedTitleCheck === true && o.title) {
if (options.reservedTitleCheck === true && o.title) {
if (o.title == Folder.conflictFolderTitle()) throw new Error(_('Notebooks cannot be named "%s", which is a reserved title.', o.title));
}