Eike Kettner c73cdd82ab Improve item detail view
- Separate page (permalink) for item details

- Use available space and hide search menu

- Disable item navigation links if there is nothing to go to

- Show notes more prominently and allow to hide them
2019-12-31 01:22:40 +01:00

58 lines
1.2 KiB
Elm

module Page.Home.Data exposing
( Model
, Msg(..)
, ViewMode(..)
, emptyModel
, itemNav
)
import Api.Model.ItemDetail exposing (ItemDetail)
import Api.Model.ItemLightList exposing (ItemLightList)
import Comp.ItemList
import Comp.SearchMenu
import Http
type alias Model =
{ searchMenuModel : Comp.SearchMenu.Model
, itemListModel : Comp.ItemList.Model
, searchInProgress : Bool
, viewMode : ViewMode
}
emptyModel : Model
emptyModel =
{ searchMenuModel = Comp.SearchMenu.emptyModel
, itemListModel = Comp.ItemList.emptyModel
, searchInProgress = False
, viewMode = Listing
}
type Msg
= Init
| SearchMenuMsg Comp.SearchMenu.Msg
| ItemListMsg Comp.ItemList.Msg
| ItemSearchResp (Result Http.Error ItemLightList)
| DoSearch
type ViewMode
= Listing
| Detail
itemNav : String -> Model -> { prev : Maybe String, next : Maybe String }
itemNav id model =
let
prev =
Comp.ItemList.prevItem model.itemListModel id
next =
Comp.ItemList.nextItem model.itemListModel id
in
{ prev = Maybe.map .id prev
, next = Maybe.map .id next
}