Add a new "Domains" page to the helpdesk module that fetches domain data from the FS_Contract_Domains OData endpoint and enriches each domain with its contract type (PI_Header_Type) by joining with FS_Contract_Lines_Test where Type = 'Domain'. New files: - domains/index().php, index(default).phtml, filter-schema.php — list page - domains-data().php — data endpoint with PHP-side filtering/sorting - helpdesk-domains-index.js — Grid.js via initStandardListPage() Gateway additions: - listDomains() — fetch all contract domains - listDomainContractLines() — fetch domain-type contract lines for type lookup Sidebar restructured into three collapsible groups (Lookup, Monitoring, Administration) with per-group icons and color coding, matching the core admin panel pattern. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
86 lines
3.1 KiB
JavaScript
86 lines
3.1 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-domains');
|
|
if (config) {
|
|
const gridjs = window.gridjs;
|
|
if (!gridjs) {
|
|
warnOnce('UI_INIT_FAIL', 'Helpdesk domains grid init failed: Grid.js missing', { module: 'helpdesk-domains', component: 'grid' });
|
|
} else {
|
|
const appBase = getAppBase();
|
|
const labels = config.labels || {};
|
|
|
|
const debitorUrlIndex = 6;
|
|
|
|
const gridOptions = {
|
|
gridjs,
|
|
container: '#helpdesk-domains-grid',
|
|
dataUrl: config.dataUrl || 'helpdesk/domains-data',
|
|
appBase,
|
|
columns: [
|
|
{ name: labels.no || 'No.', sort: true },
|
|
{
|
|
name: labels.customerName || 'Customer Name',
|
|
sort: true,
|
|
formatter: (cell) => {
|
|
const name = escapeHtml(cell?.name || '');
|
|
const detailUrl = String(cell?.url || '').trim();
|
|
if (detailUrl === '') {
|
|
return gridjs.html(name);
|
|
}
|
|
const href = escapeHtml(withCurrentListReturn(detailUrl));
|
|
return gridjs.html(`<a href="${href}">${name}</a>`);
|
|
},
|
|
},
|
|
{ name: labels.url || 'URL', sort: true },
|
|
{ name: labels.contractType || 'Contract Type', sort: true },
|
|
{
|
|
name: labels.state || 'State',
|
|
sort: true,
|
|
formatter: (cell) => {
|
|
const state = escapeHtml(cell?.state || '');
|
|
const variant = cell?.variant || 'neutral';
|
|
return gridjs.html(`<span class="badge" data-variant="${escapeHtml(variant)}">${state}</span>`);
|
|
},
|
|
},
|
|
{ name: labels.administration || 'Administration', sort: true },
|
|
{ name: 'debitor_url', hidden: true },
|
|
],
|
|
sortColumns: ['No', 'Customer_Name', 'URL', 'contract_type', 'State', 'Administration', null],
|
|
paginationLimit: 10,
|
|
language: config.gridLang || {},
|
|
mapData: (data) => (data.data || []).map((row) => [
|
|
row.No || '',
|
|
{ name: row.Customer_Name || '', url: row.debitor_url || '' },
|
|
row.URL || '',
|
|
row.contract_type || '',
|
|
{ state: row.State || '', variant: row.state_variant || 'neutral' },
|
|
row.Administration || '',
|
|
row.debitor_url || '',
|
|
]),
|
|
search: config.gridSearch || null,
|
|
filterSchema: config.filterSchema || [],
|
|
urlSync: true,
|
|
rowInteraction: { linkColumn: 1 },
|
|
rowDblClick: {
|
|
getUrl: (rowData) => rowData?.cells?.[debitorUrlIndex]?.data || '',
|
|
},
|
|
};
|
|
|
|
const { gridConfig } = initStandardListPage({
|
|
grid: gridOptions,
|
|
filters: {
|
|
mode: 'drawer',
|
|
chipMeta: config.filterChipMeta || {},
|
|
watchInputs: ['#helpdesk-domains-search-input'],
|
|
},
|
|
});
|
|
|
|
if (!gridConfig || !gridConfig.grid) {
|
|
warnOnce('UI_INIT_FAIL', 'Helpdesk domains grid init failed', { module: 'helpdesk-domains', component: 'grid' });
|
|
}
|
|
}
|
|
}
|