このコミットが含まれているのは:
@@ -5,6 +5,8 @@ import { localisedDateString, msToTime, originalCreatedAtString } from '@/lib/ut
|
||||
|
||||
import type { CountColumn, CountField, CountRecord,
|
||||
CountsResource, CountsVersion } from '@/lib/counts'
|
||||
import type { CountsClipboardCell, CountsClipboardColumn, CountsClipboardTable }
|
||||
from '@/lib/countsClipboard'
|
||||
import type { CountsDefinition } from '@/lib/countsDefinitions'
|
||||
import type { LocaleCode } from '@/lib/locales'
|
||||
|
||||
@@ -278,3 +280,61 @@ export const countsExportLabels = (
|
||||
labels.notRegistered = translateUIMessage ('notRegistered', 'counts', locale).text
|
||||
return labels
|
||||
}
|
||||
|
||||
|
||||
const clipboardColumns = (
|
||||
fields: CountField[],
|
||||
path: string,
|
||||
params: URLSearchParams,
|
||||
locale: LocaleCode,
|
||||
): CountsClipboardColumn[] => {
|
||||
const selected = selectedCountChildren (params)
|
||||
return orderedCountFields (fields, params, path)
|
||||
.filter (field => selected.has (`${path}.${field.key}`))
|
||||
.map (field => ({ label: translateUIMessage (field.label, 'counts', locale).text,
|
||||
children: field.children == null ? undefined : clipboardColumns (
|
||||
field.children, `${path}.${field.key}`, params, locale) }))
|
||||
}
|
||||
|
||||
|
||||
export const countsNestedClipboardTable = (
|
||||
rows: CountRecord[],
|
||||
fields: CountField[],
|
||||
path: string,
|
||||
params: URLSearchParams,
|
||||
locale: LocaleCode,
|
||||
): CountsClipboardTable => {
|
||||
const selected = selectedCountChildren (params)
|
||||
const columns = orderedCountFields (fields, params, path)
|
||||
.filter (field => selected.has (`${path}.${field.key}`))
|
||||
return {
|
||||
columns: clipboardColumns (fields, path, params, locale),
|
||||
rows: countsNestedOrder (rows, path, params, locale).map (row => columns.map (field =>
|
||||
field.children == null ? countsLogicalName (row, field.key, locale).text
|
||||
: countsNestedClipboardTable (row[field.key] as CountRecord[] ?? [],
|
||||
field.children, `${path}.${field.key}`, params, locale))) }
|
||||
}
|
||||
|
||||
|
||||
export const countsDetailClipboardTable = (
|
||||
rows: CountsVersion[],
|
||||
fields: CountField[],
|
||||
params: URLSearchParams,
|
||||
locale: LocaleCode,
|
||||
rowStart: number | null = null,
|
||||
): CountsClipboardTable => {
|
||||
const columns = fields.map (field => ({
|
||||
label: translateUIMessage (field.label, 'counts', locale).text,
|
||||
children: field.children == null ? undefined : clipboardColumns (
|
||||
field.children, field.key, params, locale) }))
|
||||
if (rowStart != null)
|
||||
columns.unshift ({ label: translateUIMessage ('rowNumbers', 'counts', locale).text,
|
||||
children: undefined })
|
||||
return { columns, rows: rows.map ((row, index) => {
|
||||
const cells: CountsClipboardCell[] = fields.map (field => field.children == null
|
||||
? countsCellText (row, field.key, locale, params)
|
||||
: countsNestedClipboardTable (countsNestedRows (row, field.key), field.children,
|
||||
field.key, params, locale))
|
||||
return rowStart == null ? cells : [String (rowStart + index), ...cells]
|
||||
}) }
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする