adds html for adding loot
This commit is contained in:
@@ -281,21 +281,51 @@ view model =
|
|||||||
, main_
|
, main_
|
||||||
[ class "container" ]
|
[ class "container" ]
|
||||||
[ viewNotification model.state.notification
|
[ viewNotification model.state.notification
|
||||||
|
|
||||||
-- TODO: viewAddLoot when in Add mode
|
-- TODO: viewAddLoot when in Add mode
|
||||||
|
, case model.state.mode of
|
||||||
|
Add ->
|
||||||
|
viewAddLoot model
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
text ""
|
||||||
|
|
||||||
, viewLoot header model.searchText rowRenderer canSelect isSelected <| shownItems model
|
, viewLoot header model.searchText rowRenderer canSelect isSelected <| shownItems model
|
||||||
]
|
]
|
||||||
, hr [] []
|
, hr [] []
|
||||||
, section [ class "container" ] [ viewDebugSection model ]
|
, section [ class "container" ] [ viewDebugSection model ]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{-
|
||||||
|
|
||||||
|
module ActionMode
|
||||||
|
|
||||||
|
type Model
|
||||||
|
= Add
|
||||||
|
| Sell
|
||||||
|
| ...
|
||||||
|
|
||||||
|
|
||||||
|
rowRenderer mode =
|
||||||
|
...
|
||||||
|
|
||||||
|
controlButtons mode =
|
||||||
|
...
|
||||||
|
|
||||||
|
cancelAction toMsg mode =
|
||||||
|
...
|
||||||
|
|
||||||
|
confirmAction toMsg items mode =
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-}
|
||||||
|
|
||||||
-- VIEW LOOT
|
-- VIEW LOOT
|
||||||
|
|
||||||
|
|
||||||
viewLoot : String -> String -> Maybe (Item -> Html Msg) -> Bool -> (Item -> Bool) -> Loot -> Html Msg
|
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
|
let
|
||||||
filteredItems =
|
filteredItems =
|
||||||
List.filter
|
List.filter
|
||||||
@@ -311,7 +341,7 @@ viewLoot header searchText rowRenderer canSelect isSelected items =
|
|||||||
, table [ class "table is-fullwidth is-striped is-hoverable" ]
|
, table [ class "table is-fullwidth is-striped is-hoverable" ]
|
||||||
[ thead [ class "table-header" ]
|
[ thead [ class "table-header" ]
|
||||||
[ th [] [ text "Nom" ] ]
|
[ 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
|
-- ACTION MODES
|
||||||
@@ -467,11 +547,17 @@ type Msg
|
|||||||
| SwitchSelectionState Int
|
| SwitchSelectionState Int
|
||||||
| ModeSwitched ActionMode
|
| ModeSwitched ActionMode
|
||||||
| ConfirmAction
|
| ConfirmAction
|
||||||
|
| NewItemAdded Item
|
||||||
|
|
||||||
|
|
||||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||||
update msg model =
|
update msg model =
|
||||||
case msg of
|
case msg of
|
||||||
|
NewItemAdded item ->
|
||||||
|
let
|
||||||
|
state = model.state
|
||||||
|
in
|
||||||
|
( { model | state = { state | newLoot = item :: state.newLoot } }, Cmd.none )
|
||||||
ApiMsg apiMsg ->
|
ApiMsg apiMsg ->
|
||||||
case apiMsg of
|
case apiMsg of
|
||||||
Api.GotActionResult response ->
|
Api.GotActionResult response ->
|
||||||
|
|||||||
Reference in New Issue
Block a user