Use job note toggle and require job number for job_note

This commit is contained in:
2026-03-29 02:19:13 +00:00
parent 21c8b4b4c7
commit 9a6da32504
+14 -3
View File
@@ -160,12 +160,15 @@
<select id="typeInput" class="field">
<option value="personal">personal</option>
<option value="general">general</option>
<option value="job">job</option>
<option value="manager">manager</option>
<option value="billing">billing</option>
</select>
<input id="jobNumberInput" class="field" placeholder="Job Number (optional)" />
</div>
<label class="flex items-center gap-2 text-sm text-slate-300">
<input id="jobNoteToggle" type="checkbox" class="h-4 w-4 rounded border-slate-600 bg-slate-900 text-cyan-400 focus:ring-cyan-500" />
<span>Classify as Job Note</span>
</label>
<textarea id="bodyInput" rows="8" class="field" placeholder="Write your note..."></textarea>
<input id="shareInput" class="field" placeholder="Share with (comma separated names)" />
<div class="rounded-xl border border-slate-700 bg-slate-950/60 p-3">
@@ -244,6 +247,7 @@
const titleInput = document.getElementById('titleInput');
const typeInput = document.getElementById('typeInput');
const jobNumberInput = document.getElementById('jobNumberInput');
const jobNoteToggle = document.getElementById('jobNoteToggle');
const bodyInput = document.getElementById('bodyInput');
const shareInput = document.getElementById('shareInput');
const searchInput = document.getElementById('searchInput');
@@ -622,6 +626,10 @@
if (!bodyPlain) throw new Error('Note body is required');
const noteType = typeInput.value.trim() || 'personal';
const jobNumber = jobNumberInput.value.trim();
const isJobNote = !!jobNoteToggle.checked;
if (isJobNote && !jobNumber) {
throw new Error('Job Number is required when Classify as Job Note is enabled');
}
const sharedWith = normalizeShares(shareInput.value);
const html = bodyPlain
@@ -640,7 +648,7 @@
userId: user?.id || '',
shared: sharedWith.length > 0,
shared_with: sharedWith,
job_note: noteType === 'job' || !!jobNumber,
job_note: isJobNote,
hidden: false,
};
@@ -762,6 +770,7 @@
titleInput.value = '';
typeInput.value = 'personal';
jobNumberInput.value = '';
jobNoteToggle.checked = false;
bodyInput.value = '';
shareInput.value = '';
pendingAttachments = [];
@@ -784,8 +793,10 @@
selectedNote = note;
selectedMeta.textContent = `Selected: ${note.id}`;
titleInput.value = String(note.title || '');
typeInput.value = String(note.type || 'personal');
const normalizedType = String(note.type || 'personal');
typeInput.value = normalizedType === 'job' ? 'general' : normalizedType;
jobNumberInput.value = String(note.Job_Number || '');
jobNoteToggle.checked = toBoolFlag(note.job_note) || String(note.type || '').toLowerCase() === 'job';
bodyInput.value = String(note.body_plain || '');
shareInput.value = normalizeShares(note.shared_with).join(', ');
pendingAttachments = [];