Update color-based sort language
This commit is contained in:
parent
6b888d7f81
commit
4890b17868
@ -24,7 +24,7 @@ import { AI_AUTO_GENERATED_FIELDS_ALL } from '@/photo/ai';
|
||||
import clsx from 'clsx/lite';
|
||||
import Link from 'next/link';
|
||||
import { PATH_FEED_JSON, PATH_RSS_XML } from '@/app/path';
|
||||
import { APP_DEFAULT_SORT_BY, SORT_BY_OPTIONS } from '@/photo/sort';
|
||||
import { APP_DEFAULT_SORT_BY, DEFAULT_SORT_BY_OPTIONS } from '@/photo/sort';
|
||||
import {
|
||||
AdminConfigSection,
|
||||
ConfigSectionKey,
|
||||
@ -624,13 +624,12 @@ export default function AdminAppConfigurationClient({
|
||||
optional
|
||||
>
|
||||
<div>
|
||||
{SORT_BY_OPTIONS
|
||||
.filter(({ canBeDefault }) => canBeDefault)
|
||||
.map(({sortBy, string }) =>
|
||||
{DEFAULT_SORT_BY_OPTIONS
|
||||
.map(({sortBy, configKey }) =>
|
||||
<Fragment key={ sortBy }>
|
||||
{renderSubStatus(
|
||||
sortBy === defaultSortBy ? 'checked' : 'optional',
|
||||
`${string}${sortBy === APP_DEFAULT_SORT_BY
|
||||
`${configKey}${sortBy === APP_DEFAULT_SORT_BY
|
||||
? ' (default)'
|
||||
: ''}`,
|
||||
)}
|
||||
|
||||
@ -26,7 +26,7 @@ export const PATH_FULL_INFERRED = GRID_HOMEPAGE_ENABLED
|
||||
// Sort
|
||||
export const PARAM_SORT_TYPE_TAKEN_AT = 'taken-at';
|
||||
export const PARAM_SORT_TYPE_UPLOADED_AT = 'uploaded-at';
|
||||
export const PARAM_SORT_TYPE_COLOR = 'color';
|
||||
export const PARAM_SORT_TYPE_COLOR = 'chromatic';
|
||||
export const PARAM_SORT_ORDER_DESCENDING = 'descending';
|
||||
export const PARAM_SORT_ORDER_ASCENDING = 'ascending';
|
||||
export const doesPathOfferSort = (pathname: string) =>
|
||||
|
||||
@ -178,11 +178,11 @@ export const getOrderByFromOptions = (options: PhotoQueryOptions) => {
|
||||
return sortWithPriority
|
||||
? 'ORDER BY priority_order ASC, created_at ASC'
|
||||
: 'ORDER BY created_at ASC';
|
||||
case 'hue':
|
||||
case 'color':
|
||||
return sortWithPriority
|
||||
? 'ORDER BY priority_order ASC, color_sort DESC'
|
||||
: 'ORDER BY color_sort DESC';
|
||||
case 'hueAsc':
|
||||
case 'colorAsc':
|
||||
return sortWithPriority
|
||||
? 'ORDER BY priority_order ASC, color_sort ASC'
|
||||
: 'ORDER BY color_sort ASC';
|
||||
|
||||
@ -15,32 +15,29 @@ export const getNavSortControlFromString = (
|
||||
|
||||
export const SORT_BY_OPTIONS = [{
|
||||
sortBy: 'takenAt',
|
||||
string: 'taken-at',
|
||||
canBeDefault: true,
|
||||
configKey: 'taken-at',
|
||||
}, {
|
||||
sortBy: 'takenAtAsc',
|
||||
string: 'taken-at-oldest-first',
|
||||
canBeDefault: true,
|
||||
configKey: 'taken-at-oldest-first',
|
||||
}, {
|
||||
sortBy: 'createdAt',
|
||||
string: 'uploaded-at',
|
||||
canBeDefault: true,
|
||||
configKey: 'uploaded-at',
|
||||
}, {
|
||||
sortBy: 'createdAtAsc',
|
||||
string: 'uploaded-at-oldest-first',
|
||||
canBeDefault: true,
|
||||
configKey: 'uploaded-at-oldest-first',
|
||||
}, {
|
||||
sortBy: 'hue',
|
||||
string: 'hue',
|
||||
canBeDefault: false,
|
||||
sortBy: 'color',
|
||||
configKey: undefined,
|
||||
}, {
|
||||
sortBy: 'hueAsc',
|
||||
string: 'hue-oldest-first',
|
||||
canBeDefault: false,
|
||||
sortBy: 'colorAsc',
|
||||
configKey: undefined,
|
||||
}] as const;
|
||||
|
||||
export type SortBy = (typeof SORT_BY_OPTIONS)[number]['sortBy'];
|
||||
|
||||
export const DEFAULT_SORT_BY_OPTIONS = SORT_BY_OPTIONS
|
||||
.filter(({ configKey }) => configKey);
|
||||
|
||||
export const APP_DEFAULT_SORT_BY: SortBy = 'takenAt';
|
||||
|
||||
export type SortParams = Promise<{
|
||||
@ -58,8 +55,8 @@ export const getSortByFromString = (sortBy = ''): SortBy => {
|
||||
case 'taken-at-oldest-first': return 'takenAtAsc';
|
||||
case 'uploaded-at': return 'createdAt';
|
||||
case 'uploaded-at-oldest-first': return 'createdAtAsc';
|
||||
case 'hue': return 'hue';
|
||||
case 'hue-oldest-first': return 'hueAsc';
|
||||
case 'color': return 'color';
|
||||
case 'color-ascending': return 'colorAsc';
|
||||
default: return 'takenAt';
|
||||
}
|
||||
};
|
||||
@ -67,4 +64,4 @@ export const getSortByFromString = (sortBy = ''): SortBy => {
|
||||
export const isSortAscending = (sortBy: SortBy) =>
|
||||
sortBy === 'takenAtAsc' ||
|
||||
sortBy === 'createdAtAsc' ||
|
||||
sortBy === 'hueAsc';
|
||||
sortBy === 'colorAsc';
|
||||
|
||||
@ -39,11 +39,11 @@ const getSortByComponents = (sortBy: SortBy): {
|
||||
sortType: PARAM_SORT_TYPE_UPLOADED_AT,
|
||||
sortOrder: PARAM_SORT_ORDER_ASCENDING,
|
||||
};
|
||||
case 'hue': return {
|
||||
case 'color': return {
|
||||
sortType: PARAM_SORT_TYPE_COLOR,
|
||||
sortOrder: PARAM_SORT_ORDER_DESCENDING,
|
||||
};
|
||||
case 'hueAsc': return {
|
||||
case 'colorAsc': return {
|
||||
sortType: PARAM_SORT_TYPE_COLOR,
|
||||
sortOrder: PARAM_SORT_ORDER_ASCENDING,
|
||||
};
|
||||
@ -79,8 +79,8 @@ const _getSortOptionsFromParams = (
|
||||
}
|
||||
case PARAM_SORT_TYPE_COLOR: {
|
||||
sortBy = isAscending
|
||||
? 'hueAsc'
|
||||
: 'hue';
|
||||
? 'colorAsc'
|
||||
: 'color';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user