Loading karaokatalog/ui/static/components/pages/Favorites.js 0 → 100644 +41 −0 Original line number Diff line number Diff line import Base from "./Base.js" import SongList from "../pieces/SongList.js" import Song from "../../model/Song.js" import search from "../../model/search.js" import ClearSearchLink from "../pieces/ClearSearchLink.js" export default { oncreate() { document.title = "Favoriten · Karaokatalog" }, oninit() { Song.load() }, view() { const allFavorites = Song.all?.filter(song => song.favorite) const favoritesToShow = search.apply(allFavorites) let message = null if(!allFavorites) { message = "Lade Songs..." } else if(allFavorites.length === 0) { message = "Du hast noch keine Favoriten markiert." } else if(favoritesToShow.length === 0) { message = [ `Deine Suche ergab keine Treffer unter deinen ${allFavorites.length} Favoriten. `, m(ClearSearchLink, { totalFavoriteCount: allFavorites.length}), ] } else if(allFavorites.length > favoritesToShow.length) { message = [ `Deine Suche zeigt ${favoritesToShow.length} von deinen insgesamt ${allFavorites.length} Favoriten. `, m(ClearSearchLink, { totalFavoriteCount: allFavorites.length}), ] } return m( Base, message && m("p", message), favoritesToShow && m(SongList, { songs: favoritesToShow }), ) }, } Loading
karaokatalog/ui/static/components/pages/Favorites.js 0 → 100644 +41 −0 Original line number Diff line number Diff line import Base from "./Base.js" import SongList from "../pieces/SongList.js" import Song from "../../model/Song.js" import search from "../../model/search.js" import ClearSearchLink from "../pieces/ClearSearchLink.js" export default { oncreate() { document.title = "Favoriten · Karaokatalog" }, oninit() { Song.load() }, view() { const allFavorites = Song.all?.filter(song => song.favorite) const favoritesToShow = search.apply(allFavorites) let message = null if(!allFavorites) { message = "Lade Songs..." } else if(allFavorites.length === 0) { message = "Du hast noch keine Favoriten markiert." } else if(favoritesToShow.length === 0) { message = [ `Deine Suche ergab keine Treffer unter deinen ${allFavorites.length} Favoriten. `, m(ClearSearchLink, { totalFavoriteCount: allFavorites.length}), ] } else if(allFavorites.length > favoritesToShow.length) { message = [ `Deine Suche zeigt ${favoritesToShow.length} von deinen insgesamt ${allFavorites.length} Favoriten. `, m(ClearSearchLink, { totalFavoriteCount: allFavorites.length}), ] } return m( Base, message && m("p", message), favoritesToShow && m(SongList, { songs: favoritesToShow }), ) }, }