Electron: When deleting tag that is currently selected, select a new tag or folder

pull/41/head
Laurent Cozic 2017-11-12 17:37:04 +00:00
parent f9a06bb5b9
commit 6d2a5a7b32
6 changed files with 69 additions and 22 deletions

View File

@ -469,6 +469,9 @@ msgstr ""
msgid "Search:"
msgstr ""
msgid "File"
msgstr ""
msgid "New note"
msgstr ""
@ -556,6 +559,15 @@ msgstr ""
msgid "Refresh"
msgstr ""
msgid "OneDrive Login"
msgstr ""
msgid "Import"
msgstr ""
msgid "Configuration"
msgstr ""
msgid "Delete notebook?"
msgstr ""
@ -773,9 +785,6 @@ msgstr ""
msgid "Status"
msgstr ""
msgid "Configuration"
msgstr ""
msgid "Cancel synchronisation"
msgstr ""

View File

@ -520,6 +520,9 @@ msgstr ""
msgid "Search:"
msgstr "Chercher"
msgid "File"
msgstr ""
msgid "New note"
msgstr "Nouvelle note"
@ -616,6 +619,17 @@ msgstr "Attacher un fichier"
msgid "Refresh"
msgstr "Rafraîchir"
#, fuzzy
msgid "OneDrive Login"
msgstr "OneDrive"
#, fuzzy
msgid "Import"
msgstr "Importé - %s"
msgid "Configuration"
msgstr "Configuration"
msgid "Delete notebook?"
msgstr "Supprimer le carnet ?"
@ -846,9 +860,6 @@ msgstr "Journal"
msgid "Status"
msgstr "Etat"
msgid "Configuration"
msgstr "Configuration"
msgid "Cancel synchronisation"
msgstr "Annuler synchronisation"
@ -1060,9 +1071,6 @@ msgstr "Bienvenue"
#~ "Tous les ports sont en cours d'utilisation. Veuillez signaler ce problème "
#~ "sur %s"
#~ msgid "Imported - %s"
#~ msgstr "Importé - %s"
#~ msgid ""
#~ "There is currently no notebook. Create one by clicking on the (+) button."
#~ msgstr ""

View File

@ -469,6 +469,9 @@ msgstr ""
msgid "Search:"
msgstr ""
msgid "File"
msgstr ""
msgid "New note"
msgstr ""
@ -556,6 +559,15 @@ msgstr ""
msgid "Refresh"
msgstr ""
msgid "OneDrive Login"
msgstr ""
msgid "Import"
msgstr ""
msgid "Configuration"
msgstr ""
msgid "Delete notebook?"
msgstr ""
@ -773,9 +785,6 @@ msgstr ""
msgid "Status"
msgstr ""
msgid "Configuration"
msgstr ""
msgid "Cancel synchronisation"
msgstr ""

View File

@ -1,7 +1,7 @@
const { Setting } = require('lib/models/setting.js');
const globalStyle = {
fontSize: 13,
fontSize: 12,
fontFamily: 'sans-serif',
margin: 15, // No text and no interactive component should be within this margin
itemMarginTop: 10,

View File

@ -136,10 +136,27 @@ class BaseApplication {
process.exit(code);
}
async refreshNotes(parentType, parentId) {
this.logger().debug('Refreshing notes:', parentType, parentId);
//async refreshNotes(parentType, parentId) {
//async refreshNotes(parentType, parentId) {
async refreshNotes(state) {
let parentType = state.notesParentType;
let parentId = null;
if (parentType === 'Folder') {
parentId = state.selectedFolderId;
parentType = BaseModel.TYPE_FOLDER;
} else if (parentType === 'Note') {
parentId = state.selectedNoteId;
parentType = BaseModel.TYPE_NOTE;
} else if (parentType === 'Tag') {
parentId = state.selectedTagId;
parentType = BaseModel.TYPE_TAG;
} else if (parentType === 'Search') {
parentId = state.selectedSearchId;
parentType = BaseModel.TYPE_SEARCH;
}
const state = this.store().getState();
this.logger().debug('Refreshing notes:', parentType, parentId);
let options = {
order: state.notesOrder,
@ -213,19 +230,19 @@ class BaseApplication {
if (action.type == 'FOLDER_SELECT' || action.type === 'FOLDER_DELETE') {
Setting.setValue('activeFolderId', newState.selectedFolderId);
this.currentFolder_ = newState.selectedFolderId ? await Folder.load(newState.selectedFolderId) : null;
await this.refreshNotes(Folder.modelType(), newState.selectedFolderId);
await this.refreshNotes(newState);
}
if (this.hasGui() && action.type == 'SETTING_UPDATE_ONE' && action.key == 'uncompletedTodosOnTop' || action.type == 'SETTING_UPDATE_ALL') {
await this.refreshNotes(Folder.modelType(), newState.selectedFolderId);
await this.refreshNotes(newState);
}
if (action.type == 'TAG_SELECT') {
await this.refreshNotes(Tag.modelType(), action.id);
if (action.type == 'TAG_SELECT' || action.type === 'TAG_DELETE') {
await this.refreshNotes(newState);
}
if (action.type == 'SEARCH_SELECT') {
await this.refreshNotes(BaseModel.TYPE_SEARCH, action.id);
if (action.type == 'SEARCH_SELECT' || action.type === 'SEARCH_DELETE') {
await this.refreshNotes(newState);
}
if (this.hasGui() && action.type == 'SETTING_UPDATE_ONE' && action.key == 'sync.interval' || action.type == 'SETTING_UPDATE_ALL') {

View File

@ -61,6 +61,10 @@ function handleItemDelete(state, action) {
const newIndex = previousIndex >= 0 ? newItems[previousIndex].id : null;
newState[selectedItemKey] = newIndex;
if (!newIndex && newState.notesParentType !== 'Folder') {
newState.notesParentType = 'Folder';
}
return newState;
}