Add rules language support and improve password validation across the app
This commit is contained in:
+18
-2
@@ -12,21 +12,37 @@
|
||||
if (user.is_system_admin) state.users = await API.listUsers();
|
||||
}
|
||||
|
||||
function openCompetitionModal() {
|
||||
async function openCompetitionModal() {
|
||||
const backdrop = el("div", { class: "modal-backdrop",
|
||||
onclick: (e) => { if (e.target === backdrop) backdrop.remove(); } });
|
||||
const nameInput = el("input", { type: "text" });
|
||||
const allowInput = el("input", { type: "checkbox" });
|
||||
let langs = I18N_AVAILABLE;
|
||||
try {
|
||||
const fromApi = await API.listRuleLanguages();
|
||||
if (fromApi && fromApi.length) langs = [...fromApi].sort();
|
||||
} catch (e) {}
|
||||
const defaultLang = langs.includes(user.language) ? user.language : "en";
|
||||
const langInput = el("select", null,
|
||||
...langs.map((l) => el("option", { value: l, selected: l === defaultLang },
|
||||
I18N_NAMES[l] || l))
|
||||
);
|
||||
backdrop.appendChild(el("div", { class: "modal" },
|
||||
el("h3", null, t("new_competition")),
|
||||
el("div", { class: "field" }, el("label", null, t("competition_name")), nameInput),
|
||||
el("div", { class: "field" }, el("label", null, t("rules_language")), langInput,
|
||||
el("div", { class: "muted small" }, t("rules_language_hint"))),
|
||||
el("label", { class: "row" }, allowInput, " " + t("allow_any_scorer_edit")),
|
||||
el("div", { class: "row", style: { justifyContent: "flex-end", marginTop: "1rem" } },
|
||||
el("button", { onclick: () => backdrop.remove() }, t("cancel")),
|
||||
el("button", { class: "primary", onclick: async () => {
|
||||
if (!nameInput.value.trim()) return;
|
||||
try {
|
||||
await API.createCompetition({ name: nameInput.value.trim(), allow_any_scorer_edit: allowInput.checked });
|
||||
await API.createCompetition({
|
||||
name: nameInput.value.trim(),
|
||||
allow_any_scorer_edit: allowInput.checked,
|
||||
rules_language: langInput.value,
|
||||
});
|
||||
backdrop.remove();
|
||||
await loadCompetitions();
|
||||
render();
|
||||
|
||||
Reference in New Issue
Block a user