Documentation ¶
Index ¶
- Variables
- func DefaultQueryFilterParser(f FilterQuery) (string, interface{})
- func DefaultQuerySortParser(s Sort) string
- func EndsWithFilterParser(f FilterQuery) (string, interface{})
- func GlobalMatchFilterParser(f FilterQuery) (string, interface{})
- func StartsWithFilterParser(f FilterQuery) (string, interface{})
- type Action
- type Actions
- type Columns
- type ComparisonOperator
- type DetailData
- type DetailField
- type ExportResult
- type Filter
- type FilterData
- type FilterDefinition
- type FilterGroup
- type FilterGroupDefinitions
- type FilterQuery
- type FilterToQueryParser
- type FilterType
- type FilterValue
- type Hasher
- type InToolCards
- type IntoolsResponse
- type IntoolsTable
- type MetaData
- type PageSpecification
- type QueryFilter
- type QueryFilterParserFunc
- type QuerySort
- type QuerySortParserFunc
- type ResultFilter
- type SelectOption
- type Sort
Constants ¶
This section is empty.
Variables ¶
var ( ComparisonOperatorString = map[ComparisonOperator]string{ ComparisonOperatorEqualTo: "==", ComparisonOperatorNotEqualTo: "!=", ComparisonOperatorGreaterThan: ">", ComparisonOperatorLessThan: "<", ComparisonOperatorGreaterThanEqualTo: ">=", ComparisonOperatorLessThanEqualTo: "<=", ComparisonOperatorLike: "like", } )
var ( FilterToQueryParserFunc = map[FilterToQueryParser]QueryFilterParserFunc{ FilterToQueryDefault: DefaultQueryFilterParser, FilterToQueryGlobalMatch: GlobalMatchFilterParser, FilterToQueryStartsWith: StartsWithFilterParser, FilterToQueryEndsWith: EndsWithFilterParser, } )
var ( FilterTypeString = map[FilterType]string{ FilterTypeDateRange: "date", FilterTypeSelect: "select", FilterTypeNumber: "number", FilterTypeText: "text", FilterTypeDate: "date", } )
Functions ¶
func DefaultQueryFilterParser ¶
func DefaultQueryFilterParser(f FilterQuery) (string, interface{})
func DefaultQuerySortParser ¶
func EndsWithFilterParser ¶
func EndsWithFilterParser(f FilterQuery) (string, interface{})
EndsWithFilterParser use this only with like operator or else it won't work as expected
func GlobalMatchFilterParser ¶
func GlobalMatchFilterParser(f FilterQuery) (string, interface{})
GlobalMatchFilterParser use this only with like operator or else it won't work as expected
func StartsWithFilterParser ¶
func StartsWithFilterParser(f FilterQuery) (string, interface{})
StartsWithFilterParser use this only with like operator or else it won't work as expected
Types ¶
type Action ¶
type Action struct { Id string `json:"id"` Name string `json:"name"` //GroupAccess need to check this to enterprise if this is not permitted to be wandering around then it need to be hidden but if it's permitted to wander arround it would be nice for front end to use this GroupAccess []string `json:"group_access"` //ElementID need to check this to enterprise //I think we can use this for better access management integration with enterprise UAM ElementID string `json:"element_id"` Type string `json:"type"` Class string `json:"class"` }
type ComparisonOperator ¶
type ComparisonOperator int
const ( ComparisonOperatorEqualTo ComparisonOperator = iota ComparisonOperatorNotEqualTo ComparisonOperatorGreaterThan ComparisonOperatorLessThan ComparisonOperatorGreaterThanEqualTo ComparisonOperatorLessThanEqualTo ComparisonOperatorLike )
func (ComparisonOperator) String ¶
func (c ComparisonOperator) String() string
type DetailData ¶
type DetailData struct { Title string `json:"title"` Data []DetailField `json:"data"` }
type DetailField ¶
type ExportResult ¶
type FilterData ¶
type FilterDefinition ¶
type FilterDefinition struct { Label string //Variable put url variabel name here Variable string //Operator please use the constant if you want to add new addition please make adjusment on the code Operator ComparisonOperator FilterToQueryParser FilterToQueryParser //Data put database variabel name here Data string //FilterType please use the constant if you want to add new addition please make adjusment on the code Type FilterType Hasher Hasher IsShown bool }
type FilterGroup ¶
type FilterGroupDefinitions ¶
type FilterGroupDefinitions [][]FilterDefinition
func (*FilterGroupDefinitions) GetFilterGroup ¶
func (f *FilterGroupDefinitions) GetFilterGroup(options map[string][]SelectOption) []map[string][]FilterGroup
type FilterQuery ¶
type FilterToQueryParser ¶
type FilterToQueryParser int
const ( FilterToQueryDefault FilterToQueryParser = iota FilterToQueryGlobalMatch FilterToQueryStartsWith FilterToQueryEndsWith )
func (FilterToQueryParser) ParserFunc ¶
func (c FilterToQueryParser) ParserFunc() QueryFilterParserFunc
type FilterType ¶
type FilterType int
const ( FilterTypeDateRange FilterType = iota FilterTypeSelect FilterTypeNumber FilterTypeText FilterTypeDate )
func (FilterType) String ¶
func (c FilterType) String() string
type FilterValue ¶
type FilterValue struct { Column string ColumnHash string Operator string FilterToQueryParser FilterToQueryParser Value interface{} ValueHash interface{} }
type InToolCards ¶
type IntoolsResponse ¶
type IntoolsResponse struct { Table IntoolsTable `json:"table"` Cards []InToolCards `json:"cards"` }
type IntoolsTable ¶
type MetaData ¶
type MetaData struct {
Options []SelectOption `json:"options,omitempty"`
}
type PageSpecification ¶
type PageSpecification struct { Filters FilterGroupDefinitions Columns []Columns UserActions map[string]string ActionButtons Actions }
PageSpecification Will Specify some page detail to front end
avoid using exact keyword sort,page,limit on filter variabel as it is reserved for the functional purpose if you need it so badly then you have to find other way or don't use this feature make your own.
example :
CategoryPageSpec = pagespecifier.PageSpecification{ Filters: pagespecifier.FilterGroupDefinitions{ []pagespecifier.FilterDefinition{ { Label: "Parent Category", Operator: pagespecifier.ComparisonOperatorEqualTo, Data: "c.parent_id", //base on database Variable: "parent_id", //base on url query Type: pagespecifier.FilterTypeSelect, }, }, }, Columns: []pagespecifier.Columns{ {Header: "Column1", Data: "i_am_the_json_data1", Orderable: true}, {Header: "Column2", Data: "i_am_the_json_data2", Orderable: false}, {Header: "Column3", Data: "i_am_the_json_data3", Orderable: true}, {Header: "Column4", Data: "i_am_the_json_data4", Orderable: false}, {Header: "Column5", Data: "i_am_the_json_data5", Orderable: true}, {Header: "Column6", Data: "i_am_the_json_data6", Orderable: true}, {Header: ""}, //Put Blank for action column }, UserActions: map[string]string{ "searchUrl": "/order", }, ActionButtons: pagespecifier.Actions{ Top: []pagespecifier.Action{ { Id: "download", Name: "Download", GroupAccess: []string{"put Group Access here"}, ElementID: "Put ElementID here", Class: "btn btn-sm btn-custom w-md waves-effect waves-light mr-10", }, }, Middle: []pagespecifier.Action{ { Id: "search", Name: "Search", Type: "submit", GroupAccess: []string{"put Group Access here"}, ElementID: "Put ElementID here", Class: "btn btn-sm btn-search btn-primary w-md waves-effect waves-light mr-10", }, { Id: "reset", Name: "Reset", Type: "reset", GroupAccess: []string{"ftinins-product", "fitnins-business"}, ElementID: "Put ElementID here", Class: "btn btn-sm btn-default btn-custom w-md waves-effect waves-light mr-10", }, }, }, }
func (*PageSpecification) GetFilterData ¶
func (ps *PageSpecification) GetFilterData(options map[string][]SelectOption) *FilterData
func (*PageSpecification) GetResultFilter ¶
func (ps *PageSpecification) GetResultFilter(input url.Values) ResultFilter
func (*PageSpecification) Parsefilter ¶
func (ps *PageSpecification) Parsefilter(input url.Values) []FilterValue
Parsefilter equivalent of parser.ParseFilterRaw but with input of url.values but do not support 'in' clause yet will add it later :D
type QueryFilter ¶
type QueryFilter struct { Filter []string Args []interface{} }
func GetQueryFilterWithParser ¶
func GetQueryFilterWithParser(filters []FilterValue) *QueryFilter
GetQueryFilterWithParser added 'like' operator version util.GetQueryFilterWithParser from lending-platform
func (*QueryFilter) GetWhereClause ¶
func (qf *QueryFilter) GetWhereClause() string
func (*QueryFilter) JoinFilter ¶
func (qf *QueryFilter) JoinFilter() string
type QueryFilterParserFunc ¶
type QueryFilterParserFunc func(f FilterQuery) (string, interface{})
type QuerySort ¶
type QuerySort struct {
Sort []string
}
func GetQuerySortWithParser ¶
func GetQuerySortWithParser(sort []Sort, sp QuerySortParserFunc) *QuerySort