many styling tweaks, adds sourceName field

This commit is contained in:
2019-12-07 16:28:40 +01:00
parent ff375b6052
commit 903fdd816d
11 changed files with 294 additions and 150 deletions

View File

@@ -1,4 +1,4 @@
module Chest.Selection exposing (Model, Msg, init, modifiers, selected, update, view)
module Chest.Selection exposing (Model, Msg, init, modifiers, selected, totalSelectedPrice, update, view)
import Api exposing (Item, Loot)
import Dict exposing (Dict)
@@ -147,7 +147,7 @@ modifiers (Model selection data) items =
List.map
(\item ->
Dict.get item.id inner
|> Maybe.map (\i -> toFloatingMod i)
|> Maybe.map toFloatingMod
)
items
@@ -155,6 +155,32 @@ modifiers (Model selection data) items =
[]
totalSelectedPrice : Model -> Loot -> Maybe Float
totalSelectedPrice model loot =
case selected model loot of
[] ->
Nothing
items ->
let
(Model selection data) =
model
modifier item =
Maybe.withDefault 1.0 <|
Maybe.map toFloatingMod <|
case data of
Data inner ->
Dict.get item.id inner
NoData ->
Nothing
in
Just <|
List.foldl (+) 0.0 <|
List.map (\item -> toFloat item.base_price * modifier item) items
itemInSelection : Selection -> Item -> Bool
itemInSelection selection item =
Set.member item.id selection