From 2923fbd846a6e4c2fd6eccbbad551a95cd1e42d1 Mon Sep 17 00:00:00 2001 From: antelle Date: Sun, 29 Jan 2017 19:03:38 +0100 Subject: [PATCH] fix #377: auto-type filtering issues --- app/scripts/auto-type/auto-type-filter.js | 3 ++- app/scripts/models/entry-model.js | 3 ++- app/scripts/models/file-model.js | 8 ++++---- app/scripts/models/group-model.js | 11 ++++++++--- release-notes.md | 1 + 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/scripts/auto-type/auto-type-filter.js b/app/scripts/auto-type/auto-type-filter.js index b1450538..4d6e05e0 100644 --- a/app/scripts/auto-type/auto-type-filter.js +++ b/app/scripts/auto-type/auto-type-filter.js @@ -14,7 +14,8 @@ let AutoTypeFilter = function(windowInfo, appModel) { AutoTypeFilter.prototype.getEntries = function() { let filter = { - text: this.text + text: this.text, + autoType: true }; let entries = this.appModel.getEntriesByFilter(filter); if (!this.ignoreWindowInfo && this.hasWindowInfo()) { diff --git a/app/scripts/models/entry-model.js b/app/scripts/models/entry-model.js index 21b0d89e..9eaa4577 100644 --- a/app/scripts/models/entry-model.js +++ b/app/scripts/models/entry-model.js @@ -190,7 +190,8 @@ var EntryModel = Backbone.Model.extend({ return !filter || (!filter.tagLower || this.searchTags.indexOf(filter.tagLower) >= 0) && (!filter.textLower || (filter.advanced ? this.matchesAdv(filter) : this.searchText.indexOf(filter.textLower) >= 0)) && - (!filter.color || filter.color === true && this.searchColor || this.searchColor === filter.color); + (!filter.color || filter.color === true && this.searchColor || this.searchColor === filter.color) && + (!filter.autoType || this.autoTypeEnabled); }, matchesAdv: function(filter) { diff --git a/app/scripts/models/file-model.js b/app/scripts/models/file-model.js index db8f0425..c230b027 100644 --- a/app/scripts/models/file-model.js +++ b/app/scripts/models/file-model.js @@ -172,7 +172,7 @@ var FileModel = Backbone.Model.extend({ group.forEachOwnEntry(null, entry => { entryMap[entry.id] = entry; }); - }, true); + }, { includeDisabled: true }); this.entryMap = entryMap; this.groupMap = groupMap; }, @@ -282,15 +282,15 @@ var FileModel = Backbone.Model.extend({ if (!filter.group || filter.subGroups) { top.forEachGroup(group => { group.forEachOwnEntry(filter, callback); - }); + }, filter); } } }, - forEachGroup: function(callback, includeDisabled) { + forEachGroup: function(callback, filter) { this.get('groups').forEach(group => { if (callback(group) !== false) { - group.forEachGroup(callback, includeDisabled); + group.forEachGroup(callback, filter); } }); }, diff --git a/app/scripts/models/group-model.js b/app/scripts/models/group-model.js index 734999bf..949b8593 100644 --- a/app/scripts/models/group-model.js +++ b/app/scripts/models/group-model.js @@ -107,11 +107,11 @@ var GroupModel = MenuItemModel.extend({ this.group.times.update(); }, - forEachGroup: function(callback, includeDisabled) { + forEachGroup: function(callback, filter) { var result = true; this.get('items').forEach(group => { - if (includeDisabled || group.group.enableSearching !== false) { - result = callback(group) !== false && group.forEachGroup(callback, includeDisabled) !== false; + if (group.matches(filter)) { + result = callback(group) !== false && group.forEachGroup(callback, filter) !== false; } }); return result; @@ -125,6 +125,11 @@ var GroupModel = MenuItemModel.extend({ }); }, + matches: function(filter) { + return (filter && filter.includeDisabled || this.group.enableSearching !== false) && + (!filter || !filter.autoType || this.group.enableAutoType !== false); + }, + getOwnSubGroups: function() { return this.group.groups; }, diff --git a/release-notes.md b/release-notes.md index ce0cd33f..031c595f 100644 --- a/release-notes.md +++ b/release-notes.md @@ -8,6 +8,7 @@ Release notes `+` text fields context menu on desktop `+` option to disable latest file removal `-` fix #432: drag-drop in vivaldi +`-` fix auto-type enabled/disabled issues ##### v1.3.3 (2016-09-20) `+` translations: fr, pl, pt