2019-11-13 02:14:24 +00:00
|
|
|
<template>
|
2020-05-27 01:04:18 +00:00
|
|
|
<v-popover class="filters-container">
|
|
|
|
<div class="filters">
|
|
|
|
<div
|
|
|
|
v-if="selectedTags.length > 0"
|
|
|
|
class="applied"
|
2020-06-29 01:55:10 +00:00
|
|
|
>{{ selectedTags.length }} selected</div>
|
2020-05-27 01:04:18 +00:00
|
|
|
|
|
|
|
<div
|
|
|
|
v-else
|
|
|
|
class="applied empty"
|
|
|
|
>Filter by tags</div>
|
2020-06-29 01:55:10 +00:00
|
|
|
|
|
|
|
<Icon icon="filter" />
|
2020-05-27 01:04:18 +00:00
|
|
|
</div>
|
2020-05-25 02:39:58 +00:00
|
|
|
|
|
|
|
<div slot="popover">
|
2020-07-19 01:52:36 +00:00
|
|
|
<select
|
|
|
|
v-model="mode"
|
|
|
|
class="mode"
|
|
|
|
@change="$router.push({ query: { ...$route.query, mode } })"
|
|
|
|
>
|
|
|
|
<option
|
|
|
|
value="all"
|
|
|
|
class="option"
|
|
|
|
>match all selected</option>
|
|
|
|
<option
|
|
|
|
value="any"
|
|
|
|
class="option"
|
|
|
|
>match any selected</option>
|
|
|
|
</select>
|
|
|
|
|
2020-05-25 02:39:58 +00:00
|
|
|
<ul class="tags nolist">
|
|
|
|
<li
|
2020-06-30 02:33:47 +00:00
|
|
|
v-for="tag in availableTags"
|
|
|
|
:key="`tag-${tag.id}`"
|
2020-05-25 02:39:58 +00:00
|
|
|
class="tag"
|
2020-06-30 02:33:47 +00:00
|
|
|
:class="{ selected: selectedTags.includes(tag.slug) }"
|
2020-05-25 00:02:28 +00:00
|
|
|
>
|
2020-07-19 01:52:36 +00:00
|
|
|
<router-link :to="{ query: { ...getNewRange(tag.slug), mode } }">
|
2020-05-26 23:40:10 +00:00
|
|
|
<Icon
|
|
|
|
icon="checkmark"
|
|
|
|
class="include"
|
|
|
|
/>
|
|
|
|
</router-link>
|
2020-05-25 02:39:58 +00:00
|
|
|
|
|
|
|
<router-link
|
2020-07-19 01:52:36 +00:00
|
|
|
:to="{ query: { ...(selectedTags.length === 1 && selectedTags.includes(tag.slug) ? null : { tags: tag.slug }), mode }, params: { pageNumber: 1 } }"
|
2020-05-25 02:39:58 +00:00
|
|
|
class="name"
|
2020-06-30 02:33:47 +00:00
|
|
|
>{{ tag.name }}</router-link>
|
2020-05-25 02:39:58 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</v-popover>
|
2019-11-13 02:14:24 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-05-26 23:40:10 +00:00
|
|
|
function getNewRange(tag) {
|
2020-05-27 01:04:18 +00:00
|
|
|
if (this.selectedTags.includes(tag)) {
|
2020-06-29 01:55:10 +00:00
|
|
|
if (this.selectedTags.length > 1) {
|
|
|
|
return { tags: this.selectedTags.filter(selectedTag => selectedTag !== tag).join(',') };
|
2020-05-27 01:04:18 +00:00
|
|
|
}
|
2020-05-26 23:40:10 +00:00
|
|
|
|
2020-06-29 01:55:10 +00:00
|
|
|
return {};
|
2020-05-26 23:40:10 +00:00
|
|
|
}
|
|
|
|
|
2020-06-29 01:55:10 +00:00
|
|
|
return { tags: this.selectedTags.concat(tag).join(',') };
|
2020-05-26 23:40:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function selectedTags() {
|
2020-06-29 01:55:10 +00:00
|
|
|
return this.$route.query.tags ? this.$route.query.tags.split(',') : [];
|
2020-05-26 23:40:10 +00:00
|
|
|
}
|
|
|
|
|
2019-11-13 02:14:24 +00:00
|
|
|
export default {
|
2020-05-25 00:02:28 +00:00
|
|
|
props: {
|
|
|
|
filter: {
|
|
|
|
type: Array,
|
|
|
|
default: () => [],
|
|
|
|
},
|
|
|
|
compact: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2020-06-30 02:33:47 +00:00
|
|
|
availableTags: {
|
|
|
|
type: Array,
|
|
|
|
default: () => [],
|
|
|
|
},
|
2020-05-25 00:02:28 +00:00
|
|
|
},
|
2020-07-19 01:52:36 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
mode: 'all',
|
|
|
|
};
|
|
|
|
},
|
2020-05-26 23:40:10 +00:00
|
|
|
computed: {
|
|
|
|
selectedTags,
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
getNewRange,
|
|
|
|
},
|
2019-11-13 02:14:24 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import 'theme';
|
|
|
|
|
2020-05-27 01:04:18 +00:00
|
|
|
.filters {
|
|
|
|
display: inline-flex;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
fill: var(--shadow);
|
|
|
|
margin: 0 .5rem 0 0;
|
|
|
|
}
|
2020-07-01 02:47:05 +00:00
|
|
|
|
|
|
|
&:hover {
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
.applied {
|
|
|
|
color: var(--shadow-strong);
|
|
|
|
}
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
fill: var(--shadow-strong);
|
|
|
|
}
|
|
|
|
}
|
2020-05-27 01:04:18 +00:00
|
|
|
}
|
|
|
|
|
2020-05-25 02:39:58 +00:00
|
|
|
.applied {
|
2020-06-29 01:55:10 +00:00
|
|
|
flex-grow: 1;
|
|
|
|
padding: .75rem .5rem;
|
2020-05-25 02:39:58 +00:00
|
|
|
font-size: 1rem;
|
2020-05-27 01:04:18 +00:00
|
|
|
white-space: nowrap;
|
2020-06-29 01:55:10 +00:00
|
|
|
overflow: hidden;
|
2020-05-27 01:04:18 +00:00
|
|
|
text-overflow: ellipsis;
|
2020-06-29 01:55:10 +00:00
|
|
|
text-align: right;
|
2020-05-27 01:04:18 +00:00
|
|
|
|
|
|
|
&.empty {
|
|
|
|
color: var(--shadow);
|
|
|
|
}
|
2019-11-13 02:14:24 +00:00
|
|
|
}
|
|
|
|
|
2020-07-19 01:52:36 +00:00
|
|
|
.mode {
|
|
|
|
width: 100%;
|
|
|
|
background: none;
|
|
|
|
padding: .75rem;
|
|
|
|
font-size: 1rem;
|
|
|
|
border: none;
|
|
|
|
border-bottom: solid 1px var(--shadow-hint);
|
|
|
|
}
|
|
|
|
|
2020-05-25 02:39:58 +00:00
|
|
|
.tags {
|
|
|
|
padding: .5rem 0;
|
2019-11-13 02:14:24 +00:00
|
|
|
}
|
|
|
|
|
2020-05-25 02:39:58 +00:00
|
|
|
.tag {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2019-11-14 00:18:19 +00:00
|
|
|
|
2020-05-27 01:04:18 +00:00
|
|
|
.include {
|
2020-05-25 02:39:58 +00:00
|
|
|
width: 1rem;
|
|
|
|
height: 1rem;
|
2020-05-27 01:04:18 +00:00
|
|
|
padding: .5rem .75rem .5rem 1rem;
|
2020-05-26 23:40:10 +00:00
|
|
|
fill: var(--darken-hint);
|
2020-05-25 02:39:58 +00:00
|
|
|
|
|
|
|
&:hover {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.name {
|
2020-06-30 02:33:47 +00:00
|
|
|
min-width: 8rem;
|
2020-05-27 01:04:18 +00:00
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
2020-05-26 02:11:29 +00:00
|
|
|
flex-grow: 1;
|
2020-05-27 01:04:18 +00:00
|
|
|
padding: .5rem 1rem .5rem .75rem;
|
2020-05-25 02:39:58 +00:00
|
|
|
color: var(--text);
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
2019-11-14 00:18:19 +00:00
|
|
|
|
2020-05-25 02:39:58 +00:00
|
|
|
&:hover {
|
|
|
|
background: var(--darken-hint);
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
2020-05-27 01:04:18 +00:00
|
|
|
|
|
|
|
.include:hover,
|
|
|
|
.name:hover {
|
|
|
|
background: var(--darken-hint);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.selected .include {
|
|
|
|
fill: var(--success);
|
|
|
|
}
|
2019-11-13 02:14:24 +00:00
|
|
|
}
|
2020-06-30 22:25:27 +00:00
|
|
|
|
|
|
|
@media(max-width: $breakpoint0) {
|
|
|
|
.applied {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
2019-11-13 02:14:24 +00:00
|
|
|
</style>
|