Use job note toggle and require job number for job_note
This commit is contained in:
+14
-3
@@ -160,12 +160,15 @@
|
|||||||
<select id="typeInput" class="field">
|
<select id="typeInput" class="field">
|
||||||
<option value="personal">personal</option>
|
<option value="personal">personal</option>
|
||||||
<option value="general">general</option>
|
<option value="general">general</option>
|
||||||
<option value="job">job</option>
|
|
||||||
<option value="manager">manager</option>
|
<option value="manager">manager</option>
|
||||||
<option value="billing">billing</option>
|
<option value="billing">billing</option>
|
||||||
</select>
|
</select>
|
||||||
<input id="jobNumberInput" class="field" placeholder="Job Number (optional)" />
|
<input id="jobNumberInput" class="field" placeholder="Job Number (optional)" />
|
||||||
</div>
|
</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>
|
<textarea id="bodyInput" rows="8" class="field" placeholder="Write your note..."></textarea>
|
||||||
<input id="shareInput" class="field" placeholder="Share with (comma separated names)" />
|
<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">
|
<div class="rounded-xl border border-slate-700 bg-slate-950/60 p-3">
|
||||||
@@ -244,6 +247,7 @@
|
|||||||
const titleInput = document.getElementById('titleInput');
|
const titleInput = document.getElementById('titleInput');
|
||||||
const typeInput = document.getElementById('typeInput');
|
const typeInput = document.getElementById('typeInput');
|
||||||
const jobNumberInput = document.getElementById('jobNumberInput');
|
const jobNumberInput = document.getElementById('jobNumberInput');
|
||||||
|
const jobNoteToggle = document.getElementById('jobNoteToggle');
|
||||||
const bodyInput = document.getElementById('bodyInput');
|
const bodyInput = document.getElementById('bodyInput');
|
||||||
const shareInput = document.getElementById('shareInput');
|
const shareInput = document.getElementById('shareInput');
|
||||||
const searchInput = document.getElementById('searchInput');
|
const searchInput = document.getElementById('searchInput');
|
||||||
@@ -622,6 +626,10 @@
|
|||||||
if (!bodyPlain) throw new Error('Note body is required');
|
if (!bodyPlain) throw new Error('Note body is required');
|
||||||
const noteType = typeInput.value.trim() || 'personal';
|
const noteType = typeInput.value.trim() || 'personal';
|
||||||
const jobNumber = jobNumberInput.value.trim();
|
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 sharedWith = normalizeShares(shareInput.value);
|
||||||
|
|
||||||
const html = bodyPlain
|
const html = bodyPlain
|
||||||
@@ -640,7 +648,7 @@
|
|||||||
userId: user?.id || '',
|
userId: user?.id || '',
|
||||||
shared: sharedWith.length > 0,
|
shared: sharedWith.length > 0,
|
||||||
shared_with: sharedWith,
|
shared_with: sharedWith,
|
||||||
job_note: noteType === 'job' || !!jobNumber,
|
job_note: isJobNote,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -762,6 +770,7 @@
|
|||||||
titleInput.value = '';
|
titleInput.value = '';
|
||||||
typeInput.value = 'personal';
|
typeInput.value = 'personal';
|
||||||
jobNumberInput.value = '';
|
jobNumberInput.value = '';
|
||||||
|
jobNoteToggle.checked = false;
|
||||||
bodyInput.value = '';
|
bodyInput.value = '';
|
||||||
shareInput.value = '';
|
shareInput.value = '';
|
||||||
pendingAttachments = [];
|
pendingAttachments = [];
|
||||||
@@ -784,8 +793,10 @@
|
|||||||
selectedNote = note;
|
selectedNote = note;
|
||||||
selectedMeta.textContent = `Selected: ${note.id}`;
|
selectedMeta.textContent = `Selected: ${note.id}`;
|
||||||
titleInput.value = String(note.title || '');
|
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 || '');
|
jobNumberInput.value = String(note.Job_Number || '');
|
||||||
|
jobNoteToggle.checked = toBoolFlag(note.job_note) || String(note.type || '').toLowerCase() === 'job';
|
||||||
bodyInput.value = String(note.body_plain || '');
|
bodyInput.value = String(note.body_plain || '');
|
||||||
shareInput.value = normalizeShares(note.shared_with).join(', ');
|
shareInput.value = normalizeShares(note.shared_with).join(', ');
|
||||||
pendingAttachments = [];
|
pendingAttachments = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user