zotero: set document preference before performing any action
Signed-off-by: Pranam Lashkari <lpranam@collabora.com> Change-Id: I8c6e3c7c7b75fad59cf09a2c827bcb66a57e012b
This commit is contained in:
parent
1e0c89c956
commit
444dab1648
1 changed files with 18 additions and 8 deletions
|
@ -201,13 +201,13 @@ L.Control.Zotero = L.Control.extend({
|
|||
|
||||
_getDefaultSubCollections: function () {
|
||||
return [
|
||||
{ columns: [ { text: _('My Publications') } ], row: 'https://api.zotero.org/users/' + this.userID + '/publications/items/top?v=3&key=' + this.apiKey + '&include=data,citation,bib,csljson' },
|
||||
{ columns: [ { text: _('My Publications') } ], row: 'https://api.zotero.org/users/' + this.userID + '/publications/items/top?v=3&key=' + this.apiKey + '&include=data,citation,bib,csljson&style=' + this.settings.style },
|
||||
];
|
||||
},
|
||||
|
||||
getDefaultCategories: function () {
|
||||
return [
|
||||
{ columns: [{ text: _('My Library') } ], row: 'https://api.zotero.org/users/' + this.userID + '/items/top?v=3&key=' + this.apiKey + '&include=data,citation,bib,csljson', children: this._getDefaultSubCollections() },
|
||||
{ columns: [{ text: _('My Library') } ], row: 'https://api.zotero.org/users/' + this.userID + '/items/top?v=3&key=' + this.apiKey + '&include=data,citation,bib,csljson', children: this._getDefaultSubCollections() + '&style=' + this.settings.style },
|
||||
{ columns: [{ text: _('Group Libraries')}] }];
|
||||
},
|
||||
|
||||
|
@ -304,6 +304,11 @@ L.Control.Zotero = L.Control.extend({
|
|||
},
|
||||
|
||||
showItemList: function () {
|
||||
if (!this.settings.style) {
|
||||
this.pendingAction = this.showItemList;
|
||||
this.showStyleList();
|
||||
return;
|
||||
}
|
||||
var that = this;
|
||||
this.dialogType = 'itemlist';
|
||||
|
||||
|
@ -312,28 +317,28 @@ L.Control.Zotero = L.Control.extend({
|
|||
that.map.fire('jsdialogupdate', dialogUpdateEvent);
|
||||
that.map.fire('jsdialogupdate', that.updateCategories());
|
||||
|
||||
this.getCachedOrFetch('https://api.zotero.org/users/' + this.userID + '/groups?v=3&key=' + this.apiKey + '&include=data,citation,bib,csljson')
|
||||
this.getCachedOrFetch('https://api.zotero.org/users/' + this.userID + '/groups?v=3&key=' + this.apiKey + '&include=data,citation,bib,csljson&style=' + this.settings.style)
|
||||
.then(function (data) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
that.groups.push(
|
||||
{
|
||||
columns: [ { text: data[i].data.name } ],
|
||||
id: data[i].data.id,
|
||||
row: data[i].links.self.href + '/items/top?v=3&key=' + that.apiKey + '&include=data,citation,bib,csljson'
|
||||
row: data[i].links.self.href + '/items/top?v=3&key=' + that.apiKey + '&include=data,citation,bib,csljson&style=' + this.settings.style
|
||||
});
|
||||
that.fillCategories();
|
||||
that.map.fire('jsdialogupdate', that.updateCategories());
|
||||
}
|
||||
});
|
||||
|
||||
this.getCachedOrFetch('https://api.zotero.org/users/' + this.userID + '/collections/top?v=3&key=' + this.apiKey + '&include=data,citation,bib,csljson')
|
||||
this.getCachedOrFetch('https://api.zotero.org/users/' + this.userID + '/collections/top?v=3&key=' + this.apiKey + '&include=data,citation,bib,csljson&style=' + this.settings.style)
|
||||
.then(function (data) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
that.collections.push(
|
||||
{
|
||||
columns: [ { text: data[i].data.name } ],
|
||||
id: data[i].data.key,
|
||||
row: data[i].links.self.href + '/items/top?v=3&key=' + that.apiKey + '&include=data,citation,bib,csljson',
|
||||
row: data[i].links.self.href + '/items/top?v=3&key=' + that.apiKey + '&include=data,citation,bib,csljson&style=' + this.settings.style,
|
||||
children: [ { text: '<dummy>' } ],
|
||||
ondemand: true
|
||||
});
|
||||
|
@ -464,14 +469,14 @@ L.Control.Zotero = L.Control.extend({
|
|||
|
||||
_fetchCollectionAndPushTo: function(collectionId, targetCollection) {
|
||||
var that = this;
|
||||
this.getCachedOrFetch('https://api.zotero.org/users/' + this.userID + '/collections/' + collectionId + '/collections/?v=3&key=' + this.apiKey + '&include=data,citation,bib,csljson')
|
||||
this.getCachedOrFetch('https://api.zotero.org/users/' + this.userID + '/collections/' + collectionId + '/collections/?v=3&key=' + this.apiKey + '&include=data,citation,bib,csljson&style=' + this.settings.style)
|
||||
.then(function (data) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
targetCollection.children.push(
|
||||
{
|
||||
columns: [ { text: data[i].data.name } ],
|
||||
id: data[i].data.key,
|
||||
row: data[i].links.self.href + '/items/top?v=3&key=' + that.apiKey + '&include=data,citation,bib,csljson',
|
||||
row: data[i].links.self.href + '/items/top?v=3&key=' + that.apiKey + '&include=data,citation,bib,csljson&style=' + this.settings.style,
|
||||
children: [ { text: '<dummy>' } ],
|
||||
ondemand: true
|
||||
});
|
||||
|
@ -557,6 +562,11 @@ L.Control.Zotero = L.Control.extend({
|
|||
}
|
||||
};
|
||||
this.map.fire(window.mode.isMobile() ? 'closemobilewizard' : 'jsdialog', closeEvent);
|
||||
|
||||
if (this.pendingAction) {
|
||||
this.pendingAction();
|
||||
delete this.pendingAction;
|
||||
}
|
||||
},
|
||||
|
||||
_onOk: function (selected) {
|
||||
|
|
Loading…
Reference in a new issue