Skip to content

Commit

Permalink
Add some aggregation options
Browse files Browse the repository at this point in the history
  • Loading branch information
maxhille committed Jan 22, 2024
1 parent 0981497 commit acdcfd6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/AgGrid.elm
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ type alias ColumnDef dataType =
-}
type alias ColumnSettings =
{ aggFunc : Aggregation
, allowedAggFuncs : Maybe (List Aggregation)
, defaultAggFunc : Aggregation
, autoHeaderHeight : Bool
, cellClassRules : List ( String, Expression.Eval Bool )
, checkboxSelection : Bool
Expand Down Expand Up @@ -520,6 +522,8 @@ Can be used when implementing column configurations for the table.
Default column settings:
{ aggFunc = NoAggregation
, allowedAggFuncs = []
, defaultAggFunc = SumAggregation
, autoHeaderHeight = False
, cellClassRules = []
, checkboxSelection = False
Expand Down Expand Up @@ -566,6 +570,8 @@ Default column settings:
defaultSettings : ColumnSettings
defaultSettings =
{ aggFunc = NoAggregation
, allowedAggFuncs = Nothing
, defaultAggFunc = SumAggregation
, autoHeaderHeight = False
, cellClassRules = []
, checkboxSelection = False
Expand Down Expand Up @@ -1013,6 +1019,8 @@ columnDefEncoder gridConfig columnDef =
in
Json.Encode.object
[ ( "aggFunc", encodeMaybe Json.Encode.string (aggregationToString columnDef.settings.aggFunc) )
, ( "allowedAggFuncs", encodeMaybe (List.filterMap aggregationToString >> Json.Encode.list Json.Encode.string) columnDef.settings.allowedAggFuncs )
, ( "defaultAggFunc", encodeMaybe Json.Encode.string (aggregationToString columnDef.settings.defaultAggFunc) )
, ( "autoHeaderHeight", Json.Encode.bool columnDef.settings.autoHeaderHeight )
, ( "cellClassRules"
, Json.Encode.object <|
Expand Down
5 changes: 4 additions & 1 deletion tests/AgGridTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module AgGridTest exposing (suite)

import AgGrid exposing (Aggregation(..), PinningType(..), Sorting(..), defaultGridConfig)
import Expect
import Html.Attributes exposing (default)
import Test exposing (..)


Expand Down Expand Up @@ -84,6 +83,8 @@ suite =
|> (\settings ->
{ settings
| aggFunc = AgGrid.NoAggregation
, allowedAggFuncs = Just [ AgGrid.SumAggregation, AgGrid.AvgAggregation ]
, defaultAggFunc = AgGrid.SumAggregation
, flex = Nothing
, hide = False
, pinned = AgGrid.Unpinned
Expand Down Expand Up @@ -147,6 +148,8 @@ suite =
| settings =
{ defaultSettings
| aggFunc = AgGrid.AvgAggregation
, allowedAggFuncs = Just [ AgGrid.SumAggregation, AgGrid.AvgAggregation ]
, defaultAggFunc = AgGrid.SumAggregation
, flex = Just 5
, hide = True
, pinned = AgGrid.PinnedToLeft
Expand Down

0 comments on commit acdcfd6

Please sign in to comment.