sxh / ui-base / UiBase.Product

Provide Product type and functions for sorting lists of products

Product


type alias Product =
{ id : Basics.Int
, source : String
, manufacturer : String
, product_code : String
, description : String
, scale : String
, category : String
, url : String
, image_url : Maybe String
, price : String
, display_short_description : Basics.Bool
, indexed : Basics.Bool
, first_seen : Date
, last_price_update : Date 
}

Product type

Sorting


type SortDirection
    = Ascending
    | Descending
    | Unsorted

Possible sort directions


type alias SortDescription =
{ columnName : String
, accessor : Product -> String
, direction : SortDirection 
}

Details of what column is currently sorted, and how to sort it

sortDirection : String -> SortDescription -> SortDirection

Given a column name and the current sort description, determine the appropriate sort direction

toggleSort : String -> (Product -> String) -> SortDescription -> SortDescription

Given a column name to sort on and the current sort description, determine the new sort description

Utility

productSources : List String

List of product sources