feat(helpdesk): add handover protocol management
Implement handover protocols as a new entity in the helpdesk module, allowing users to create fillable protocol records from admin-defined software product schemas. Key additions: - DB migration (helpdesk_handovers table) with tenant scope - HandoverService with status workflow (draft/in_progress/completed/archived) - Three-tier permissions (view/create/manage) - Two-step creation wizard (Stripe-style assistant) - Grid.js list page with search and status filter - Edit/detail page with aside metadata and status controls - Reusable core autocomplete lookup component (app-lookup-field) - Debitor lookup data endpoint for autocomplete - Dynamic form rendering from schema snapshots - 11 PHPUnit tests for HandoverService - DE+EN i18n translations (48 keys each) Also includes: PHPStan fixes (dead code removal, stale baseline cleanup), software product edit title improvement, fieldset simplification, and Stripe-style hover for schema preview. Workflow: HD-HANDOVERS-001 (.agents/runs/HD-HANDOVERS-001/) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -46,9 +46,22 @@ function init(root) {
|
||||
clearElement(root);
|
||||
|
||||
if (fields.length === 0) {
|
||||
const empty = document.createElement('p');
|
||||
empty.className = 'handover-schema-empty';
|
||||
empty.textContent = t.no_fields || 'No fields defined yet.';
|
||||
const empty = document.createElement('div');
|
||||
empty.className = 'handover-schema-empty-state';
|
||||
const emptyText = document.createElement('p');
|
||||
emptyText.textContent = t.no_fields || 'No fields defined yet.';
|
||||
empty.appendChild(emptyText);
|
||||
const addButton = document.createElement('button');
|
||||
addButton.type = 'button';
|
||||
addButton.className = 'secondary outline';
|
||||
addButton.appendChild(createIcon('bi-plus-lg'));
|
||||
addButton.appendChild(document.createTextNode(' ' + (t.add_field || 'Add field')));
|
||||
addButton.addEventListener('click', () => {
|
||||
fields.push({ type: 'text', key: '', label: '', required: false, options: [] });
|
||||
render();
|
||||
notifyChange();
|
||||
});
|
||||
empty.appendChild(addButton);
|
||||
root.appendChild(empty);
|
||||
} else {
|
||||
const list = document.createElement('div');
|
||||
@@ -60,9 +73,8 @@ function init(root) {
|
||||
list.appendChild(buildFieldRow(field, index));
|
||||
});
|
||||
root.appendChild(list);
|
||||
root.appendChild(buildInsertDivider(fields.length));
|
||||
}
|
||||
|
||||
root.appendChild(buildInsertDivider(fields.length));
|
||||
}
|
||||
|
||||
function buildInsertDivider(insertIndex) {
|
||||
@@ -314,7 +326,7 @@ function init(root) {
|
||||
if (field.type === 'checkbox') {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'checkbox';
|
||||
input.disabled = true;
|
||||
input.addEventListener('click', (e) => e.preventDefault());
|
||||
group.appendChild(input);
|
||||
const label = document.createElement('label');
|
||||
label.textContent = field.label || '';
|
||||
|
||||
86
modules/helpdesk/web/js/pages/helpdesk-handovers-index.js
Normal file
86
modules/helpdesk/web/js/pages/helpdesk-handovers-index.js
Normal file
@@ -0,0 +1,86 @@
|
||||
import { initStandardListPage } from '/js/core/app-grid-factory.js';
|
||||
import { readPageConfig } from '/js/core/app-page-config.js';
|
||||
import { warnOnce } from '/js/core/app-dom.js';
|
||||
import { escapeHtml, getAppBase, withCurrentListReturn } from '/js/pages/app-list-utils.js';
|
||||
|
||||
const config = readPageConfig('helpdesk-handovers');
|
||||
if (config) {
|
||||
const gridjs = window.gridjs;
|
||||
if (!gridjs) {
|
||||
warnOnce('UI_INIT_FAIL', 'Helpdesk handovers grid init failed: Grid.js missing', { module: 'helpdesk-handovers', component: 'grid' });
|
||||
} else {
|
||||
const appBase = getAppBase();
|
||||
const labels = config.labels || {};
|
||||
|
||||
const editUrlIndex = 6;
|
||||
|
||||
const gridOptions = {
|
||||
gridjs,
|
||||
container: '#helpdesk-handovers-grid',
|
||||
dataUrl: config.dataUrl || 'helpdesk/handovers-data',
|
||||
appBase,
|
||||
columns: [
|
||||
{
|
||||
name: labels.id || 'ID',
|
||||
sort: true,
|
||||
width: '80px',
|
||||
formatter: (cell) => {
|
||||
const id = escapeHtml(String(cell?.id || ''));
|
||||
const editUrl = String(cell?.url || '').trim();
|
||||
if (editUrl === '') {
|
||||
return gridjs.html(id);
|
||||
}
|
||||
const href = escapeHtml(withCurrentListReturn(editUrl));
|
||||
return gridjs.html(`<a href="${href}">#${id}</a>`);
|
||||
},
|
||||
},
|
||||
{ name: labels.debitorName || 'Customer', sort: true },
|
||||
{ name: labels.productCode || 'Software product', sort: true },
|
||||
{
|
||||
name: labels.status || 'Status',
|
||||
sort: true,
|
||||
formatter: (cell) => {
|
||||
const label = escapeHtml(cell?.label || '');
|
||||
const variant = cell?.variant || 'neutral';
|
||||
return gridjs.html(`<span class="badge" data-variant="${escapeHtml(variant)}">${label}</span>`);
|
||||
},
|
||||
},
|
||||
{ name: labels.createdAt || 'Created', sort: true },
|
||||
{ name: labels.createdBy || 'Created by', sort: true },
|
||||
{ name: 'edit_url', hidden: true },
|
||||
],
|
||||
sortColumns: ['id', 'debitor_name', 'product_code', 'status', 'created_at', 'created_by', null],
|
||||
paginationLimit: 20,
|
||||
language: config.gridLang || {},
|
||||
mapData: (data) => (data.data || []).map((row) => [
|
||||
{ id: row.id || '', url: row.edit_url || '' },
|
||||
row.debitor_name || '',
|
||||
row.product_code || '',
|
||||
{ label: row.status_label || '', variant: row.status_variant || 'neutral' },
|
||||
row.created_at || '',
|
||||
row.created_by_name || '',
|
||||
row.edit_url || '',
|
||||
]),
|
||||
search: config.gridSearch || null,
|
||||
filterSchema: config.filterSchema || [],
|
||||
urlSync: true,
|
||||
rowInteraction: { linkColumn: 0 },
|
||||
rowDblClick: {
|
||||
getUrl: (rowData) => rowData?.cells?.[editUrlIndex]?.data || '',
|
||||
},
|
||||
};
|
||||
|
||||
const { gridConfig } = initStandardListPage({
|
||||
grid: gridOptions,
|
||||
filters: {
|
||||
mode: 'drawer',
|
||||
chipMeta: config.filterChipMeta || {},
|
||||
watchInputs: ['#helpdesk-handovers-search-input'],
|
||||
},
|
||||
});
|
||||
|
||||
if (!gridConfig || !gridConfig.grid) {
|
||||
warnOnce('UI_INIT_FAIL', 'Helpdesk handovers grid init failed', { module: 'helpdesk-handovers', component: 'grid' });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user