BUILD126 - легкие правки по интерфейсу
This commit is contained in:
@@ -2494,7 +2494,7 @@ function startCustomTooltips() {
|
||||
description: String(selector?.description || "").slice(0, 300),
|
||||
group_id: String(selector?.group_id || "").slice(0, 48),
|
||||
button_id: String(selector?.button_id || "").slice(0, 48),
|
||||
style: String(selector?.style || "segments") === "select" ? "select" : "segments",
|
||||
style: ["select", "periods"].includes(String(selector?.style || "segments")) ? String(selector.style) : "segments",
|
||||
options: fallbackOptions,
|
||||
default_value: defaultValue,
|
||||
sort_order: Number.isFinite(Number(selector?.sort_order)) ? Number(selector.sort_order) : index * 10,
|
||||
@@ -8824,7 +8824,7 @@ function openHockeyPrematchButtonsEditor() {
|
||||
let activeEditorSection = "buttons";
|
||||
if (activeEditorGroupId === "__ungrouped") activeEditorGroupId = "";
|
||||
if (activeEditorGroupId && !draftGroups.some((group) => group.id === activeEditorGroupId)) activeEditorGroupId = draftGroups[0]?.id || "";
|
||||
const collapsedEditorGroups = new Set();
|
||||
const collapsedEditorGroups = new Set(["", ...draftGroups.map((group) => String(group.id || ""))]);
|
||||
|
||||
const groupButtons = (groupId) => draft
|
||||
.filter((button) => String(button.group_id || "") === String(groupId || ""))
|
||||
@@ -8875,9 +8875,12 @@ function openHockeyPrematchButtonsEditor() {
|
||||
<label>ID для SQL<input type="text" maxlength="48" data-quick-selector-field="id" data-quick-selector-id="${escapeHtml(selector.id)}" value="${escapeHtml(selector.id)}"></label>
|
||||
<label>Вкладка<select data-quick-selector-field="group_id" data-quick-selector-id="${escapeHtml(selector.id)}">${hockeyPrematchGroupOptions(draftGroups, selector.group_id)}</select></label>
|
||||
<label>Рядом с кнопкой<select data-quick-selector-field="button_id" data-quick-selector-id="${escapeHtml(selector.id)}">${hockeyQuickPanelButtonOptions(draft, selector.button_id)}</select></label>
|
||||
<label>Вид<select data-quick-selector-field="style" data-quick-selector-id="${escapeHtml(selector.id)}">${triggerSelectOptions([["segments","Маленькие кнопки"],["select","Выпадающий список"]], selector.style)}</select></label>
|
||||
<label class="quick-selector-options-field">Варианты <small>значение=подпись; разделитель — точка с запятой</small><input type="text" data-quick-selector-options="${escapeHtml(selector.id)}" value="${escapeHtml(quickPanelSelectorOptionsText(selector))}" placeholder="all=МАТЧ; 1=1; 2=2; 3=3"></label>
|
||||
<label class="quick-selector-default-field">По умолчанию<input type="text" maxlength="64" data-quick-selector-field="default_value" data-quick-selector-id="${escapeHtml(selector.id)}" value="${escapeHtml(selector.default_value)}"></label>
|
||||
<label>Вид<select data-quick-selector-field="style" data-quick-selector-id="${escapeHtml(selector.id)}">${triggerSelectOptions([["segments","Маленькие кнопки"],["select","Выпадающий список"],["periods","Периоды матча · авто"]], selector.style)}</select></label>
|
||||
${selector.style === "periods"
|
||||
? `<label class="quick-selector-options-field quick-selector-auto-note">Периоды <small>Автоматически из режима текущего матча</small><input type="text" value="1 · 2 · 3 · ОТ / ОТ1, ОТ2…" disabled></label>
|
||||
<label class="quick-selector-default-field">По умолчанию<input type="text" value="1" disabled></label>`
|
||||
: `<label class="quick-selector-options-field">Варианты <small>значение=подпись; разделитель — точка с запятой</small><input type="text" data-quick-selector-options="${escapeHtml(selector.id)}" value="${escapeHtml(quickPanelSelectorOptionsText(selector))}" placeholder="all=МАТЧ; 1=1; 2=2; 3=3"></label>
|
||||
<label class="quick-selector-default-field">По умолчанию<input type="text" maxlength="64" data-quick-selector-field="default_value" data-quick-selector-id="${escapeHtml(selector.id)}" value="${escapeHtml(selector.default_value)}"></label>`}
|
||||
<button type="button" class="icon-btn danger" data-quick-selector-delete="${escapeHtml(selector.id)}" title="Удалить переключатель">×</button>
|
||||
</article>`;
|
||||
|
||||
@@ -9112,6 +9115,9 @@ function openHockeyPrematchButtonsEditor() {
|
||||
activeEditorGroupId = String(selector.group_id || "");
|
||||
collapsedEditorGroups.delete(activeEditorGroupId);
|
||||
renderEditor();
|
||||
} else if (field === "style") {
|
||||
if (selector.style === "periods") selector.default_value = "1";
|
||||
renderEditor();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -9233,11 +9239,57 @@ function hockeyMatchRuntimeValues() {
|
||||
return values && typeof values === "object" ? values : {};
|
||||
}
|
||||
|
||||
function quickPanelPeriodLabel(value) {
|
||||
const key = String(value || "").toLowerCase();
|
||||
if (key === "1" || key === "2" || key === "3") return key;
|
||||
if (key === "ot") return "ОТ";
|
||||
const match = key.match(/^ot(\d+)$/);
|
||||
return match ? `ОТ${match[1]}` : String(value || "");
|
||||
}
|
||||
|
||||
function quickPanelSelectorRuntimeOptions(selector) {
|
||||
if (String(selector?.style || "") !== "periods") return Array.isArray(selector?.options) ? selector.options : [];
|
||||
const control = getByPath(state.data, "hockey.game_control") || {};
|
||||
const tournament = getByPath(state.data, "hockey.selected_tournament") || {};
|
||||
const stage = String(control?.stage || tournament?.stage_key || "").toLowerCase();
|
||||
const raw = Array.isArray(control?.period_options) ? control.period_options : [];
|
||||
let options = raw
|
||||
.map((item) => ({ value: String(item?.value || ""), label: quickPanelPeriodLabel(item?.value) }))
|
||||
.filter((item) => {
|
||||
if (["1", "2", "3"].includes(item.value)) return true;
|
||||
if (stage === "playoff") return /^ot\d+$/.test(item.value);
|
||||
return item.value === "ot";
|
||||
});
|
||||
if (!options.length) {
|
||||
options = [
|
||||
{ value: "1", label: "1" },
|
||||
{ value: "2", label: "2" },
|
||||
{ value: "3", label: "3" },
|
||||
];
|
||||
if (stage === "playoff") {
|
||||
const current = String(control?.current_period || "").toLowerCase().match(/^ot(\d+)$/);
|
||||
const count = Math.max(2, Number(current?.[1] || 0) + 1);
|
||||
for (let number = 1; number <= count; number += 1) options.push({ value: `ot${number}`, label: `ОТ${number}` });
|
||||
} else {
|
||||
options.push({ value: "ot", label: "ОТ" });
|
||||
}
|
||||
}
|
||||
const seen = new Set();
|
||||
return options.filter((item) => {
|
||||
if (!item.value || seen.has(item.value)) return false;
|
||||
seen.add(item.value);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
function quickPanelSelectorValue(selector) {
|
||||
const options = quickPanelSelectorRuntimeOptions(selector);
|
||||
const values = hockeyMatchRuntimeValues();
|
||||
const stored = String(values[`panel.${selector.id}.value`] ?? "");
|
||||
if (selector.options.some((option) => option.value === stored)) return stored;
|
||||
return selector.default_value || selector.options[0]?.value || "";
|
||||
if (options.some((option) => option.value === stored)) return stored;
|
||||
const configuredDefault = String(selector?.default_value || "");
|
||||
if (options.some((option) => option.value === configuredDefault)) return configuredDefault;
|
||||
return options[0]?.value || "";
|
||||
}
|
||||
|
||||
async function hockeyRefreshQuickPanelMapping() {
|
||||
@@ -9355,16 +9407,18 @@ function hockeyScoreDockMarkup() {
|
||||
}
|
||||
|
||||
function quickPanelSelectorMarkup(selector) {
|
||||
const options = quickPanelSelectorRuntimeOptions(selector);
|
||||
const current = quickPanelSelectorValue(selector);
|
||||
const tooltip = selector.description || selector.label;
|
||||
if (selector.style === "select") {
|
||||
return `<label class="quick-command-selector is-select" data-tooltip="${escapeHtml(tooltip)}"><span>${escapeHtml(selector.label)}</span><select data-quick-selector-runtime="${escapeHtml(selector.id)}">${selector.options.map((option) => `<option value="${escapeHtml(option.value)}" ${option.value === current ? "selected" : ""}>${escapeHtml(option.label)}</option>`).join("")}</select></label>`;
|
||||
return `<label class="quick-command-selector is-select" data-tooltip="${escapeHtml(tooltip)}"><span>${escapeHtml(selector.label)}</span><select data-quick-selector-runtime="${escapeHtml(selector.id)}">${options.map((option) => `<option value="${escapeHtml(option.value)}" ${option.value === current ? "selected" : ""}>${escapeHtml(option.label)}</option>`).join("")}</select></label>`;
|
||||
}
|
||||
return `<div class="quick-command-selector is-segments" data-tooltip="${escapeHtml(tooltip)}"><span>${escapeHtml(selector.label)}</span><div>${selector.options.map((option) => `<button type="button" data-quick-selector-runtime="${escapeHtml(selector.id)}" data-quick-selector-value="${escapeHtml(option.value)}" class="${option.value === current ? "active" : ""}">${escapeHtml(option.label)}</button>`).join("")}</div></div>`;
|
||||
const modeClass = selector.style === "periods" ? " is-match-periods" : "";
|
||||
return `<div class="quick-command-selector is-segments${modeClass}" data-tooltip="${escapeHtml(tooltip)}"><span>${escapeHtml(selector.label)}</span><div>${options.map((option) => `<button type="button" data-quick-selector-runtime="${escapeHtml(selector.id)}" data-quick-selector-value="${escapeHtml(option.value)}" class="${option.value === current ? "active" : ""}">${escapeHtml(option.label)}</button>`).join("")}</div></div>`;
|
||||
}
|
||||
|
||||
async function hockeyApplyQuickSelector(selector, value, label = "") {
|
||||
const option = selector.options.find((item) => item.value === value);
|
||||
const option = quickPanelSelectorRuntimeOptions(selector).find((item) => item.value === value);
|
||||
const displayLabel = String(label || option?.label || value);
|
||||
await hockeySetMatchValues({
|
||||
[`panel.${selector.id}.value`]: value,
|
||||
@@ -9379,7 +9433,7 @@ async function hockeyCommitQuickPanelButtonContext(button, attachedSelectors, {
|
||||
};
|
||||
for (const selector of attachedSelectors) {
|
||||
const value = quickPanelSelectorValue(selector);
|
||||
const option = selector.options.find((item) => item.value === value);
|
||||
const option = quickPanelSelectorRuntimeOptions(selector).find((item) => item.value === value);
|
||||
patch[`panel.${selector.id}.value`] = value;
|
||||
patch[`panel.${selector.id}.label`] = option?.label || value;
|
||||
patch[`panel.last_button.${selector.id}`] = value;
|
||||
@@ -9440,7 +9494,7 @@ function renderHockeyQuickCommandDock() {
|
||||
const selector = selectors.find((item) => item.id === control.dataset.quickSelectorRuntime);
|
||||
if (!selector) return;
|
||||
const value = control.tagName === "SELECT" ? control.value : String(control.dataset.quickSelectorValue || "");
|
||||
const option = selector.options.find((item) => item.value === value);
|
||||
const option = quickPanelSelectorRuntimeOptions(selector).find((item) => item.value === value);
|
||||
try {
|
||||
await hockeyApplyQuickSelector(selector, value, option?.label || value);
|
||||
toast(`Параметр «${selector.label}»: ${option?.label || value}`);
|
||||
|
||||
Reference in New Issue
Block a user