Added css style for each cluster type. Unified cluster handling in UI
This commit is contained in:
@@ -172,6 +172,22 @@ LmsApplication::createReleaseAnchor(Database::Release::pointer release, bool add
|
||||
return res;
|
||||
}
|
||||
|
||||
std::unique_ptr<Wt::WTemplate>
|
||||
LmsApplication::createCluster(Database::Cluster::pointer cluster, bool canDelete)
|
||||
{
|
||||
LMS_LOG(UI, DEBUG) << " Creating cluster for name " << cluster->getName();
|
||||
auto res = std::make_unique<Wt::WTemplate>(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()
|
||||
{
|
||||
|
||||
@@ -60,6 +60,7 @@ class LmsApplication : public Wt::WApplication
|
||||
|
||||
static std::unique_ptr<Wt::WAnchor> createArtistAnchor(Database::Artist::pointer artist, bool addText = true);
|
||||
static std::unique_ptr<Wt::WAnchor> createReleaseAnchor(Database::Release::pointer release, bool addText = true);
|
||||
static std::unique_ptr<Wt::WTemplate> createCluster(Database::Cluster::pointer cluster, bool canDelete= false);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -79,10 +79,7 @@ Artist::refresh()
|
||||
auto clusters = artist->getClusters(3);
|
||||
|
||||
for (auto cluster : clusters)
|
||||
{
|
||||
Wt::WTemplate* entry = clusterContainers->addNew<Wt::WTemplate>(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);
|
||||
|
||||
@@ -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::WPushButton>(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<Wt::WPushButton>("add-filter", Wt::WText::tr("Lms.Explore.add-filter"));
|
||||
addFilterBtn->clicked().connect(this, &Filters::showDialog);
|
||||
|
||||
_filters = bindNew<Wt::WContainerWidget>("filters");
|
||||
_filters = bindNew<Wt::WContainerWidget>("clusters");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -112,10 +112,7 @@ Release::refresh()
|
||||
auto clusters = release->getClusters(3);
|
||||
|
||||
for (auto cluster : clusters)
|
||||
{
|
||||
Wt::WTemplate* entry = clusterContainers->addNew<Wt::WTemplate>(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));
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user