discourse-topic-voting/assets/javascripts/discourse/widgets/vote-options.js
2024-01-16 17:43:56 +01:00

36 lines
829 B
JavaScript

import { h } from "virtual-dom";
import { createWidget } from "discourse/widgets/widget";
import I18n from "I18n";
export default createWidget("vote-options", {
tagName: "div.vote-options",
buildClasses() {
return "voting-popup-menu popup-menu hidden";
},
html(attrs) {
let contents = [];
if (attrs.user_voted) {
contents.push(this.attach("remove-vote", attrs));
} else if (
this.currentUser &&
this.currentUser.votes_exceeded &&
!attrs.user_voted
) {
contents.push([
h("div", I18n.t("topic_voting.reached_limit")),
h(
"p",
h(
"a",
{ href: this.currentUser.get("path") + "/activity/votes" },
I18n.t("topic_voting.list_votes")
)
),
]);
}
return contents;
},
});