このコミットが含まれているのは:
@@ -1,6 +1,7 @@
|
||||
import { countsAttributes, countsFieldLabel } from '@/lib/countsDefinitions'
|
||||
import { countsFieldLabel } from '@/lib/countsDefinitions'
|
||||
import { apiDownload, apiGet } from '@/lib/api'
|
||||
|
||||
import type { CountsDefinition } from '@/lib/countsDefinitions'
|
||||
import type { LocaleCode } from '@/lib/locales'
|
||||
import type { TagNameSnapshot } from '@/types'
|
||||
|
||||
@@ -135,7 +136,10 @@ const nested: Partial<Record<CountColumn, CountField[]>> = {
|
||||
parents: [{ key: 'id', label: 'counts:columns.resourceId' }] }
|
||||
|
||||
|
||||
export const columnsForCounts = (resource: CountsResource): CountColumn[] => [
|
||||
export const columnsForCounts = (
|
||||
resource: CountsResource,
|
||||
definition?: CountsDefinition,
|
||||
): CountColumn[] => [
|
||||
...(resource === 'posts' ? ['thumbnail'] : []),
|
||||
'resource_id', 'version_no', 'is_latest',
|
||||
...(resource === 'posts'
|
||||
@@ -143,12 +147,16 @@ export const columnsForCounts = (resource: CountsResource): CountColumn[] => [
|
||||
'original_created_at', 'original_created_from', 'original_created_before']
|
||||
: (resource === 'tags'
|
||||
? ['name', 'names', 'category', 'aliases', 'parents', 'deprecated']
|
||||
: Object.keys (countsAttributes[resource]))),
|
||||
: (definition?.fields.filter (field => ![
|
||||
'resource_id', 'version_no', 'event_type', 'user', 'created_at']
|
||||
.includes (field.key)).map (field => field.key) ?? []))),
|
||||
'event_type', 'user', 'created_at']
|
||||
|
||||
|
||||
export const fieldsForCounts = (resource: CountsResource): CountField[] =>
|
||||
columnsForCounts (resource).map (key => ({
|
||||
export const fieldsForCounts = (
|
||||
resource: CountsResource,
|
||||
definition?: CountsDefinition,
|
||||
): CountField[] => columnsForCounts (resource, definition).map (key => ({
|
||||
key,
|
||||
label: (key === 'parents' && resource === 'tags') ? 'tags:parents'
|
||||
: (countColumns[key] ?? countsFieldLabel (key)),
|
||||
@@ -196,12 +204,13 @@ export const reorderCountFields = (
|
||||
export const selectedCountColumns = (
|
||||
resource: CountsResource,
|
||||
params: URLSearchParams,
|
||||
definition?: CountsDefinition,
|
||||
): CountColumn[] => {
|
||||
const selected = params.has ('columns') ? params.get ('columns')!.split (',') :
|
||||
columnsForCounts (resource).filter (key => ![
|
||||
columnsForCounts (resource, definition).filter (key => ![
|
||||
'thumbnail', 'original_created_from', 'original_created_before']
|
||||
.includes (key))
|
||||
return orderedCountFields (fieldsForCounts (resource), params)
|
||||
return orderedCountFields (fieldsForCounts (resource, definition), params)
|
||||
.map (field => field.key as CountColumn).filter (key => selected.includes (key))
|
||||
}
|
||||
|
||||
@@ -281,7 +290,7 @@ export const normaliseCountsParams = (
|
||||
params.set ('through', params.get ('before')!)
|
||||
for (const key of ['basis', 'axis', 'latest', 'grain', 'before', 'summary_columns'])
|
||||
params.delete (key)
|
||||
if (params.has ('columns'))
|
||||
if (params.has ('columns') && ['posts', 'tags'].includes (resource))
|
||||
{
|
||||
const selected = new Set (params.get ('columns')!.split (','))
|
||||
params.set ('columns', columnsForCounts (resource).filter (key => selected.has (key))
|
||||
@@ -321,10 +330,11 @@ export const exportCounts = (
|
||||
columns: string[],
|
||||
headers: string[],
|
||||
labels: Record<string, string>,
|
||||
onError?: () => void,
|
||||
): Promise<void> => apiDownload ('/counts/export', {
|
||||
...Object.fromEntries (params), resource, format,
|
||||
columns: columns.join (','), headers: JSON.stringify (headers),
|
||||
labels: JSON.stringify (labels) }, locale)
|
||||
labels: JSON.stringify (labels) }, locale, onError)
|
||||
|
||||
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする