mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
parent
3bda77d504
commit
5c7dcf0117
@ -13,7 +13,6 @@ const Menu = bridge().Menu;
|
|||||||
const MenuItem = bridge().MenuItem;
|
const MenuItem = bridge().MenuItem;
|
||||||
import Note from '@joplin/lib/models/Note';
|
import Note from '@joplin/lib/models/Note';
|
||||||
import Setting from '@joplin/lib/models/Setting';
|
import Setting from '@joplin/lib/models/Setting';
|
||||||
const { substrWithEllipsis } = require('@joplin/lib/string-utils');
|
|
||||||
|
|
||||||
interface ContextMenuProps {
|
interface ContextMenuProps {
|
||||||
notes: any[];
|
notes: any[];
|
||||||
@ -204,14 +203,8 @@ export default class NoteListUtils {
|
|||||||
static async confirmDeleteNotes(noteIds: string[]) {
|
static async confirmDeleteNotes(noteIds: string[]) {
|
||||||
if (!noteIds.length) return;
|
if (!noteIds.length) return;
|
||||||
|
|
||||||
let msg = '';
|
const msg = await Note.deleteMessage(noteIds);
|
||||||
if (noteIds.length === 1) {
|
if (!msg) return;
|
||||||
const note = await Note.load(noteIds[0]);
|
|
||||||
if (!note) return;
|
|
||||||
msg = _('Delete note "%s"?', substrWithEllipsis(note.title, 0, 32));
|
|
||||||
} else {
|
|
||||||
msg = _('Delete these %d notes?', noteIds.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
const ok = bridge().showConfirmMessageBox(msg, {
|
const ok = bridge().showConfirmMessageBox(msg, {
|
||||||
buttons: [_('Delete'), _('Cancel')],
|
buttons: [_('Delete'), _('Cancel')],
|
||||||
|
@ -184,10 +184,14 @@ class ScreenHeaderComponent extends React.PureComponent {
|
|||||||
async deleteButton_press() {
|
async deleteButton_press() {
|
||||||
// Dialog needs to be displayed as a child of the parent component, otherwise
|
// Dialog needs to be displayed as a child of the parent component, otherwise
|
||||||
// it won't be visible within the header component.
|
// it won't be visible within the header component.
|
||||||
const ok = await dialogs.confirm(this.props.parentComponent, _('Delete these notes?'));
|
const noteIds = this.props.selectedNoteIds;
|
||||||
|
|
||||||
|
const msg = await Note.deleteMessage(noteIds);
|
||||||
|
if (!msg) return;
|
||||||
|
|
||||||
|
const ok = await dialogs.confirm(this.props.parentComponent, msg);
|
||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
|
|
||||||
const noteIds = this.props.selectedNoteIds;
|
|
||||||
this.props.dispatch({ type: 'NOTE_SELECTION_END' });
|
this.props.dispatch({ type: 'NOTE_SELECTION_END' });
|
||||||
await Note.batchDelete(noteIds);
|
await Note.batchDelete(noteIds);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import Tag from './Tag';
|
|||||||
|
|
||||||
const { sprintf } = require('sprintf-js');
|
const { sprintf } = require('sprintf-js');
|
||||||
import Resource from './Resource';
|
import Resource from './Resource';
|
||||||
const { pregQuote } = require('../string-utils.js');
|
const { pregQuote, substrWithEllipsis } = require('../string-utils.js');
|
||||||
const { _ } = require('../locale');
|
const { _ } = require('../locale');
|
||||||
const ArrayUtils = require('../ArrayUtils.js');
|
const ArrayUtils = require('../ArrayUtils.js');
|
||||||
const lodash = require('lodash');
|
const lodash = require('lodash');
|
||||||
@ -731,6 +731,18 @@ export default class Note extends BaseItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async deleteMessage(noteIds: string[]): Promise<string|null> {
|
||||||
|
let msg = '';
|
||||||
|
if (noteIds.length === 1) {
|
||||||
|
const note = await Note.load(noteIds[0]);
|
||||||
|
if (!note) return null;
|
||||||
|
msg = _('Delete note "%s"?', substrWithEllipsis(note.title, 0, 32));
|
||||||
|
} else {
|
||||||
|
msg = _('Delete these %d notes?', noteIds.length);
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
static dueNotes() {
|
static dueNotes() {
|
||||||
return this.modelSelectAll('SELECT id, title, body, is_todo, todo_due, todo_completed, is_conflict FROM notes WHERE is_conflict = 0 AND is_todo = 1 AND todo_completed = 0 AND todo_due > ?', [time.unixMs()]);
|
return this.modelSelectAll('SELECT id, title, body, is_todo, todo_due, todo_completed, is_conflict FROM notes WHERE is_conflict = 0 AND is_todo = 1 AND todo_completed = 0 AND todo_due > ?', [time.unixMs()]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user