Fix engagement task categories and add Tally Data upload

This commit is contained in:
A R R R Associates
2026-09-02 12:50:30 +05:30
parent 2a4fd2bfdd
commit ec00a76ace
3 changed files with 161 additions and 32 deletions
@@ -60,16 +60,23 @@
<div class="rounded-2xl border border-slate-200 bg-slate-50 p-4">
<div class="text-sm font-semibold text-slate-900">Upload from Engagement Page</div>
<p class="mt-1 text-xs text-slate-500">Choose the task category so the file remains linked to the existing task/evidence workflow.</p>
{% if resources.default_upload_task_id %}
<form method="post" enctype="multipart/form-data" action="/documents/tasks/{{ resources.default_upload_task_id }}/upload" class="mt-4 space-y-3" data-engagement-upload-form>
<p class="mt-1 text-xs text-slate-500">Select Tally Data or a service task category. Category uploads stay linked to the existing task/evidence workflow.</p>
<form method="post" enctype="multipart/form-data" action="/documents/engagements/{{ engagement_id }}/upload" class="mt-4 space-y-3" data-engagement-upload-form data-engagement-id="{{ engagement_id }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<input type="hidden" name="return_to" value="{{ return_to }}">
<div>
<label class="mb-1 block text-xs font-semibold uppercase tracking-wide text-slate-500">Task Category</label>
<select class="w-full rounded-xl border border-slate-300 bg-white px-3 py-2 text-sm" data-upload-task-select>
{% for category in resources.task_categories %}<option value="{{ category.task_id }}">{{ category.name }}</option>{% endfor %}
<label class="mb-1 block text-xs font-semibold uppercase tracking-wide text-slate-500">Upload To</label>
<select class="w-full rounded-xl border border-slate-300 bg-white px-3 py-2 text-sm" data-upload-target-select>
<option value="tally" data-kind="tally">Tally Data</option>
{% for category in resources.task_categories %}
<option value="category-{{ loop.index }}" data-kind="category" data-task-id="{{ category.task_id or '' }}" {% if not category.available %}disabled{% endif %}>
{{ category.name }}{% if not category.available %} — no task in this engagement{% endif %}
</option>
{% endfor %}
</select>
{% if resources.task_categories %}
<p class="mt-1 text-[11px] text-slate-500">Categories come from this service's Task Category master; older engagements are mapped through their task templates where needed.</p>
{% endif %}
</div>
<div>
<label class="mb-1 block text-xs font-semibold uppercase tracking-wide text-slate-500">Upload Action</label>
@@ -107,11 +114,9 @@
<label class="mb-1 block text-xs font-semibold uppercase tracking-wide text-slate-500">Description / Remarks</label>
<input name="remarks" class="w-full rounded-xl border border-slate-300 bg-white px-3 py-2 text-sm" placeholder="Optional">
</div>
<div data-upload-target-note class="rounded-xl border border-indigo-100 bg-indigo-50 px-3 py-2 text-xs text-indigo-700">Tally Data is stored at engagement level and remains separate from task-category evidence.</div>
<button class="w-full rounded-xl bg-brand-600 px-4 py-2.5 text-sm font-semibold text-white hover:bg-brand-700">Upload Document</button>
</form>
{% else %}
<div class="mt-4 rounded-xl border border-dashed border-slate-300 bg-white p-5 text-center text-sm text-slate-500">No task is available to receive an engagement upload.</div>
{% endif %}
</div>
</div>
</section>
@@ -120,12 +125,24 @@
(function () {
const form = document.querySelector('[data-engagement-upload-form]');
if (form) {
const taskSelect = form.querySelector('[data-upload-task-select]');
const targetSelect = form.querySelector('[data-upload-target-select]');
const mode = form.querySelector('[data-upload-mode]');
const wrap = form.querySelector('[data-existing-document-wrap]');
const existing = form.querySelector('[data-existing-document-select]');
const note = form.querySelector('[data-upload-target-note]');
const engagementId = form.getAttribute('data-engagement-id');
const updateAction = function () {
form.action = '/documents/tasks/' + taskSelect.value + '/upload';
const option = targetSelect.options[targetSelect.selectedIndex];
const kind = option ? option.getAttribute('data-kind') : 'tally';
const taskId = option ? option.getAttribute('data-task-id') : '';
if (kind === 'category' && taskId) {
form.action = '/documents/tasks/' + taskId + '/upload';
note.textContent = 'This file will be linked to the selected category through its existing engagement task, preserving evidence and AQMM behaviour.';
} else {
form.action = '/documents/engagements/' + engagementId + '/upload';
note.textContent = 'Tally Data is stored at engagement level and remains separate from task-category evidence.';
}
};
const updateMode = function () {
const useExisting = mode.value !== 'new';
@@ -133,7 +150,7 @@
existing.required = useExisting;
if (!useExisting) existing.value = '';
};
taskSelect.addEventListener('change', updateAction);
targetSelect.addEventListener('change', updateAction);
mode.addEventListener('change', updateMode);
updateAction();
updateMode();