Files
pulse-signage/src/web/public/js/slides/slide-form-template-lock.js
T
lzstealth 2ea8d389fa This PR breaks the large web and player bootstrap files into smaller modules with clearer ownership.
Web changes:

Split shared helpers, bootstrap logic, route groups, and upload-sync behavior out of web.js.
Kept web.js focused on wiring and server startup.
Fixed screen playlist reassignment so changing a screen’s playlist now triggers a refresh.
Fixed single-slide playlist refresh behavior so updates do not get stuck behind the current slide.
Player changes:

Split websocket/runtime handling into runtime.js.
Split playlist assembly and revision hashing into playlist.js.
Split onboarding and player HTTP routes into dedicated modules.
Split render utilities and template loading into render-helpers.js.
Kept player.js mostly as startup/orchestration.
Validation:

Rebuilt both services with Docker Compose.
Smoke-checked web and player routes after the refactor.
Verified get_errors was clean on the touched modules.
2026-07-20 23:58:27 +01:00

87 lines
1.8 KiB
JavaScript

export function createTemplateSelectorLockController(templateSelect) {
var locked = false;
var armed = false;
var lockInput = null;
function clearLockInput() {
if (lockInput && lockInput.parentNode) {
lockInput.parentNode.removeChild(lockInput);
}
lockInput = null;
}
function reset() {
locked = false;
armed = false;
clearLockInput();
if (!templateSelect) {
return;
}
templateSelect.disabled = false;
templateSelect.removeAttribute('aria-disabled');
templateSelect.removeAttribute('title');
templateSelect.classList.remove('is-locked');
}
function arm() {
armed = true;
}
function syncLockedValue() {
if (lockInput) {
lockInput.value = templateSelect.value;
}
}
function lock() {
if (!templateSelect || locked) {
return;
}
locked = true;
lockInput = lockInput || document.createElement('input');
lockInput.type = 'hidden';
lockInput.name = templateSelect.name;
lockInput.value = templateSelect.value;
templateSelect.insertAdjacentElement('afterend', lockInput);
templateSelect.disabled = true;
templateSelect.setAttribute('aria-disabled', 'true');
templateSelect.setAttribute('title', 'Template is locked after you edit its content.');
templateSelect.classList.add('is-locked');
}
function markEdited() {
if (!armed) {
return false;
}
lock();
syncLockedValue();
return locked;
}
function sync() {
if (!templateSelect) {
return false;
}
if (locked) {
syncLockedValue();
return true;
}
return false;
}
return {
reset: reset,
arm: arm,
markEdited: markEdited,
sync: sync,
isLocked: function () {
return locked;
}
};
}