+
{shell?.handle}
{resizable &&
}
diff --git a/frontend/src/components/counts/CountsTableLayout.tsx b/frontend/src/components/counts/CountsTableLayout.tsx
index a2864ab..1a4dc08 100644
--- a/frontend/src/components/counts/CountsTableLayout.tsx
+++ b/frontend/src/components/counts/CountsTableLayout.tsx
@@ -1,6 +1,7 @@
import { useState } from 'react'
-import { CountsLayoutContext, defaultCountWidths, MAX_COUNT_WIDTH, MIN_COUNT_WIDTH }
+import { CountsLayoutContext, defaultCountWidths, MAX_COUNT_WIDTH, MIN_COUNT_WIDTH,
+ MAX_INITIAL_COUNT_WIDTH }
from '@/lib/countsTableLayout'
import type { ReactNode } from 'react'
@@ -8,8 +9,15 @@ import type { ReactNode } from 'react'
const CountsTableLayout = ({ children }: { children: ReactNode }) => {
const [widths, setWidths] = useState> ({ })
+ const [headings, setHeadings] = useState> ({ })
const width = (family: string, key: string) =>
- widths[`${family}/${key}`] ?? defaultCountWidths[key] ?? 160
+ widths[`${family}/${key}`]
+ ?? Math.max (defaultCountWidths[key] ?? 160, headings[`${family}/${key}`] ?? 0)
+ const fit = (family: string, key: string, value: number) => {
+ const next = Math.ceil (Math.min (MAX_INITIAL_COUNT_WIDTH, value))
+ setHeadings (previous => previous[`${family}/${key}`] === next ? previous
+ : { ...previous, [`${family}/${key}`]: next })
+ }
const custom = (family: string, key: string) => widths[`${family}/${key}`] != null
const resize = (family: string, key: string, value: number) => {
const next = Math.round (Math.max (MIN_COUNT_WIDTH, Math.min (MAX_COUNT_WIDTH, value)))
@@ -17,7 +25,7 @@ const CountsTableLayout = ({ children }: { children: ReactNode }) => {
: { ...previous, [`${family}/${key}`]: next })
}
return (
-
+
{children}
)
}
diff --git a/frontend/src/components/counts/countsTable.css b/frontend/src/components/counts/countsTable.css
index 1ecd66d..9ac5b96 100644
--- a/frontend/src/components/counts/countsTable.css
+++ b/frontend/src/components/counts/countsTable.css
@@ -74,7 +74,12 @@
}
.counts-grid > tbody > tr > td:has(> .counts-nested) {
- padding: 0;
+ padding: 8px 12px;
+}
+
+.counts-nested .counts-grid > thead > tr > th,
+.counts-nested .counts-grid > tbody > tr > td {
+ padding: 8px 12px;
}
.counts-nested {
diff --git a/frontend/src/lib/counts.ts b/frontend/src/lib/counts.ts
index 905d086..3ecbb79 100644
--- a/frontend/src/lib/counts.ts
+++ b/frontend/src/lib/counts.ts
@@ -262,6 +262,17 @@ export const selectedCountChildren = (
): Set => {
const selected = new Set (params.has ('children') ? params.get ('children')!.split (' ')
: ['tags.name', 'parents.id', 'aliases.name', 'members.tagId'])
+ if (!params.has ('children') && fields != null)
+ {
+ const language = localeLanguage (currentViewingLocale ())
+ const name = fields.find (field => field.key === 'tags')?.children?.find (field =>
+ !field.multipleValues && field.nameLocale?.languageCode === language)
+ if (name != null)
+ {
+ selected.delete ('tags.name')
+ selected.add (`tags.${name.key}`)
+ }
+ }
if (fields != null)
{
const valid = new Set (countChildPaths (fields).filter (path => path.includes ('.')))
@@ -357,6 +368,7 @@ export const normaliseCountsParams = (
definition?: CountsDefinition,
): URLSearchParams => {
const params = new URLSearchParams (source)
+ if (!params.has ('limit')) params.set ('limit', '100')
const nameScope = params.get ('name_scope')
if (definition?.conditionAliases != null && (nameScope == null || nameScope === 'locale'))
{
@@ -448,9 +460,18 @@ export const normaliseCountsParams = (
.filter (key => key !== 'original_created_at').join (' '))
const defaults = definition?.defaults?.find (entry =>
entry.definition === params.get ('definition') && entry.mode === params.get ('mode'))
+ if (params.get ('mode') === 'details' && !params.has ('sort'))
+ params.set ('sort', 'resource_id:asc version_no:asc')
for (const { key, value } of defaults?.params ?? [])
{
if (params.has (key)) continue
+ if (key === 'children' && resource === 'posts' && params.get ('mode') === 'details')
+ {
+ const name = definition?.nameColumns?.find (field => !field.multipleValues
+ && field.nameLocale?.languageCode === localeLanguage (currentViewingLocale ()))
+ params.set (key, name == null ? value : `tags.${name.key} parents.id`)
+ continue
+ }
if (key === 'sort')
{
const expected = defaults?.params.find (entry => entry.key === 'rows')?.value
@@ -541,7 +562,7 @@ export const countsExportPayload = (
const payload = new URLSearchParams (params)
if (!payload.has ('children'))
{
- const selected = selectedCountChildren (params)
+ const selected = selectedCountChildren (params, fieldsForCounts (resource, definition))
payload.set ('children', countChildPaths (fieldsForCounts (resource, definition))
.filter (path => selected.has (path)).join (' '))
}
diff --git a/frontend/src/lib/countsTableLayout.ts b/frontend/src/lib/countsTableLayout.ts
index 1120353..ec3fabd 100644
--- a/frontend/src/lib/countsTableLayout.ts
+++ b/frontend/src/lib/countsTableLayout.ts
@@ -2,6 +2,7 @@ import { createContext, useContext } from 'react'
export const MIN_COUNT_WIDTH = 64
export const MAX_COUNT_WIDTH = 2000
+export const MAX_INITIAL_COUNT_WIDTH = 640
export const defaultCountWidths: Record = {
row_number: 72, thumbnail: 88, resource_id: 88, version_no: 88, latest: 104,
@@ -15,6 +16,7 @@ export const defaultCountWidths: Record = {
type Layout = {
width: (family: string, key: string) => number
custom: (family: string, key: string) => boolean
+ fit: (family: string, key: string, width: number) => void
resize: (family: string, key: string, width: number) => void }
export const CountsLayoutContext = createContext (null)
export const CountsTableScope = createContext ('')