diff --git a/api/funkwhale_api/music/filters.py b/api/funkwhale_api/music/filters.py index d8d703407..f9eba868a 100644 --- a/api/funkwhale_api/music/filters.py +++ b/api/funkwhale_api/music/filters.py @@ -101,6 +101,7 @@ class ArtistFilter( q = fields.SearchFilter(search_fields=["name"], fts_search_fields=["body_text"]) playable = filters.BooleanFilter(field_name="_", method="filter_playable") + has_albums = filters.BooleanFilter(field_name="_", method="filter_has_albums") tag = TAG_FILTER scope = common_filters.ActorScopeFilter( actor_field="tracks__uploads__library__actor", distinct=True @@ -130,6 +131,12 @@ class ArtistFilter( actor = utils.get_actor_from_request(self.request) return queryset.playable_by(actor, value).distinct() + def filter_has_albums(self, queryset, name, value): + if value is True: + return queryset.filter(albums__isnull=False) + else: + return queryset.filter(albums__isnull=True) + class TrackFilter( RelatedFilterSet, diff --git a/changes/changelog.d/1053.feature b/changes/changelog.d/1053.feature new file mode 100644 index 000000000..8f4c1b9d4 --- /dev/null +++ b/changes/changelog.d/1053.feature @@ -0,0 +1 @@ +Allow users to hide compilation artists on the artist search page (#1053) \ No newline at end of file diff --git a/docs/api/parameters.yml b/docs/api/parameters.yml index f8345ff86..088716e22 100644 --- a/docs/api/parameters.yml +++ b/docs/api/parameters.yml @@ -67,6 +67,14 @@ Playable: schema: required: false type: "boolean" +HasAlbums: + name: "has_albums" + in: "query" + default: null + description: "Filter/exclude artists with no associated albums" + schema: + required: false + type: "boolean" Refresh: name: "refresh" in: "query" diff --git a/docs/swagger.yml b/docs/swagger.yml index 6327dde77..6b34c752e 100644 --- a/docs/swagger.yml +++ b/docs/swagger.yml @@ -361,6 +361,7 @@ paths: - name - random - $ref: "./api/parameters.yml#/Playable" + - $ref: "./api/parameters.yml#/HasAlbums" - $ref: "./api/parameters.yml#/Library" - $ref: "./api/parameters.yml#/PageNumber" - $ref: "./api/parameters.yml#/PageSize" diff --git a/front/src/components/library/Artists.vue b/front/src/components/library/Artists.vue index 98d06e776..e72228589 100644 --- a/front/src/components/library/Artists.vue +++ b/front/src/components/library/Artists.vue @@ -44,6 +44,13 @@ +
+ +
+ + +
+
@@ -116,6 +123,7 @@ export default { return { isLoading: true, result: null, + excludeCompilation: true, page: parseInt(this.defaultPage), query: this.defaultQuery, tags: (this.defaultTags || []).filter((t) => { return t.length > 0 }), @@ -161,6 +169,7 @@ export default { scope: this.scope, page: this.page, page_size: this.paginateBy, + has_albums: this.excludeCompilation, q: this.query, ordering: this.getOrderingAsString(), playable: "true", @@ -195,6 +204,9 @@ export default { }, "$store.state.moderation.lastUpdate": function () { this.fetchData() + }, + excludeCompilation() { + this.fetchData() } } } diff --git a/front/src/style/_main.scss b/front/src/style/_main.scss index bcd41d204..c04600460 100644 --- a/front/src/style/_main.scss +++ b/front/src/style/_main.scss @@ -47,6 +47,7 @@ $bottom-player-height: 4rem; @import "./pages/_admin_account_detail.scss"; @import "./pages/_admin_domain_detail.scss"; @import "./pages/_admin_library.scss"; +@import "./pages/_artists.scss"; @import "./pages/_home.scss"; @import "./pages/_library.scss"; @import "./pages/_notifications.scss"; diff --git a/front/src/style/pages/_artists.scss b/front/src/style/pages/_artists.scss new file mode 100644 index 000000000..dd632dd53 --- /dev/null +++ b/front/src/style/pages/_artists.scss @@ -0,0 +1,7 @@ +#excludeCompilation { + margin-top: 0.7rem; +} + +.ui.multiple.search.dropdown > input.search { + width: auto; +} \ No newline at end of file