Skip to content

Commit d68143b

Browse files
committed
Added indication for which items are currently selected
1 parent 1038dce commit d68143b

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

VueMovies/src/components/OrderMenu.vue

+30-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
<th>Year</th>
1313
<th>Link</th>
1414
</tr>
15-
<tr v-for="movie in movies" v-on:click="selectedMovieID=movie.id">
15+
<tr
16+
:class="{selected: movie.id == selectedMovieID}"
17+
class="option" v-for="movie in movies" v-on:click="selectedMovieID=movie.id">
1618
<td>{{movie.title}}</td>
1719
<td>{{movie.producer}}</td>
1820
<td>{{movie.year}}</td>
@@ -30,7 +32,9 @@
3032
<th>City</th>
3133
<th>Address</th>
3234
</tr>
33-
<tr v-for="location in locations" v-on:click="selectedLocationID=location.id">
35+
<tr
36+
:class="{selected: location.id == selectedLocationID}"
37+
class="option" v-for="location in locations" v-on:click="selectedLocationID=location.id">
3438
<td>{{location.country}}</td>
3539
<td>{{location.city}}</td>
3640
<td>{{location.address}}</td>
@@ -50,14 +54,17 @@
5054
<th>Location ID</th>
5155
<th>Canceled</th>
5256
</tr>
53-
<tr v-for="order in orders" v-on:click="selectedOrderID=order.id">
57+
<tr
58+
:class="{selected: order.id == selectedOrderID}"
59+
class="option" v-for="order in orders" v-on:click="selectedOrderID=order.id">
5460
<td>{{order.id}}</td>
5561
<td>{{order.movieID}}</td>
5662
<td>{{order.locationID}}</td>
5763
<td>{{order.canceled}}</td>
5864
</tr>
5965
</tbody>
6066
</table>
67+
<button v-on:click="cancelOrder">Cancel</button>
6168

6269
</div>
6370
</template>
@@ -86,12 +93,19 @@ export default {
8693
this.refreshHistory();
8794
},
8895
refreshHistory: function(){
89-
console.log(this.userKey);
9096
this.$http.get('http://localhost/History/key=' + this.userKey)
9197
.then(function(response){
9298
if (response.body.status == "success")
9399
this.orders = response.body.orders;
94100
})
101+
},
102+
cancelOrder: function(){
103+
console.log(this.selectedOrderID,this.userKey);
104+
105+
// Here should request @ localhost/Cancel/
106+
107+
//And then:
108+
this.refreshHistory();
95109
}
96110
},
97111
created: function(){
@@ -119,5 +133,17 @@ export default {
119133

120134
<!-- Add "scoped" attribute to limit CSS to this component only -->
121135
<style scoped>
136+
.option{
137+
cursor:pointer;
138+
}
139+
140+
.option:hover{
141+
background-color:red;
142+
color:white;
143+
}
122144

145+
.selected{
146+
background-color:green;
147+
color:white;
148+
}
123149
</style>

0 commit comments

Comments
 (0)