import { type Moment } from 'moment' import { type HeaderInterface, type TextHeaderInterface, type TextSearchHeaderInterface, type RelationSelectHeaderInterface, type EnumSelectHeaderInterface, type DefaultSelectHeaderInterface, type MultipleRelationSelectHeaderInterface, type MultipleEnumSelectHeaderInterface, type MultipleDefaultSelectHeaderInterface, type PeriodCalendarHeaderInterface, type CalendarHeaderInterface, type RangeNumberHeaderInterface, } from '../tables/headers/HeadersTableInterfaces' import { type paramsSerializationOptions } from '../../composables/use-endless-scroll-api' type ParamType = { id: string, name: string } export interface RadioSelectHeaderInterface extends HeaderInterface { type: 'radioSelect' selectedParam: string options: ParamType[] } export function isRadioSelectHeaderInterface(i: HeaderInterface) : i is RadioSelectHeaderInterface { return i.type === 'radioSelect' } export interface CheckboxSelectHeaderInterface extends HeaderInterface { type: 'checkboxSelect' selectedParam: string options: ParamType[] } export function isCheckboxSelectHeaderInterface(i: HeaderInterface) : i is CheckboxSelectHeaderInterface { return i.type === 'checkboxSelect' } export interface RelationExtensionInterface { params?: { [key: string]: string | string[] } searchKey?: string itemConverter?: (v: any) => ParamType paramsSerialization?: paramsSerializationOptions requestPageKey?: string requestPerPageKey?: string responseItemsKey?: string responseTotalKey?: string paginationType?: string additionalItems?: { id: string, name: string }[] } export function isRelationExtendedInterface(i: any) : i is RelationExtensionInterface { return Boolean( ('params' in i) || ('searchKey' in i) || ('itemConverter' in i) || ('paramsSerialization' in i) || ('requestPageKey' in i) || ('requestPerPageKey' in i) || ('responseItemsKey' in i) || ('responseTotalKey' in i) || ('paginationType' in i) || ('additionalItems' in i), ) } export interface WeekCalendarHeaderInterface extends HeaderInterface { type: 'weekCalendar' endDateParam: string startDateParam: string defaultValue?: { startDate?: Moment, endDate?: Moment } saveDefaultFilterValueOnReset?: boolean } export function isWeekCalendarHeaderInterface(i: HeaderInterface) : i is WeekCalendarHeaderInterface { return i.type === 'weekCalendar' } export interface FilterInterface { label: string filter: | HeaderInterface | TextHeaderInterface | TextSearchHeaderInterface | (RelationSelectHeaderInterface & RelationExtensionInterface) | (EnumSelectHeaderInterface & RelationExtensionInterface) | DefaultSelectHeaderInterface | (MultipleRelationSelectHeaderInterface & RelationExtensionInterface) | (MultipleEnumSelectHeaderInterface & RelationExtensionInterface) | MultipleDefaultSelectHeaderInterface | PeriodCalendarHeaderInterface | WeekCalendarHeaderInterface | CalendarHeaderInterface | RangeNumberHeaderInterface | RadioSelectHeaderInterface | CheckboxSelectHeaderInterface }