Added a button to star/unstar tracks, fixes #687
This commit is contained in:
@@ -19,6 +19,8 @@
|
|||||||
<message id="Lms.template.edit-btn"><i class="fa fa-fw fa-edit"></i></message>
|
<message id="Lms.template.edit-btn"><i class="fa fa-fw fa-edit"></i></message>
|
||||||
<message id="Lms.template.more-btn"><i class="fa fa-fw fa-ellipsis-v"></i></message>
|
<message id="Lms.template.more-btn"><i class="fa fa-fw fa-ellipsis-v"></i></message>
|
||||||
<message id="Lms.template.play-btn"><i class="fa fa-fw fa-play"></i></message>
|
<message id="Lms.template.play-btn"><i class="fa fa-fw fa-play"></i></message>
|
||||||
|
<message id="Lms.template.star-btn"><i class="fa fa-fw fa-star-o"></i></message>
|
||||||
<message id="Lms.template.toggle-visibility-btn"><i class="fa fa-fw fa-eye"></i></message>
|
<message id="Lms.template.toggle-visibility-btn"><i class="fa fa-fw fa-eye"></i></message>
|
||||||
|
<message id="Lms.template.unstar-btn"><i class="fa fa-fw fa-star"></i></message>
|
||||||
|
|
||||||
</messages>
|
</messages>
|
||||||
|
|||||||
@@ -101,6 +101,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="p-2 d-flex">
|
<div class="p-2 d-flex">
|
||||||
${play-btn class="d-none d-sm-block btn btn-sm btn-outline-secondary border-0"}
|
${play-btn class="d-none d-sm-block btn btn-sm btn-outline-secondary border-0"}
|
||||||
|
${star-btn class="d-none d-sm-block btn btn-sm btn-outline-secondary border-0"}
|
||||||
<div class="dropdown d-inline-block">
|
<div class="dropdown d-inline-block">
|
||||||
${more-btn data-bs-toggle="dropdown" aria-expanded="false" class="btn btn-sm btn-outline-secondary border-0"}
|
${more-btn data-bs-toggle="dropdown" aria-expanded="false" class="btn btn-sm btn-outline-secondary border-0"}
|
||||||
<ul class="dropdown-menu" aria-labelledby="${id:more-btn}">
|
<ul class="dropdown-menu" aria-labelledby="${id:more-btn}">
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="p-2 d-flex">
|
<div class="p-2 d-flex">
|
||||||
${play-btn class="d-none d-sm-block btn btn-sm btn-outline-secondary border-0"}
|
${play-btn class="d-none d-sm-block btn btn-sm btn-outline-secondary border-0"}
|
||||||
|
${star-btn class="d-none d-sm-block btn btn-sm btn-outline-secondary border-0"}
|
||||||
<div class="dropdown d-inline-block">
|
<div class="dropdown d-inline-block">
|
||||||
${more-btn data-bs-toggle="dropdown" aria-expanded="false" class="btn btn-sm btn-outline-secondary border-0"}
|
${more-btn data-bs-toggle="dropdown" aria-expanded="false" class="btn btn-sm btn-outline-secondary border-0"}
|
||||||
<ul class="dropdown-menu" aria-labelledby="${id:more-btn}">
|
<ul class="dropdown-menu" aria-labelledby="${id:more-btn}">
|
||||||
|
|||||||
@@ -497,21 +497,32 @@ namespace lms::ui
|
|||||||
_playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, { trackId });
|
_playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, { trackId });
|
||||||
});
|
});
|
||||||
|
|
||||||
auto isStarred{ [=] { return core::Service<feedback::IFeedbackService>::get()->isStarred(LmsApp->getUserId(), trackId); } };
|
{
|
||||||
|
auto isStarred{ [=] { return core::Service<feedback::IFeedbackService>::get()->isStarred(LmsApp->getUserId(), trackId); } };
|
||||||
|
|
||||||
Wt::WPushButton* starBtn{ entry->bindNew<Wt::WPushButton>("star", Wt::WString::tr(isStarred() ? "Lms.Explore.unstar" : "Lms.Explore.star")) };
|
Wt::WPushButton* starBtn{ entry->bindNew<Wt::WPushButton>("star-btn", Wt::WString::tr(isStarred() ? "Lms.template.unstar-btn" : "Lms.template.star-btn"), Wt::TextFormat::XHTML) };
|
||||||
starBtn->clicked().connect([=] {
|
Wt::WPushButton* starMenuEntry{ entry->bindNew<Wt::WPushButton>("star", Wt::WString::tr(isStarred() ? "Lms.Explore.unstar" : "Lms.Explore.star")) };
|
||||||
if (isStarred())
|
|
||||||
{
|
auto toggle{ [=] {
|
||||||
core::Service<feedback::IFeedbackService>::get()->unstar(LmsApp->getUserId(), trackId);
|
auto transaction{ LmsApp->getDbSession().createWriteTransaction() };
|
||||||
starBtn->setText(Wt::WString::tr("Lms.Explore.star"));
|
|
||||||
}
|
if (isStarred())
|
||||||
else
|
{
|
||||||
{
|
core::Service<feedback::IFeedbackService>::get()->unstar(LmsApp->getUserId(), trackId);
|
||||||
core::Service<feedback::IFeedbackService>::get()->star(LmsApp->getUserId(), trackId);
|
starMenuEntry->setText(Wt::WString::tr("Lms.Explore.star"));
|
||||||
starBtn->setText(Wt::WString::tr("Lms.Explore.unstar"));
|
starBtn->setText(Wt::WString::tr("Lms.template.star-btn"));
|
||||||
}
|
}
|
||||||
});
|
else
|
||||||
|
{
|
||||||
|
core::Service<feedback::IFeedbackService>::get()->star(LmsApp->getUserId(), trackId);
|
||||||
|
starMenuEntry->setText(Wt::WString::tr("Lms.Explore.unstar"));
|
||||||
|
starBtn->setText(Wt::WString::tr("Lms.template.unstar-btn"));
|
||||||
|
}
|
||||||
|
} };
|
||||||
|
|
||||||
|
starMenuEntry->clicked().connect([=] { toggle(); });
|
||||||
|
starBtn->clicked().connect([=] { toggle(); });
|
||||||
|
}
|
||||||
|
|
||||||
entry->bindNew<Wt::WPushButton>("download", Wt::WString::tr("Lms.Explore.download"))
|
entry->bindNew<Wt::WPushButton>("download", Wt::WString::tr("Lms.Explore.download"))
|
||||||
->setLink(Wt::WLink{ std::make_unique<DownloadTrackResource>(trackId) });
|
->setLink(Wt::WLink{ std::make_unique<DownloadTrackResource>(trackId) });
|
||||||
|
|||||||
@@ -259,6 +259,7 @@ namespace lms::ui::TrackListHelpers
|
|||||||
});
|
});
|
||||||
|
|
||||||
entry->bindNew<Wt::WPushButton>("more-btn", Wt::WString::tr("Lms.template.more-btn"), Wt::TextFormat::XHTML);
|
entry->bindNew<Wt::WPushButton>("more-btn", Wt::WString::tr("Lms.template.more-btn"), Wt::TextFormat::XHTML);
|
||||||
|
|
||||||
entry->bindNew<Wt::WPushButton>("play", Wt::WString::tr("Lms.Explore.play"))
|
entry->bindNew<Wt::WPushButton>("play", Wt::WString::tr("Lms.Explore.play"))
|
||||||
->clicked()
|
->clicked()
|
||||||
.connect([trackId, &playQueueController] {
|
.connect([trackId, &playQueueController] {
|
||||||
@@ -278,21 +279,28 @@ namespace lms::ui::TrackListHelpers
|
|||||||
{
|
{
|
||||||
auto isStarred{ [=] { return core::Service<feedback::IFeedbackService>::get()->isStarred(LmsApp->getUserId(), trackId); } };
|
auto isStarred{ [=] { return core::Service<feedback::IFeedbackService>::get()->isStarred(LmsApp->getUserId(), trackId); } };
|
||||||
|
|
||||||
Wt::WPushButton* starBtn{ entry->bindNew<Wt::WPushButton>("star", Wt::WString::tr(isStarred() ? "Lms.Explore.unstar" : "Lms.Explore.star")) };
|
Wt::WPushButton* starBtn{ entry->bindNew<Wt::WPushButton>("star-btn", Wt::WString::tr(isStarred() ? "Lms.template.unstar-btn" : "Lms.template.star-btn"), Wt::TextFormat::XHTML) };
|
||||||
starBtn->clicked().connect([=] {
|
Wt::WPushButton* starMenuEntry{ entry->bindNew<Wt::WPushButton>("star", Wt::WString::tr(isStarred() ? "Lms.Explore.unstar" : "Lms.Explore.star")) };
|
||||||
|
|
||||||
|
auto toggle{ [=] {
|
||||||
auto transaction{ LmsApp->getDbSession().createWriteTransaction() };
|
auto transaction{ LmsApp->getDbSession().createWriteTransaction() };
|
||||||
|
|
||||||
if (isStarred())
|
if (isStarred())
|
||||||
{
|
{
|
||||||
core::Service<feedback::IFeedbackService>::get()->unstar(LmsApp->getUserId(), trackId);
|
core::Service<feedback::IFeedbackService>::get()->unstar(LmsApp->getUserId(), trackId);
|
||||||
starBtn->setText(Wt::WString::tr("Lms.Explore.star"));
|
starMenuEntry->setText(Wt::WString::tr("Lms.Explore.star"));
|
||||||
|
starBtn->setText(Wt::WString::tr("Lms.template.star-btn"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
core::Service<feedback::IFeedbackService>::get()->star(LmsApp->getUserId(), trackId);
|
core::Service<feedback::IFeedbackService>::get()->star(LmsApp->getUserId(), trackId);
|
||||||
starBtn->setText(Wt::WString::tr("Lms.Explore.unstar"));
|
starMenuEntry->setText(Wt::WString::tr("Lms.Explore.unstar"));
|
||||||
|
starBtn->setText(Wt::WString::tr("Lms.template.unstar-btn"));
|
||||||
}
|
}
|
||||||
});
|
} };
|
||||||
|
|
||||||
|
starMenuEntry->clicked().connect([=] { toggle(); });
|
||||||
|
starBtn->clicked().connect([=] { toggle(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
entry->bindNew<Wt::WPushButton>("download", Wt::WString::tr("Lms.Explore.download"))
|
entry->bindNew<Wt::WPushButton>("download", Wt::WString::tr("Lms.Explore.download"))
|
||||||
|
|||||||
Reference in New Issue
Block a user