feat(ui): explain unavailable workspaces
This commit is contained in:
@@ -127,8 +127,8 @@
|
|||||||
|
|
||||||
const layouts = {
|
const layouts = {
|
||||||
compact: { label: "Compact", description: "Essential tuning and audio controls", advanced: false, preferredTab: "main" },
|
compact: { label: "Compact", description: "Essential tuning and audio controls", advanced: false, preferredTab: "main" },
|
||||||
broadcast: { label: "Broadcast", description: "WFM, RDS, stereo and interference monitoring", advanced: false, preferredTab: "main", capability: "broadcast" },
|
broadcast: { label: "Broadcast", description: "WFM, RDS, stereo and interference monitoring", unavailable: "Broadcast requires an enumerated WFM-capable receiver", advanced: false, preferredTab: "main", capability: "broadcast" },
|
||||||
digital: { label: "Digital", description: "Decoder status, messages and background decoding", advanced: false, preferredTab: "digital-modes", capability: "digital" },
|
digital: { label: "Digital", description: "Decoder status, messages and background decoding", unavailable: "Digital requires a compatible rig mode and an available decoder", advanced: false, preferredTab: "digital-modes", capability: "digital" },
|
||||||
full: { label: "Full controls", description: "Every control supported by the selected rig", advanced: true, preferredTab: "main" },
|
full: { label: "Full controls", description: "Every control supported by the selected rig", advanced: true, preferredTab: "main" },
|
||||||
};
|
};
|
||||||
const layoutCapabilities = { broadcast: false, digital: false };
|
const layoutCapabilities = { broadcast: false, digital: false };
|
||||||
@@ -146,6 +146,17 @@
|
|||||||
return !layout.capability || layoutCapabilities[layout.capability] === true;
|
return !layout.capability || layoutCapabilities[layout.capability] === true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function unavailableLayoutMessage() {
|
||||||
|
const unavailable = Object.values(layouts).filter(layout => !layoutAvailable(layout) && layout.unavailable);
|
||||||
|
return unavailable.length ? `Unavailable: ${unavailable.map(layout => layout.unavailable).join("; ")}.` : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateLayoutDescription(layout) {
|
||||||
|
const description = document.getElementById("operator-layout-description");
|
||||||
|
if (!description) return;
|
||||||
|
description.textContent = [layout.description, unavailableLayoutMessage()].filter(Boolean).join(" · ");
|
||||||
|
}
|
||||||
|
|
||||||
function refreshLayoutOptions() {
|
function refreshLayoutOptions() {
|
||||||
const select = document.getElementById("operator-layout-select");
|
const select = document.getElementById("operator-layout-select");
|
||||||
if (!select) return;
|
if (!select) return;
|
||||||
@@ -158,6 +169,8 @@
|
|||||||
const available = Array.from(select.options).some(option => option.value === previous);
|
const available = Array.from(select.options).some(option => option.value === previous);
|
||||||
select.value = available ? previous : "compact";
|
select.value = available ? previous : "compact";
|
||||||
if (!available && previous !== "compact") api.applyLayout("compact", { persist: false });
|
if (!available && previous !== "compact") api.applyLayout("compact", { persist: false });
|
||||||
|
select.title = unavailableLayoutMessage();
|
||||||
|
updateLayoutDescription(layouts[select.value] || layouts.compact);
|
||||||
}
|
}
|
||||||
|
|
||||||
api.setLayoutCapabilities = function setLayoutCapabilities(capabilities = {}) {
|
api.setLayoutCapabilities = function setLayoutCapabilities(capabilities = {}) {
|
||||||
@@ -189,8 +202,7 @@
|
|||||||
if (options.persist !== false) localStorage.setItem(layoutStorageKey(), document.body.dataset.operatorLayout);
|
if (options.persist !== false) localStorage.setItem(layoutStorageKey(), document.body.dataset.operatorLayout);
|
||||||
const details = document.getElementById("advanced-radio-controls");
|
const details = document.getElementById("advanced-radio-controls");
|
||||||
if (details) details.open = layout.advanced;
|
if (details) details.open = layout.advanced;
|
||||||
const description = document.getElementById("operator-layout-description");
|
updateLayoutDescription(layout);
|
||||||
if (description) description.textContent = layout.description;
|
|
||||||
if (options.navigate && typeof window.navigateToTab === "function") {
|
if (options.navigate && typeof window.navigateToTab === "function") {
|
||||||
window.navigateToTab(layout.preferredTab);
|
window.navigateToTab(layout.preferredTab);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user