commit 7ba54886a6d8d85d7abf60ca0fc63338d3a510ae
parent 79733c75f1f696aae448bac8d2e4ae0058203f24
Author: Dan Stillman <dstillman@zotero.org>
Date: Fri, 19 Jun 2015 03:49:36 -0400
Add toJSON() for searches and make Collection::toJSON() async
Diffstat:
2 files changed, 16 insertions(+), 24 deletions(-)
diff --git a/chrome/content/zotero/xpcom/data/collection.js b/chrome/content/zotero/xpcom/data/collection.js
@@ -645,18 +645,15 @@ Zotero.Collection.prototype.fromJSON = Zotero.Promise.coroutine(function* (json)
});
-Zotero.Collection.prototype.toJSON = function (options, patch) {
+Zotero.Collection.prototype.toJSON = Zotero.Promise.coroutine(function* (options) {
var obj = {};
- if (options && options.includeKey) {
- obj.collectionKey = this.key;
- }
- if (options && options.includeVersion) {
- obj.collectionVersion = this.version;
- }
+ obj.key = this.key;
+ obj.version = this.version;
obj.name = this.name;
obj.parentCollection = this.parentKey ? this.parentKey : false;
+ obj.relations = {}; // TEMP
return obj;
-}
+});
/**
diff --git a/chrome/content/zotero/xpcom/search.js b/chrome/content/zotero/xpcom/search.js
@@ -772,22 +772,6 @@ Zotero.Search.prototype.search = Zotero.Promise.coroutine(function* (asTempTable
});
-Zotero.Search.prototype.serialize = function() {
- var obj = {
- primary: {
- id: this.id,
- libraryID: this.libraryID,
- key: this.key
- },
- fields: {
- name: this.name,
- },
- conditions: this.getConditions()
- };
- return obj;
-}
-
-
Zotero.Search.prototype.fromJSON = Zotero.Promise.coroutine(function* (json) {
yield this.loadAllData();
@@ -807,6 +791,17 @@ Zotero.Search.prototype.fromJSON = Zotero.Promise.coroutine(function* (json) {
});
+Zotero.Search.prototype.toJSON = Zotero.Promise.coroutine(function* (options) {
+ var obj = {};
+ obj.key = this.key;
+ obj.version = this.version;
+ obj.name = this.name;
+ yield this.loadConditions();
+ obj.conditions = this.getConditions();
+ return obj;
+});
+
+
/*
* Get the SQL string for the search
*/