Skip to content
Snippets Groups Projects
Commit 7c031eb1 authored by Ciarán Ainsworth's avatar Ciarán Ainsworth Committed by Agate
Browse files

Resolve "Allow hiding compilation artists in the Artists tab"

parent 806912c0
No related branches found
No related tags found
No related merge requests found
......@@ -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,
......
Allow users to hide compilation artists on the artist search page (#1053)
\ No newline at end of file
......@@ -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"
......
......@@ -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"
......
......@@ -44,6 +44,13 @@
<option :value="parseInt(50)">50</option>
</select>
</div>
<div class="field">
<label><translate translate-context="Content/Search/Checkbox/Noun">Exclude Compilation Artists</translate></label>
<div id="excludeCompilation" class="ui fitted toggle checkbox">
<input id="exclude-compilation" v-model="excludeCompilation" true-value="true" false-value="null" type="checkbox">
<label></label>
</div>
</div>
</div>
</form>
<div class="ui hidden divider"></div>
......@@ -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()
}
}
}
......
......@@ -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";
......
#excludeCompilation {
margin-top: 0.7rem;
}
.ui.multiple.search.dropdown > input.search {
width: auto;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment