(params, 'cols', [])].map (axis => ({
+ key: axis.field, label: countsFieldLabel (axis.field) })),
+ { key: 'count', label: 'count' }]
: selectedCountColumns (resource, params).map (column =>
fieldsForCounts (resource).find (field => field.key === column)!)
- const file = await exportCounts (resource, params, locale, format,
+ await exportCounts (resource, params, locale, format,
fields.map (field => field.key), fields.map (field => message (field.label).text),
- countsExportLabels (resource, locale))
- const url = URL.createObjectURL (file)
- const link = document.createElement ('a')
- link.href = url
- link.download = `counts-${resource}.${format}`
- link.click ()
- setTimeout (() => URL.revokeObjectURL (url), 1000)
+ { ...countsExportLabels (resource, locale),
+ ...Object.fromEntries (countsAxisFields (resource, !state).map (field => [
+ field.key, message (field.label).text])), count: message ('count').text })
+
}
catch
{
@@ -117,17 +132,23 @@ const CountsResourcePage = ({ resource }: { resource: CountsResource }) => {
lang={message ('target').language}>
{label ('target')}
- {(['posts', 'tags'] as const).map (target => {
- const next = new URLSearchParams (params)
- for (const key of ['resource_id', 'tag', 'columns', 'summary_columns',
- 'sort', 'page', 'children', 'child_sort']) next.delete (key)
- return -
- {label (target === 'posts' ? 'history:post' : 'navigation:tags')}
-
- })}
+ {countsResources.map (target => -
+ {label (`resources.${target}`)}
+
+ {['latest', 'history'].map (definition => {
+ const next = new URLSearchParams ({ definition, mode })
+ for (const key of ['timezone', 'at', 'execution_at'])
+ if (params.get (key)) next.set (key, params.get (key)!)
+ const active = target === resource
+ && params.get ('definition') === definition
+ return -
+ {label (definition)}
+ })}
+
+ )}
@@ -153,7 +174,7 @@ const CountsResourcePage = ({ resource }: { resource: CountsResource }) => {
>}/>
{exportError && {label ('common:fetchError')}
}
@@ -161,14 +182,7 @@ const CountsResourcePage = ({ resource }: { resource: CountsResource }) => {
{isPending && {label ('shared:messages.loadingEllipsis')}
}
{isError && {label ('common:fetchError')}
}
{data != null && <>
- {data.at &&
- {label ('state.boundary')}:{data.at.replace ('T', ' ')}
- {data.totals && (['posts', 'tags', 'assignments'] as const).map (key => (
- {label (`state.totals.${key}`)}:
- {data.totals![key] ?? '—'}
- ))}
-
}
- {!state && {label ('total', { count: data.count })}
}
+ {label ('recordTotal', { count: data.count })}
{mode === 'summary' ? : (