www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit c1f7a188e2e6eec0daba38654575a5c14983f0a7
parent 18cf6088b0d737c20717c3f66982ed0b55d49e67
Author: Dan Stillman <dstillman@zotero.org>
Date:   Thu,  7 Jul 2016 07:55:15 -0400

Fix error modifying existing saved search with more than 1 condition

Closes #1056, which wasn't actually the problem

Diffstat:
Mchrome/content/zotero/xpcom/search.js | 4++--
Mtest/content/support.js | 1+
Mtest/tests/searchTest.js | 1+
3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/chrome/content/zotero/xpcom/search.js b/chrome/content/zotero/xpcom/search.js @@ -440,7 +440,7 @@ Zotero.Search.prototype.removeCondition = function (searchConditionID) { this._requireData('conditions'); if (typeof this._conditions[searchConditionID] == 'undefined'){ - throw ('Invalid searchConditionID ' + searchConditionID + ' in removeCondition()'); + throw new Error('Invalid searchConditionID ' + searchConditionID + ' in removeCondition()'); } delete this._conditions[searchConditionID]; @@ -825,7 +825,7 @@ Zotero.Search.prototype.fromJSON = function (json) { } this.name = json.name; - Object.keys(this.getConditions()).forEach(id => this.removeCondition(0)); + Object.keys(this.getConditions()).forEach(id => this.removeCondition(id)); for (let i = 0; i < json.conditions.length; i++) { let condition = json.conditions[i]; this.addCondition( diff --git a/test/content/support.js b/test/content/support.js @@ -386,6 +386,7 @@ function createUnsavedDataObject(objectType, params = {}) { if (objectType == 'search') { obj.addCondition('title', 'contains', Zotero.Utilities.randomString()); + obj.addCondition('title', 'isNot', Zotero.Utilities.randomString()); } Zotero.Utilities.assignProps(obj, params, allowedParams); diff --git a/test/tests/searchTest.js b/test/tests/searchTest.js @@ -221,6 +221,7 @@ describe("Zotero.Search", function() { let s = new Zotero.Search(); s.name = "Test"; s.addCondition('joinMode', 'any'); + s.addCondition('title', 'isNot', 'foo'); let json = s.toJSON(); json.name = "Test 2"; json.conditions = [