import { CmsFieldTypePlugins , CmsModel } from "~/types" ; import get from "lodash/get" ; interface RenderListFilterFields { ( params ) : string ; } export const renderListFilterFields = ( { model , type , fieldTypePlugins } ) => { const fields = [ [ "id: ID" , "id_not: ID" , "id_in: [ID!]" , "id_not_in: [ID!]" , "entryId: String" , "entryId_not: String" , "entryId_in: [String!]" , "entryId_not_in: [String!]" , "createdOn: DateTime" , "createdOn_gt: DateTime" , "createdOn_gte: DateTime" , "createdOn_lt: DateTime" , "createdOn_lte: DateTime" , "createdOn_between: [DateTime!]" , "createdOn_not_between: [DateTime!]" , "savedOn: DateTime" , "savedOn_gt: DateTime" , "savedOn_gte: DateTime" , "savedOn_lt: DateTime" , "savedOn_lte: DateTime" , "savedOn_between: [DateTime!]" , "savedOn_not_between: [DateTime!]" , "createdBy: String" , "createdBy_not: String" , "createdBy_in: [String!]" , "createdBy_not_in: [String!]" , "ownedBy: String" , "ownedBy_not: String" , "ownedBy_in: [String!]" , "ownedBy_not_in: [String!]" ] . join ( "\n" ) ] ; for ( let i = 0 ; i < model . fields . length ; i ++ ) { const field = model . fields [ i ] ; const createListFilters = get ( fieldTypePlugins , `${ field . type }.${ type }.createListFilters` ) ; if ( typeof createListFilters === "function" ) { fields . push ( createListFilters ( { model , field } ) ) ; } } return fields . filter ( Boolean ) . join ( "\n" ) ; } ;