mirror of
https://ghfast.top/https://github.com/discourse/discourse-topic-voting.git
synced 2026-05-28 00:44:08 +08:00
36 lines
829 B
JavaScript
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;
|
|
},
|
|
});
|