このコミットが含まれているのは:
@@ -1,6 +1,6 @@
|
||||
import { countsFieldLabel } from '@/lib/countsDefinitions'
|
||||
import { apiDownload, apiGet } from '@/lib/api'
|
||||
import { currentViewingLocale } from '@/lib/locales'
|
||||
import { currentViewingLocale, localeLanguage } from '@/lib/locales'
|
||||
|
||||
import { readCountState, encodeCountState } from '@/lib/queryState'
|
||||
|
||||
@@ -99,7 +99,7 @@ export type CountSort = { key: string; direction: 'asc' | 'desc' }
|
||||
export type CountField = { key: string; label: string; children?: CountField[]
|
||||
labelValues?: Record<string, string>
|
||||
multipleValues?: boolean
|
||||
nameLocale?: { code: string; languageCode: string; scriptCode: string } }
|
||||
nameLocale?: { code: string; languageCode: string; scriptCode?: string } }
|
||||
export type CountRecord = Record<string, unknown>
|
||||
|
||||
export const countColumns: Record<string, string> = {
|
||||
@@ -233,7 +233,8 @@ export const selectedCountColumns = (
|
||||
const defaults: Record<CountsResource, string[]> = {
|
||||
posts: ['title', 'url', 'tags', 'parents', 'video_ms'],
|
||||
tags: [...(definition?.nameColumns ?? []).filter (field =>
|
||||
field.nameLocale?.code === currentViewingLocale ()).map (field => field.key),
|
||||
field.nameLocale?.languageCode === localeLanguage (currentViewingLocale ()))
|
||||
.map (field => field.key),
|
||||
'category', 'parents'],
|
||||
nico_tags: ['name', 'linked_tags'],
|
||||
tag_descriptions: ['language_code', 'body', 'source_language_code'],
|
||||
@@ -356,14 +357,31 @@ export const normaliseCountsParams = (
|
||||
definition?: CountsDefinition,
|
||||
): URLSearchParams => {
|
||||
const params = new URLSearchParams (source)
|
||||
const nameScope = params.get ('name_scope')
|
||||
if (definition?.conditionAliases != null && (nameScope == null || nameScope === 'locale'))
|
||||
{
|
||||
const predicates = new Map ((definition.conditionAliases ?? [])
|
||||
.map (entry => [entry.key, entry.value]))
|
||||
for (const [key, value] of params)
|
||||
if (/^conditions\.\d+\.field$/.test (key)) params.set (key, value.replace (
|
||||
/(?:name|aliases)_[a-z0-9_]+/g, field => predicates.get (field) ?? field))
|
||||
params.set ('name_scope', 'language')
|
||||
}
|
||||
const aliasesByKey = new Map ((definition?.columnAliases ?? [])
|
||||
.map (entry => [entry.key, entry.value]))
|
||||
for (const key of ['columns', 'children', 'order', 'sort', 'child_sort'])
|
||||
if (params.has (key)) params.set (key, params.get (key)!.replace (
|
||||
/(?:name|aliases)_[a-z0-9_]+/g, field => aliasesByKey.get (field) ?? field))
|
||||
if (definition?.nameColumns != null)
|
||||
{
|
||||
const names = definition.nameColumns.filter (field => !field.multipleValues)
|
||||
.map (field => field.key)
|
||||
const current = definition.nameColumns.find (field =>
|
||||
!field.multipleValues && field.nameLocale?.code === currentViewingLocale ())?.key
|
||||
!field.multipleValues
|
||||
&& field.nameLocale?.languageCode === localeLanguage (currentViewingLocale ()))?.key
|
||||
const aliases = definition.nameColumns.find (field =>
|
||||
field.multipleValues && field.nameLocale?.code === currentViewingLocale ())?.key
|
||||
field.multipleValues
|
||||
&& field.nameLocale?.languageCode === localeLanguage (currentViewingLocale ()))?.key
|
||||
const rootKey = (key: string) => (key === 'name' && current != null) ? current
|
||||
: ((key === 'aliases' && aliases != null) ? aliases : key)
|
||||
const childKeys = (key: string): string[] => {
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする