Add remove option for new depicts list.

This commit is contained in:
Edward Betts 2019-09-25 14:28:03 +01:00
parent 9b92884523
commit fa75292e22
2 changed files with 6 additions and 2 deletions

View file

@ -6,6 +6,9 @@ var app = new Vue({
new_depicts: [], new_depicts: [],
}, },
methods: { methods: {
remove(index) {
this.$delete(this.new_depicts, index);
},
add_depicts(hit) { add_depicts(hit) {
this.new_depicts.push(hit); this.new_depicts.push(hit);
this.hits = []; this.hits = [];

View file

@ -62,10 +62,11 @@
<div id="app" class="mt-2"> <div id="app" class="mt-2">
<h3>what can you see in this painting?</h3> <h3>what can you see in this painting?</h3>
<div v-for="hit in new_depicts"> <div v-for="(hit, index) in new_depicts">
<div> <div>
{{ hit.label }} {{ hit.label }}
<span v-if="hit.alt_label">({{ hit.alt_label }})</span> <span v-if="hit.alt_label">({{ hit.alt_label }})</span>
<a href="#" @click.prevent="remove(index)" >remove</a>
&mdash; {{ hit.count }} existing paintings &mdash; {{ hit.count }} existing paintings
({{ hit.qid }}) ({{ hit.qid }})
<a :href="'https://www.wikidata.org/wiki/' + hit.qid">view on Wikidata</a> <a :href="'https://www.wikidata.org/wiki/' + hit.qid">view on Wikidata</a>
@ -79,7 +80,7 @@
<div id="item-list"> <div id="item-list">
<div v-for="hit in hits"> <div v-for="hit in hits">
<div> <div>
<a href="#" @click="add_depicts(hit)">{{ hit.label }}</a> <a href="#" @click.prevent="add_depicts(hit)">{{ hit.label }}</a>
<span v-if="hit.alt_label">({{ hit.alt_label }})</span> <span v-if="hit.alt_label">({{ hit.alt_label }})</span>
&mdash; {{ hit.count }} existing paintings &mdash; {{ hit.count }} existing paintings
({{ hit.qid }}) ({{ hit.qid }})