forked from dbroqua/MusicTopus
#45 - Ajouter de nouveaux filtres sur la liste
This commit is contained in:
parent
f5196edfb8
commit
9dd7a35f22
4 changed files with 164 additions and 1 deletions
|
@ -81,6 +81,9 @@ class Albums extends Pages {
|
|||
order = "asc",
|
||||
artists_sort,
|
||||
format,
|
||||
year,
|
||||
genre,
|
||||
style,
|
||||
userId: collectionUserId,
|
||||
} = this.req.query;
|
||||
|
||||
|
@ -94,6 +97,15 @@ class Albums extends Pages {
|
|||
if (format) {
|
||||
where["formats.name"] = format;
|
||||
}
|
||||
if (year) {
|
||||
where.year = year;
|
||||
}
|
||||
if (genre) {
|
||||
where.genres = genre;
|
||||
}
|
||||
if (style) {
|
||||
where.styles = style;
|
||||
}
|
||||
|
||||
if (!this.req.user && !collectionUserId) {
|
||||
throw new ErrorEvent(
|
||||
|
@ -199,9 +211,21 @@ class Albums extends Pages {
|
|||
"formats.name",
|
||||
this.req.user._id
|
||||
);
|
||||
const years = await Albums.getAllDistincts("year", this.req.user._id);
|
||||
const genres = await Albums.getAllDistincts(
|
||||
"genres",
|
||||
this.req.user._id
|
||||
);
|
||||
const styles = await Albums.getAllDistincts(
|
||||
"styles",
|
||||
this.req.user._id
|
||||
);
|
||||
|
||||
this.setPageContent("artists", artists);
|
||||
this.setPageContent("formats", formats);
|
||||
this.setPageContent("years", years);
|
||||
this.setPageContent("genres", genres);
|
||||
this.setPageContent("styles", styles);
|
||||
this.setPageTitle("Ma collection");
|
||||
}
|
||||
|
||||
|
@ -245,11 +269,17 @@ class Albums extends Pages {
|
|||
|
||||
const artists = await Albums.getAllDistincts("artists_sort", userId);
|
||||
const formats = await Albums.getAllDistincts("formats.name", userId);
|
||||
const years = await Albums.getAllDistincts("year", userId);
|
||||
const genres = await Albums.getAllDistincts("genres", userId);
|
||||
const styles = await Albums.getAllDistincts("styles", userId);
|
||||
|
||||
this.setPageContent("username", user.username);
|
||||
this.setPageTitle(`Collection publique de ${user.username}`);
|
||||
this.setPageContent("artists", artists);
|
||||
this.setPageContent("formats", formats);
|
||||
this.setPageContent("years", years);
|
||||
this.setPageContent("genres", genres);
|
||||
this.setPageContent("styles", styles);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue