This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Zaimki/components/SourceList.vue

39 lines
973 B
Vue

<template>
<div v-if="notEmpty">
<slot></slot>
<ul class="list-unstyled">
<li v-for="source in sources" v-if="isVisible(source)" class="my-2">
<Source :source="source"/>
</li>
</ul>
</div>
</template>
<script>
export default {
props: {
sources: { required: true },
filter: { default: '' },
filterType: { default: '' },
},
methods: {
isVisible(source) {
if (this.filterType && this.filterType !== source.type) {
return false;
}
if (this.filter) {
return source.index.includes(this.filter.toLowerCase());
}
return true;
},
},
computed: {
notEmpty() {
return this.sources.filter(this.isVisible).length > 0;
},
},
}
</script>