
3 changed files with 105 additions and 16 deletions
@ -0,0 +1,90 @@ |
|||||
|
<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 { |
||||
|
name: "seat", |
||||
|
props:[ |
||||
|
"seats", |
||||
|
"classType", |
||||
|
"personCount", |
||||
|
"value", |
||||
|
|
||||
|
], |
||||
|
data: function() { |
||||
|
return { |
||||
|
chosenSeats: this.value |
||||
|
} |
||||
|
|
||||
|
}, |
||||
|
methods: { |
||||
|
methods: { |
||||
|
addSeatClick: function(seat) { |
||||
|
if (this.chosenSeats.length < this.personCount) { |
||||
|
this.chosenSeats.push(seat); |
||||
|
this.$emit("input", this.chosenSeats); |
||||
|
|
||||
|
} |
||||
|
else { |
||||
|
alert("Všichni cestující již sedí!"); |
||||
|
} |
||||
|
}, |
||||
|
watch: { |
||||
|
value: function(value){ |
||||
|
this.chosenSeats = value; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style> |
||||
|
.seat { |
||||
|
display: inline-block; |
||||
|
width: 50px; |
||||
|
height: 50px; |
||||
|
text-align: center; |
||||
|
border: 1px solid gray; |
||||
|
margin: 2px; |
||||
|
background-color: rgb(62, 156, 53); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
.seat div:hover { |
||||
|
cursor: pointer; |
||||
|
background-color: lightgray; |
||||
|
} |
||||
|
|
||||
|
.seat .disabled { |
||||
|
color: rgb(255, 255, 255); |
||||
|
} |
||||
|
|
||||
|
.seat .disabled:hover { |
||||
|
cursor: default; |
||||
|
background-color: transparent; |
||||
|
} |
||||
|
|
||||
|
.seat .chosen { |
||||
|
background-color: lightgreen; |
||||
|
} |
||||
|
|
||||
|
</style> |
Loading…
Reference in new issue