Skip to content

Commit

Permalink
Prettier assets, add remove selection to bulk moderation, fix noscrip…
Browse files Browse the repository at this point in the history
…t multistage moderation, move fixed moderation styles to CSS
  • Loading branch information
rafalp committed Jul 25, 2024
1 parent befff1c commit 48f1146
Show file tree
Hide file tree
Showing 16 changed files with 98 additions and 48 deletions.
6 changes: 3 additions & 3 deletions frontend/src/AjaxLoader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class AjaxLoader {
constructor() {
this.element = document.getElementById("misago-ajax-loader");
this.element = document.getElementById("misago-ajax-loader")
this.requests = 0
this.timeout = null
}
Expand Down Expand Up @@ -28,7 +28,7 @@ class AjaxLoader {
} else {
this.element.classList.remove("busy")
this.element.classList.add("complete")

this.timeout = setTimeout(() => {
this.element.classList.remove("complete")
}, 1500)
Expand All @@ -45,4 +45,4 @@ export function useLoader(target) {
return true
}

export default AjaxLoader
export default AjaxLoader
53 changes: 29 additions & 24 deletions frontend/src/BulkModeration.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ class BulkModeration {
}

registerActions = () => {
this.actions.forEach(element => {
element.addEventListener("click", this.onAction)
});
this.actions.forEach((element) => {
if (element.getAttribute("moderation-action") === "remove-selection") {
element.addEventListener("click", this.onRemoveSelection)
} else {
element.addEventListener("click", this.onAction)
}
})
}

onAction = (event) => {
const form = document.querySelector(this.form)
const data = {};
const data = {}

(new FormData(form)).forEach((value, key) => {
new FormData(form).forEach((value, key) => {
if (typeof data[key] === "undefined") {
data[key] = []
}
Expand All @@ -36,33 +40,34 @@ class BulkModeration {
data.moderation = target.getAttribute("moderation-action")

if (target.getAttribute("moderation-multistage") === "true") {
htmx.ajax(
"POST",
document.location.href,
{
htmx
.ajax("POST", document.location.href, {
target: this.modal,
swap: "innerHTML",
values: data,
}
).then(() => {
$(this.modal).modal("show")
})
})
.then(() => {
$(this.modal).modal("show")
})
} else {
htmx.ajax(
"POST",
document.location.href,
{
target: "#misago-htmx-root",
swap: "outerHTML",
values: data,
}
)
htmx.ajax("POST", document.location.href, {
target: "#misago-htmx-root",
swap: "outerHTML",
values: data,
})
}
}

onRemoveSelection = (event) => {
document.querySelectorAll(this.selection).forEach((element) => {
element.checked = false
})
this.update()
}

registerEvents = () => {
document.body.addEventListener("click", ({ target }) => {
if(target.tagName === "INPUT" && target.type === "checkbox") {
if (target.tagName === "INPUT" && target.type === "checkbox") {
this.update()
}
})
Expand All @@ -86,4 +91,4 @@ class BulkModeration {
}
}

export default BulkModeration
export default BulkModeration
2 changes: 1 addition & 1 deletion frontend/src/htmxErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ export function setupHtmxErrors() {
document.addEventListener("htmx:timeout", handleTimeoutError)
}

setupHtmxErrors()
setupHtmxErrors()
2 changes: 1 addition & 1 deletion frontend/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "jquery-caret"
import htmx from "htmx.org"
import OrderedList from "misago/utils/ordered-list"
import "misago/style/index.less"
import AjaxLoader, { useLoader} from "./AjaxLoader"
import AjaxLoader, { useLoader } from "./AjaxLoader"
import BulkModeration from "./BulkModeration"
import "./formValidators"
import "./htmxErrors"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/style/misago/buttons.less
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@
// Moderation button
.btn-moderation {
.button-variant(@btn-moderation-color; @btn-moderation-bg; @btn-moderation-border);
}
}
8 changes: 6 additions & 2 deletions frontend/src/style/misago/javascript.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
}

.misago-javascript {
.d-js-block { display: block; }
.d-js-flex { display: flex; }
.d-js-block {
display: block;
}
.d-js-flex {
display: flex;
}
}
36 changes: 33 additions & 3 deletions frontend/src/style/misago/moderation.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
@keyframes fixed-moderation-fade-in {
from {opacity: 0;}
to {opacity: 1;}
from {
opacity: 0;
}
to {
opacity: 1;
}
}

.fixed-moderation {
Expand All @@ -22,4 +26,30 @@
animation-name: fixed-moderation-fade-in;
animation-duration: 300ms;
}
}

.container {
display: flex;
flex-direction: row;
justify-content: end;
pointer-events: none;
}

.dropup {
pointer-events: all;
}
}

@media screen and (max-width: @screen-xs-max) {
.fixed-moderation .container {
display: block;
}

.fixed-moderation .dropdown-menu {
width: 100%;
}

.btn-moderation {
display: block;
width: 100%;
}
}
2 changes: 1 addition & 1 deletion frontend/src/style/misago/noscript-collapsible.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ input:checked + .noscript-collapsible-items {

.noscript-collapsible-items .btn {
margin-top: @line-height-computed / 2;
}
}
2 changes: 1 addition & 1 deletion frontend/src/style/misago/responsive-utils.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
.flex-order-last-xs {
order: 9999;
}
}
}
9 changes: 5 additions & 4 deletions frontend/src/style/misago/threads-lists.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.threads-list {
padding: 0;
margin-bottom: @line-height-computed;

background-color: @list-group-bg;
border: 1px solid @list-group-border;
border-radius: @list-group-border-radius;
Expand Down Expand Up @@ -64,7 +64,7 @@

.threads-list-item-animate {
animation-name: misago-threads-list-item-animate;
animation-duration: .5s;
animation-duration: 0.5s;
animation-iteration-count: 1;
}

Expand Down Expand Up @@ -283,7 +283,8 @@

line-height: 0;
}
a:hover, a:focus {
a:hover,
a:focus {
text-decoration: none;
}
}
Expand Down Expand Up @@ -526,4 +527,4 @@
.threads-list-blankslate-message {
font-size: @font-size-base;
}
}
}
2 changes: 1 addition & 1 deletion misago/static/misago/css/misago.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion misago/static/misago/css/misago.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion misago/static/misago/js/misago.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion misago/static/misago/js/misago.js.map

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions misago/templates/misago/threads/moderation.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% load i18n %}
{% if threads.moderation_actions %}
<div class="fixed-moderation">
<div class="container" style="display: flex; flex-direction: row; justify-content: end;">
<div class="dropup" style="pointer-events: auto;">
<div class="container">
<div class="dropup">
<button
class="btn btn-moderation dropdown-toggle"
type="button"
Expand All @@ -13,6 +13,16 @@
>
</button>
<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="threads-moderation-menu">
<li>
<button
class="btn btn-link"
type="button"
moderation-action="remove-selection"
>
{% trans "Remove selection" context "moderation menu" %}
</button>
</li>
<li role="separator" class="divider"></li>
{% for action in threads.moderation_actions %}
<li>
<button
Expand Down
2 changes: 1 addition & 1 deletion misago/templates/misago/threads/moderation_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h3 class="panel-title">
</h3>
</div>
<div class="panel-body">
{% incladude template_name %}
{% include template_name %}
</div>
<div class="panel-footer panel-footer-sticky">
<button class="btn btn-primary" type="submit">
Expand Down

0 comments on commit 48f1146

Please sign in to comment.