1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-06 09:19:22 +02:00

Fixed import-enex logic

This commit is contained in:
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 folderTitle = args['notebook'];
let force = args.options.force === true; let force = args.options.force === true;
if (folderTitle) { if (!folderTitle) folderTitle = filename(filePath);
folder = await Folder.loadByField('title', folderTitle); folder = await Folder.loadByField('title', folderTitle);
if (!folder) { 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));
let ok = force ? true : await vorpalUtils.cmdPromptConfirm(this, _('Folder does not exists: "%s". Create it?', folderTitle)) const ok = force ? true : await vorpalUtils.cmdPromptConfirm(this, msg);
if (!ok) return;
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; if (!ok) return;
let options = { let options = {

View File

@@ -2,7 +2,6 @@ import { BaseCommand } from './base-command.js';
import { app } from './app.js'; import { app } from './app.js';
import { _ } from 'lib/locale.js'; import { _ } from 'lib/locale.js';
import { Note } from 'lib/models/note.js'; import { Note } from 'lib/models/note.js';
import { reg } from 'lib/registry.js';
class Command extends BaseCommand { 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 "" msgstr ""
#, javascript-format #, javascript-format
msgid "Folder does not exists: \"%s\". Create it?" msgid "File \"%s\" will be imported into existing notebook \"%s\". Continue?"
msgstr "" msgstr ""
#, javascript-format #, 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 "" msgstr ""
#, javascript-format #, javascript-format
@@ -219,6 +221,9 @@ msgstr ""
msgid "Notes can only be created within a notebook." msgid "Notes can only be created within a notebook."
msgstr "" msgstr ""
msgid "Creates a new todo."
msgstr ""
msgid "" msgid ""
"Moves the notes matching <pattern> to <destination>. If <pattern> is a note, " "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, " "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." msgid "Do not ask for confirmation."
msgstr "Ne pas demander de confirmation." msgstr "Ne pas demander de confirmation."
#, javascript-format #, fuzzy, javascript-format
msgid "Folder does not exists: \"%s\". Create it?" msgid "File \"%s\" will be imported into existing notebook \"%s\". Continue?"
msgstr "Ce carnet n'existe pas : \"%s\". Le créer ?" msgstr "Le fichier \"%s\" va être importé dans le carnet \"%s\". Continuer ?"
#, javascript-format #, fuzzy, 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 "Le fichier \"%s\" va être importé dans le carnet \"%s\". Continuer ?" msgstr "Le fichier \"%s\" va être importé dans le carnet \"%s\". Continuer ?"
#, javascript-format #, javascript-format
@@ -238,6 +240,10 @@ msgstr "Créer une note."
msgid "Notes can only be created within a notebook." msgid "Notes can only be created within a notebook."
msgstr "Les notes ne peuvent être créées que dans un carnet." msgstr "Les notes ne peuvent être créées que dans un carnet."
#, fuzzy
msgid "Creates a new todo."
msgstr "Créer un carnet."
msgid "" msgid ""
"Moves the notes matching <pattern> to <destination>. If <pattern> is a note, " "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, " "it will be moved to the notebook <destination>. If <pattern> is a notebook, "
@@ -599,6 +605,9 @@ msgstr ""
msgid "Welcome" msgid "Welcome"
msgstr "Bienvenu" 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>" #~ msgid "Usage: --profile <dir-path>"
#~ msgstr "Utilisation: --profile <chemin>" #~ msgstr "Utilisation: --profile <chemin>"

View File

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