This commit is contained in:
@ -204,6 +204,13 @@ function renderClientTableBody() {
|
||||
body.querySelectorAll('.restore-client-btn').forEach(btn => {
|
||||
btn.addEventListener('click', () => setClientArchived(btn.dataset.code, false));
|
||||
});
|
||||
body.querySelectorAll('.save-client-note-btn').forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
const tr = btn.closest('tr');
|
||||
const ta = tr?.querySelector('.client-note-input');
|
||||
saveClientNote(btn.dataset.client, ta);
|
||||
});
|
||||
});
|
||||
bindCoachBandPickerEvents(body);
|
||||
}
|
||||
|
||||
@ -740,13 +747,20 @@ function clientRowHTML(c) {
|
||||
archived,
|
||||
showDelete: true,
|
||||
});
|
||||
const note = String(c.note || '').trim();
|
||||
const noteCell = note
|
||||
? `<td class="client-note-cell"><span class="client-note-text">${esc(note)}</span></td>`
|
||||
: `<td class="client-note-cell client-note-empty">—</td>`;
|
||||
const note = String(c.note || '');
|
||||
const noteCell = `
|
||||
<td class="followup-note-cell client-note-cell">
|
||||
<textarea class="followup-note-input client-note-input" rows="2"
|
||||
data-client="${esc(c.clientCode)}" maxlength="200"
|
||||
placeholder="Client note…">${esc(note)}</textarea>
|
||||
<div class="followup-note-actions">
|
||||
<button type="button" class="btn btn-sm btn-primary save-client-note-btn"
|
||||
data-client="${esc(c.clientCode)}">Save note</button>
|
||||
</div>
|
||||
</td>`;
|
||||
|
||||
return `
|
||||
<tr class="${archived ? 'client-row-archived' : ''}">
|
||||
<tr class="${archived ? 'client-row-archived' : ''}" data-client="${esc(c.clientCode)}">
|
||||
<td>
|
||||
${expandControl}<strong>${esc(c.clientCode)}</strong>${clientArchivedLabel(c)}
|
||||
</td>
|
||||
@ -806,6 +820,25 @@ function toggleVersion(clientCode, questionnaireID, submissionID) {
|
||||
renderClientTableBody();
|
||||
}
|
||||
|
||||
async function saveClientNote(clientCode, ta) {
|
||||
if (!ta || !clientCode) return;
|
||||
const note = ta.value.trim();
|
||||
if (note.length > 200) {
|
||||
showToast('Note must be at most 200 characters', 'error');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await apiPut('analytics.php', { clientCode, note });
|
||||
const saved = res?.note ?? note;
|
||||
ta.value = saved;
|
||||
const row = clientsList.find(c => c.clientCode === clientCode);
|
||||
if (row) row.note = saved;
|
||||
showToast('Note saved', 'success');
|
||||
} catch (e) {
|
||||
showToast(e.message, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function setClientArchived(clientCode, archived) {
|
||||
const ok = await confirmAndPatchClientArchive(clientCode, archived);
|
||||
if (!ok) return;
|
||||
|
||||
Reference in New Issue
Block a user