From 52eb0f61898c503b1cdf52236d6b91dffdb33d85 Mon Sep 17 00:00:00 2001 From: Ian Keane Date: Thu, 11 Jun 2026 17:12:05 -0400 Subject: [PATCH] Require key, instrument, tuning --- app.js | 35 ++++++++++++++++++++++++++++++++++- index.html | 1 + style.css | 4 ++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index e5602e3..df4dc48 100644 --- a/app.js +++ b/app.js @@ -504,6 +504,7 @@ function openAdd() { editingTuneId = null; editingEntryId = null; editingOriginalRefIds = []; + setTuneError(''); $('modal-title').textContent = 'Add tune'; tuneForm.reset(); refsList.innerHTML = ''; @@ -659,11 +660,43 @@ function addRefRow(link = '', site = '', refId = null, siteId = null, initialMus // ── Save ────────────────────────────────────────────────────── $('btn-save-tune').addEventListener('click', saveTune); -$('btn-cancel').addEventListener('click', () => tuneModal.close()); +$('btn-cancel').addEventListener('click', () => { setTuneError(''); tuneModal.close(); }); + +function setTuneError(msg) { + const el = $('tune-error'); + el.textContent = msg; + el.hidden = !msg; +} async function saveTune() { const f = tuneForm.elements; + // Validate required fields + const keyVal = f.key.value.trim(); + const tuningVal = f.inst_tuning.value.trim(); + + if (!keyVal) { + setTuneError('Key is required.'); + f.key.focus(); + return; + } + if (!instrumentSelect.value) { + setTuneError('Instrument is required.'); + instrumentSelect.focus(); + return; + } + if (!tuningVal) { + setTuneError('Tuning is required.'); + f.inst_tuning.focus(); + return; + } + if (!resolveTuningId(tuningVal)) { + setTuneError(`Tuning "${tuningVal}" not found — use + to add it first.`); + f.inst_tuning.focus(); + return; + } + setTuneError(''); + const tuneBody = { name: f.name.value || null, key: f.key.value || null, diff --git a/index.html b/index.html index f38b339..064659d 100644 --- a/index.html +++ b/index.html @@ -154,6 +154,7 @@ +