Skip to content

Commit

Permalink
Automatically uncheck 'fuzzy' when editing translations
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Jul 4, 2024
1 parent 1d7230e commit 6b977e5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions frontend/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ import "./styles/table.css"
import "./styles/entries.css"
import "./styles/login.css"

import { onReady } from "./js/utils.js"
import { onReady, qs } from "./js/utils.js"

onReady(() => {
document.body.addEventListener("change", (e) => {
if (e.target.matches(".form--filter input[type=checkbox]")) {
e.target.form.requestSubmit()
}

const entry = e.target.closest(".entry")
if (e.target.closest(".entry__msgstr")) {
qs(".entry__fuzzy input", e.target.closest(".entry")).checked = false
}
})
})

Expand All @@ -34,16 +39,14 @@ onReady(() => {
method: "POST",
credentials: "same-origin",
headers: {
"x-csrftoken": document.querySelector(
"input[name=csrfmiddlewaretoken]",
).value,
"x-csrftoken": qs("input[name=csrfmiddlewaretoken]").value,
},
body,
})
if (r.ok) {
const data = await r.json()
if (data.msgstr) {
t.closest(".field").querySelector("textarea").value = data.msgstr
qs("textarea", t.closest(".field")).value = data.msgstr
} else if (data.error) {
alert(data.error)
}
Expand Down

0 comments on commit 6b977e5

Please sign in to comment.