Basic search view for shares

This commit is contained in:
eikek
2021-10-05 01:06:52 +02:00
parent a286556116
commit 83dd675e4f
12 changed files with 577 additions and 23 deletions

View File

@ -5,28 +5,83 @@
-}
module Page.Share.Data exposing (Model, Msg, init)
module Page.Share.Data exposing (Mode(..), Model, Msg(..), PageError(..), init)
import Api
import Api.Model.ItemLightList exposing (ItemLightList)
import Api.Model.ShareSecret exposing (ShareSecret)
import Api.Model.ShareVerifyResult exposing (ShareVerifyResult)
import Comp.ItemCardList
import Comp.PowerSearchInput
import Comp.SearchMenu
import Data.Flags exposing (Flags)
import Http
type Mode
= ModeInitial
| ModePassword
| ModeShare
type PageError
= PageErrorNone
| PageErrorHttp Http.Error
| PageErrorAuthFail
type alias PasswordModel =
{ password : String
, passwordFailed : Bool
}
type alias Model =
{}
{ mode : Mode
, verifyResult : ShareVerifyResult
, passwordModel : PasswordModel
, pageError : PageError
, items : ItemLightList
, searchMenuModel : Comp.SearchMenu.Model
, powerSearchInput : Comp.PowerSearchInput.Model
, searchInProgress : Bool
, itemListModel : Comp.ItemCardList.Model
}
emptyModel : Flags -> Model
emptyModel flags =
{ mode = ModeInitial
, verifyResult = Api.Model.ShareVerifyResult.empty
, passwordModel =
{ password = ""
, passwordFailed = False
}
, pageError = PageErrorNone
, items = Api.Model.ItemLightList.empty
, searchMenuModel = Comp.SearchMenu.init flags
, powerSearchInput = Comp.PowerSearchInput.init
, searchInProgress = False
, itemListModel = Comp.ItemCardList.init
}
init : Maybe String -> Flags -> ( Model, Cmd Msg )
init shareId flags =
case shareId of
Just id ->
let
_ =
Debug.log "share" id
in
( {}, Cmd.none )
( emptyModel flags, Api.verifyShare flags (ShareSecret id Nothing) VerifyResp )
Nothing ->
( {}, Cmd.none )
( emptyModel flags, Cmd.none )
type Msg
= Msg
= VerifyResp (Result Http.Error ShareVerifyResult)
| SearchResp (Result Http.Error ItemLightList)
| SetPassword String
| SubmitPassword
| SearchMenuMsg Comp.SearchMenu.Msg
| PowerSearchMsg Comp.PowerSearchInput.Msg
| ResetSearch
| ItemListMsg Comp.ItemCardList.Msg