Fix load more button

This commit is contained in:
Eike Kettner 2020-08-06 00:48:57 +02:00
parent 0883637e89
commit cf3e051e83
3 changed files with 33 additions and 21 deletions

View File

@ -37,6 +37,7 @@ type alias Model =
, throttle : Throttle Msg , throttle : Throttle Msg
, searchTypeDropdown : Comp.FixedDropdown.Model SearchType , searchTypeDropdown : Comp.FixedDropdown.Model SearchType
, searchType : SearchType , searchType : SearchType
, searchTypeForm : SearchType
, contentOnlySearch : Maybe String , contentOnlySearch : Maybe String
} }
@ -63,7 +64,8 @@ init flags =
, searchTypeDropdown = , searchTypeDropdown =
Comp.FixedDropdown.initMap searchTypeString Comp.FixedDropdown.initMap searchTypeString
searchTypeOptions searchTypeOptions
, searchType = defaultSearchType flags , searchType = BasicSearch
, searchTypeForm = defaultSearchType flags
, contentOnlySearch = Nothing , contentOnlySearch = Nothing
} }
@ -134,19 +136,15 @@ itemNav id model =
doSearchCmd : Flags -> UiSettings -> Int -> Model -> Cmd Msg doSearchCmd : Flags -> UiSettings -> Int -> Model -> Cmd Msg
doSearchCmd flags settings offset model = doSearchCmd flags settings offset model =
if model.menuCollapsed then case model.searchType of
case model.searchType of BasicSearch ->
BasicSearch -> doSearchDefaultCmd flags settings offset model
doSearchDefaultCmd flags settings offset model
ContentSearch -> ContentSearch ->
doSearchDefaultCmd flags settings offset model doSearchDefaultCmd flags settings offset model
ContentOnlySearch -> ContentOnlySearch ->
doSearchIndexCmd flags settings offset model doSearchIndexCmd flags settings offset model
else
doSearchDefaultCmd flags settings offset model
doSearchDefaultCmd : Flags -> UiSettings -> Int -> Model -> Cmd Msg doSearchDefaultCmd : Flags -> UiSettings -> Int -> Model -> Cmd Msg

View File

@ -12,6 +12,7 @@ import Throttle
import Time import Time
import Util.Html exposing (KeyCode(..)) import Util.Html exposing (KeyCode(..))
import Util.Maybe import Util.Maybe
import Util.String
import Util.Update import Util.Update
@ -157,7 +158,7 @@ update key flags settings msg model =
SetBasicSearch str -> SetBasicSearch str ->
let let
smMsg = smMsg =
case model.searchType of case model.searchTypeForm of
BasicSearch -> BasicSearch ->
SearchMenuMsg (Comp.SearchMenu.SetAllName str) SearchMenuMsg (Comp.SearchMenu.SetAllName str)
@ -183,7 +184,7 @@ update key flags settings msg model =
withSub withSub
( { model ( { model
| searchTypeDropdown = sm | searchTypeDropdown = sm
, searchType = Maybe.withDefault model.searchType mv , searchTypeForm = Maybe.withDefault model.searchTypeForm mv
} }
, Cmd.none , Cmd.none
) )
@ -202,14 +203,27 @@ update key flags settings msg model =
doSearch : Flags -> UiSettings -> Model -> ( Model, Cmd Msg, Sub Msg ) doSearch : Flags -> UiSettings -> Model -> ( Model, Cmd Msg, Sub Msg )
doSearch flags settings model = doSearch flags settings model =
let let
stype =
if
not model.menuCollapsed
|| Util.String.isNothingOrBlank model.contentOnlySearch
then
BasicSearch
else
model.searchTypeForm
model_ =
{ model | searchType = stype }
searchCmd = searchCmd =
doSearchCmd flags settings 0 model doSearchCmd flags settings 0 model_
( newThrottle, cmd ) = ( newThrottle, cmd ) =
Throttle.try searchCmd model.throttle Throttle.try searchCmd model.throttle
in in
withSub withSub
( { model ( { model_
| searchInProgress = cmd /= Cmd.none | searchInProgress = cmd /= Cmd.none
, viewMode = Listing , viewMode = Listing
, searchOffset = 0 , searchOffset = 0

View File

@ -122,11 +122,11 @@ viewSearchBar flags model =
let let
searchTypeItem = searchTypeItem =
Comp.FixedDropdown.Item Comp.FixedDropdown.Item
model.searchType model.searchTypeForm
(searchTypeString model.searchType) (searchTypeString model.searchTypeForm)
searchInput = searchInput =
case model.searchType of case model.searchTypeForm of
BasicSearch -> BasicSearch ->
model.searchMenuModel.allNameModel model.searchMenuModel.allNameModel
@ -153,7 +153,7 @@ viewSearchBar flags model =
[ class "item" [ class "item"
, onClick ToggleSearchMenu , onClick ToggleSearchMenu
, href "#" , href "#"
, if model.searchType == ContentOnlySearch then , if model.searchTypeForm == ContentOnlySearch then
title "Search menu disabled" title "Search menu disabled"
else else
@ -163,7 +163,7 @@ viewSearchBar flags model =
, i [ class "icons" ] , i [ class "icons" ]
[ i [ class "grey bars icon" ] [] [ i [ class "grey bars icon" ] []
, i [ class "bottom left corner search icon" ] [] , i [ class "bottom left corner search icon" ] []
, if model.searchType == ContentOnlySearch then , if model.searchTypeForm == ContentOnlySearch then
i [ class "top right red corner delete icon" ] [] i [ class "top right red corner delete icon" ] []
else if hasMoreSearch model then else if hasMoreSearch model then