#171 - a PoC of the idea of metadata value extractors. Completed the sorting spec parser part.
This commit is contained in:
parent
42a5f1feb2
commit
d82a80c063
|
@ -1,3 +1,5 @@
|
||||||
|
import {MDataExtractor} from "./mdata-extractors";
|
||||||
|
|
||||||
export enum CustomSortGroupType {
|
export enum CustomSortGroupType {
|
||||||
Outsiders, // Not belonging to any of other groups
|
Outsiders, // Not belonging to any of other groups
|
||||||
MatchAll, // like a wildard *, used in connection with foldersOnly or filesOnly. The difference between the MatchAll and Outsiders is
|
MatchAll, // like a wildard *, used in connection with foldersOnly or filesOnly. The difference between the MatchAll and Outsiders is
|
||||||
|
@ -51,8 +53,10 @@ export enum CustomSortOrder {
|
||||||
export interface RecognizedOrderValue {
|
export interface RecognizedOrderValue {
|
||||||
order: CustomSortOrder
|
order: CustomSortOrder
|
||||||
applyToMetadataField?: string
|
applyToMetadataField?: string
|
||||||
|
metadataValueExtractor?: MDataExtractor
|
||||||
secondaryOrder?: CustomSortOrder
|
secondaryOrder?: CustomSortOrder
|
||||||
secondaryApplyToMetadataField?: string
|
secondaryApplyToMetadataField?: string
|
||||||
|
secondaryMetadataValueExtractor?: MDataExtractor
|
||||||
}
|
}
|
||||||
|
|
||||||
export type NormalizerFn = (s: string) => string | null
|
export type NormalizerFn = (s: string) => string | null
|
||||||
|
|
|
@ -116,6 +116,7 @@ interface CustomSortOrderAscDescPair {
|
||||||
interface CustomSortOrderSpec {
|
interface CustomSortOrderSpec {
|
||||||
order: CustomSortOrder
|
order: CustomSortOrder
|
||||||
byMetadataField?: string
|
byMetadataField?: string
|
||||||
|
metadataFieldExtractor?: MDataExtractor
|
||||||
}
|
}
|
||||||
|
|
||||||
const MAX_SORT_LEVEL: number = 1
|
const MAX_SORT_LEVEL: number = 1
|
||||||
|
@ -1578,13 +1579,7 @@ export class SortingSpecProcessor {
|
||||||
sortOrderSpec[level] = {
|
sortOrderSpec[level] = {
|
||||||
order: order!,
|
order: order!,
|
||||||
byMetadataField: metadataName,
|
byMetadataField: metadataName,
|
||||||
|
|
||||||
metadataFieldExtractor: metadataExtractor
|
metadataFieldExtractor: metadataExtractor
|
||||||
|
|
||||||
... and the carry the metadataFieldExtractor attribute down the parser, handle correctly in the 4-levels mdata sorting options
|
|
||||||
and execute at runtime
|
|
||||||
|
|
||||||
Seems to be far too complex to be worth it.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sortOrderSpec
|
return sortOrderSpec
|
||||||
|
@ -1595,8 +1590,10 @@ export class SortingSpecProcessor {
|
||||||
return recognized ? (recognized instanceof AttrError ? recognized : {
|
return recognized ? (recognized instanceof AttrError ? recognized : {
|
||||||
order: recognized[0].order,
|
order: recognized[0].order,
|
||||||
applyToMetadataField: recognized[0].byMetadataField,
|
applyToMetadataField: recognized[0].byMetadataField,
|
||||||
|
metadataValueExtractor: recognized[0].metadataFieldExtractor,
|
||||||
secondaryOrder: recognized[1]?.order,
|
secondaryOrder: recognized[1]?.order,
|
||||||
secondaryApplyToMetadataField: recognized[1]?.byMetadataField
|
secondaryApplyToMetadataField: recognized[1]?.byMetadataField,
|
||||||
|
secondaryMetadataValueExtractor: recognized[1]?.metadataFieldExtractor
|
||||||
}) : null;
|
}) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue