commit 07ca00edd538bc6e3111ba5d83349cfe47d632fb
parent 87d5625bac85a9c45be4b08c16da799c6c79b612
Author: Aurimas Vinckevicius <aurimas.dev@gmail.com>
Date: Mon, 1 Jun 2015 23:31:38 -0500
Use _canHaveParent property to determine if object can have parent
Diffstat:
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git 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
@@ -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) {