Skip to content

Commit 88adec3

Browse files
committed
Fix iteration over the photos object, improve layout, add delete button
1 parent 5d3450c commit 88adec3

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

src/components/Gallery.vue

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,35 @@
77
<v-toolbar-title>Galleria</v-toolbar-title>
88
</v-toolbar>
99
<v-content>
10-
Placeholder content {{ photos.length }}
1110
<v-layout>
1211
<v-flex xs12 sm8 offset-sm2>
12+
<template v-if="photos.length == 0">
13+
<br>
14+
<h3>Galleria vuota!</h3>
15+
</template>
16+
<template v-else>
1317
<v-card>
1418
<v-container grid-list-sm fluid>
1519
<v-layout row wrap>
16-
<v-flex v-for="n in photos.length - 1" :key="n" xs3 d-flex>
20+
<v-flex v-for="n in photos.length" :key="n" xs3 d-flex>
1721
<v-card flat tile class="d-flex">
18-
19-
<v-img :src="CBv1+'/photos/'+photos[n].name" aspect-ratio="1" class="grey lighten-2">
20-
<span> {{ photos[n].name }} </span>
21-
<span v-on:click="deletePhoto(photos[n].name)"> Elimina </span>
22-
<v-layout slot="placeholder" fill-height align-center justify-center ma-0>
23-
<v-progress-circular indeterminate color="grey lighten-5"></v-progress-circular>
24-
</v-layout>
25-
</v-img>
26-
</a>
22+
<v-layout column>
23+
<div class="subheading">{{ photos[n-1].name }} <v-btn v-on:click="deletePhoto(photos[n-1].name)" flat icon color="red lighten-2">
24+
<v-icon>delete</v-icon>
25+
</v-btn>
26+
</div>
27+
<v-img :src="CBv1+'/photos/'+photos[n-1].name" aspect-ratio="1" class="grey lighten-2">
28+
<v-layout slot="placeholder" fill-height align-center justify-center ma-0>
29+
<v-progress-circular indeterminate color="grey lighten-5"></v-progress-circular>
30+
</v-layout>
31+
</v-img>
32+
</v-layout>
2733
</v-card>
2834
</v-flex>
2935
</v-layout>
3036
</v-container>
3137
</v-card>
38+
</template>
3239
</v-flex>
3340
</v-layout>
3441
</v-content>
@@ -41,11 +48,6 @@ import sidebar from "../components/Sidebar"
4148
export default {
4249
components: { sidebar },
4350
name: 'HelloWorld',
44-
watch: {
45-
photosN: function() {
46-
this.l = this.photos.length
47-
}
48-
},
4951
mounted() {
5052
this.getPhotos()
5153
},
@@ -61,7 +63,7 @@ export default {
6163
deletePhoto: function(name) {
6264
let axios = this.$axios
6365
let CBv1 = this.$data.CBv1
64-
axios.delete(CBv1 + '/photos/'+name)
66+
axios.delete(CBv1 + '/photos/' + name)
6567
.then(function(response) {
6668
this.getPhotos()
6769
}.bind(this))
@@ -83,3 +85,12 @@ export default {
8385
};
8486
8587
</script>
88+
<style scoped>
89+
.v-card{
90+
margin: 10px;
91+
}
92+
.container{
93+
padding-top: 0px;
94+
margin-top:0px;
95+
}
96+
</style>

0 commit comments

Comments
 (0)