Fixed import-enex logic

pull/41/head
Laurent Cozic 2017-07-31 18:57:31 +00:00
parent 4a7e8cdbaa
commit bc2fa8932a
6 changed files with 63 additions and 32 deletions

View File

@ -29,29 +29,11 @@ class Command extends BaseCommand {
let folderTitle = args['notebook'];
let force = args.options.force === true;
if (folderTitle) {
folder = await Folder.loadByField('title', folderTitle);
if (!folder) {
let ok = force ? true : await vorpalUtils.cmdPromptConfirm(this, _('Folder does not exists: "%s". Create it?', folderTitle))
if (!ok) return;
if (!folderTitle) folderTitle = filename(filePath);
folder = await Folder.loadByField('title', folderTitle);
const msg = folder ? _('File "%s" will be imported into existing notebook "%s". Continue?', basename(filePath), folderTitle) : _('New notebook "%s" will be created and file "%s" will be imported into it. Continue?', folderTitle, basename(filePath));
const ok = force ? true : await vorpalUtils.cmdPromptConfirm(this, msg);
folder = await Folder.save({ title: folderTitle });
}
} else {
folderTitle = filename(filePath);
let inc = 0;
while (true) {
let t = folderTitle + (inc ? ' (' + inc + ')' : '');
let f = await Folder.loadByField('title', t);
if (!f) {
folderTitle = t;
break;
}
inc++;
}
}
let ok = force ? true : await vorpalUtils.cmdPromptConfirm(this, _('File "%s" will be imported into notebook "%s". Continue?', basename(filePath), folderTitle))
if (!ok) return;
let options = {

View File

@ -2,7 +2,6 @@ import { BaseCommand } from './base-command.js';
import { app } from './app.js';
import { _ } from 'lib/locale.js';
import { Note } from 'lib/models/note.js';
import { reg } from 'lib/registry.js';
class Command extends BaseCommand {

View File

@ -0,0 +1,31 @@
import { BaseCommand } from './base-command.js';
import { app } from './app.js';
import { _ } from 'lib/locale.js';
import { Note } from 'lib/models/note.js';
class Command extends BaseCommand {
usage() {
return 'mktodo <note>';
}
description() {
return _('Creates a new todo.');
}
async action(args) {
if (!app().currentFolder()) throw new Error(_('Notes can only be created within a notebook.'));
let note = {
title: args.note,
parent_id: app().currentFolder().id,
is_todo: 1,
};
note = await Note.save(note);
Note.updateGeolocation(note.id);
}
}
module.exports = Command;

View File

@ -145,11 +145,13 @@ msgid "Do not ask for confirmation."
msgstr ""
#, javascript-format
msgid "Folder does not exists: \"%s\". Create it?"
msgid "File \"%s\" will be imported into existing notebook \"%s\". Continue?"
msgstr ""
#, javascript-format
msgid "File \"%s\" will be imported into notebook \"%s\". Continue?"
msgid ""
"New notebook \"%s\" will be created and file \"%s\" will be imported into "
"it. Continue?"
msgstr ""
#, javascript-format
@ -219,6 +221,9 @@ msgstr ""
msgid "Notes can only be created within a notebook."
msgstr ""
msgid "Creates a new todo."
msgstr ""
msgid ""
"Moves the notes matching <pattern> to <destination>. If <pattern> is a note, "
"it will be moved to the notebook <destination>. If <pattern> is a notebook, "

View File

@ -155,12 +155,14 @@ msgstr "Importer un carnet Evernote (fichier .enex)."
msgid "Do not ask for confirmation."
msgstr "Ne pas demander de confirmation."
#, javascript-format
msgid "Folder does not exists: \"%s\". Create it?"
msgstr "Ce carnet n'existe pas : \"%s\". Le créer ?"
#, fuzzy, javascript-format
msgid "File \"%s\" will be imported into existing notebook \"%s\". Continue?"
msgstr "Le fichier \"%s\" va être importé dans le carnet \"%s\". Continuer ?"
#, javascript-format
msgid "File \"%s\" will be imported into notebook \"%s\". Continue?"
#, fuzzy, javascript-format
msgid ""
"New notebook \"%s\" will be created and file \"%s\" will be imported into "
"it. Continue?"
msgstr "Le fichier \"%s\" va être importé dans le carnet \"%s\". Continuer ?"
#, javascript-format
@ -238,6 +240,10 @@ msgstr "Créer une note."
msgid "Notes can only be created within a notebook."
msgstr "Les notes ne peuvent être créées que dans un carnet."
#, fuzzy
msgid "Creates a new todo."
msgstr "Créer un carnet."
msgid ""
"Moves the notes matching <pattern> to <destination>. If <pattern> is a note, "
"it will be moved to the notebook <destination>. If <pattern> is a notebook, "
@ -599,6 +605,9 @@ msgstr ""
msgid "Welcome"
msgstr "Bienvenu"
#~ msgid "Folder does not exists: \"%s\". Create it?"
#~ msgstr "Ce carnet n'existe pas : \"%s\". Le créer ?"
#~ msgid "Usage: --profile <dir-path>"
#~ msgstr "Utilisation: --profile <chemin>"

View File

@ -145,11 +145,13 @@ msgid "Do not ask for confirmation."
msgstr ""
#, javascript-format
msgid "Folder does not exists: \"%s\". Create it?"
msgid "File \"%s\" will be imported into existing notebook \"%s\". Continue?"
msgstr ""
#, javascript-format
msgid "File \"%s\" will be imported into notebook \"%s\". Continue?"
msgid ""
"New notebook \"%s\" will be created and file \"%s\" will be imported into "
"it. Continue?"
msgstr ""
#, javascript-format
@ -219,6 +221,9 @@ msgstr ""
msgid "Notes can only be created within a notebook."
msgstr ""
msgid "Creates a new todo."
msgstr ""
msgid ""
"Moves the notes matching <pattern> to <destination>. If <pattern> is a note, "
"it will be moved to the notebook <destination>. If <pattern> is a notebook, "