
5 changed files with 105 additions and 62 deletions
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 26 KiB |
@ -0,0 +1,74 @@ |
|||||
|
<template> |
||||
|
|
||||
|
<div class="seatWrap"> |
||||
|
<div class="seat" v-for="(seat, index) in seats" :key="index"> |
||||
|
<div v-if="chosenSeats.indexOf(seat) >= 0" v-on:click="chosenSeats.splice(chosenSeats.indexOf(seat), 1)" class="chosen">{{ seat }}</div> |
||||
|
<div v-else-if="seat.startsWith(classType.value)" v-on:click="addSeatClick(seat)"> |
||||
|
{{ seat }} |
||||
|
</div> |
||||
|
<div v-else class="disabled"> |
||||
|
{{ seat }} |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default { |
||||
|
props: ["seats", "classType", "personCount", "value",], |
||||
|
data: function() { |
||||
|
return { |
||||
|
chosenSeats: this.value |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
addSeatClick: function(seat) { |
||||
|
if (this.chosenSeats.length < this.personCount){ |
||||
|
this.chosenSeats.push(seat); |
||||
|
this.$emit("input", this.chosenSeats); |
||||
|
} |
||||
|
else { |
||||
|
alert("Všichni cestujcí již sedí!"); |
||||
|
} |
||||
|
}, |
||||
|
}, |
||||
|
watch: { |
||||
|
value: function(value) { |
||||
|
this.chosenSeats = value; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style> |
||||
|
.wrapper { |
||||
|
display: grid; |
||||
|
grid-template-columns: 1fr 1fr; |
||||
|
text-align: center; |
||||
|
} |
||||
|
.seat { |
||||
|
display: inline-block; |
||||
|
width: 30px; |
||||
|
border: 1px solid gray; |
||||
|
margin: 2px; |
||||
|
} |
||||
|
.seat div:hover { |
||||
|
cursor: pointer; |
||||
|
background-color: lightgray; |
||||
|
} |
||||
|
|
||||
|
.seat .disabled { |
||||
|
color: lightgray; |
||||
|
} |
||||
|
|
||||
|
.seat .disabled:hover { |
||||
|
cursor: default; |
||||
|
background-color: transparent; |
||||
|
} |
||||
|
|
||||
|
.seat .chosen { |
||||
|
background-color: lightgreen; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
</style> |
Loading…
Reference in new issue