From 6ad8b212cff39072c8890796b31dbb19c306a41c Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Sun, 17 Dec 2017 20:07:18 +0100 Subject: [PATCH] Fixed #50: ordering for favorites --- api/funkwhale_api/music/views.py | 7 +- front/src/components/favorites/List.vue | 76 ++++++++++++++++++++-- front/src/components/library/Artists.vue | 31 +++------ front/src/components/mixins/Ordering.vue | 26 ++++++++ front/src/components/mixins/Pagination.vue | 8 +++ front/src/router/index.js | 6 +- 6 files changed, 124 insertions(+), 30 deletions(-) create mode 100644 front/src/components/mixins/Ordering.vue create mode 100644 front/src/components/mixins/Pagination.vue diff --git a/api/funkwhale_api/music/views.py b/api/funkwhale_api/music/views.py index 5bfefc29b..532942e2e 100644 --- a/api/funkwhale_api/music/views.py +++ b/api/funkwhale_api/music/views.py @@ -95,7 +95,12 @@ class TrackViewSet(TagViewSetMixin, SearchMixin, viewsets.ReadOnlyModelViewSet): serializer_class = serializers.TrackSerializerNested permission_classes = [ConditionalAuthentication] search_fields = ['title', 'artist__name'] - ordering_fields = ('creation_date',) + ordering_fields = ( + 'creation_date', + 'title', + 'album__title', + 'artist__name', + ) def get_queryset(self): queryset = super().get_queryset() diff --git a/front/src/components/favorites/List.vue b/front/src/components/favorites/List.vue index 63c3ba79d..91efd7290 100644 --- a/front/src/components/favorites/List.vue +++ b/front/src/components/favorites/List.vue @@ -9,9 +9,36 @@ {{ favoriteTracks.count }} favorites -
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
diff --git a/front/src/components/mixins/Pagination.vue b/front/src/components/mixins/Pagination.vue new file mode 100644 index 000000000..532faaaa3 --- /dev/null +++ b/front/src/components/mixins/Pagination.vue @@ -0,0 +1,8 @@ + diff --git a/front/src/router/index.js b/front/src/router/index.js index f6653e73d..7db5da6ba 100644 --- a/front/src/router/index.js +++ b/front/src/router/index.js @@ -47,7 +47,11 @@ export default new Router({ }, { path: '/favorites', - component: Favorites + component: Favorites, + props: (route) => ({ + defaultOrdering: route.query.ordering, + defaultPage: route.query.page + }) }, { path: '/library',