Commit 6bf077b3 authored by Yoran Hillion's avatar Yoran Hillion
Browse files

feat: adds advanced search results csv export

parent 9a7ede47
Pipeline #64317 passed with stages
in 5 minutes and 15 seconds
......@@ -105,19 +105,31 @@
:label="$t('search.sortOptions')"
hide-details
>
<template #append-outer>
<template #prepend-inner>
<v-btn
icon
small
@click="tab.isDescending = !tab.isDescending"
@click.stop="tab.isDescending = !tab.isDescending"
>
<v-icon>{{ tab.isDescending ? 'mdi-sort-descending' : 'mdi-sort-ascending' }}</v-icon>
</v-btn>
</template>
</v-select>
<v-btn
class="mx-2"
tile
elevation="0"
color="secondary"
:disabled="!tab.selected.length"
@click="onExport(tab.id)"
>
{{ $t('template.csv.export') }}
</v-btn>
</v-toolbar>
<v-divider />
<v-data-table
v-model="tab.selected"
show-select
:items="tab.results"
:footer-props="{ itemsPerPageOptions: [2, 5, 10, -1] }"
:options.sync="tab.options"
......@@ -125,35 +137,39 @@
:sort-desc="tab.isDescending"
:server-items-length="tab.serverItemsLength"
>
<template #item="{ item }">
<template #item="{ item, isSelected, select }">
<tr>
<v-card>
<div class="d-flex">
<avatar
:name="item.name"
:image="item.thumbnail"
:isPublic="item.isPublic"
class="ml-4 mt-4"
/>
<div class="d-flex flex-column">
<v-card-title>
<router-link :to="item.to">{{ item.name }}</router-link>
</v-card-title>
<v-card-subtitle class="pb-2">
<div>
<span
v-for="(subtitle, index) in item.subtitles"
:key="index"
>
<span v-if="index"> - </span>
{{ subtitle }}
</span>
</div>
</v-card-subtitle>
<v-card-text v-html="item.highlight.description ? item.highlight.description.join('[...]') : item.description">
</v-card-text>
<v-card class="pl-4">
<div class="d-flex">
<v-simple-checkbox
:value="isSelected"
@click="select(!isSelected)"
/>
<avatar
:name="item.name"
:image="item.thumbnail"
:isPublic="item.isPublic"
class="ml-4 mt-4"
/>
<div class="d-flex flex-column">
<v-card-title>
<router-link :to="item.to">{{ item.name }}</router-link>
</v-card-title>
<v-card-subtitle class="pb-2">
<div>
<span
v-for="(subtitle, index) in item.subtitles"
:key="index"
>
<span v-if="index"> - </span>
{{ subtitle }}
</span>
</div>
</v-card-subtitle>
<v-card-text v-html="item.highlight.description ? item.highlight.description.join('[...]') : item.description">
</v-card-text>
</div>
</div>
</div>
</v-card>
</tr>
</template>
......@@ -226,6 +242,7 @@ export default {
sort: 'score',
isDescending: true,
results: [],
selected: [],
},
item: {
id: 'item',
......@@ -235,6 +252,7 @@ export default {
sort: 'score',
isDescending: true,
results: [],
selected: [],
},
},
activeTab: 0,
......@@ -330,6 +348,18 @@ export default {
this.search('item');
this.activeTab=1;
},
onExport(mode) {
this.axios.post('export/search/', {
type: mode,
ids: this.tabs[mode].selected.map((item) => item.id).join(),
}).then((response) => {
const hiddenElement = document.createElement('a');
hiddenElement.href = `data:${response.headers['content-type']}, ${encodeURI(response.data)}`;
hiddenElement.target = '_blank';
hiddenElement.download = `searched_${mode}s.csv`;
hiddenElement.click();
});
},
},
};
</script>
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