Implement 'learn' button
This commit is contained in:
parent
7706459daa
commit
cccfba0712
3 changed files with 15 additions and 9 deletions
22
app.js
22
app.js
|
|
@ -880,23 +880,24 @@ function openRefsModal(tuneId) {
|
||||||
refsModal.showModal();
|
refsModal.showModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Call mode ─────────────────────────────────────────────────────
|
// ── Call / Learn mode ────────────────────────────────────────────
|
||||||
const callModal = $('call-modal');
|
const callModal = $('call-modal');
|
||||||
|
let callMode = 'callable'; // 'callable' | 'to_learn'
|
||||||
let callStep = 0;
|
let callStep = 0;
|
||||||
let callInstrumentId = null;
|
let callInstrumentId = null;
|
||||||
let callTuningId = null;
|
let callTuningId = null;
|
||||||
|
|
||||||
function callableEntries() {
|
function callGetEntries() {
|
||||||
const result = [];
|
const result = [];
|
||||||
for (const tune of allTunes)
|
for (const tune of allTunes)
|
||||||
for (const entry of tune.instruments)
|
for (const entry of tune.instruments)
|
||||||
if (entry.callable) result.push({ tune, entry });
|
if (entry[callMode]) result.push({ tune, entry });
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function callGetInstruments() {
|
function callGetInstruments() {
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
callableEntries().forEach(({ entry }) => {
|
callGetEntries().forEach(({ entry }) => {
|
||||||
if (!map.has(entry.instrument_id)) map.set(entry.instrument_id, entry.instrument_name);
|
if (!map.has(entry.instrument_id)) map.set(entry.instrument_id, entry.instrument_name);
|
||||||
});
|
});
|
||||||
return [...map.entries()].map(([id, name]) => ({ id, name }))
|
return [...map.entries()].map(([id, name]) => ({ id, name }))
|
||||||
|
|
@ -905,7 +906,7 @@ function callGetInstruments() {
|
||||||
|
|
||||||
function callGetTunings() {
|
function callGetTunings() {
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
callableEntries()
|
callGetEntries()
|
||||||
.filter(({ entry }) => callInstrumentId === null || entry.instrument_id === callInstrumentId)
|
.filter(({ entry }) => callInstrumentId === null || entry.instrument_id === callInstrumentId)
|
||||||
.forEach(({ entry }) => {
|
.forEach(({ entry }) => {
|
||||||
if (entry.tuning_id != null && !map.has(entry.tuning_id))
|
if (entry.tuning_id != null && !map.has(entry.tuning_id))
|
||||||
|
|
@ -917,7 +918,7 @@ function callGetTunings() {
|
||||||
|
|
||||||
function callGetKeys() {
|
function callGetKeys() {
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
callableEntries()
|
callGetEntries()
|
||||||
.filter(({ entry }) =>
|
.filter(({ entry }) =>
|
||||||
(callInstrumentId === null || entry.instrument_id === callInstrumentId) &&
|
(callInstrumentId === null || entry.instrument_id === callInstrumentId) &&
|
||||||
(callTuningId === null || entry.tuning_id === callTuningId)
|
(callTuningId === null || entry.tuning_id === callTuningId)
|
||||||
|
|
@ -932,7 +933,8 @@ function callGetKeys() {
|
||||||
.sort((a, b) => a.key.localeCompare(b.key) || (a.modal ? 1 : -1));
|
.sort((a, b) => a.key.localeCompare(b.key) || (a.modal ? 1 : -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
function openCallModal() {
|
function openCallModal(mode) {
|
||||||
|
callMode = mode;
|
||||||
callStep = 0;
|
callStep = 0;
|
||||||
callInstrumentId = null;
|
callInstrumentId = null;
|
||||||
callTuningId = null;
|
callTuningId = null;
|
||||||
|
|
@ -984,7 +986,8 @@ function callSelect(value, modal) {
|
||||||
callStep = 2;
|
callStep = 2;
|
||||||
renderCallStep();
|
renderCallStep();
|
||||||
} else {
|
} else {
|
||||||
filters.callable = true;
|
filters.callable = callMode === 'callable' ? true : null;
|
||||||
|
filters.to_learn = callMode === 'to_learn' ? true : null;
|
||||||
filters.instrument = callInstrumentId !== null ? String(callInstrumentId) : null;
|
filters.instrument = callInstrumentId !== null ? String(callInstrumentId) : null;
|
||||||
filters.tuning = callTuningId !== null ? String(callTuningId) : null;
|
filters.tuning = callTuningId !== null ? String(callTuningId) : null;
|
||||||
filters.key = value;
|
filters.key = value;
|
||||||
|
|
@ -995,7 +998,8 @@ function callSelect(value, modal) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$('btn-call').addEventListener('click', openCallModal);
|
$('btn-call').addEventListener('click', () => openCallModal('callable'));
|
||||||
|
$('btn-learn').addEventListener('click', () => openCallModal('to_learn'));
|
||||||
$('call-close').addEventListener('click', () => callModal.close());
|
$('call-close').addEventListener('click', () => callModal.close());
|
||||||
$('call-back').addEventListener('click', () => {
|
$('call-back').addEventListener('click', () => {
|
||||||
callStep--;
|
callStep--;
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
<button id="btn-clear-filters" hidden>✕ Clear filters</button>
|
<button id="btn-clear-filters" hidden>✕ Clear filters</button>
|
||||||
<span id="status"></span>
|
<span id="status"></span>
|
||||||
<button id="btn-call">Call</button>
|
<button id="btn-call">Call</button>
|
||||||
|
<button id="btn-learn">Learn</button>
|
||||||
<button id="btn-bulk-edit" hidden>⚡ Bulk Edit</button>
|
<button id="btn-bulk-edit" hidden>⚡ Bulk Edit</button>
|
||||||
<button id="btn-add-tune" hidden>+ Add tune</button>
|
<button id="btn-add-tune" hidden>+ Add tune</button>
|
||||||
<button id="btn-unlock">🔒 Unlock</button>
|
<button id="btn-unlock">🔒 Unlock</button>
|
||||||
|
|
|
||||||
|
|
@ -490,6 +490,7 @@ fieldset.active .fs-body { display: contents; }
|
||||||
|
|
||||||
#btn-bulk-edit { background: transparent; border: 1px solid var(--border); color: var(--muted); }
|
#btn-bulk-edit { background: transparent; border: 1px solid var(--border); color: var(--muted); }
|
||||||
#btn-call { background: #1b4332; color: #74c69d; border: 1px solid #2d6a4f; font-weight: 600; }
|
#btn-call { background: #1b4332; color: #74c69d; border: 1px solid #2d6a4f; font-weight: 600; }
|
||||||
|
#btn-learn { background: #3d2e10; color: #f2c94c; border: 1px solid #4d3a1e; font-weight: 600; }
|
||||||
|
|
||||||
/* ── Call modal ───────────────────────────────────────────── */
|
/* ── Call modal ───────────────────────────────────────────── */
|
||||||
#call-modal {
|
#call-modal {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue