pgkiln 0.42.0 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/db/migrations/099_layout_positions.sql +29 -0
- package/db/migrations/100_generated_labels.sql +381 -0
- package/db/migrations/101_theme_choice.sql +15 -0
- package/docs/apex-feature-parity.md +36 -9
- package/docs/guide/03-builder.md +82 -21
- package/docs/guide/04-pages-and-regions.md +55 -5
- package/docs/guide/05-items.md +1 -1
- package/docs/guide/09-reference.md +5 -1
- package/docs/guide/12-development.md +2 -1
- package/docs/guide/14-globalization.md +5 -1
- package/package.json +1 -1
- package/public/app.css +80 -0
- package/public/app.js +189 -1
- package/public/builder.css +112 -0
- package/public/builder.js +280 -3
- package/src/builder/appsheets.ts +53 -13
- package/src/builder/appwizard.ts +5 -3
- package/src/builder/arrange.ts +133 -17
- package/src/builder/components.ts +28 -22
- package/src/builder/designer.ts +67 -18
- package/src/builder/forms.ts +4 -1
- package/src/builder/object-browser.ts +342 -0
- package/src/builder/pwa.ts +3 -3
- package/src/builder/routes.ts +85 -26
- package/src/builder/shared.ts +103 -1
- package/src/builder/sql.ts +13 -65
- package/src/builder/ui.ts +21 -6
- package/src/i18n/ar.ts +18 -0
- package/src/i18n/cs.ts +18 -0
- package/src/i18n/da.ts +18 -0
- package/src/i18n/de.ts +18 -0
- package/src/i18n/el.ts +18 -0
- package/src/i18n/es.ts +18 -0
- package/src/i18n/fi.ts +18 -0
- package/src/i18n/fr.ts +18 -0
- package/src/i18n/he.ts +18 -0
- package/src/i18n/it.ts +18 -0
- package/src/i18n/ja.ts +18 -0
- package/src/i18n/ko.ts +18 -0
- package/src/i18n/nb.ts +18 -0
- package/src/i18n/pl.ts +18 -0
- package/src/i18n/pt.ts +18 -0
- package/src/i18n/ru.ts +18 -0
- package/src/i18n/sv.ts +18 -0
- package/src/i18n/tr.ts +18 -0
- package/src/i18n/uk.ts +18 -0
- package/src/i18n/zh.ts +18 -0
- package/src/i18n.ts +36 -0
- package/src/metadata.ts +5 -1
- package/src/runtime/account.ts +5 -5
- package/src/runtime/devbar.ts +16 -13
- package/src/runtime/engine.ts +6 -0
- package/src/runtime/facets.ts +34 -3
- package/src/runtime/format.ts +52 -0
- package/src/runtime/items.ts +27 -0
- package/src/runtime/locale.ts +7 -1
- package/src/runtime/regions.ts +36 -2
- package/src/runtime/render.ts +27 -6
- package/src/runtime/report.ts +141 -81
- package/src/runtime/routes.ts +39 -7
package/src/runtime/render.ts
CHANGED
|
@@ -292,9 +292,14 @@ export async function chrome(ctx: PageContext, main: Raw, title: string) {
|
|
|
292
292
|
</form>
|
|
293
293
|
</div>
|
|
294
294
|
</details>`
|
|
295
|
-
:
|
|
295
|
+
: // (sprint 79, UI-3; APEX: the user menu of a public page) signed out: Appearance and Sign in in the user menu
|
|
296
|
+
ctx.locale.themeChoice || styleChoice(ctx.app)
|
|
297
|
+
? html`<details class="menu t-user"><summary>${icon('user')}<span>${t('login.sign_in_link')}</span></summary>
|
|
298
|
+
<div class="menu-panel align-right">${themeSwitch(ctx, here(ctx))}${styleSwitch(ctx, here(ctx))}
|
|
299
|
+
<div class="menu-section"><a href="${ctx.base}/login">${icon('arrow-right')} ${t('login.sign_in_link')}</a></div></div></details>`
|
|
300
|
+
: html`<a href="${ctx.base}/login">${t('login.sign_in_link')}</a>`
|
|
296
301
|
: ctx.locale.themeChoice || styleChoice(ctx.app)
|
|
297
|
-
? html`<details class="menu t-user"><summary>${icon('settings')}<span class="sr-only">${t('theme.label')}</span></summary>
|
|
302
|
+
? html`<details class="menu t-user"><summary title="${t('theme.label')}">${icon('settings')}<span class="sr-only">${t('theme.label')}</span></summary>
|
|
298
303
|
<div class="menu-panel align-right">${themeSwitch(ctx, here(ctx))}${styleSwitch(ctx, here(ctx))}</div></details>`
|
|
299
304
|
: ''}
|
|
300
305
|
</header>
|
|
@@ -331,7 +336,9 @@ const CLIENT_TEXTS = ['pwa.offline_banner', 'pwa.queued', 'pwa.queue_waiting', '
|
|
|
331
336
|
'pwa.status.signin', 'pwa.status.invalid', 'pwa.status.error', 'item.locate_error', 'item.address_none', 'item.address_error', 'item.scan_close', 'common.dismiss',
|
|
332
337
|
'crop.title', 'crop.apply', 'crop.skip', 'crop.help',
|
|
333
338
|
'push.turn_on', 'push.turn_off', 'push.on', 'push.off', 'push.blocked', 'push.unsupported', 'push.failed', 'page.unsaved_changes', 'page.link_copied',
|
|
334
|
-
'session.warning', 'session.stay', 'session.max', 'session.ended', 'login.sign_in_link'
|
|
339
|
+
'session.warning', 'session.stay', 'session.max', 'session.ended', 'login.sign_in_link',
|
|
340
|
+
// (sprint 76) a report column heading's menu
|
|
341
|
+
'report.sort_asc', 'report.sort_desc', 'report.hide', 'report.break', 'report.filter_values', 'report.no_values'] as const;
|
|
335
342
|
export const clientTexts = (ctx: PageContext) => Object.fromEntries(CLIENT_TEXTS.map((k) => [k, ctx.locale.t(k)]));
|
|
336
343
|
|
|
337
344
|
/**
|
|
@@ -360,8 +367,21 @@ export async function renderPage(ctx: PageContext) {
|
|
|
360
367
|
const hidden = initiallyHidden(ctx);
|
|
361
368
|
const defaultButton = [...ctx.vis!.buttons.values()].find((b) => b.hot && b.action === 'submit');
|
|
362
369
|
const pageItems = await renderItems(ctx, ctx.page.items.filter((i) => i.region_id === null), hidden);
|
|
363
|
-
|
|
364
|
-
|
|
370
|
+
// (099) regions by display position; the side column of a side-column page template, else its regions in the body
|
|
371
|
+
const side = ctx.page.page_template === 'left_side_column' ? 'left' : ctx.page.page_template === 'right_side_column' ? 'right' : null;
|
|
372
|
+
const at: Record<string, Raw[]> = { banner: [], breadcrumb: [], side: [], body: [], footer: [] };
|
|
373
|
+
for (const r of ctx.page.regions) {
|
|
374
|
+
const pos = r.position ?? 'body';
|
|
375
|
+
const into = pos === 'left' || pos === 'right' ? (pos === side ? 'side' : 'body') : pos in at ? pos : 'body';
|
|
376
|
+
// a region its condition or authorization leaves out ('') leaves no empty position behind
|
|
377
|
+
const out = await renderRegion(ctx, r, hidden);
|
|
378
|
+
if (out) at[into].push(out);
|
|
379
|
+
}
|
|
380
|
+
const area = (cls: string, list: Raw[]) => (list.length ? html`<div class="t-regions ${cls}">${list}</div>` : '');
|
|
381
|
+
const regions = side && at.side.length
|
|
382
|
+
? html`<div class="t-columns t-columns-${side}"><aside class="t-side" aria-label="${side === 'left' ? 'Left column' : 'Right column'}"><div class="t-regions t-pos-side">${at.side}</div></aside>
|
|
383
|
+
<div class="t-regions t-pos-body">${at.body}</div></div>`
|
|
384
|
+
: html`<div class="t-regions">${at.body}</div>`;
|
|
365
385
|
// (078) the origins of the page's URL regions (also those a refresh or lazy load shows later)
|
|
366
386
|
for (const o of frameOrigins(ctx.page.regions.filter((r) => ctx.vis!.regions.has(r.id)))) ctx.frameSrc?.add(o);
|
|
367
387
|
const title = substitute(ctx.page.title ?? ctx.page.name, ctx, (v) => v);
|
|
@@ -391,8 +411,9 @@ export async function renderPage(ctx: PageContext) {
|
|
|
391
411
|
${formKeys(ctx)}
|
|
392
412
|
${ctx.dialog ? html`<input type="hidden" name="__dialog" value="1">` : ''}
|
|
393
413
|
${defaultButton ? html`<button type="submit" name="__request" value="${defaultButton.name}" class="default-submit" tabindex="-1" aria-hidden="true"></button>` : ''}
|
|
414
|
+
${area('t-pos-banner', at.banner)}${area('t-pos-breadcrumb', at.breadcrumb)}
|
|
394
415
|
${pageItems.length ? html`<div class="page-items form-grid">${pageItems}</div>` : ''}
|
|
395
|
-
|
|
416
|
+
${regions}${area('t-pos-footer', at.footer)}
|
|
396
417
|
${await buttonsFor(ctx, null)}
|
|
397
418
|
</form>
|
|
398
419
|
${ctx.detached}
|
package/src/runtime/report.ts
CHANGED
|
@@ -186,6 +186,10 @@ interface Highlight extends Filter {
|
|
|
186
186
|
|
|
187
187
|
export interface ReportState {
|
|
188
188
|
search: string;
|
|
189
|
+
/** (sprint 76) the column the search is limited to (the search field's column list), or null: all */
|
|
190
|
+
searchCol: string | null;
|
|
191
|
+
/** (sprint 76) columns the user hid (a column heading's menu → Hide) */
|
|
192
|
+
hideCols: string[];
|
|
189
193
|
sort: number;
|
|
190
194
|
desc: boolean;
|
|
191
195
|
page: number;
|
|
@@ -236,6 +240,8 @@ export function reportState(ctx: PageContext, r: Region): ReportState {
|
|
|
236
240
|
const size = parseInt(p.get(key(r, 'n')) ?? '', 10) || Number(r.config.page_size) || 15;
|
|
237
241
|
const st: ReportState = {
|
|
238
242
|
search: (p.get(key(r, 'q')) ?? '').trim(),
|
|
243
|
+
searchCol: (p.get(key(r, 'qc')) ?? '').trim() || null,
|
|
244
|
+
hideCols: p.getAll(key(r, 'x')).filter(Boolean).slice(0, 100),
|
|
239
245
|
sort: r.config.sortable === false ? 0 : Math.max(0, Math.min(1000, parseInt(p.get(key(r, 's')) ?? '0', 10) || 0)),
|
|
240
246
|
desc: p.get(key(r, 'd')) === 'desc',
|
|
241
247
|
page: Math.max(1, Math.min(MAX_PAGE, parseInt(p.get(key(r, 'p')) ?? '1', 10) || 1)),
|
|
@@ -415,13 +421,14 @@ export async function filtered(ctx: PageContext, r: Region, st: ReportState) {
|
|
|
415
421
|
const p = new SqlParams();
|
|
416
422
|
const hides = hidesColumns(r);
|
|
417
423
|
const facets = facetFilters(ctx.params, r.id, reportFacetDefs(ctx.page.regions, r.id, ctx.vis?.regions));
|
|
418
|
-
const needCols = st.filters.length || facets.length || st.breakCol || st.aggregates.length || st.highlights.length || st.view !== 'report' || st.area || st.near || keysetColumns(r) || (hides && (st.search || st.sort));
|
|
424
|
+
const needCols = st.filters.length || facets.length || st.breakCol || st.aggregates.length || st.highlights.length || st.view !== 'report' || st.area || st.near || keysetColumns(r) || (hides && (st.search || st.sort)) || (st.search && st.searchCol);
|
|
419
425
|
// column name → type oid
|
|
420
426
|
const fields = needCols ? await fieldsOf(ctx, src) : [];
|
|
421
427
|
const cols = new Map<string, number>(fields.map((f) => [f.name, f.dataTypeID]));
|
|
422
428
|
// the columns the user may choose (filters, highlights, control break, aggregates, views, sorting): not the hidden ones
|
|
423
429
|
const userCols = new Map<string, number>(userColumnNames(r, [...cols.keys()]).map((n) => [n, cols.get(n)!]));
|
|
424
|
-
|
|
430
|
+
// (sprint 76) the search in one column the user may see, or in all
|
|
431
|
+
if (st.search) where.push(searchSql(st.search, p, st.searchCol && userCols.has(st.searchCol) ? [st.searchCol] : hides ? [...userCols.keys()] : undefined));
|
|
425
432
|
for (const f of st.filters) if (userCols.has(f.column)) where.push(OPERATORS[f.op].sql(q(f.column), f.value));
|
|
426
433
|
for (const f of facets) {
|
|
427
434
|
const cond = facetFilterSql(f, cols, p);
|
|
@@ -536,7 +543,9 @@ export function chartSection(ctx: PageContext, r: Region, st: ReportState, names
|
|
|
536
543
|
/** The pager under a report or grid: "X–Y of N" (or "Rows X–Y"), Previous and Next. */
|
|
537
544
|
export function pagerNav(ctx: PageContext, r: Region, info: PageInfo, linkAttr: Raw | '' = '') {
|
|
538
545
|
const t = ctx.locale.t;
|
|
539
|
-
|
|
546
|
+
// (sprint 76) "1 – 14 of 14" and the rows per page, also on a single page (APEX's pagination)
|
|
547
|
+
const sizes = sizeChooser(ctx, r, info);
|
|
548
|
+
if (!info.more && info.page <= 1) return info.total ? html`<div class="pager"><span>${t('report.range', { from: 1, to: info.total, total: info.total })}</span>${sizes}</div>` : '';
|
|
540
549
|
// a page number, and the keyset position when there is one
|
|
541
550
|
const go = (page: number, seek: string | null) => (p: URLSearchParams) => {
|
|
542
551
|
p.set(key(r, 'p'), String(page));
|
|
@@ -546,13 +555,54 @@ export function pagerNav(ctx: PageContext, r: Region, info: PageInfo, linkAttr:
|
|
|
546
555
|
const text =
|
|
547
556
|
info.total === null ? t('report.range_open', { from: info.from, to: info.to })
|
|
548
557
|
: t(info.capped ? 'report.range_more' : 'report.range', { from: info.from, to: info.to, total: info.total });
|
|
558
|
+
// the last page, when the total is known and pages are counted (not keyset paging)
|
|
559
|
+
const lastPage = info.total !== null && !info.capped && !info.next && !info.prev ? Math.ceil(info.total / reportState(ctx, r).size) : null;
|
|
549
560
|
return html`<nav class="pager" aria-label="${t('report.pagination')}">
|
|
550
561
|
<span>${text}</span>
|
|
562
|
+
${info.page > 2 ? html`<a class="btn" href="${regionUrl(ctx, r, go(1, null))}"${linkAttr} aria-label="${t('report.first')}" title="${t('report.first')}">«</a>` : ''}
|
|
551
563
|
${info.page > 1 ? html`<a class="btn" href="${regionUrl(ctx, r, go(info.page - 1, info.prev))}"${linkAttr}>‹ ${t('report.previous')}</a>` : ''}
|
|
552
564
|
${info.more ? html`<a class="btn" href="${regionUrl(ctx, r, go(info.page + 1, info.next))}"${linkAttr}>${t('report.next')} ›</a>` : ''}
|
|
565
|
+
${info.more && lastPage && lastPage > info.page + 1 ? html`<a class="btn" href="${regionUrl(ctx, r, go(lastPage, null))}"${linkAttr} aria-label="${t('report.last')}" title="${t('report.last')}">»</a>` : ''}
|
|
566
|
+
${sizes}
|
|
553
567
|
</nav>`;
|
|
554
568
|
}
|
|
555
569
|
|
|
570
|
+
/** (sprint 76) Rows per page as a select in the pager (a detached GET form; app.js sends it on change, else its button). */
|
|
571
|
+
function sizeChooser(ctx: PageContext, r: Region, info: PageInfo): Raw | '' {
|
|
572
|
+
if (r.type !== 'report' || r.config.interactive === false) return '';
|
|
573
|
+
const st = reportState(ctx, r);
|
|
574
|
+
const keep = [...ctx.params.entries()].filter(([k]) => k !== key(r, 'n') && k !== key(r, 'p') && k !== key(r, 'k') && !['clear', 'cs'].includes(k));
|
|
575
|
+
const t = ctx.locale.t;
|
|
576
|
+
if (info.total !== null && info.total <= PAGE_SIZES[0] && st.size === PAGE_SIZES[0]) return '';
|
|
577
|
+
// the region sits inside the page's form: the GET form is detached, the select and its button join it by its id
|
|
578
|
+
const form = `rn${r.id}`;
|
|
579
|
+
ctx.detached.push(html`<form id="${form}" method="get" action="${ctx.base}/${ctx.page.page_no}">${keep.map(([k, v]) => html`<input type="hidden" name="${k}" value="${v}">`)}${ctx.dialog ? html`<input type="hidden" name="dialog" value="1">` : ''}</form>`);
|
|
580
|
+
return html`<span class="pager-size">
|
|
581
|
+
<label for="r${r.id}_size">${t('report.rows_per_page')}</label>
|
|
582
|
+
<select id="r${r.id}_size" name="${key(r, 'n')}" form="${form}" data-go>${[...new Set([...PAGE_SIZES, st.size])].sort((a, b) => a - b).map((n) => html`<option value="${n}"${n === st.size ? raw(' selected') : ''}>${n}</option>`)}</select>
|
|
583
|
+
<button class="btn btn-sm no-js-only" form="${form}">${t('report.go')}</button></span>`;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/** (sprint 76) The most values a column heading's menu lists. */
|
|
587
|
+
export const MAX_COLUMN_VALUES = 200;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* (sprint 76) A column's values with their counts, for its heading's menu (APEX: the column heading's quick
|
|
591
|
+
* filter list): the report's rows with the user's search and filters, only a column the user may see.
|
|
592
|
+
*/
|
|
593
|
+
export async function columnValues(ctx: PageContext, r: Region, column: string) {
|
|
594
|
+
const st = reportState(ctx, r);
|
|
595
|
+
const { src, where, userCols, values } = await filtered(ctx, r, { ...st, filters: [...st.filters] });
|
|
596
|
+
// the column's own type is needed: filtered() reads the columns when anything asks for them
|
|
597
|
+
const names = userCols.size ? userCols : new Map((await fieldsOf(ctx, src)).filter((f) => userColumnNames(r, [f.name]).length).map((f) => [f.name, f.dataTypeID]));
|
|
598
|
+
if (!names.has(column)) return null;
|
|
599
|
+
const c = ctx.client!;
|
|
600
|
+
const res = await savepoint(c, () =>
|
|
601
|
+
c.query({ text: `select ${q(column)}::text as v, count(*)::int as n from (\n${src}\n) "__q"${where} group by 1 order by 1 nulls first limit ${MAX_COLUMN_VALUES}`, values }),
|
|
602
|
+
);
|
|
603
|
+
return res.rows.map((row: { v: string | null; n: number }) => ({ value: row.v, count: row.n }));
|
|
604
|
+
}
|
|
605
|
+
|
|
556
606
|
/**
|
|
557
607
|
* The aggregates over all filtered rows (not just the page): the totals,
|
|
558
608
|
* and per control-break value when there is a break column.
|
|
@@ -741,6 +791,8 @@ export async function renderReport(ctx: PageContext, r: Region, filterItems: Raw
|
|
|
741
791
|
const st = reportState(ctx, r);
|
|
742
792
|
const searchable = r.config.searchable !== false;
|
|
743
793
|
const interactive = r.config.interactive !== false && searchable;
|
|
794
|
+
// (sprint 78; APEX: a faceted search's results have no search bar) one search field: the facets'
|
|
795
|
+
const searchBox = !ctx.page.regions.some((x) => x.type === 'facets' && x.config.search === true && Number(x.config.report) === r.id && ctx.vis?.regions.has(x.id) !== false);
|
|
744
796
|
|
|
745
797
|
let res: pg.QueryResult<any[]>;
|
|
746
798
|
let pageNo = st.page;
|
|
@@ -783,7 +835,9 @@ export async function renderReport(ctx: PageContext, r: Region, filterItems: Raw
|
|
|
783
835
|
if (info.page > 2) info.prev = seekToken(ctx, r, st, info.page - 1, 'p', at(info.rows[0]));
|
|
784
836
|
}
|
|
785
837
|
const hlIdx = st.highlights.map((_, i) => res.fields.findIndex((f) => f.name === `__h${i}`));
|
|
786
|
-
|
|
838
|
+
// (sprint 76) without the columns the user hid (a heading's menu → Hide)
|
|
839
|
+
const userHidden = new Set(st.hideCols.map((c) => c.toLowerCase()));
|
|
840
|
+
const allCols = visibleColumns(r, fields).filter(({ f }) => !userHidden.has(f.name.toLowerCase()));
|
|
787
841
|
// a control break on a shown column only (its values head the groups)
|
|
788
842
|
const breakIdx = st.breakCol ? (allCols.find(({ f }) => f.name === st.breakCol)?.i ?? -1) : -1;
|
|
789
843
|
const cols = allCols.filter(({ i }) => i !== breakIdx);
|
|
@@ -840,7 +894,13 @@ export async function renderReport(ctx: PageContext, r: Region, filterItems: Raw
|
|
|
840
894
|
else p.delete(key(r, 'd'));
|
|
841
895
|
p.delete(key(r, 'p'));
|
|
842
896
|
});
|
|
843
|
-
|
|
897
|
+
// (sprint 76) a heading's menu (app.js): sort either way, hide, control break and the column's values to filter by;
|
|
898
|
+
// without JavaScript the heading sorts
|
|
899
|
+
const set = (fn: (p: URLSearchParams) => void) => regionUrl(ctx, r, (p) => { fn(p); p.delete(key(r, 'p')); p.delete(key(r, 'k')); });
|
|
900
|
+
const menu = interactive
|
|
901
|
+
? raw(` data-col="${esc(f.name)}" data-label="${esc(label)}" data-asc="${esc(set((p) => { p.set(key(r, 's'), String(pos)); p.delete(key(r, 'd')); }))}" data-desc="${esc(set((p) => { p.set(key(r, 's'), String(pos)); p.set(key(r, 'd'), 'desc'); }))}" data-hide="${esc(set((p) => p.append(key(r, 'x'), f.name)))}" data-break="${esc(set((p) => p.set(key(r, 'b'), f.name)))}" data-filter="${esc(key(r, 'f'))}" data-values="${esc(`${ctx.base}/${ctx.page.page_no}/report/${r.id}/values`)}"`)
|
|
902
|
+
: '';
|
|
903
|
+
return html`<th scope="col" class="${cls}" aria-sort="${active ? (st.desc ? 'descending' : 'ascending') : 'none'}"${menu}><a href="${href}">${label}<span class="sort-ind" aria-hidden="true">${active ? (st.desc ? '▼' : '▲') : ''}</span></a></th>`;
|
|
844
904
|
});
|
|
845
905
|
if (editIcon) header.unshift(html`<th scope="col" class="row-edit" aria-label="${t('report.edit')}"></th>`);
|
|
846
906
|
if (selIdx >= 0) header.unshift(html`<th scope="col" class="row-select"><label><input type="checkbox" data-select-all="${selection!.item}" aria-label="${t('report.select_all')}"><span class="row-select-label" aria-hidden="true">${t('report.select_all')}</span></label></th>`);
|
|
@@ -901,7 +961,7 @@ export async function renderReport(ctx: PageContext, r: Region, filterItems: Raw
|
|
|
901
961
|
.map(([k, v]) => html`<input type="hidden" name="${k}" value="${v}">`);
|
|
902
962
|
const action = `${ctx.base}/${ctx.page.page_no}`;
|
|
903
963
|
if (searchable) {
|
|
904
|
-
ctx.detached.push(html`<form id="${searchForm}" method="get" action="${action}">${hiddenInputs([key(r, 'q'), key(r, 'p')])}${ctx.dialog ? html`<input type="hidden" name="dialog" value="1">` : ''}</form>`);
|
|
964
|
+
ctx.detached.push(html`<form id="${searchForm}" method="get" action="${action}">${hiddenInputs([key(r, 'q'), key(r, 'qc'), key(r, 'p')])}${ctx.dialog ? html`<input type="hidden" name="dialog" value="1">` : ''}</form>`);
|
|
905
965
|
}
|
|
906
966
|
const breakForm = `rb${r.id}`;
|
|
907
967
|
const aggForm = `ra${r.id}`;
|
|
@@ -971,101 +1031,96 @@ export async function renderReport(ctx: PageContext, r: Region, filterItems: Raw
|
|
|
971
1031
|
if (st.area) chips.push(chip(t('report.map_area'), 'bb'));
|
|
972
1032
|
if (st.near) chips.push(chip(t('report.near', { km: ctx.locale.number.format(st.near.km) }), 'near'));
|
|
973
1033
|
}
|
|
1034
|
+
for (const c of st.hideCols)
|
|
1035
|
+
chips.push(html`<span class="chip">${t('report.hidden_column')}: <b>${headingOf(r, c, ctx.locale.tr)}</b>
|
|
1036
|
+
<a href="${regionUrl(ctx, r, (p) => { const rest = p.getAll(key(r, 'x')).filter((x) => x !== c); p.delete(key(r, 'x')); for (const x of rest) p.append(key(r, 'x'), x); })}" aria-label="${t('report.show_column')}">×</a></span>`);
|
|
974
1037
|
if (st.search)
|
|
975
1038
|
chips.unshift(
|
|
976
|
-
html`<span class="chip">${t('report.search_chip')} <b>${st.search}</b> <a href="${regionUrl(ctx, r, (p) => { p.delete(key(r, 'q')); p.delete(key(r, 'p')); })}" aria-label="${t('report.clear_search')}">×</a></span>`,
|
|
1039
|
+
html`<span class="chip">${t('report.search_chip')}${st.searchCol ? html` ${headingOf(r, st.searchCol, ctx.locale.tr)}:` : ''} <b>${st.search}</b> <a href="${regionUrl(ctx, r, (p) => { p.delete(key(r, 'q')); p.delete(key(r, 'qc')); p.delete(key(r, 'p')); })}" aria-label="${t('report.clear_search')}">×</a></span>`,
|
|
977
1040
|
);
|
|
978
1041
|
|
|
1042
|
+
// (sprint 76) Actions is a short menu like APEX's; each entry opens a dialog (app.js), or unfolds in place without JavaScript
|
|
1043
|
+
const columnsForm = `rx${r.id}`;
|
|
1044
|
+
if (interactive)
|
|
1045
|
+
ctx.detached.push(html`<form id="${columnsForm}" method="get" action="${ctx.base}/${ctx.page.page_no}">${hiddenInputs([key(r, 'x'), key(r, 'p')])}${ctx.dialog ? html`<input type="hidden" name="dialog" value="1">` : ''}</form>`);
|
|
1046
|
+
const item = (k: string, ic: string, label: string, body: Raw | '') =>
|
|
1047
|
+
html`<li><details class="ir-item" data-ir-dialog="${k}"><summary>${icon(ic)}<span>${label}</span></summary><div class="ir-body" role="group" aria-label="${label}">${body}</div></details></li>`;
|
|
1048
|
+
const sub = (ic: string, label: string, items: (Raw | '')[]) =>
|
|
1049
|
+
html`<li><details class="ir-item ir-sub"><summary>${icon(ic)}<span>${label}</span><span class="ir-more" aria-hidden="true">›</span></summary><ul class="ir-menu">${items}</ul></details></li>`;
|
|
1050
|
+
const menuLink = (ic: string, label: Raw | string, href: string, attrs: Raw | '' = '') => html`<li><a class="ir-link" href="${href}"${attrs}>${icon(ic)}<span>${label}</span></a></li>`;
|
|
1051
|
+
const sortLinks = r.config.sortable === false
|
|
1052
|
+
? ''
|
|
1053
|
+
: html`<div class="seg">${cols.map(({ f, i }) => {
|
|
1054
|
+
const pos = i + 1;
|
|
1055
|
+
const active = st.sort === pos;
|
|
1056
|
+
const href = regionUrl(ctx, r, (p) => {
|
|
1057
|
+
p.set(key(r, 's'), String(pos));
|
|
1058
|
+
if (active && !st.desc) p.set(key(r, 'd'), 'desc');
|
|
1059
|
+
else p.delete(key(r, 'd'));
|
|
1060
|
+
p.delete(key(r, 'p'));
|
|
1061
|
+
});
|
|
1062
|
+
return html`<a href="${href}"${active ? raw(' aria-current="true"') : ''}>${headingOf(r, f.name, ctx.locale.tr)}${active ? (st.desc ? ' ▼' : ' ▲') : ''}</a>`;
|
|
1063
|
+
})}</div>`;
|
|
979
1064
|
const actionsMenu = interactive
|
|
980
1065
|
? html`<details class="menu actions-menu">
|
|
981
1066
|
<summary class="btn">${t('report.actions')} <span aria-hidden="true">▾</span></summary>
|
|
982
|
-
<div class="menu-panel">
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
<
|
|
1067
|
+
<div class="menu-panel"><ul class="ir-menu">
|
|
1068
|
+
${item('columns', 'eye-off', t('report.columns'), html`<fieldset class="ir-columns"><legend>${t('report.hide_columns')}</legend>
|
|
1069
|
+
${visibleColumns(r, fields).map(({ f }) => html`<label class="check"><input type="checkbox" name="${key(r, 'x')}" value="${f.name}" form="${columnsForm}"${userHidden.has(f.name.toLowerCase()) ? raw(' checked') : ''}> ${headingOf(r, f.name, ctx.locale.tr)}</label>`)}</fieldset>
|
|
1070
|
+
<button class="btn btn-hot" form="${columnsForm}">${t('report.apply')}</button>`)}
|
|
1071
|
+
${item('filter', 'filter', t('report.filter'), html`<div class="filter-row">
|
|
986
1072
|
<select name="${key(r, 'fc')}" form="${filterForm}" aria-label="${t('report.column')}">${cols.map(({ f }) => html`<option value="${f.name}">${headingOf(r, f.name, ctx.locale.tr)}</option>`)}</select>
|
|
987
1073
|
<select name="${key(r, 'fo')}" form="${filterForm}" aria-label="${t('report.operator')}">${Object.keys(OPERATORS).map((k) => html`<option value="${k}"${k === 'contains' ? raw(' selected') : ''}>${opLabel(t, k)}</option>`)}</select>
|
|
988
1074
|
<input name="${key(r, 'fv')}" form="${filterForm}" aria-label="${t('report.value')}" placeholder="${t('report.value')}">
|
|
989
1075
|
<button class="btn btn-hot" form="${filterForm}">${t('report.apply')}</button>
|
|
990
|
-
</div
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
});
|
|
1004
|
-
return html`<a href="${href}"${active ? raw(' aria-current="true"') : ''}>${headingOf(r, f.name, ctx.locale.tr)}${active ? (st.desc ? ' ▼' : ' ▲') : ''}</a>`;
|
|
1005
|
-
})}</div>
|
|
1006
|
-
</div>`}
|
|
1007
|
-
<div class="menu-section">
|
|
1008
|
-
<strong>${t('report.break')}</strong>
|
|
1009
|
-
<div class="filter-row">
|
|
1076
|
+
</div>`)}
|
|
1077
|
+
${sub('table', t('report.data'), [
|
|
1078
|
+
r.config.sortable === false ? '' : item('sort', 'arrow-down', t('report.sort'), sortLinks),
|
|
1079
|
+
item('aggregate', 'calculator', t('report.aggregate'), html`<div class="filter-row">
|
|
1080
|
+
<select name="${key(r, 'af')}" form="${aggForm}" aria-label="${t('report.function')}">${Object.keys(AGGREGATES).map((fn) => html`<option value="${fn}">${t(`agg.${fn}`)}</option>`)}</select>
|
|
1081
|
+
<select name="${key(r, 'ac')}" form="${aggForm}" aria-label="${t('report.column')}">${cols.map(({ f }) => html`<option value="${f.name}">${headingOf(r, f.name, ctx.locale.tr)}</option>`)}</select>
|
|
1082
|
+
<button class="btn btn-hot" form="${aggForm}">${t('report.apply')}</button></div>`),
|
|
1083
|
+
item('compute', 'percent', t('report.compute'), html`<div class="filter-row">
|
|
1084
|
+
<input name="${key(r, 'cn')}" form="${computeForm}" maxlength="40" aria-label="${t('report.compute_name')}" placeholder="${t('report.compute_name')}">
|
|
1085
|
+
<input name="${key(r, 'ce')}" form="${computeForm}" maxlength="500" aria-label="${t('report.compute_expr')}" placeholder="${t('report.compute_expr')}">
|
|
1086
|
+
<button class="btn btn-hot" form="${computeForm}">${t('report.apply')}</button></div>
|
|
1087
|
+
<small class="help">${t('report.compute_help')}</small>`),
|
|
1088
|
+
item('break', 'list', t('report.break'), html`<div class="filter-row">
|
|
1010
1089
|
<select name="${key(r, 'bc')}" form="${breakForm}" aria-label="${t('report.break')}">
|
|
1011
1090
|
<option value="">${t('report.none')}</option>
|
|
1012
1091
|
${allCols.map(({ f }) => html`<option value="${f.name}"${f.name === st.breakCol ? raw(' selected') : ''}>${headingOf(r, f.name, ctx.locale.tr)}</option>`)}
|
|
1013
1092
|
</select>
|
|
1014
|
-
<button class="btn" form="${breakForm}">${t('report.apply')}</button
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
<strong>${t('report.aggregate')}</strong>
|
|
1019
|
-
<div class="filter-row">
|
|
1020
|
-
<select name="${key(r, 'af')}" form="${aggForm}" aria-label="${t('report.function')}">${Object.keys(AGGREGATES).map((fn) => html`<option value="${fn}">${t(`agg.${fn}`)}</option>`)}</select>
|
|
1021
|
-
<select name="${key(r, 'ac')}" form="${aggForm}" aria-label="${t('report.column')}">${cols.map(({ f }) => html`<option value="${f.name}">${headingOf(r, f.name, ctx.locale.tr)}</option>`)}</select>
|
|
1022
|
-
<button class="btn" form="${aggForm}">${t('report.apply')}</button>
|
|
1023
|
-
</div>
|
|
1024
|
-
</div>
|
|
1025
|
-
<div class="menu-section">
|
|
1026
|
-
<strong>${t('report.highlight')}</strong>
|
|
1027
|
-
<div class="filter-row">
|
|
1093
|
+
<button class="btn btn-hot" form="${breakForm}">${t('report.apply')}</button></div>`),
|
|
1094
|
+
])}
|
|
1095
|
+
${sub('sliders', t('report.format'), [
|
|
1096
|
+
item('highlight', 'tag', t('report.highlight'), html`<div class="filter-row">
|
|
1028
1097
|
<select name="${key(r, 'hc')}" form="${hlForm}" aria-label="${t('report.column')}">${allCols.map(({ f }) => html`<option value="${f.name}">${headingOf(r, f.name, ctx.locale.tr)}</option>`)}</select>
|
|
1029
1098
|
<select name="${key(r, 'ho')}" form="${hlForm}" aria-label="${t('report.operator')}">${Object.keys(OPERATORS).map((k) => html`<option value="${k}"${k === 'eq' ? raw(' selected') : ''}>${opLabel(t, k)}</option>`)}</select>
|
|
1030
1099
|
<input name="${key(r, 'hv')}" form="${hlForm}" aria-label="${t('report.value')}" placeholder="${t('report.value')}">
|
|
1031
1100
|
<select name="${key(r, 'hk')}" form="${hlForm}" aria-label="${t('report.color')}">${HIGHLIGHT_COLORS.map((c) => html`<option value="${c}">${t(`color.${c}`)}</option>`)}</select>
|
|
1032
|
-
<button class="btn" form="${hlForm}">${t('report.apply')}</button
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
<input name="${key(r, 'ce')}" form="${computeForm}" maxlength="500" aria-label="${t('report.compute_expr')}" placeholder="${t('report.compute_expr')}">
|
|
1040
|
-
<button class="btn" form="${computeForm}">${t('report.apply')}</button>
|
|
1041
|
-
</div>
|
|
1042
|
-
<small class="help">${t('report.compute_help')}</small>
|
|
1043
|
-
</div>
|
|
1044
|
-
${groupBySection(ctx, r, st, allCols.map(({ f }) => f.name), groupForm)}
|
|
1045
|
-
<div class="menu-section">
|
|
1046
|
-
<strong>${t('report.pivot')}</strong>
|
|
1047
|
-
<div class="filter-row">
|
|
1101
|
+
<button class="btn btn-hot" form="${hlForm}">${t('report.apply')}</button></div>`),
|
|
1102
|
+
item('rows', 'hash', t('report.rows_per_page'), html`<div class="seg">${PAGE_SIZES.map((n) =>
|
|
1103
|
+
html`<a href="${regionUrl(ctx, r, (p) => { p.set(key(r, 'n'), String(n)); p.delete(key(r, 'p')); })}"${n === st.size ? raw(' aria-current="true"') : ''}>${n}</a>`)}</div>`),
|
|
1104
|
+
])}
|
|
1105
|
+
${item('chart', 'chart', t('report.chart'), chartSection(ctx, r, st, allCols.map(({ f }) => f.name), chartForm))}
|
|
1106
|
+
${item('group', 'layers', t('report.group_by'), groupBySection(ctx, r, st, allCols.map(({ f }) => f.name), groupForm))}
|
|
1107
|
+
${item('pivot', 'grid', t('report.pivot'), html`<div class="filter-row">
|
|
1048
1108
|
<select name="${key(r, 'pr')}" form="${pivotForm}" aria-label="${t('report.pivot_row')}">${allCols.map(({ f }) => html`<option value="${f.name}"${f.name === st.pivot?.row ? raw(' selected') : ''}>${headingOf(r, f.name, ctx.locale.tr)}</option>`)}</select>
|
|
1049
1109
|
<select name="${key(r, 'pp')}" form="${pivotForm}" aria-label="${t('report.pivot_column')}">${allCols.map(({ f }) => html`<option value="${f.name}"${f.name === st.pivot?.column ? raw(' selected') : ''}>${headingOf(r, f.name, ctx.locale.tr)}</option>`)}</select>
|
|
1050
1110
|
<select name="${key(r, 'pf')}" form="${pivotForm}" aria-label="${t('report.function')}">${Object.keys(AGGREGATES).map((fn) => html`<option value="${fn}"${fn === (st.pivot?.fn ?? 'count') ? raw(' selected') : ''}>${t(`agg.${fn}`)}</option>`)}</select>
|
|
1051
1111
|
<select name="${key(r, 'pc')}" form="${pivotForm}" aria-label="${t('report.value_column')}">${allCols.map(({ f }) => html`<option value="${f.name}"${f.name === st.pivot?.value ? raw(' selected') : ''}>${headingOf(r, f.name, ctx.locale.tr)}</option>`)}</select>
|
|
1052
|
-
<button class="btn" form="${pivotForm}">${t('report.apply')}</button
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
<a href="${regionUrl(ctx, r, (p) => p.set(key(r, 'pdf'), '1'))}" download>${icon('download')} ${t('report.download_pdf')}</a>
|
|
1065
|
-
<button type="button" data-print>${icon('printer')} ${t('report.print')}</button>
|
|
1066
|
-
<a href="${regionUrl(ctx, r, (p) => { for (const k of [...p.keys()]) if (k.startsWith(`r${r.id}_`)) p.delete(k); })}">${icon('history')} ${t('report.reset')}</a>
|
|
1067
|
-
</div>
|
|
1068
|
-
</div>
|
|
1112
|
+
<button class="btn btn-hot" form="${pivotForm}">${t('report.apply')}</button></div>`)}
|
|
1113
|
+
${sub('bookmark', t('report.report'), [
|
|
1114
|
+
saved ? item('saved', 'save', t('report.saved_reports'), saved) : '',
|
|
1115
|
+
menuLink('history', t('report.reset'), regionUrl(ctx, r, (p) => { for (const k of [...p.keys()]) if (k.startsWith(`r${r.id}_`)) p.delete(k); })),
|
|
1116
|
+
])}
|
|
1117
|
+
${sub('download', t('report.download_menu'), [
|
|
1118
|
+
menuLink('download', t('report.download'), regionUrl(ctx, r, (p) => p.set(key(r, 'csv'), '1')), raw(' download')),
|
|
1119
|
+
menuLink('download', t('report.download_xlsx'), regionUrl(ctx, r, (p) => p.set(key(r, 'xlsx'), '1')), raw(' download')),
|
|
1120
|
+
menuLink('download', t('report.download_pdf'), regionUrl(ctx, r, (p) => p.set(key(r, 'pdf'), '1')), raw(' download')),
|
|
1121
|
+
html`<li><button type="button" class="ir-link" data-print>${icon('printer')}<span>${t('report.print')}</span></button></li>`,
|
|
1122
|
+
])}
|
|
1123
|
+
</ul></div>
|
|
1069
1124
|
</details>`
|
|
1070
1125
|
: '';
|
|
1071
1126
|
|
|
@@ -1074,9 +1129,14 @@ export async function renderReport(ctx: PageContext, r: Region, filterItems: Raw
|
|
|
1074
1129
|
? html`<div class="report-toolbar">
|
|
1075
1130
|
${filterItems}
|
|
1076
1131
|
${searchable
|
|
1077
|
-
? html`<div class="search" role="search">
|
|
1078
|
-
|
|
1079
|
-
|
|
1132
|
+
? html`<div class="search"${searchBox ? raw(' role="search"') : ''}>
|
|
1133
|
+
${searchBox ? html`<div class="search-field">${interactive
|
|
1134
|
+
? html`<label class="sr-only" for="r${r.id}_qc">${t('report.search_column')}</label>
|
|
1135
|
+
<span class="search-scope-wrap" title="${t('report.search_column')}">${icon('search')}<select id="r${r.id}_qc" class="search-scope" name="${key(r, 'qc')}" form="${searchForm}">
|
|
1136
|
+
<option value="">${t('report.all_columns')}</option>${cols.map(({ f }) => html`<option value="${f.name}"${f.name === st.searchCol ? raw(' selected') : ''}>${headingOf(r, f.name, ctx.locale.tr)}</option>`)}</select></span>`
|
|
1137
|
+
: ''}
|
|
1138
|
+
<input type="search" name="${key(r, 'q')}" value="${st.search}" placeholder="${t('report.search_all')}" form="${searchForm}" aria-label="${t('report.search')} ${r.title ?? ''}"></div>
|
|
1139
|
+
<button class="btn no-js-only" form="${searchForm}">${t('report.go')}</button>` : ''}
|
|
1080
1140
|
${actionsMenu}
|
|
1081
1141
|
</div>`
|
|
1082
1142
|
: ''}
|
package/src/runtime/routes.ts
CHANGED
|
@@ -24,15 +24,16 @@ import { startDebug } from '../debug.ts';
|
|
|
24
24
|
import { assignable, clearPageItems, fetchForms, processConditionHolds, ProcessFailed, runAppProcesses, runProcesses, runSql, validate, ValidationFailed } from './engine.ts';
|
|
25
25
|
import { aiInputs, aiProcessOf, runAiProcess } from './ai.ts';
|
|
26
26
|
import { branchTarget, ComputationFailed, runComputations } from './logic.ts';
|
|
27
|
-
import { comboMultiple, itemMask, MULTI_VALUE, popupPageSize, renderItem, searchLov, splitValues } from './items.ts';
|
|
27
|
+
import { comboMultiple, itemDateMask, itemMask, MULTI_VALUE, popupPageSize, renderItem, searchLov, splitValues } from './items.ts';
|
|
28
28
|
import { parseNumber } from '../numformat.ts';
|
|
29
|
+
import { parseDateMask } from './format.ts';
|
|
29
30
|
import { cleanRichText } from '../richtext.ts';
|
|
30
31
|
import { applyUploads, fileRoutes, readMultipart, type Upload } from './files.ts';
|
|
31
32
|
import { renderRegion } from './regions.ts';
|
|
32
33
|
import { downloadHeaders, type Download } from './processes.ts';
|
|
33
34
|
import { moveGanttTask } from './gantt-move.ts';
|
|
34
35
|
import { moveCalendarEvent } from './calendar.ts';
|
|
35
|
-
import { openDownload, reportParams, normaliseReportParams, selectionOf } from './report.ts';
|
|
36
|
+
import { columnValues, openDownload, reportParams, normaliseReportParams, selectionOf } from './report.ts';
|
|
36
37
|
import { invalidatePage, lazyOf } from './region-cache.ts';
|
|
37
38
|
import { applyRowSelection, mastersOf } from './master-detail.ts';
|
|
38
39
|
import { layerInArea, layerTile, parseTile, servedLayer } from './maps.ts';
|
|
@@ -43,7 +44,7 @@ import { PassThrough } from 'node:stream';
|
|
|
43
44
|
import { reportPdf } from './pdf.ts';
|
|
44
45
|
import { renderDocument } from './documents.ts';
|
|
45
46
|
import { pwaHead } from './pwa.ts';
|
|
46
|
-
import { resolveLocale, THEME_COOKIE, translateApp, translatePage, validTimeZone, type Locale } from './locale.ts';
|
|
47
|
+
import { resolveLocale, THEME_COOKIE, themeCookieOptions, translateApp, translatePage, validTimeZone, type Locale } from './locale.ts';
|
|
47
48
|
import { chrome, dialogClosePage, languagePicker, renderPage } from './render.ts';
|
|
48
49
|
import { LOGIN_ERROR, LOGIN_USER, safeNext, signInForm } from './signin.ts';
|
|
49
50
|
import { passwordResetRoutes } from './password-reset.ts';
|
|
@@ -121,13 +122,14 @@ export async function signIn(req: FastifyRequest, reply: FastifyReply, a: App, o
|
|
|
121
122
|
// the browser's time zone (sent before signing in) stays with the new session
|
|
122
123
|
if (typeof oldSession.state.__TZ === 'string') s.state.__TZ = oldSession.state.__TZ;
|
|
123
124
|
// the account's preferences: light/dark, language and time zone
|
|
124
|
-
const pref = await runtime.one<{ theme_pref: string; language: string | null; time_zone: string | null }>(
|
|
125
|
+
const pref = await runtime.one<{ theme_pref: string | null; language: string | null; time_zone: string | null }>(
|
|
125
126
|
'select theme_pref, language, time_zone from meta.account where lower(username) = lower($1)', [username]);
|
|
126
127
|
if (pref) {
|
|
127
|
-
s
|
|
128
|
+
// (sprint 79) no choice (null): the application's own mode
|
|
129
|
+
if (pref.theme_pref) s.state.__THEME = pref.theme_pref;
|
|
128
130
|
if (pref.language) s.state.__LANG = pref.language;
|
|
129
131
|
if (pref.time_zone) s.state.__TZ_PREF = pref.time_zone;
|
|
130
|
-
if (a.theme?.user_choice !== false) reply.setCookie(THEME_COOKIE, pref.theme_pref,
|
|
132
|
+
if (pref.theme_pref && a.theme?.user_choice !== false) reply.setCookie(THEME_COOKIE, pref.theme_pref, themeCookieOptions(base));
|
|
131
133
|
}
|
|
132
134
|
// the account's style variant for this app (honoured only while the app offers it: styles.ts)
|
|
133
135
|
const style = await runtime.one<{ style: string }>(
|
|
@@ -373,7 +375,10 @@ function applyPostedItems(ctx: PageContext, body: Body, only?: string[]) {
|
|
|
373
375
|
else if (item.type === 'markdown') ctx.session.state[item.name] = posted ? String(posted).replace(/\r\n?/g, '\n') : null;
|
|
374
376
|
else if (item.type === 'checkbox' || item.type === 'switch') ctx.session.state[item.name] = posted === 'true' ? 'true' : 'false';
|
|
375
377
|
else if (item.type === 'password' && !posted) continue;
|
|
376
|
-
else if (
|
|
378
|
+
else if (item.type === 'date' && itemDateMask(ctx, item) && posted !== undefined && posted !== '') {
|
|
379
|
+
// (sprint 76) "23-05-1987" in the date format → "1987-05-23"; other text is kept as typed, and validate() reports it
|
|
380
|
+
ctx.session.state[item.name] = parseDateMask(String(posted), itemDateMask(ctx, item)!, ctx.locale.lang) ?? String(posted);
|
|
381
|
+
} else if (itemMask(item) && posted !== undefined && posted !== '') {
|
|
377
382
|
// "1.234,50 €" → "1234.5"; text that isn't a number is kept as typed, and validate() reports it
|
|
378
383
|
const parsed = parseNumber(String(posted), itemMask(item), ctx.locale.numbers);
|
|
379
384
|
ctx.session.state[item.name] = parsed === null ? String(posted) : parsed || null;
|
|
@@ -736,6 +741,33 @@ export async function runtimeRoutes(app: FastifyInstance) {
|
|
|
736
741
|
}
|
|
737
742
|
});
|
|
738
743
|
|
|
744
|
+
// ---------------------------------------------------------------- a column heading's values
|
|
745
|
+
// (sprint 76) The values of a report column with their counts, for its heading's menu: the report must be
|
|
746
|
+
// visible and interactive; the query runs as the application's role with the request's search and filters;
|
|
747
|
+
// only a column the user may see. Read only.
|
|
748
|
+
app.get('/a/:alias/:page/report/:id/values', async (req: Req, reply) => {
|
|
749
|
+
const ctx = await loadContext(req, reply, { json: true });
|
|
750
|
+
if (!ctx) return;
|
|
751
|
+
reply.header('cache-control', 'private, no-store');
|
|
752
|
+
const column = String((req.query as Record<string, unknown>)?.col ?? '');
|
|
753
|
+
try {
|
|
754
|
+
const out = await appTx(txContext(ctx), async (c) => {
|
|
755
|
+
ctx.client = c;
|
|
756
|
+
await checkPageAccess(ctx);
|
|
757
|
+
const vis = await computeVisibility(ctx);
|
|
758
|
+
const r = ctx.page.regions.find((x) => x.id === Number(req.params.id) && x.type === 'report');
|
|
759
|
+
if (!r || !vis.regions.has(r.id) || r.config.interactive === false || r.config.searchable === false) throw new Forbidden(ctx.locale.t('error.access_denied'));
|
|
760
|
+
const list = column ? await columnValues(ctx, r, column) : null;
|
|
761
|
+
if (!list) throw new Forbidden(ctx.locale.t('error.access_denied'));
|
|
762
|
+
return { values: list };
|
|
763
|
+
});
|
|
764
|
+
return reply.send(out);
|
|
765
|
+
} catch (e) {
|
|
766
|
+
if (e instanceof Forbidden) return reply.code(403).send({ error: e.message });
|
|
767
|
+
return reply.code(400).send({ error: await publicError(ctx, e, 'column values') });
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
|
|
739
771
|
// ---------------------------------------------------------------- map layers loaded by the browser
|
|
740
772
|
// (0.31) A map layer with "visible_area" (JSON for ?bb=south,west,north,east)
|
|
741
773
|
// or "tiles" (Mapbox Vector Tiles, …/tiles/<layer>/<z>/<x>/<y>.mvt). Page
|