diff --git a/approot/artist.xml b/approot/artist.xml index d9946518..bc13da08 100644 --- a/approot/artist.xml +++ b/approot/artist.xml @@ -19,10 +19,6 @@ ${releases class="list-group"} - - ${name} - - diff --git a/approot/explore.xml b/approot/explore.xml index f20c320b..9cb083b3 100644 --- a/approot/explore.xml +++ b/approot/explore.xml @@ -12,10 +12,14 @@ - ${add-filter}${filters} + ${add-filter}${clusters} + + ${}${} ${name} + + diff --git a/approot/release.xml b/approot/release.xml index 0a110c52..e2932eaa 100644 --- a/approot/release.xml +++ b/approot/release.xml @@ -22,10 +22,6 @@ ${tracks} - - ${name} - - ${}${disc-number}-${}${}${track-number}. ${} ${}${artist-name} - ${} diff --git a/src/ui/LmsApplication.cpp b/src/ui/LmsApplication.cpp index f2d302e3..49528722 100644 --- a/src/ui/LmsApplication.cpp +++ b/src/ui/LmsApplication.cpp @@ -172,6 +172,22 @@ LmsApplication::createReleaseAnchor(Database::Release::pointer release, bool add return res; } +std::unique_ptr +LmsApplication::createCluster(Database::Cluster::pointer cluster, bool canDelete) +{ + LMS_LOG(UI, DEBUG) << " Creating cluster for name " << cluster->getName(); + auto res = std::make_unique(Wt::WString::tr("Lms.Explore.template.cluster-entry")); + res->addFunction("tr", &Wt::WTemplate::Functions::tr); + + res->bindString("name", Wt::WString::fromUTF8(cluster->getName()), Wt::TextFormat::Plain); + res->setCondition("if-can-delete", canDelete); + + std::string styleClass = "cluster-type-" + std::to_string(cluster->getType().id() % 10); + res->setStyleClass(styleClass); + + return res; +} + void LmsApplication::goHome() { diff --git a/src/ui/LmsApplication.hpp b/src/ui/LmsApplication.hpp index b8ceda11..e9499347 100644 --- a/src/ui/LmsApplication.hpp +++ b/src/ui/LmsApplication.hpp @@ -60,6 +60,7 @@ class LmsApplication : public Wt::WApplication static std::unique_ptr createArtistAnchor(Database::Artist::pointer artist, bool addText = true); static std::unique_ptr createReleaseAnchor(Database::Release::pointer release, bool addText = true); + static std::unique_ptr createCluster(Database::Cluster::pointer cluster, bool canDelete= false); private: diff --git a/src/ui/explore/ArtistView.cpp b/src/ui/explore/ArtistView.cpp index c11a66d0..2fac685e 100644 --- a/src/ui/explore/ArtistView.cpp +++ b/src/ui/explore/ArtistView.cpp @@ -79,10 +79,7 @@ Artist::refresh() auto clusters = artist->getClusters(3); for (auto cluster : clusters) - { - Wt::WTemplate* entry = clusterContainers->addNew(Wt::WString::tr("Lms.Explore.Artist.template.cluster-entry")); - entry->bindString("name", Wt::WString::fromUTF8(cluster->getName()), Wt::TextFormat::Plain); - } + clusterContainers->addWidget(LmsApp->createCluster(cluster)); } t->bindString("name", Wt::WString::fromUTF8(artist->getName()), Wt::TextFormat::Plain); diff --git a/src/ui/explore/Filters.cpp b/src/ui/explore/Filters.cpp index 59619d08..aa6b03ac 100644 --- a/src/ui/explore/Filters.cpp +++ b/src/ui/explore/Filters.cpp @@ -54,7 +54,6 @@ Filters::showDialog() for (auto type : types) typeCombo->addItem(Wt::WString::fromUTF8(type->getName())); - if (!types.empty()) { auto values = types.front()->getClusters(); @@ -114,11 +113,10 @@ Filters::showDialog() _filterIds.insert(clusterId); _sigUpdated.emit(); - Wt::WPushButton* filterBtn = _filters->addNew(Wt::WString::fromUTF8(value), Wt::TextFormat::Plain); - - filterBtn->clicked().connect(std::bind([=] + auto filter = _filters->addWidget(LmsApp->createCluster(cluster, true)); + filter->clicked().connect(std::bind([=] { - _filters->removeWidget(filterBtn); + _filters->removeWidget(filter); _filterIds.erase(clusterId); _sigUpdated.emit(); })); @@ -134,7 +132,7 @@ Filters::Filters() Wt::WPushButton *addFilterBtn = bindNew("add-filter", Wt::WText::tr("Lms.Explore.add-filter")); addFilterBtn->clicked().connect(this, &Filters::showDialog); - _filters = bindNew("filters"); + _filters = bindNew("clusters"); } diff --git a/src/ui/explore/ReleaseView.cpp b/src/ui/explore/ReleaseView.cpp index 809e8998..ea888001 100644 --- a/src/ui/explore/ReleaseView.cpp +++ b/src/ui/explore/ReleaseView.cpp @@ -112,10 +112,7 @@ Release::refresh() auto clusters = release->getClusters(3); for (auto cluster : clusters) - { - Wt::WTemplate* entry = clusterContainers->addNew(Wt::WString::tr("Lms.Explore.Release.template.cluster-entry")); - entry->bindString("name", Wt::WString::fromUTF8(cluster->getName()), Wt::TextFormat::Plain); - } + clusterContainers->addWidget(LmsApp->createCluster(cluster)); } {