Files
breadcrumb-the-shire/modules/audit/web/js/pages/admin-user-lifecycle-audit-index.js
fs a93788acf1 fix(audit): use absolute import paths in module JS files
Module JS files were using relative imports (../core/) which resolved
incorrectly when served from modules/audit/js/pages/ instead of the
original web/js/pages/. Changed to absolute paths (/js/core/, /js/pages/)
so they correctly resolve to the core JS utilities.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 08:26:29 +01:00

78 lines
2.7 KiB
JavaScript

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 { getAppBase } from '/js/pages/app-list-utils.js';
const config = readPageConfig('admin-user-lifecycle-audit-index');
if (config) {
const appBase = getAppBase();
const gridSearch = config.gridSearch ?? null;
const filterSchema = config.filterSchema ?? [];
const filterChipMeta = config.filterChipMeta ?? [];
const labels = config.labels ?? {};
const gridOptions = {
gridjs: window.gridjs,
container: '#user-lifecycle-audit-grid',
dataUrl: 'admin/user-lifecycle-audit/data',
appBase,
columns: [
{ name: labels.created || 'Created', sort: true },
{
name: labels.status || 'Status',
sort: true,
formatter: (cell) => {
if (!cell || typeof cell !== 'object') {
return gridjs.html('-');
}
return gridjs.html(`<span class="badge" data-variant="${cell.variant || 'neutral'}">${cell.label || '-'}</span>`);
},
},
{ name: labels.action || 'Action', sort: true },
{ name: labels.trigger || 'Trigger', sort: true },
{ name: labels.targetEmail || 'Target email', sort: false },
{ name: labels.targetUuid || 'Target UUID', sort: false },
{ name: labels.reasonCode || 'Reason code', sort: false },
{ name: labels.restoredAt || 'Restored at', sort: true },
{ name: 'ID', hidden: true },
],
sortColumns: ['created_at', 'status', 'action', 'trigger_type', null, null, null, 'restored_at', null],
paginationLimit: 10,
language: config.gridLang ?? {},
mapData: (data) => data.data.map((row) => [
row.created_at,
{ variant: row.status_badge, label: row.status_label || row.status || '' },
row.action_label || row.action || '-',
row.trigger_type_label || row.trigger_type || '-',
row.target_user_email || '-',
row.target_user_uuid || '-',
row.reason_code || '-',
row.restored_at || '-',
row.id,
]),
rowInteraction: { linkColumn: 2 },
search: gridSearch,
filterSchema,
urlSync: true,
rowDblClick: {
getUrl: (rowData) => {
const id = rowData?.cells?.[8]?.data;
return id ? new URL(`admin/user-lifecycle-audit/view/${id}`, appBase).toString() : '';
},
},
};
const { gridConfig } = initStandardListPage({
grid: gridOptions,
filters: {
mode: 'drawer',
chipMeta: filterChipMeta,
watchInputs: ['#user-lifecycle-audit-search'],
},
});
if (!gridConfig || !gridConfig.grid) {
warnOnce('UI_INIT_FAIL', 'User lifecycle audit grid init failed', { module: 'admin-user-lifecycle-audit-index', component: 'grid' });
}
}