свои плюсы
This commit is contained in:
3
app.py
3
app.py
@@ -30,7 +30,8 @@ from ui_builder import install_ui_builder
|
|||||||
from khl_site.khl_data_center import APP as khl_site_app
|
from khl_site.khl_data_center import APP as khl_site_app
|
||||||
|
|
||||||
BASE_DIR = Path(__file__).resolve().parent
|
BASE_DIR = Path(__file__).resolve().parent
|
||||||
BUILD_VERSION = "2026.09.23.7"
|
BUILD_VERSION = "2026.09.23.8"
|
||||||
|
# compatibility: BUILD_VERSION = "2026.09.23.7"
|
||||||
# compatibility: BUILD_VERSION = "2026.09.23.6"
|
# compatibility: BUILD_VERSION = "2026.09.23.6"
|
||||||
# compatibility: BUILD_VERSION = "2026.08.26.1"
|
# compatibility: BUILD_VERSION = "2026.08.26.1"
|
||||||
# compatibility: BUILD_VERSION = "2026.08.25.1"
|
# compatibility: BUILD_VERSION = "2026.08.25.1"
|
||||||
|
|||||||
@@ -938,6 +938,37 @@ class ShootoutAttempt(Base):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class CustomPlusRow(Base):
|
||||||
|
"""One operator-entered row from the match-scoped "Свои плюсы" workspace."""
|
||||||
|
|
||||||
|
__tablename__ = "hockey_custom_plus_rows"
|
||||||
|
|
||||||
|
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||||
|
game_external_id: Mapped[str] = mapped_column(
|
||||||
|
String(64), ForeignKey("hockey_games.external_id", ondelete="CASCADE"),
|
||||||
|
nullable=False,
|
||||||
|
)
|
||||||
|
side: Mapped[str] = mapped_column(String(16), nullable=False)
|
||||||
|
sort_order: Mapped[int] = mapped_column(Integer, nullable=False, default=1)
|
||||||
|
text_value: Mapped[str] = mapped_column(Text, nullable=False, default="")
|
||||||
|
status: Mapped[str] = mapped_column(String(16), nullable=False, default="skip")
|
||||||
|
updated_by: Mapped[str] = mapped_column(String(128), nullable=False, default="")
|
||||||
|
created_at: Mapped[datetime] = mapped_column(
|
||||||
|
DateTime, nullable=False, default=datetime.utcnow
|
||||||
|
)
|
||||||
|
updated_at: Mapped[datetime] = mapped_column(
|
||||||
|
DateTime, nullable=False, default=datetime.utcnow
|
||||||
|
)
|
||||||
|
|
||||||
|
__table_args__ = (
|
||||||
|
UniqueConstraint(
|
||||||
|
"game_external_id", "side", "sort_order",
|
||||||
|
name="uq_hockey_custom_plus_game_side_order",
|
||||||
|
),
|
||||||
|
Index("ix_hockey_custom_plus_game_side", "game_external_id", "side"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class OperatorSession(Base):
|
class OperatorSession(Base):
|
||||||
__tablename__ = "hockey_operator_sessions"
|
__tablename__ = "hockey_operator_sessions"
|
||||||
|
|
||||||
|
|||||||
@@ -142,6 +142,22 @@ class GameLinesPayload(BaseModel):
|
|||||||
language: str = Field(default="ru", pattern="^(ru|en)$")
|
language: str = Field(default="ru", pattern="^(ru|en)$")
|
||||||
|
|
||||||
|
|
||||||
|
class CustomPlusRowPayload(BaseModel):
|
||||||
|
model_config = ConfigDict(extra="ignore")
|
||||||
|
|
||||||
|
side: str = Field(pattern="^(home|away)$")
|
||||||
|
sort_order: int = Field(default=1, ge=1, le=999)
|
||||||
|
text: str = Field(default="", max_length=4000)
|
||||||
|
status: str = Field(default="skip", pattern="^(skip|check|cross)$")
|
||||||
|
|
||||||
|
|
||||||
|
class CustomPlusesPayload(BaseModel):
|
||||||
|
model_config = ConfigDict(extra="ignore")
|
||||||
|
|
||||||
|
rows: list[CustomPlusRowPayload] = Field(default_factory=list)
|
||||||
|
language: str = Field(default="ru", pattern="^(ru|en)$")
|
||||||
|
|
||||||
|
|
||||||
class ShootoutSetupPayload(BaseModel):
|
class ShootoutSetupPayload(BaseModel):
|
||||||
initial_attempts: int = Field(default=3)
|
initial_attempts: int = Field(default=3)
|
||||||
reset: bool = False
|
reset: bool = False
|
||||||
@@ -1202,6 +1218,33 @@ def create_hockey_router(
|
|||||||
except ValueError as error:
|
except ValueError as error:
|
||||||
raise HTTPException(status_code=400, detail=str(error)) from error
|
raise HTTPException(status_code=400, detail=str(error)) from error
|
||||||
|
|
||||||
|
@router.get("/games/{external_id}/custom-pluses")
|
||||||
|
async def get_custom_pluses(
|
||||||
|
external_id: str,
|
||||||
|
language: str = Query("ru", pattern="^(ru|en)$"),
|
||||||
|
user: HockeyUser = Depends(auth_dependency),
|
||||||
|
) -> dict[str, Any]:
|
||||||
|
try:
|
||||||
|
return service.custom_pluses(external_id, language=language)
|
||||||
|
except ValueError as error:
|
||||||
|
raise HTTPException(status_code=404, detail=str(error)) from error
|
||||||
|
|
||||||
|
@router.put("/games/{external_id}/custom-pluses")
|
||||||
|
async def update_custom_pluses(
|
||||||
|
external_id: str,
|
||||||
|
payload: CustomPlusesPayload,
|
||||||
|
user: HockeyUser = Depends(auth_dependency),
|
||||||
|
) -> dict[str, Any]:
|
||||||
|
try:
|
||||||
|
return service.save_custom_pluses(
|
||||||
|
external_id,
|
||||||
|
rows=[item.model_dump() for item in payload.rows],
|
||||||
|
updated_by=user.id,
|
||||||
|
language=payload.language,
|
||||||
|
)
|
||||||
|
except ValueError as error:
|
||||||
|
raise HTTPException(status_code=400, detail=str(error)) from error
|
||||||
|
|
||||||
@router.put("/games/{external_id}/control/values")
|
@router.put("/games/{external_id}/control/values")
|
||||||
async def update_game_values(
|
async def update_game_values(
|
||||||
external_id: str,
|
external_id: str,
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ from .models import (
|
|||||||
Coach,
|
Coach,
|
||||||
CoachTournament,
|
CoachTournament,
|
||||||
Country,
|
Country,
|
||||||
|
CustomPlusRow,
|
||||||
EndpointDiscovery,
|
EndpointDiscovery,
|
||||||
Game,
|
Game,
|
||||||
GameControlState,
|
GameControlState,
|
||||||
@@ -7661,6 +7662,118 @@ class HockeyDataService:
|
|||||||
raise ValueError("Матч не найден")
|
raise ValueError("Матч не найден")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _custom_plus_row_payload(row: CustomPlusRow) -> dict[str, Any]:
|
||||||
|
return {
|
||||||
|
"id": row.id,
|
||||||
|
"game_external_id": row.game_external_id,
|
||||||
|
"side": row.side,
|
||||||
|
"sort_order": int(row.sort_order or 0),
|
||||||
|
"text": row.text_value or "",
|
||||||
|
"status": row.status or "skip",
|
||||||
|
"updated_by": row.updated_by or "",
|
||||||
|
"created_at": row.created_at.isoformat() if row.created_at else None,
|
||||||
|
"updated_at": row.updated_at.isoformat() if row.updated_at else None,
|
||||||
|
}
|
||||||
|
|
||||||
|
def custom_pluses(
|
||||||
|
self,
|
||||||
|
game_external_id: str,
|
||||||
|
*,
|
||||||
|
language: str = "ru",
|
||||||
|
) -> dict[str, Any]:
|
||||||
|
settings = self.settings.public()
|
||||||
|
language = normalise_language(language, settings["ui_language"])
|
||||||
|
fallback_language = settings["fallback_language"]
|
||||||
|
with self.database.session() as session:
|
||||||
|
game = session.scalar(select(Game).where(Game.external_id == str(game_external_id)))
|
||||||
|
if game is None:
|
||||||
|
raise ValueError("Матч не найден")
|
||||||
|
rows = list(session.scalars(
|
||||||
|
select(CustomPlusRow)
|
||||||
|
.where(CustomPlusRow.game_external_id == game.external_id)
|
||||||
|
.order_by(CustomPlusRow.side, CustomPlusRow.sort_order, CustomPlusRow.id)
|
||||||
|
))
|
||||||
|
game_payload = self._serialize_game(
|
||||||
|
game, language=language, fallback_language=fallback_language
|
||||||
|
)
|
||||||
|
grouped = {"home": [], "away": []}
|
||||||
|
for row in rows:
|
||||||
|
if row.side in grouped:
|
||||||
|
grouped[row.side].append(self._custom_plus_row_payload(row))
|
||||||
|
return {
|
||||||
|
"game_external_id": str(game_external_id),
|
||||||
|
"home": grouped["home"],
|
||||||
|
"away": grouped["away"],
|
||||||
|
"teams": {
|
||||||
|
"home": game_payload.get("home") or {},
|
||||||
|
"away": game_payload.get("away") or {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
def save_custom_pluses(
|
||||||
|
self,
|
||||||
|
game_external_id: str,
|
||||||
|
*,
|
||||||
|
rows: list[dict[str, Any]],
|
||||||
|
updated_by: str = "",
|
||||||
|
language: str = "ru",
|
||||||
|
) -> dict[str, Any]:
|
||||||
|
normalised: dict[tuple[str, int], dict[str, Any]] = {}
|
||||||
|
for index, item in enumerate(rows or []):
|
||||||
|
side = str(item.get("side") or "").strip().lower()
|
||||||
|
if side not in {"home", "away"}:
|
||||||
|
raise ValueError("Неизвестная сторона строки")
|
||||||
|
try:
|
||||||
|
sort_order = int(item.get("sort_order") or index + 1)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
sort_order = index + 1
|
||||||
|
if sort_order < 1 or sort_order > 999:
|
||||||
|
raise ValueError("Порядок строки должен быть от 1 до 999")
|
||||||
|
status = str(item.get("status") or "skip").strip().lower()
|
||||||
|
if status not in {"skip", "check", "cross"}:
|
||||||
|
raise ValueError("Неизвестный статус строки")
|
||||||
|
text_value = str(item.get("text") or "").strip()
|
||||||
|
if len(text_value) > 4000:
|
||||||
|
raise ValueError("Текст строки не должен быть длиннее 4000 символов")
|
||||||
|
normalised[(side, sort_order)] = {
|
||||||
|
"side": side,
|
||||||
|
"sort_order": sort_order,
|
||||||
|
"text_value": text_value,
|
||||||
|
"status": status,
|
||||||
|
}
|
||||||
|
|
||||||
|
now = datetime.utcnow()
|
||||||
|
with self.database.session() as session:
|
||||||
|
game = session.scalar(select(Game).where(Game.external_id == str(game_external_id)))
|
||||||
|
if game is None:
|
||||||
|
raise ValueError("Матч не найден")
|
||||||
|
existing = list(session.scalars(
|
||||||
|
select(CustomPlusRow).where(CustomPlusRow.game_external_id == game.external_id)
|
||||||
|
))
|
||||||
|
existing_by_key = {(row.side, int(row.sort_order or 0)): row for row in existing}
|
||||||
|
incoming_keys = set(normalised)
|
||||||
|
for row in existing:
|
||||||
|
key = (row.side, int(row.sort_order or 0))
|
||||||
|
if key not in incoming_keys:
|
||||||
|
session.delete(row)
|
||||||
|
for key, item in normalised.items():
|
||||||
|
row = existing_by_key.get(key)
|
||||||
|
if row is None:
|
||||||
|
row = CustomPlusRow(
|
||||||
|
game_external_id=game.external_id,
|
||||||
|
side=item["side"],
|
||||||
|
sort_order=item["sort_order"],
|
||||||
|
created_at=now,
|
||||||
|
)
|
||||||
|
session.add(row)
|
||||||
|
row.text_value = item["text_value"]
|
||||||
|
row.status = item["status"]
|
||||||
|
row.updated_by = str(updated_by or "")[:128]
|
||||||
|
row.updated_at = now
|
||||||
|
|
||||||
|
return self.custom_pluses(game_external_id, language=language)
|
||||||
|
|
||||||
def set_game_period(
|
def set_game_period(
|
||||||
self,
|
self,
|
||||||
game_external_id: str,
|
game_external_id: str,
|
||||||
|
|||||||
@@ -144,6 +144,15 @@
|
|||||||
preparedTitlePanelId: "",
|
preparedTitlePanelId: "",
|
||||||
preparedTitleMappingSources: [],
|
preparedTitleMappingSources: [],
|
||||||
preparedTitleSnapshotLoading: false,
|
preparedTitleSnapshotLoading: false,
|
||||||
|
customPluses: { home: [], away: [] },
|
||||||
|
customPlusesTeams: { home: {}, away: {} },
|
||||||
|
customPlusesLoading: false,
|
||||||
|
customPlusesSaving: false,
|
||||||
|
customPlusesLoadedKey: "",
|
||||||
|
customPlusesSaveTimer: null,
|
||||||
|
customPlusesDirty: false,
|
||||||
|
customPlusesLastSavedAt: "",
|
||||||
|
customPlusesRevision: 0,
|
||||||
modalLocked: false,
|
modalLocked: false,
|
||||||
timerQuickEditorInterval: null,
|
timerQuickEditorInterval: null,
|
||||||
timers: {},
|
timers: {},
|
||||||
@@ -794,7 +803,7 @@
|
|||||||
project_name: "Хоккей — назначения удалений",
|
project_name: "Хоккей — назначения удалений",
|
||||||
data_source: "vmix_demo",
|
data_source: "vmix_demo",
|
||||||
canvas: { ...state.config.canvas, width: 1440, height: 760, background: "#060d17", show_grid: true, snap_enabled: true },
|
canvas: { ...state.config.canvas, width: 1440, height: 760, background: "#060d17", show_grid: true, snap_enabled: true },
|
||||||
tabs: [{ id: "main", label: "Игра" }, { id: "lines", label: "Пятёрки" }, { id: "referees", label: "Судьи" }, { id: "statistics", label: "Статистика" }, { id: "standings", label: "Турнирная таблица" }, { id: "schedule", label: "Расписание" }, { id: "shootout", label: "Буллиты" }, { id: "prepared_titles", label: "Заготовки" }],
|
tabs: [{ id: "main", label: "Игра" }, { id: "lines", label: "Пятёрки" }, { id: "referees", label: "Судьи" }, { id: "statistics", label: "Статистика" }, { id: "standings", label: "Турнирная таблица" }, { id: "schedule", label: "Расписание" }, { id: "shootout", label: "Буллиты" }, { id: "custom_pluses", label: "Свои плюсы" }, { id: "prepared_titles", label: "Заготовки" }],
|
||||||
components: [gameTimer, board, shootout, referees, statistics, schedule, standings],
|
components: [gameTimer, board, shootout, referees, statistics, schedule, standings],
|
||||||
triggers: []
|
triggers: []
|
||||||
};
|
};
|
||||||
@@ -2628,6 +2637,7 @@ function startCustomTooltips() {
|
|||||||
{ id: "standings", label: "Турнирная таблица" },
|
{ id: "standings", label: "Турнирная таблица" },
|
||||||
{ id: "schedule", label: "Расписание" },
|
{ id: "schedule", label: "Расписание" },
|
||||||
{ id: "shootout", label: "Буллиты" },
|
{ id: "shootout", label: "Буллиты" },
|
||||||
|
{ id: "custom_pluses", label: "Свои плюсы" },
|
||||||
{ id: "prepared_titles", label: "Заготовки" },
|
{ id: "prepared_titles", label: "Заготовки" },
|
||||||
];
|
];
|
||||||
const existingTabsById = new Map(state.config.tabs.map((tab) => [String(tab?.id || ""), tab]));
|
const existingTabsById = new Map(state.config.tabs.map((tab) => [String(tab?.id || ""), tab]));
|
||||||
@@ -10215,6 +10225,258 @@ function renderHockeyRuntimeSideWindows() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function hockeyCustomPlusesWorkspaceKey() {
|
||||||
|
return hockeyTimerSelectedGameId();
|
||||||
|
}
|
||||||
|
|
||||||
|
function hockeyCustomPlusBlankRow(side, sortOrder) {
|
||||||
|
return {
|
||||||
|
id: `new-${side}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
||||||
|
side,
|
||||||
|
sort_order: sortOrder,
|
||||||
|
text: "",
|
||||||
|
status: "skip",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function hockeyCustomPlusRows(side) {
|
||||||
|
if (!state.customPluses || typeof state.customPluses !== "object") {
|
||||||
|
state.customPluses = { home: [], away: [] };
|
||||||
|
}
|
||||||
|
if (!Array.isArray(state.customPluses[side])) state.customPluses[side] = [];
|
||||||
|
return state.customPluses[side];
|
||||||
|
}
|
||||||
|
|
||||||
|
function hockeySeedCustomPlusRows(side, rows) {
|
||||||
|
const normalised = (Array.isArray(rows) ? rows : []).map((row, index) => ({
|
||||||
|
id: row?.id || `loaded-${side}-${index + 1}`,
|
||||||
|
side,
|
||||||
|
sort_order: Number(row?.sort_order) || index + 1,
|
||||||
|
text: String(row?.text ?? row?.text_value ?? ""),
|
||||||
|
status: ["skip", "check", "cross"].includes(String(row?.status || "").toLowerCase())
|
||||||
|
? String(row.status).toLowerCase()
|
||||||
|
: "skip",
|
||||||
|
})).sort((a, b) => Number(a.sort_order) - Number(b.sort_order));
|
||||||
|
if (!normalised.length) {
|
||||||
|
for (let index = 0; index < 5; index += 1) normalised.push(hockeyCustomPlusBlankRow(side, index + 1));
|
||||||
|
}
|
||||||
|
normalised.forEach((row, index) => { row.sort_order = index + 1; });
|
||||||
|
state.customPluses[side] = normalised;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hockeyCustomPlusStatusLabel(status) {
|
||||||
|
if (status === "check") return "✓ Галочка";
|
||||||
|
if (status === "cross") return "✕ Крестик";
|
||||||
|
return "— Пропуск";
|
||||||
|
}
|
||||||
|
|
||||||
|
function hockeyCustomPlusTeamName(side) {
|
||||||
|
const fromPayload = state.customPlusesTeams?.[side]?.name || state.customPlusesTeams?.[side]?.short_name;
|
||||||
|
const fromGame = getByPath(state.data, `hockey.selected_game.${side}.name`)
|
||||||
|
|| getByPath(state.data, `hockey.selected_game.${side}.short_name`);
|
||||||
|
return String(fromPayload || fromGame || (side === "home" ? "Левая таблица" : "Правая таблица"));
|
||||||
|
}
|
||||||
|
|
||||||
|
function hockeyCustomPlusesSaveStateText() {
|
||||||
|
if (state.customPlusesSaving) return "Сохраняю…";
|
||||||
|
if (state.customPlusesDirty) return "Есть несохранённые изменения";
|
||||||
|
if (state.customPlusesLastSavedAt) return "Сохранено";
|
||||||
|
return "Автосохранение включено";
|
||||||
|
}
|
||||||
|
|
||||||
|
function hockeyUpdateCustomPlusesSaveIndicator() {
|
||||||
|
const indicator = el.runtimeStage?.querySelector?.("[data-custom-pluses-save-state]");
|
||||||
|
if (!indicator) return;
|
||||||
|
indicator.textContent = hockeyCustomPlusesSaveStateText();
|
||||||
|
indicator.classList.toggle("is-saving", Boolean(state.customPlusesSaving));
|
||||||
|
indicator.classList.toggle("is-dirty", Boolean(state.customPlusesDirty));
|
||||||
|
indicator.classList.toggle("is-saved", !state.customPlusesSaving && !state.customPlusesDirty && Boolean(state.customPlusesLastSavedAt));
|
||||||
|
}
|
||||||
|
|
||||||
|
function hockeyCustomPlusesPayloadRows() {
|
||||||
|
return ["home", "away"].flatMap((side) => hockeyCustomPlusRows(side).map((row, index) => ({
|
||||||
|
side,
|
||||||
|
sort_order: index + 1,
|
||||||
|
text: String(row.text || ""),
|
||||||
|
status: ["skip", "check", "cross"].includes(row.status) ? row.status : "skip",
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function hockeySaveCustomPluses({ immediate = false } = {}) {
|
||||||
|
const gameId = hockeyCustomPlusesWorkspaceKey();
|
||||||
|
if (!gameId) return false;
|
||||||
|
if (state.customPlusesSaveTimer) {
|
||||||
|
clearTimeout(state.customPlusesSaveTimer);
|
||||||
|
state.customPlusesSaveTimer = null;
|
||||||
|
}
|
||||||
|
if (state.customPlusesSaving) {
|
||||||
|
state.customPlusesSaveTimer = setTimeout(() => {
|
||||||
|
state.customPlusesSaveTimer = null;
|
||||||
|
hockeySaveCustomPluses({ immediate: true }).catch(() => {});
|
||||||
|
}, 160);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!state.customPlusesDirty && !immediate) return true;
|
||||||
|
const revision = state.customPlusesRevision;
|
||||||
|
state.customPlusesSaving = true;
|
||||||
|
hockeyUpdateCustomPlusesSaveIndicator();
|
||||||
|
const rows = hockeyCustomPlusesPayloadRows();
|
||||||
|
try {
|
||||||
|
await hockeyGameControlRequest(`/games/${encodeURIComponent(gameId)}/custom-pluses`, {
|
||||||
|
method: "PUT",
|
||||||
|
body: JSON.stringify({ rows, language: hockeyGameControlLanguage() }),
|
||||||
|
});
|
||||||
|
if (gameId === hockeyCustomPlusesWorkspaceKey() && state.customPlusesRevision === revision) {
|
||||||
|
state.customPlusesDirty = false;
|
||||||
|
state.customPlusesLastSavedAt = new Date().toISOString();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
toast(`Свои плюсы: ${error.message}`, true);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
state.customPlusesSaving = false;
|
||||||
|
hockeyUpdateCustomPlusesSaveIndicator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function hockeyScheduleCustomPlusesSave(delay = 500) {
|
||||||
|
state.customPlusesRevision += 1;
|
||||||
|
state.customPlusesDirty = true;
|
||||||
|
hockeyUpdateCustomPlusesSaveIndicator();
|
||||||
|
if (state.customPlusesSaveTimer) clearTimeout(state.customPlusesSaveTimer);
|
||||||
|
state.customPlusesSaveTimer = setTimeout(() => {
|
||||||
|
state.customPlusesSaveTimer = null;
|
||||||
|
hockeySaveCustomPluses({ immediate: true }).catch(() => {});
|
||||||
|
}, Math.max(0, Number(delay) || 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function hockeyLoadCustomPlusesWorkspace({ force = false } = {}) {
|
||||||
|
const gameId = hockeyCustomPlusesWorkspaceKey();
|
||||||
|
if (!gameId) {
|
||||||
|
state.customPlusesLoadedKey = "";
|
||||||
|
state.customPluses = { home: [], away: [] };
|
||||||
|
state.customPlusesTeams = { home: {}, away: {} };
|
||||||
|
if (state.activeTab === "custom_pluses") renderRuntime();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!force && state.customPlusesLoadedKey === gameId) return true;
|
||||||
|
if (state.customPlusesLoading) return false;
|
||||||
|
state.customPlusesLoading = true;
|
||||||
|
try {
|
||||||
|
const payload = await hockeyGameControlRequest(`/games/${encodeURIComponent(gameId)}/custom-pluses?language=${encodeURIComponent(hockeyGameControlLanguage())}`);
|
||||||
|
if (gameId !== hockeyCustomPlusesWorkspaceKey()) return false;
|
||||||
|
state.customPluses = { home: [], away: [] };
|
||||||
|
hockeySeedCustomPlusRows("home", payload?.home);
|
||||||
|
hockeySeedCustomPlusRows("away", payload?.away);
|
||||||
|
state.customPlusesTeams = payload?.teams || { home: {}, away: {} };
|
||||||
|
state.customPlusesLoadedKey = gameId;
|
||||||
|
state.customPlusesDirty = false;
|
||||||
|
state.customPlusesLastSavedAt = "";
|
||||||
|
state.customPlusesRevision = 0;
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
toast(`Свои плюсы: ${error.message}`, true);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
state.customPlusesLoading = false;
|
||||||
|
if (state.activeTab === "custom_pluses") renderRuntime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function hockeyCustomPlusRowMarkup(side, row, index) {
|
||||||
|
const status = ["skip", "check", "cross"].includes(row.status) ? row.status : "skip";
|
||||||
|
return `
|
||||||
|
<div class="hcp-row" data-custom-plus-row="${escapeHtml(side)}:${index}">
|
||||||
|
<span class="hcp-row-number">${index + 1}</span>
|
||||||
|
<input type="text" maxlength="4000" data-custom-plus-text="${escapeHtml(side)}:${index}" value="${escapeHtml(row.text || "")}" placeholder="Введите текст…">
|
||||||
|
<select class="hcp-status is-${escapeHtml(status)}" data-custom-plus-status="${escapeHtml(side)}:${index}" aria-label="Статус строки">
|
||||||
|
${["skip", "check", "cross"].map((value) => `<option value="${value}" ${status === value ? "selected" : ""}>${escapeHtml(hockeyCustomPlusStatusLabel(value))}</option>`).join("")}
|
||||||
|
</select>
|
||||||
|
<button type="button" class="hcp-delete" data-custom-plus-delete="${escapeHtml(side)}:${index}" title="Удалить строку" aria-label="Удалить строку">×</button>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderHockeyCustomPlusesWorkspace() {
|
||||||
|
const node = div("hcp-workspace");
|
||||||
|
const gameId = hockeyCustomPlusesWorkspaceKey();
|
||||||
|
if (!gameId) {
|
||||||
|
node.innerHTML = `<div class="hcp-empty"><strong>Матч не выбран</strong><span>Откройте матч, чтобы заполнить «Свои плюсы».</span></div>`;
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
if (state.customPlusesLoading && state.customPlusesLoadedKey !== gameId) {
|
||||||
|
node.innerHTML = `<div class="hcp-empty"><strong>Загружаю «Свои плюсы»…</strong><span>Данные привязаны к матчу ${escapeHtml(gameId)}</span></div>`;
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
node.innerHTML = `
|
||||||
|
<header class="hcp-header">
|
||||||
|
<div><span>MATCH NOTES</span><strong>Свои плюсы</strong><small>Матч ${escapeHtml(gameId)} · каждая строка сохраняется в базе</small></div>
|
||||||
|
<span class="hcp-save-state" data-custom-pluses-save-state>${escapeHtml(hockeyCustomPlusesSaveStateText())}</span>
|
||||||
|
</header>
|
||||||
|
<div class="hcp-columns">
|
||||||
|
${["home", "away"].map((side) => `
|
||||||
|
<section class="hcp-table side-${side}">
|
||||||
|
<header><div><span>${side === "home" ? "ЛЕВАЯ ТАБЛИЦА" : "ПРАВАЯ ТАБЛИЦА"}</span><strong>${escapeHtml(hockeyCustomPlusTeamName(side))}</strong></div><button type="button" data-custom-plus-add="${side}">+ Добавить строку</button></header>
|
||||||
|
<div class="hcp-table-head"><span>№</span><span>Текст</span><span>Статус</span><span></span></div>
|
||||||
|
<div class="hcp-rows">${hockeyCustomPlusRows(side).map((row, index) => hockeyCustomPlusRowMarkup(side, row, index)).join("")}</div>
|
||||||
|
</section>`).join("")}
|
||||||
|
</div>`;
|
||||||
|
|
||||||
|
const rowRef = (raw) => {
|
||||||
|
const [side, indexRaw] = String(raw || "").split(":");
|
||||||
|
const index = Number(indexRaw);
|
||||||
|
if (!["home", "away"].includes(side) || !Number.isInteger(index) || index < 0) return null;
|
||||||
|
const row = hockeyCustomPlusRows(side)[index];
|
||||||
|
return row ? { side, index, row } : null;
|
||||||
|
};
|
||||||
|
|
||||||
|
node.querySelectorAll("[data-custom-plus-text]").forEach((input) => {
|
||||||
|
input.addEventListener("input", () => {
|
||||||
|
const ref = rowRef(input.dataset.customPlusText);
|
||||||
|
if (!ref) return;
|
||||||
|
ref.row.text = input.value;
|
||||||
|
hockeyScheduleCustomPlusesSave();
|
||||||
|
});
|
||||||
|
input.addEventListener("blur", () => {
|
||||||
|
if (state.customPlusesDirty) hockeyScheduleCustomPlusesSave(120);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
node.querySelectorAll("[data-custom-plus-status]").forEach((select) => {
|
||||||
|
select.addEventListener("change", () => {
|
||||||
|
const ref = rowRef(select.dataset.customPlusStatus);
|
||||||
|
if (!ref) return;
|
||||||
|
ref.row.status = select.value;
|
||||||
|
select.classList.remove("is-skip", "is-check", "is-cross");
|
||||||
|
select.classList.add(`is-${select.value}`);
|
||||||
|
hockeyScheduleCustomPlusesSave(120);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
node.querySelectorAll("[data-custom-plus-add]").forEach((button) => button.addEventListener("click", () => {
|
||||||
|
const side = button.dataset.customPlusAdd;
|
||||||
|
if (!["home", "away"].includes(side)) return;
|
||||||
|
const rows = hockeyCustomPlusRows(side);
|
||||||
|
rows.push(hockeyCustomPlusBlankRow(side, rows.length + 1));
|
||||||
|
hockeyScheduleCustomPlusesSave(120);
|
||||||
|
renderRuntime();
|
||||||
|
const newInput = el.runtimeStage?.querySelector?.(`[data-custom-plus-text="${side}:${rows.length - 1}"]`);
|
||||||
|
newInput?.focus?.();
|
||||||
|
}));
|
||||||
|
node.querySelectorAll("[data-custom-plus-delete]").forEach((button) => button.addEventListener("click", () => {
|
||||||
|
const ref = rowRef(button.dataset.customPlusDelete);
|
||||||
|
if (!ref) return;
|
||||||
|
const rows = hockeyCustomPlusRows(ref.side);
|
||||||
|
rows.splice(ref.index, 1);
|
||||||
|
if (!rows.length) rows.push(hockeyCustomPlusBlankRow(ref.side, 1));
|
||||||
|
rows.forEach((row, index) => { row.sort_order = index + 1; });
|
||||||
|
state.customPlusesDirty = true;
|
||||||
|
hockeyScheduleCustomPlusesSave(80);
|
||||||
|
renderRuntime();
|
||||||
|
}));
|
||||||
|
hockeyUpdateCustomPlusesSaveIndicator();
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
function hockeyPreparedNumber(value, fallback = 999999) {
|
function hockeyPreparedNumber(value, fallback = 999999) {
|
||||||
const raw = String(value ?? "").trim();
|
const raw = String(value ?? "").trim();
|
||||||
return /^\d+$/.test(raw) ? Number(raw) : fallback;
|
return /^\d+$/.test(raw) ? Number(raw) : fallback;
|
||||||
@@ -13866,7 +14128,7 @@ function renderHockeyPenaltyDashboard(node, component, runtime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function runtimeHasFixedHockeyCanvas() {
|
function runtimeHasFixedHockeyCanvas() {
|
||||||
if (["prepared_titles", "lines"].includes(state.activeTab)) return true;
|
if (["prepared_titles", "lines", "custom_pluses"].includes(state.activeTab)) return true;
|
||||||
return state.config.components.some((component) =>
|
return state.config.components.some((component) =>
|
||||||
[
|
[
|
||||||
"hockey_penalty_dashboard",
|
"hockey_penalty_dashboard",
|
||||||
@@ -13958,6 +14220,12 @@ function renderHockeyPenaltyDashboard(node, component, runtime) {
|
|||||||
state.hockeySettingsRenderPending = true;
|
state.hockeySettingsRenderPending = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Keep manual text editing stable while background match-data refreshes arrive.
|
||||||
|
if (state.activeTab === "custom_pluses"
|
||||||
|
&& document.activeElement?.closest?.(".hcp-workspace")
|
||||||
|
&& document.activeElement?.matches?.("input, textarea, select")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const activeShootoutSearch = document.activeElement?.matches?.("[data-shootout-search]")
|
const activeShootoutSearch = document.activeElement?.matches?.("[data-shootout-search]")
|
||||||
? {
|
? {
|
||||||
side: document.activeElement.dataset.shootoutSearch,
|
side: document.activeElement.dataset.shootoutSearch,
|
||||||
@@ -13977,7 +14245,12 @@ function renderHockeyPenaltyDashboard(node, component, runtime) {
|
|||||||
el.runtimeStage.innerHTML = "";
|
el.runtimeStage.innerHTML = "";
|
||||||
state.timerNodes = new Map();
|
state.timerNodes = new Map();
|
||||||
state.hockeyPenaltyBoardNodes = new Map();
|
state.hockeyPenaltyBoardNodes = new Map();
|
||||||
if (state.activeTab === "prepared_titles") {
|
if (state.activeTab === "custom_pluses") {
|
||||||
|
el.runtimeStage.appendChild(renderHockeyCustomPlusesWorkspace());
|
||||||
|
if (state.customPlusesLoadedKey !== hockeyCustomPlusesWorkspaceKey() && !state.customPlusesLoading) {
|
||||||
|
setTimeout(() => hockeyLoadCustomPlusesWorkspace({ force: true }).catch(() => {}), 0);
|
||||||
|
}
|
||||||
|
} else if (state.activeTab === "prepared_titles") {
|
||||||
el.runtimeStage.appendChild(renderHockeyPreparedTitlesWorkspace());
|
el.runtimeStage.appendChild(renderHockeyPreparedTitlesWorkspace());
|
||||||
if (state.preparedTitlesLoadedKey !== hockeyPreparedWorkspaceKey() && !state.preparedTitlesLoading) {
|
if (state.preparedTitlesLoadedKey !== hockeyPreparedWorkspaceKey() && !state.preparedTitlesLoading) {
|
||||||
setTimeout(() => hockeyLoadPreparedTitlesWorkspace({ force: true }).catch(() => {}), 0);
|
setTimeout(() => hockeyLoadPreparedTitlesWorkspace({ force: true }).catch(() => {}), 0);
|
||||||
|
|||||||
@@ -7916,3 +7916,205 @@ body.hockey-navigation-open .runtime-viewport.has-hockey-pbp { gap: 14px !import
|
|||||||
background: #245f9d;
|
background: #245f9d;
|
||||||
box-shadow: 0 0 0 1px rgba(77, 156, 255, .12), inset 0 -2px 0 rgba(117, 190, 255, .45);
|
box-shadow: 0 0 0 1px rgba(77, 156, 255, .12), inset 0 -2px 0 rgba(117, 190, 255, .45);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* BUILD 2026.09.23.8 — match-scoped manual "Свои плюсы" workspace */
|
||||||
|
.hcp-workspace {
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 1440px;
|
||||||
|
height: 760px;
|
||||||
|
padding: 22px 26px 26px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 18px;
|
||||||
|
color: #eef4fb;
|
||||||
|
background:
|
||||||
|
radial-gradient(circle at 18% 0%, rgba(70, 128, 190, .10), transparent 34%),
|
||||||
|
#0c1421;
|
||||||
|
}
|
||||||
|
.hcp-header {
|
||||||
|
min-height: 70px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 24px;
|
||||||
|
}
|
||||||
|
.hcp-header > div {
|
||||||
|
min-width: 0;
|
||||||
|
display: grid;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
.hcp-header > div > span,
|
||||||
|
.hcp-table > header span {
|
||||||
|
color: #7f93aa;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 800;
|
||||||
|
letter-spacing: .13em;
|
||||||
|
}
|
||||||
|
.hcp-header strong {
|
||||||
|
font-size: 27px;
|
||||||
|
line-height: 1.05;
|
||||||
|
}
|
||||||
|
.hcp-header small {
|
||||||
|
color: #8fa1b5;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
.hcp-save-state {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
min-width: 172px;
|
||||||
|
padding: 10px 14px;
|
||||||
|
border: 1px solid #27384c;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: #101c2b;
|
||||||
|
color: #94a7bb;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 700;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.hcp-save-state.is-saving { color: #d6b967; border-color: #5c4f2a; }
|
||||||
|
.hcp-save-state.is-dirty { color: #e4b5a0; border-color: #694231; }
|
||||||
|
.hcp-save-state.is-saved { color: #93d2ae; border-color: #315b45; }
|
||||||
|
.hcp-columns {
|
||||||
|
min-height: 0;
|
||||||
|
flex: 1;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||||
|
gap: 18px;
|
||||||
|
}
|
||||||
|
.hcp-table {
|
||||||
|
min-width: 0;
|
||||||
|
min-height: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 1px solid #223348;
|
||||||
|
border-radius: 14px;
|
||||||
|
background: rgba(14, 24, 38, .94);
|
||||||
|
box-shadow: 0 12px 28px rgba(0, 0, 0, .18);
|
||||||
|
}
|
||||||
|
.hcp-table > header {
|
||||||
|
min-height: 72px;
|
||||||
|
padding: 13px 16px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 14px;
|
||||||
|
border-bottom: 1px solid #223348;
|
||||||
|
background: #111e2e;
|
||||||
|
}
|
||||||
|
.hcp-table > header > div {
|
||||||
|
min-width: 0;
|
||||||
|
display: grid;
|
||||||
|
gap: 3px;
|
||||||
|
}
|
||||||
|
.hcp-table > header strong {
|
||||||
|
overflow: hidden;
|
||||||
|
color: #f3f7fb;
|
||||||
|
font-size: 18px;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.hcp-table > header button {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
padding: 9px 12px;
|
||||||
|
border: 1px solid #31506e;
|
||||||
|
border-radius: 9px;
|
||||||
|
background: #172a3f;
|
||||||
|
color: #c9dbec;
|
||||||
|
font: inherit;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 750;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.hcp-table > header button:hover { background: #1d344d; border-color: #41698f; }
|
||||||
|
.hcp-table-head,
|
||||||
|
.hcp-row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 34px minmax(0, 1fr) 154px 34px;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.hcp-table-head {
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-bottom: 1px solid #1e2e42;
|
||||||
|
color: #6f8298;
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: 800;
|
||||||
|
letter-spacing: .08em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
.hcp-rows {
|
||||||
|
min-height: 0;
|
||||||
|
flex: 1;
|
||||||
|
overflow: auto;
|
||||||
|
padding: 8px 10px 12px;
|
||||||
|
scrollbar-color: #334b65 transparent;
|
||||||
|
scrollbar-width: thin;
|
||||||
|
}
|
||||||
|
.hcp-row {
|
||||||
|
min-height: 50px;
|
||||||
|
padding: 5px 2px;
|
||||||
|
border-bottom: 1px solid rgba(39, 56, 76, .62);
|
||||||
|
}
|
||||||
|
.hcp-row:last-child { border-bottom: 0; }
|
||||||
|
.hcp-row-number {
|
||||||
|
color: #677b90;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 800;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.hcp-row input,
|
||||||
|
.hcp-status {
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 100%;
|
||||||
|
height: 36px;
|
||||||
|
border: 1px solid #2b3e54;
|
||||||
|
border-radius: 8px;
|
||||||
|
outline: none;
|
||||||
|
background: #0b1624;
|
||||||
|
color: #edf4fb;
|
||||||
|
font: inherit;
|
||||||
|
font-size: 13px;
|
||||||
|
transition: border-color .14s ease, background .14s ease, box-shadow .14s ease;
|
||||||
|
}
|
||||||
|
.hcp-row input { padding: 0 11px; }
|
||||||
|
.hcp-row input::placeholder { color: #53687e; }
|
||||||
|
.hcp-row input:focus,
|
||||||
|
.hcp-status:focus {
|
||||||
|
border-color: #5786b2;
|
||||||
|
box-shadow: 0 0 0 2px rgba(87, 134, 178, .15);
|
||||||
|
}
|
||||||
|
.hcp-status {
|
||||||
|
padding: 0 28px 0 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: 750;
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
.hcp-status.is-skip { color: #9aabba; background: #111c29; }
|
||||||
|
.hcp-status.is-check { color: #9ee0b9; border-color: #315c45; background: #10251d; }
|
||||||
|
.hcp-status.is-cross { color: #efaaa9; border-color: #603d42; background: #291619; }
|
||||||
|
.hcp-delete {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
padding: 0;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: transparent;
|
||||||
|
color: #708398;
|
||||||
|
font-size: 20px;
|
||||||
|
line-height: 1;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.hcp-delete:hover { color: #efaaa9; border-color: #53363b; background: #25171b; }
|
||||||
|
.hcp-empty {
|
||||||
|
margin: auto;
|
||||||
|
min-width: 420px;
|
||||||
|
padding: 30px;
|
||||||
|
display: grid;
|
||||||
|
gap: 7px;
|
||||||
|
border: 1px solid #27384c;
|
||||||
|
border-radius: 14px;
|
||||||
|
background: #101c2b;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.hcp-empty strong { font-size: 19px; }
|
||||||
|
.hcp-empty span { color: #8799ad; font-size: 13px; }
|
||||||
|
|||||||
Reference in New Issue
Block a user