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

44 lines
1.2 KiB
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" :manage="manage" @edit-source="edit"/>
</li>
</ul>
</div>
</template>
<script>
export default {
props: {
sources: { required: true },
filter: { default: '' },
filterType: { default: '' },
manage: { type: Boolean },
},
methods: {
isVisible(source) {
if (this.filterType && this.filterType !== source.type) {
return false;
}
if (this.filter) {
return source.index.includes(this.filter.toLowerCase());
}
return true;
},
edit(source) {
// TODO it should be possible to do it nicer
this.$emit('edit-source', source);
}
},
computed: {
notEmpty() {
return this.sources.filter(this.isVisible).length > 0;
},
},
}
</script>