Commit 1cab3a66 authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

simplication du process + sélection émise au format JSON

parent f64bd419
...@@ -36,14 +36,11 @@ Another example with custom options : ...@@ -36,14 +36,11 @@ Another example with custom options :
default-id="475425" default-id="475425"
:options="{ :options="{
pageLength: 10, pageLength: 10,
editableConfig: false, editableConfig: false
format: 'json'
}" }"
@entry-selected="selectedEntryCallback"/> @entry-selected="selectedEntryCallback"/>
``` ```
`selectedEntryCallback` will received the selected entry as argument (in JSON format)
available formats : https://www.zotero.org/support/dev/web_api/v3/basics#export_formats. *zotero-vue-client* uses 'tei'
as default one.
### Customize configuration ### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/). See [Configuration Reference](https://cli.vuejs.org/config/).
{ {
"name": "zotero-vue-client", "name": "zotero-vue-client",
"version": "0.1.2", "version": "0.1.3",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
......
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
methods : { methods : {
selectedEntry(entry){ selectedEntry(entry){
console.log("entry key = ", entry.key) alert(JSON.stringify(entry))
alert(entry.serialized)
} }
} }
} }
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
<ul> <ul>
<li class="zotero-entry" <li class="zotero-entry"
v-for="entry in entries" v-for="entry in entries"
@click="entrySelected(entry.key)" @click="entrySelected(entry)"
:key="'entry-' + entry.key"> :key="'entry-' + entry.key">
<ul> <ul>
<li class="zotero-title">{{entry.data.title}}</li> <li class="zotero-title">{{entry.data.title}}</li>
...@@ -77,8 +77,7 @@ ...@@ -77,8 +77,7 @@
default: function() { default: function() {
return { return {
editableConfig: true, editableConfig: true,
pageLength: 5, pageLength: 5
format: 'tei'
} }
} }
} }
...@@ -135,20 +134,8 @@ ...@@ -135,20 +134,8 @@
this.doQuery(false); this.doQuery(false);
}, },
entrySelected(entryKey){ entrySelected(entry){
let suffix = this.type + 's' +'/' + this.groupOrUserId + '/items/' + entryKey this.$emit('entry-selected',entry)
fetch('https://api.zotero.org/'
+ suffix + '?format=' + this.format)
.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