added room filter

This commit is contained in:
2019-11-22 14:40:53 +01:00
parent c071591d82
commit a9a94d6f3c

View File

@@ -15,6 +15,13 @@
<font-awesome-icon icon="list"/>&nbsp;<font-awesome-icon icon="door-open"/> <font-awesome-icon icon="list"/>&nbsp;<font-awesome-icon icon="door-open"/>
<strong>Room</strong>&nbsp;<i>list</i> <strong>Room</strong>&nbsp;<i>list</i>
</template> </template>
<div class="mt-3">
<b-button-group>
<b-button variant="success" @click="showAllRooms()">{{$t('All rooms')}}</b-button>
<b-button variant="info" @click="showRoomsWithRecorder()">{{$t('Rooms with recorders')}}</b-button>
<b-button variant="warning" @click="showRoomsWithoutRecorder()">{{$t('Rooms without recorders')}}</b-button>
</b-button-group>
</div>
<p>{{ $tc('rooms_defined', rooms.length, {num: rooms.length})}}:</p> <p>{{ $tc('rooms_defined', rooms.length, {num: rooms.length})}}:</p>
<b-card-group deck> <b-card-group deck>
<b-card class="mb-2" style="max-width: 30rem; min-width:20rem;" v-for="(room) in rooms" <b-card class="mb-2" style="max-width: 30rem; min-width:20rem;" v-for="(room) in rooms"
@@ -330,7 +337,7 @@
<div class="column"> <div class="column">
<section class="section"> <section class="section">
{{recorders}} {{rooms}}
</section> </section>
</div> </div>
@@ -351,6 +358,8 @@
props: [], props: [],
data() { data() {
return { return {
onlyShowRoomsWithRecorder: false,
onlyShowRoomsWithoutRecorder: false,
tabIndex: 0, tabIndex: 0,
updateValues: {}, updateValues: {},
formEditField: {}, formEditField: {},
@@ -365,6 +374,18 @@
}; };
}, },
methods: { methods: {
showAllRooms(){
this.onlyShowRoomsWithRecorder = false;
this.onlyShowRoomsWithoutRecorder = false;
},
showRoomsWithRecorder(){
this.onlyShowRoomsWithRecorder = true;
this.onlyShowRoomsWithoutRecorder = false;
},
showRoomsWithoutRecorder(){
this.onlyShowRoomsWithRecorder = false;
this.onlyShowRoomsWithoutRecorder = true;
},
saveRoom() { saveRoom() {
this.$parent.$data.isLoading = true; this.$parent.$data.isLoading = true;
RoomRepository.createRoom(this.form) RoomRepository.createRoom(this.form)
@@ -433,6 +454,16 @@
}; };
}, },
rooms() { rooms() {
if(this.onlyShowRoomsWithRecorder){
return this.$store.state.rooms.filter(item => {
return item.recorder
});
}
else if(this.onlyShowRoomsWithoutRecorder){
return this.$store.state.rooms.filter(item => {
return !item.recorder
});
}
return this.$store.state.rooms; return this.$store.state.rooms;
}, },
recorders() { recorders() {