Require key, instrument, tuning
This commit is contained in:
parent
eaf89d1d89
commit
52eb0f6189
3 changed files with 39 additions and 1 deletions
35
app.js
35
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,
|
||||
|
|
|
|||
|
|
@ -154,6 +154,7 @@
|
|||
<button type="button" id="btn-add-ref">+ reference</button>
|
||||
</div>
|
||||
|
||||
<p id="tune-error" class="modal-error" hidden></p>
|
||||
<div class="modal-actions">
|
||||
<button type="button" id="btn-delete-tune" class="btn-danger" hidden>Delete tune</button>
|
||||
<button type="button" id="btn-edit-notes" hidden>📝 Notes</button>
|
||||
|
|
|
|||
|
|
@ -305,6 +305,8 @@ fieldset label {
|
|||
font-size: .85rem;
|
||||
}
|
||||
|
||||
fieldset input[type="checkbox"] { justify-self: start; }
|
||||
|
||||
fieldset input[type="text"],
|
||||
fieldset input[type="date"],
|
||||
fieldset select {
|
||||
|
|
@ -357,6 +359,8 @@ fieldset.active .fs-body { display: contents; }
|
|||
|
||||
.btn-danger { background: var(--accent); }
|
||||
|
||||
.modal-error { color: #eb5757; font-size: .82rem; margin: .3rem 0 0; }
|
||||
|
||||
.note-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue