ticket #94 attempt 1
This commit is contained in:
parent
43c5a948e8
commit
ecaed0adaa
@ -5,18 +5,21 @@ import { OptimisticAction } from "./OptimisticAction.js";
|
|||||||
export class VoteManager extends OptimisticAction {
|
export class VoteManager extends OptimisticAction {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.initVoteButtons();
|
document.addEventListener("click", (event) => this.onClick(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
initVoteButtons() {
|
onClick(event) {
|
||||||
document.querySelectorAll('form[action^="/votes/"] button[type="submit"]').forEach((button) => {
|
const button = event.target.closest('form[action^="/votes/"] button[type="submit"]');
|
||||||
|
if (!button) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const form = button.closest("form");
|
const form = button.closest("form");
|
||||||
button.addEventListener("click", (event) => {
|
if (!form) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
this.cast(form, button);
|
this.cast(form, button);
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cast(form, button) {
|
cast(form, button) {
|
||||||
|
|||||||
@ -29,7 +29,7 @@ def is_self(user, uid) -> bool:
|
|||||||
def guest_disabled(user) -> Markup:
|
def guest_disabled(user) -> Markup:
|
||||||
if user:
|
if user:
|
||||||
return Markup("")
|
return Markup("")
|
||||||
return Markup(' disabled aria-disabled="true"')
|
return Markup(' disabled aria-disabled="true" title="Log in to vote"')
|
||||||
|
|
||||||
|
|
||||||
def static_url(path) -> str:
|
def static_url(path) -> str:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user