1212<template >
1313 <v-list class =" snapshotlist"
1414 three-line >
15+ <div v-for =" (snapshot, index) in groupedsnapshots" :key =" snapshot.id" >
16+ <v-subheader
17+ v-if =" showTopic(index) && withTopic"
18+ class =" px-0" >{{ snapshot.topic }}</v-subheader >
19+ <v-list-item class =" px-0 mb-4" dense
1520
16- <v-list-item class =" px-2 mb-4" dense
17- v-for =" snapshot in snapshots" :key =" snapshot.id"
1821 :to =" createRouteLink(snapshot.pk)" >
19- <v-list-item-avatar tile size =" 64" class =" my-2 " >
22+ <v-list-item-avatar tile size =" 64" class =" my-0 " >
2023 <v-img
2124 v-if =" snapshot.thumbnail"
2225 :src =" djangobaseurl + '/media/' + snapshot.thumbnail" >
2326 </v-img >
2427 </v-list-item-avatar >
2528 <v-list-item-content >
2629 <v-list-item-title style =" font-weight :700 " >{{ snapshot.title }}</v-list-item-title >
27- <v-list-item-subtitle >{{ snapshot.topic }}</v-list-item-subtitle >
2830 </v-list-item-content >
29- <v-list-item-action style =" margin :0 0 4px 0 ; align-self : flex-end ;" >
31+ <v-list-item-action style =" margin :0 0 4px 0 ; align-self : center ;" >
3032 <v-btn icon
33+ class =" nobg"
3134 v-if =" snapshot.screenshot"
3235 v-on:click.stop =" function(){}"
3336 :href =" djangobaseurl + '/downloads/' + snapshot.screenshot" >
3437 <v-icon color =" grey lighten-1" >mdi-download</v-icon >
3538 </v-btn >
3639 </v-list-item-action >
3740 </v-list-item >
41+ </div >
3842 </v-list >
3943</template >
4044
4145<style >
4246.snapshotlist .v-list-item {
4347 background-color : #f8f8f8 ;
4448 border-radius : 4px ;
49+ overflow : hidden ;
4550}
4651.snapshotlist .v-list-item ,
4752.snapshotlist .v-list-item__content {
48- min-height : 80 px ;
53+ min-height : 64 px ;
4954}
55+
5056.snapshotlist .v-list-item--active ::before {
51- background-color : transparent ;
57+ background-color : #543076 ;
5258 border : 1px solid #000 ;
5359 border-radius : 4px ;
5460}
61+
62+ .v-list-item__title {
63+ display : -webkit-box ;
64+ -webkit-box-orient : vertical ;
65+ -webkit-line-clamp : 3 ;
66+ overflow : hidden ;
67+ white-space : initial ;
68+ text-overflow : ellipsis ;
69+ }
5570 </style >
5671
5772
@@ -60,7 +75,8 @@ export default {
6075 name: ' SnapshotList' ,
6176 data () {
6277 return {
63- djangobaseurl: process .env .VUE_APP_DJANGOBASEURL
78+ djangobaseurl: process .env .VUE_APP_DJANGOBASEURL ,
79+ groupedsnapshots: []
6480 };
6581 },
6682
@@ -69,7 +85,11 @@ export default {
6985 type: String ,
7086 default: ' '
7187 },
72- snapshots: Array
88+ snapshots: Array ,
89+ withTopic: {
90+ type: Boolean ,
91+ default: true
92+ }
7393 },
7494
7595 methods: {
@@ -78,6 +98,32 @@ export default {
7898 return ` /${ this .$i18n .locale } /${ this .workspaceHash } /${ hash} /` ;
7999 }
80100 return ` /${ this .$i18n .locale } /${ hash} /` ;
101+ },
102+ showTopic (curindex ) {
103+ if (curindex > 0 ) {
104+ if (this .groupedsnapshots [curindex - 1 ].topic !== this .groupedsnapshots [curindex].topic ) {
105+ return true ;
106+ }
107+ return false ;
108+ }
109+ return true ;
110+ }
111+ },
112+ watch: {
113+ snapshots (newsnaps ) {
114+ const topicgroups = {};
115+ newsnaps .forEach ((snapshot ) => {
116+ if (typeof (topicgroups[snapshot .topic ]) === ' undefined' ) {
117+ topicgroups[snapshot .topic ] = [];
118+ }
119+ topicgroups[snapshot .topic ].push (snapshot);
120+ });
121+
122+ Object .keys (topicgroups).forEach ((group ) => {
123+ topicgroups[group].forEach ((snapshot ) => {
124+ this .groupedsnapshots .push (snapshot);
125+ });
126+ });
81127 }
82128 }
83129};
0 commit comments