diff --git a/chrome/content/zotero/xpcom/data/dataObject.js b/chrome/content/zotero/xpcom/data/dataObject.js index 7eaebb807..e5c02fc43 100644 --- a/chrome/content/zotero/xpcom/data/dataObject.js +++ b/chrome/content/zotero/xpcom/data/dataObject.js @@ -89,6 +89,10 @@ Zotero.defineProperty(Zotero.DataObject.prototype, 'parentID', { set: function(v) this._setParentID(v) }); +Zotero.defineProperty(Zotero.DataObject.prototype, '_canHaveParent', { + value: true +}); + Zotero.defineProperty(Zotero.DataObject.prototype, 'ObjectsClass', { get: function() this._ObjectsClass }); @@ -241,7 +245,7 @@ Zotero.DataObject.prototype._setParentID = function (id) { Zotero.DataObject.prototype._getParentKey = function () { - if (this._objectType == 'search') { + if (!this._canHaveParent) { return undefined; } return this._parentKey ? this._parentKey : false @@ -254,8 +258,8 @@ Zotero.DataObject.prototype._getParentKey = function () { * @return {Boolean} True if changed, false if stayed the same */ Zotero.DataObject.prototype._setParentKey = function(key) { - if (this._objectType == 'search') { - throw new Error("Cannot set parent key for search"); + if (!this._canHaveParent) { + throw new Error("Cannot set parent key for " + this._objectType); } key = Zotero.DataObjectUtilities.checkKey(key) || false; diff --git a/chrome/content/zotero/xpcom/search.js b/chrome/content/zotero/xpcom/search.js index bd1028d52..fbea83df0 100644 --- a/chrome/content/zotero/xpcom/search.js +++ b/chrome/content/zotero/xpcom/search.js @@ -86,6 +86,9 @@ Zotero.defineProperty(Zotero.Search.prototype, 'synced', { Zotero.defineProperty(Zotero.Search.prototype, 'conditions', { get: function() this.getConditions() }); +Zotero.defineProperty(Zotero.Search.prototype, '_canHaveParent', { + value: false +}); Zotero.Search.prototype.loadFromRow = function (row) {