mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Handle case when note is deleted while being edited. Show note on map.
This commit is contained in:
parent
4f7edf8371
commit
729b8f7c79
@ -81,6 +81,8 @@ class Application {
|
||||
}
|
||||
|
||||
async loadItems(type, pattern, options = null) {
|
||||
pattern = pattern ? pattern.toString() : '';
|
||||
|
||||
if (type == BaseModel.TYPE_FOLDER && (pattern == Folder.conflictFolderTitle() || pattern == Folder.conflictFolderId())) return [Folder.conflictFolder()];
|
||||
|
||||
if (!options) options = {};
|
||||
|
@ -15,52 +15,52 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:92
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:94
|
||||
msgid "No notebook selected."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:97
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:99
|
||||
msgid "No notebook has been specified."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:128
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:130
|
||||
msgid "Usage: --profile <dir-path>"
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:135
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:137
|
||||
msgid "Usage: --env <dev|prod>"
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:160
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:162
|
||||
msgid "Usage: --log-level <none|error|warn|info|debug>"
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:167
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:169
|
||||
#, javascript-format
|
||||
msgid "Unknown flag: %s"
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:183
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:185
|
||||
#, javascript-format
|
||||
msgid ""
|
||||
"Command line argument \"%s\" contains both quotes and double-quotes - "
|
||||
"aborting."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:203
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:205
|
||||
msgid "Provides help for a given command."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:205
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:207
|
||||
msgid "Exits the application."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:337
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:339
|
||||
#, javascript-format
|
||||
msgid "Synchronizing with directory \"%s\""
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:420
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:422
|
||||
msgid "No notebook is defined. Create one with `mkbook <notebook>`."
|
||||
msgstr ""
|
||||
|
||||
@ -553,7 +553,7 @@ msgstr ""
|
||||
msgid "Show metadata"
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:395
|
||||
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:409
|
||||
msgid "Edit"
|
||||
msgstr ""
|
||||
|
||||
|
@ -15,32 +15,32 @@ msgstr ""
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.8.7.1\n"
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:92
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:94
|
||||
msgid "No notebook selected."
|
||||
msgstr "Aucun carnet n'est sélectionné."
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:97
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:99
|
||||
msgid "No notebook has been specified."
|
||||
msgstr "Aucun carnet n'est spécifié."
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:128
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:130
|
||||
msgid "Usage: --profile <dir-path>"
|
||||
msgstr "Utilisation: --profile <chemin>"
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:135
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:137
|
||||
msgid "Usage: --env <dev|prod>"
|
||||
msgstr "Utilisation : --env <dev|prod>"
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:160
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:162
|
||||
msgid "Usage: --log-level <none|error|warn|info|debug>"
|
||||
msgstr "Utilisation: --log-level <none|error|warn|info|debug>"
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:167
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:169
|
||||
#, javascript-format
|
||||
msgid "Unknown flag: %s"
|
||||
msgstr "Paramètre inconnu : %s"
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:183
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:185
|
||||
#, javascript-format
|
||||
msgid ""
|
||||
"Command line argument \"%s\" contains both quotes and double-quotes - "
|
||||
@ -49,20 +49,20 @@ msgstr ""
|
||||
"Paramètre de ligne de command \"%s\" contient à la fois des guillemets "
|
||||
"simples et doubles - impossible de continuer."
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:203
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:205
|
||||
msgid "Provides help for a given command."
|
||||
msgstr "Affiche l'aide pour la commande donnée."
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:205
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:207
|
||||
msgid "Exits the application."
|
||||
msgstr "Quitter le logiciel."
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:337
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:339
|
||||
#, javascript-format
|
||||
msgid "Synchronizing with directory \"%s\""
|
||||
msgstr "Synchronisation avec dossier \"%s\""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:420
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:422
|
||||
msgid "No notebook is defined. Create one with `mkbook <notebook>`."
|
||||
msgstr "Aucun carnet n'est défini. Créez-en un avec `mkbook <carnet>`."
|
||||
|
||||
@ -593,7 +593,7 @@ msgstr ""
|
||||
msgid "Show metadata"
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:395
|
||||
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:409
|
||||
msgid "Edit"
|
||||
msgstr ""
|
||||
|
||||
|
@ -15,52 +15,52 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:92
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:94
|
||||
msgid "No notebook selected."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:97
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:99
|
||||
msgid "No notebook has been specified."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:128
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:130
|
||||
msgid "Usage: --profile <dir-path>"
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:135
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:137
|
||||
msgid "Usage: --env <dev|prod>"
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:160
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:162
|
||||
msgid "Usage: --log-level <none|error|warn|info|debug>"
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:167
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:169
|
||||
#, javascript-format
|
||||
msgid "Unknown flag: %s"
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:183
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:185
|
||||
#, javascript-format
|
||||
msgid ""
|
||||
"Command line argument \"%s\" contains both quotes and double-quotes - "
|
||||
"aborting."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:203
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:205
|
||||
msgid "Provides help for a given command."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:205
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:207
|
||||
msgid "Exits the application."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:337
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:339
|
||||
#, javascript-format
|
||||
msgid "Synchronizing with directory \"%s\""
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:420
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:422
|
||||
msgid "No notebook is defined. Create one with `mkbook <notebook>`."
|
||||
msgstr ""
|
||||
|
||||
@ -553,7 +553,7 @@ msgstr ""
|
||||
msgid "Show metadata"
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:395
|
||||
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:409
|
||||
msgid "Edit"
|
||||
msgstr ""
|
||||
|
||||
|
@ -167,9 +167,18 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
this.noteComponent_change('body', text);
|
||||
}
|
||||
|
||||
async noteExists(noteId) {
|
||||
const existingNote = await Note.load(noteId);
|
||||
return !!existingNote;
|
||||
}
|
||||
|
||||
async saveNoteButton_press() {
|
||||
let note = Object.assign({}, this.state.note);
|
||||
|
||||
// Note has been deleted while user was modifying it. In that, we
|
||||
// just save a new note by clearing the note ID.
|
||||
if (note.id && !(await this.noteExists(note.id))) delete note.id;
|
||||
|
||||
reg.logger().info('Saving note: ', note);
|
||||
|
||||
if (!note.parent_id) {
|
||||
@ -194,6 +203,33 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
reg.scheduleSync();
|
||||
}
|
||||
|
||||
async saveOneProperty(name, value) {
|
||||
let note = Object.assign({}, this.state.note);
|
||||
|
||||
// Note has been deleted while user was modifying it. In that, we
|
||||
// just save a new note by clearing the note ID.
|
||||
if (note.id && !(await this.noteExists(note.id))) delete note.id;
|
||||
|
||||
reg.logger().info('Saving note property: ', note.id, name, value);
|
||||
|
||||
if (note.id) {
|
||||
let toSave = { id: note.id };
|
||||
toSave[name] = value;
|
||||
toSave = await Note.save(toSave);
|
||||
note[name] = toSave[name];
|
||||
|
||||
this.setState({
|
||||
lastSavedNote: Object.assign({}, note),
|
||||
note: note,
|
||||
});
|
||||
|
||||
reg.scheduleSync();
|
||||
} else {
|
||||
note[name] = value;
|
||||
this.setState({ note: note });
|
||||
}
|
||||
}
|
||||
|
||||
async deleteNote_onPress() {
|
||||
let note = this.state.note;
|
||||
if (!note.id) return;
|
||||
@ -225,6 +261,18 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
this.refreshNoteMetadata(true);
|
||||
}
|
||||
|
||||
async showOnMap_onPress() {
|
||||
if (!this.state.note.id) return;
|
||||
|
||||
let note = await Note.load(this.state.note.id);
|
||||
try {
|
||||
const url = Note.geolocationUrl(note);
|
||||
Linking.openURL(url);
|
||||
} catch (error) {
|
||||
await dialogs.error(this, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
menuOptions() {
|
||||
const note = this.state.note;
|
||||
|
||||
@ -233,32 +281,10 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
{ title: _('Delete note'), onPress: () => { this.deleteNote_onPress(); } },
|
||||
{ title: note && !!note.is_todo ? _('Convert to regular note') : _('Convert to todo'), onPress: () => { this.toggleIsTodo_onPress(); } },
|
||||
{ title: this.state.showNoteMetadata ? _('Hide metadata') : _('Show metadata'), onPress: () => { this.showMetadata_onPress(); } },
|
||||
{ title: _('View location on map'), onPress: () => { this.showOnMap_onPress(); } },
|
||||
];
|
||||
}
|
||||
|
||||
async saveOneProperty(name, value) {
|
||||
let note = Object.assign({}, this.state.note);
|
||||
|
||||
reg.logger().info('Saving note property: ', note.id, name, value);
|
||||
|
||||
if (note.id) {
|
||||
let toSave = { id: note.id };
|
||||
toSave[name] = value;
|
||||
toSave = await Note.save(toSave);
|
||||
note[name] = toSave[name];
|
||||
|
||||
this.setState({
|
||||
lastSavedNote: Object.assign({}, note),
|
||||
note: note,
|
||||
});
|
||||
|
||||
reg.scheduleSync();
|
||||
} else {
|
||||
note[name] = value;
|
||||
this.setState({ note: note });
|
||||
}
|
||||
}
|
||||
|
||||
async todoCheckbox_change(checked) {
|
||||
await this.saveOneProperty('todo_completed', checked ? time.unixMs() : 0);
|
||||
reg.scheduleSync();
|
||||
|
@ -42,7 +42,7 @@ class Note extends BaseItem {
|
||||
}
|
||||
|
||||
static geolocationUrl(note) {
|
||||
if (!('latitude' in note) || !('longitude' in note)) throw new Error('Latitude or longitude missing');
|
||||
if (!('latitude' in note) || !('longitude' in note)) throw new Error('Latitude or longitude is missing');
|
||||
if (!note.latitude && !note.longitude) throw new Error(_('This note does not have geolocation information.'));
|
||||
return sprintf('https://www.openstreetmap.org/?lat=%s&lon=%s&zoom=20', note.latitude, note.longitude)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user