feat(ui): improve radio operator experience
This commit was merged in pull request #15.
This commit is contained in:
@@ -331,8 +331,13 @@ async function bmSave(e) {
|
||||
const comment = document.getElementById("bm-comment").value.trim();
|
||||
const decoders = bmReadDecoders();
|
||||
|
||||
const formError = document.getElementById("bm-form-error");
|
||||
if (formError) formError.textContent = "";
|
||||
if (!name || !Number.isFinite(freq_hz) || !mode) {
|
||||
alert("Name, Frequency, and Mode are required.");
|
||||
if (formError) formError.textContent = "Enter a name, a valid frequency, and a mode.";
|
||||
const invalid = !name ? document.getElementById("bm-name")
|
||||
: !Number.isFinite(freq_hz) ? document.getElementById("bm-freq") : document.getElementById("bm-mode");
|
||||
invalid?.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -373,12 +378,13 @@ async function bmSave(e) {
|
||||
await bmFetch(document.getElementById("bm-category-filter").value);
|
||||
} catch (err) {
|
||||
console.error("Failed to save bookmark:", err);
|
||||
alert("Failed to save bookmark: " + err.message);
|
||||
if (formError) formError.textContent = "Failed to save bookmark: " + err.message;
|
||||
window.trxUi?.notify("Bookmark could not be saved", { kind: "error" });
|
||||
}
|
||||
}
|
||||
|
||||
async function bmDelete(id) {
|
||||
if (!confirm("Delete this bookmark?")) return;
|
||||
if (!await window.trxUi.confirm({ title: "Delete bookmark?", message: "This bookmark will be permanently removed.", confirmLabel: "Delete" })) return;
|
||||
const bm = bmList.find((b) => b.id === id);
|
||||
const scope = bm ? bm.scope : undefined;
|
||||
try {
|
||||
@@ -389,7 +395,7 @@ async function bmDelete(id) {
|
||||
await bmFetch(document.getElementById("bm-category-filter").value);
|
||||
} catch (err) {
|
||||
console.error("Failed to delete bookmark:", err);
|
||||
alert("Failed to delete bookmark: " + err.message);
|
||||
window.trxUi?.notify("Failed to delete bookmark: " + err.message, { kind: "error" });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -555,7 +561,12 @@ async function bmMoveSelected() {
|
||||
const target = document.getElementById("bm-move-target")?.value;
|
||||
if (!target) return;
|
||||
const targetLabel = document.getElementById("bm-move-target")?.selectedOptions[0]?.textContent || target;
|
||||
if (!confirm(`Move ${ids.length} bookmark${ids.length > 1 ? "s" : ""} to "${targetLabel}"?`)) return;
|
||||
if (!await window.trxUi.confirm({
|
||||
title: "Move selected bookmarks?",
|
||||
message: `${ids.length} bookmark${ids.length > 1 ? "s" : ""} will move to “${targetLabel}”.`,
|
||||
confirmLabel: "Move",
|
||||
danger: false,
|
||||
})) return;
|
||||
try {
|
||||
// Group selected IDs by their owning scope (skip if already in target).
|
||||
const byScope = {};
|
||||
@@ -577,7 +588,7 @@ async function bmMoveSelected() {
|
||||
await bmFetch(document.getElementById("bm-category-filter").value);
|
||||
} catch (err) {
|
||||
console.error("Failed to move bookmarks:", err);
|
||||
alert("Failed to move bookmarks: " + err.message);
|
||||
window.trxUi?.notify("Failed to move bookmarks: " + err.message, { kind: "error" });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -598,7 +609,11 @@ function bmSyncSelectAllCheckbox() {
|
||||
async function bmDeleteSelected() {
|
||||
const ids = Array.from(bmSelected);
|
||||
if (ids.length === 0) return;
|
||||
if (!confirm(`Delete ${ids.length} selected bookmark${ids.length > 1 ? "s" : ""}?`)) return;
|
||||
if (!await window.trxUi.confirm({
|
||||
title: "Delete selected bookmarks?",
|
||||
message: `${ids.length} bookmark${ids.length > 1 ? "s" : ""} will be permanently removed.`,
|
||||
confirmLabel: "Delete",
|
||||
})) return;
|
||||
try {
|
||||
// Group selected IDs by their owning scope.
|
||||
const byScope = {};
|
||||
@@ -619,7 +634,7 @@ async function bmDeleteSelected() {
|
||||
await bmFetch(document.getElementById("bm-category-filter").value);
|
||||
} catch (err) {
|
||||
console.error("Failed to delete bookmarks:", err);
|
||||
alert("Failed to delete bookmarks: " + err.message);
|
||||
window.trxUi?.notify("Failed to delete bookmarks: " + err.message, { kind: "error" });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user