Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
feb1963aad |
@@ -5,21 +5,18 @@ import { OptimisticAction } from "./OptimisticAction.js";
|
|||||||
export class VoteManager extends OptimisticAction {
|
export class VoteManager extends OptimisticAction {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
document.addEventListener("click", (event) => this.onClick(event));
|
this.initVoteButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
onClick(event) {
|
initVoteButtons() {
|
||||||
const button = event.target.closest('form[action^="/votes/"] button[type="submit"]');
|
document.querySelectorAll('form[action^="/votes/"] button[type="submit"]').forEach((button) => {
|
||||||
if (!button) {
|
const form = button.closest("form");
|
||||||
return;
|
button.addEventListener("click", (event) => {
|
||||||
}
|
event.preventDefault();
|
||||||
const form = button.closest("form");
|
event.stopPropagation();
|
||||||
if (!form) {
|
this.cast(form, button);
|
||||||
return;
|
});
|
||||||
}
|
});
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
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" title="Log in to vote"')
|
return Markup(' disabled aria-disabled="true"')
|
||||||
|
|
||||||
|
|
||||||
def static_url(path) -> str:
|
def static_url(path) -> str:
|
||||||
|
|||||||
+2
-1
@@ -4,7 +4,8 @@ version = "1.0.0"
|
|||||||
description = "DevPlace - The Developer Social Network"
|
description = "DevPlace - The Developer Social Network"
|
||||||
requires-python = ">=3.12"
|
requires-python = ">=3.12"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fastapi",
|
"fastapi>=0.110.0",
|
||||||
|
"starlette>=0.37.0",
|
||||||
"uvicorn[standard]",
|
"uvicorn[standard]",
|
||||||
"jinja2",
|
"jinja2",
|
||||||
"python-multipart",
|
"python-multipart",
|
||||||
|
|||||||
Reference in New Issue
Block a user