Commit 4d6ec178 authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

ajout de l'url de la ref dans l'événement de sélection

parent e316f579
{ {
"name": "zotero-vue-client", "name": "zotero-vue-client",
"version": "0.1.1", "version": "0.1.2",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
......
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
}, },
methods : { methods : {
selectedEntry(entryKey, serializedEntry){ selectedEntry(entry){
console.log("entry key = ", entryKey) console.log("entry key = ", entry.key)
alert(serializedEntry) alert(entry.serialized)
} }
} }
} }
......
...@@ -110,11 +110,14 @@ ...@@ -110,11 +110,14 @@
} }
}, },
methods: { methods: {
doQuery() { doQuery(reset=true) {
if(reset)
this.currentPage = 1;
this.isFetching = true; this.isFetching = true;
this.entries = null; this.entries = null;
let library = new Zotero.Library(this.type, this.groupOrUserId); let library = new Zotero.Library(this.type, this.groupOrUserId);
library.loadItems({start: this.start, limit: this.pageLength, q: this.textQuery}).then((response)=>{ library.loadItems({start: this.start, limit: this.pageLength, q: this.textQuery}).then((response)=>{
console.log(response.data)
this.entries = response.data; this.entries = response.data;
this.nbResults = response.totalResults; this.nbResults = response.totalResults;
this.isFetching = false; this.isFetching = false;
...@@ -124,19 +127,29 @@ ...@@ -124,19 +127,29 @@
previousPage(){ previousPage(){
this.start -= this.pageLength; this.start -= this.pageLength;
this.currentPage --; this.currentPage --;
this.doQuery(); this.doQuery(false);
}, },
nextPage(){ nextPage(){
this.start += this.pageLength; this.start += this.pageLength;
this.currentPage ++; this.currentPage ++;
this.doQuery(); this.doQuery(false);
}, },
entrySelected(entryKey){ entrySelected(entryKey){
let suffix = this.type + 's' +'/' + this.groupOrUserId + '/items/' + entryKey
fetch('https://api.zotero.org/' fetch('https://api.zotero.org/'
+ this.type + 's' +'/' + this.groupOrUserId + '/items/' + entryKey + '?format=' + this.format) + suffix + '?format=' + this.format)
.then(response => response.text()).then(entry => { this.$emit('entry-selected',entryKey, entry)}) .then(response => response.text()).then(entry => {
console.log()
this.$emit(
'entry-selected',
{
key: entryKey,
url : 'http://zotero.org/' + suffix,
serialized :entry
})
})
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment