1
0
Files
breadcrumb-the-shire/modules/helpdesk/web/js/pages/helpdesk-search-index.js
fs a0d7670dd7 feat(helpdesk): align module with core list/drawer standards
- add helpdesk module pages, services, settings and tests

- standardize debtor list on drawer/grid contracts and robust filter drawer behavior

- add helpdesk aside panel navigation and settings visibility provider

- switch primary list slug to helpdesk/debitor and remove helpdesk/search compatibility

- include required core contract updates for list contracts and detail/drawer integration
2026-04-02 17:48:27 +02:00

74 lines
2.5 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 { escapeHtml, getAppBase, withCurrentListReturn } from '/js/pages/app-list-utils.js';
const config = readPageConfig('helpdesk-search');
if (config) {
const gridjs = window.gridjs;
if (!gridjs) {
warnOnce('UI_INIT_FAIL', 'Helpdesk search grid init failed: Grid.js missing', { module: 'helpdesk-search', component: 'grid' });
} else {
const appBase = getAppBase();
const labels = config.labels || {};
const gridOptions = {
gridjs,
container: '#helpdesk-search-grid',
dataUrl: config.dataUrl || 'helpdesk/search-data',
appBase,
columns: [
{
name: labels.debtorNo || 'Debtor No.',
sort: true,
formatter: (cell) => {
const debtorNo = escapeHtml(cell?.no || '');
const detailUrl = String(cell?.url || '').trim();
if (detailUrl === '') {
return gridjs.html(debtorNo);
}
const href = escapeHtml(withCurrentListReturn(detailUrl));
return gridjs.html(`<a href="${href}">${debtorNo}</a>`);
},
},
{ name: labels.name || 'Name', sort: true },
{ name: labels.city || 'City', sort: true },
{ name: labels.phone || 'Phone', sort: false },
{ name: labels.email || 'E-Mail', sort: false },
{ name: 'detail_url', hidden: true },
],
sortColumns: ['No', 'Name', 'City', null, null, null],
paginationLimit: 10,
language: config.gridLang || {},
mapData: (data) => (data.data || []).map((row) => [
{ no: row.No || '', url: row.detail_url || '' },
row.Name || '',
row.City || '',
row.Phone_No || '',
row.E_Mail || '',
row.detail_url || '',
]),
search: config.gridSearch || null,
filterSchema: config.filterSchema || [],
urlSync: true,
rowInteraction: { linkColumn: 0 },
rowDblClick: {
getUrl: (rowData) => rowData?.cells?.[5]?.data || '',
},
};
const { gridConfig } = initStandardListPage({
grid: gridOptions,
filters: {
mode: 'drawer',
chipMeta: config.filterChipMeta || {},
watchInputs: ['#helpdesk-search-input'],
},
});
if (!gridConfig || !gridConfig.grid) {
warnOnce('UI_INIT_FAIL', 'Helpdesk search grid init failed', { module: 'helpdesk-search', component: 'grid' });
}
}
}