1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

Delete folders and tags

This commit is contained in:
Laurent Cozic
2017-11-08 21:22:24 +00:00
parent 7d12da27ad
commit e3554c7aec
20 changed files with 176 additions and 92 deletions

View File

@@ -143,7 +143,7 @@ class Folder extends BaseItem {
return super.save(o, options).then((folder) => {
this.dispatch({
type: 'FOLDERS_UPDATE_ONE',
type: 'FOLDER_UPDATE_ONE',
folder: folder,
});
return folder;

View File

@@ -386,7 +386,7 @@ class Note extends BaseItem {
return super.save(o, options).then((note) => {
this.dispatch({
type: 'NOTES_UPDATE_ONE',
type: 'NOTE_UPDATE_ONE',
note: note,
});
@@ -398,7 +398,7 @@ class Note extends BaseItem {
let r = await super.delete(id, options);
this.dispatch({
type: 'NOTES_DELETE',
type: 'NOTE_DELETE',
noteId: id,
});
}
@@ -407,7 +407,7 @@ class Note extends BaseItem {
const result = super.batchDelete(ids, options);
for (let i = 0; i < ids.length; i++) {
this.dispatch({
type: 'NOTES_DELETE',
type: 'NOTE_DELETE',
noteId: ids[i],
});
}

View File

@@ -80,7 +80,7 @@ class Setting extends BaseModel {
}
this.dispatch({
type: 'SETTINGS_UPDATE_ALL',
type: 'SETTING_UPDATE_ALL',
settings: keyToValues,
});
}
@@ -113,7 +113,7 @@ class Setting extends BaseModel {
c.value = this.formatValue(key, value);
this.dispatch({
type: 'SETTINGS_UPDATE_ONE',
type: 'SETTING_UPDATE_ONE',
key: key,
value: c.value,
});
@@ -129,7 +129,7 @@ class Setting extends BaseModel {
});
this.dispatch({
type: 'SETTINGS_UPDATE_ONE',
type: 'SETTING_UPDATE_ONE',
key: key,
value: this.formatValue(key, value),
});

View File

@@ -39,6 +39,30 @@ class Tag extends BaseItem {
});
}
// Untag all the notes and delete tag
static async untagAll(tagId) {
const noteTags = await NoteTag.modelSelectAll('SELECT id FROM note_tags WHERE tag_id = ?', [tagId]);
for (let i = 0; i < noteTags.length; i++) {
await NoteTag.delete(noteTags[i].id);
}
const tags = await Tag.allWithNotes();
this.dispatch({
type: 'TAG_UPDATE_ALL',
tags: tags,
});
this.dispatch({
type: 'TAG_SELECT',
id: null,
});
// Currently not actually deleting it as the reducer would need to be updated. The
// tag will stay in the db but just won't show up in the UI.
//await Tag.delete(tagId);
}
static async addNote(tagId, noteId) {
let hasIt = await this.hasNote(tagId, noteId);
if (hasIt) return;
@@ -49,7 +73,7 @@ class Tag extends BaseItem {
});
this.dispatch({
type: 'TAGS_UPDATE_ONE',
type: 'TAG_UPDATE_ONE',
tag: await Tag.load(tagId),
});
@@ -63,7 +87,7 @@ class Tag extends BaseItem {
}
this.dispatch({
type: 'TAGS_UPDATE_ONE',
type: 'TAG_UPDATE_ONE',
tag: await Tag.load(tagId),
});
}
@@ -80,7 +104,7 @@ class Tag extends BaseItem {
static async save(o, options = null) {
return super.save(o, options).then((tag) => {
this.dispatch({
type: 'TAGS_UPDATE_ONE',
type: 'TAG_UPDATE_ONE',
tag: tag,
});
return tag;