diff --git a/src/Page/Chest.elm b/src/Page/Chest.elm index 20ed533..67700fc 100644 --- a/src/Page/Chest.elm +++ b/src/Page/Chest.elm @@ -281,21 +281,51 @@ view model = , main_ [ class "container" ] [ viewNotification model.state.notification - -- TODO: viewAddLoot when in Add mode + , case model.state.mode of + Add -> + viewAddLoot model + + _ -> + text "" + , viewLoot header model.searchText rowRenderer canSelect isSelected <| shownItems model ] , hr [] [] , section [ class "container" ] [ viewDebugSection model ] ] +{- +module ActionMode + +type Model + = Add + | Sell + | ... + + +rowRenderer mode = + ... + +controlButtons mode = + ... + +cancelAction toMsg mode = + ... + +confirmAction toMsg items mode = + ... + + + +-} -- VIEW LOOT viewLoot : String -> String -> Maybe (Item -> Html Msg) -> Bool -> (Item -> Bool) -> Loot -> Html Msg -viewLoot header searchText rowRenderer canSelect isSelected items = +viewLoot header searchText maybeRowRenderer canSelect isSelected items = let filteredItems = List.filter @@ -311,7 +341,7 @@ viewLoot header searchText rowRenderer canSelect isSelected items = , table [ class "table is-fullwidth is-striped is-hoverable" ] [ thead [ class "table-header" ] [ th [] [ text "Nom" ] ] - , tbody [] <| List.map (viewItemTableRow isSelected canSelect rowRenderer) filteredItems + , tbody [] <| List.map (viewItemTableRow isSelected canSelect maybeRowRenderer) filteredItems ] ] @@ -403,6 +433,56 @@ viewItemTableRow isSelected canSelect rowRenderer item = ] ] +-- Adding new loot +-- +viewAddLoot : Model -> Html Msg +viewAddLoot model = + let + showCompletionTips = True + newItem = Item 0 "New one #1" 2000 + in + div [ class "box is-primary container" ] + [ div [ class "field is-horizontal" ] + [ div [ class "field-label" ] + [ label [ class "label" ] [ text "Nouvel objet" ]] + , div [ class "field-body" ] + [ div [ class "field" ] + [ div [ class "control is-expanded" ] + [ input [ class "input", type_ "text" ] [] ] + , div [ class "dropdown" + , classList [("is-active", showCompletionTips)] ] + [ div [ class "dropdown-menu" ] + [ div [ class "dropdown-content" ] + [ a [ class "dropdown-item" ] [ text "item" ] ] + ] + ] + ] + , div [ class "field is-expanded has-addons" ] + [ p [ class "control" ] [ a [class "button is-static"] [ text "PO" ] ] + , p [ class "control" ] + [ input [ type_ "text" + , class "input" + , classList [ ("is-danger", True) ]] + [] + ] + ] + , div [ class "field" ] + [ div [ class "control" ] + [ button [ class "button is-primary" + , disabled True + , onClick <| NewItemAdded newItem ] + [ text "Ajouter au coffre" ] ] + ] + ] + ] + , div [ class "field is-horizontal" ] + [ div [ class "field-label" ] [ label [ class "label" ] [ text "ou" ] ] + , div [ class "field-body" ] + [ div [ class "control" ] + [ button [ class "button" ] [ text "Depuis une liste" ] ] + ] + ] + ] -- ACTION MODES @@ -467,11 +547,17 @@ type Msg | SwitchSelectionState Int | ModeSwitched ActionMode | ConfirmAction + | NewItemAdded Item update : Msg -> Model -> ( Model, Cmd Msg ) update msg model = case msg of + NewItemAdded item -> + let + state = model.state + in + ( { model | state = { state | newLoot = item :: state.newLoot } }, Cmd.none ) ApiMsg apiMsg -> case apiMsg of Api.GotActionResult response ->