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
Raw Normal View History

2020-11-09 11:11:47 -08:00
<template>
2020-11-09 12:41:52 -08:00
<div v-if="notEmpty">
<slot></slot>
<ul class="list-unstyled">
2020-12-04 13:09:57 -08:00
<li v-for="source in sources" v-if="isVisible(source)" class="my-2">
2020-11-09 12:41:52 -08:00
<Source :source="source"/>
</li>
</ul>
</div>
2020-11-09 11:11:47 -08:00
</template>
<script>
export default {
props: {
2020-12-04 13:09:57 -08:00
sources: { required: true },
2020-11-09 11:11:47 -08:00
filter: { default: '' },
2020-11-09 12:41:52 -08:00
filterType: { default: '' },
2020-11-09 11:11:47 -08:00
},
methods: {
2020-11-09 12:41:52 -08:00
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() {
2020-12-04 13:09:57 -08:00
return this.sources.filter(this.isVisible).length > 0;
2020-11-09 12:41:52 -08:00
},
2020-11-09 11:11:47 -08:00
},
}
</script>