This commit is contained in:
Ondřej Žára 2020-07-26 22:36:03 +02:00
parent f6c094046b
commit d28cc59d08
3 changed files with 18 additions and 6 deletions

View file

@ -1513,7 +1513,8 @@ customElements.define("cyp-yt", YT);
const ICONS$1 = {
"AlbumArtist": "artist",
"Album": "album"
"Album": "album",
"Genre": "music"
};
class Tag extends Item {
@ -1626,7 +1627,8 @@ customElements.define("cyp-filter", Filter);
const TAGS$1 = {
"Album": "Albums",
"AlbumArtist": "Artists"
"AlbumArtist": "Artists",
"Genre": "Genres"
};
function nonempty(str) { return (str.length > 0); }
@ -1693,6 +1695,9 @@ class Library extends Component {
button({icon:"artist"}, "Artists and albums", nav)
.addEventListener("click", _ => this._pushState({type:"tags", tag:"AlbumArtist"}));
button({icon:"music"}, "Genres", nav)
.addEventListener("click", _ => this._pushState({type:"tags", tag:"Genre"}));
button({icon:"folder"}, "Files and directories", nav)
.addEventListener("click", _ => this._pushState({type:"path", path:""}));
@ -1720,7 +1725,7 @@ class Library extends Component {
const values = (await this._mpd.listTags(tag, filter)).filter(nonempty);
clear(this);
if ("AlbumArtist" in filter) { this._buildBack(); }
if ("AlbumArtist" in filter || "Genre" in filter) { this._buildBack(); }
(values.length > 0) && this._addFilter();
values.forEach(value => this._buildTag(tag, value, filter));
}
@ -1795,6 +1800,7 @@ class Library extends Component {
let node;
switch (tag) {
case "AlbumArtist":
case "Genre":
node = new Tag(tag, value, filter);
this.appendChild(node);
node.onClick = () => this._pushState({type:"tags", tag:"Album", filter:node.createChildFilter()});

View file

@ -12,7 +12,8 @@ import { escape, serializeFilter } from "../mpd.js";
const SORT = "-Track";
const TAGS = {
"Album": "Albums",
"AlbumArtist": "Artists"
"AlbumArtist": "Artists",
"Genre": "Genres"
}
function nonempty(str) { return (str.length > 0); }
@ -79,6 +80,9 @@ class Library extends Component {
html.button({icon:"artist"}, "Artists and albums", nav)
.addEventListener("click", _ => this._pushState({type:"tags", tag:"AlbumArtist"}));
html.button({icon:"music"}, "Genres", nav)
.addEventListener("click", _ => this._pushState({type:"tags", tag:"Genre"}));
html.button({icon:"folder"}, "Files and directories", nav)
.addEventListener("click", _ => this._pushState({type:"path", path:""}));
@ -106,7 +110,7 @@ class Library extends Component {
const values = (await this._mpd.listTags(tag, filter)).filter(nonempty);
html.clear(this);
if ("AlbumArtist" in filter) { this._buildBack(); }
if ("AlbumArtist" in filter || "Genre" in filter) { this._buildBack(); }
(values.length > 0) && this._addFilter();
values.forEach(value => this._buildTag(tag, value, filter));
}
@ -181,6 +185,7 @@ class Library extends Component {
let node;
switch (tag) {
case "AlbumArtist":
case "Genre":
node = new Tag(tag, value, filter);
this.appendChild(node);
node.onClick = () => this._pushState({type:"tags", tag:"Album", filter:node.createChildFilter()});

View file

@ -5,7 +5,8 @@ import Item from "../item.js";
const ICONS = {
"AlbumArtist": "artist",
"Album": "album"
"Album": "album",
"Genre": "music"
}
export default class Tag extends Item {