Add toJSON() for searches and make Collection::toJSON() async
This commit is contained in:
parent
79733c75f1
commit
7ba54886a6
2 changed files with 16 additions and 24 deletions
|
@ -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 = {};
|
var obj = {};
|
||||||
if (options && options.includeKey) {
|
obj.key = this.key;
|
||||||
obj.collectionKey = this.key;
|
obj.version = this.version;
|
||||||
}
|
|
||||||
if (options && options.includeVersion) {
|
|
||||||
obj.collectionVersion = this.version;
|
|
||||||
}
|
|
||||||
obj.name = this.name;
|
obj.name = this.name;
|
||||||
obj.parentCollection = this.parentKey ? this.parentKey : false;
|
obj.parentCollection = this.parentKey ? this.parentKey : false;
|
||||||
|
obj.relations = {}; // TEMP
|
||||||
return obj;
|
return obj;
|
||||||
}
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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) {
|
Zotero.Search.prototype.fromJSON = Zotero.Promise.coroutine(function* (json) {
|
||||||
yield this.loadAllData();
|
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
|
* Get the SQL string for the search
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue