mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 10:28:27 +00:00
Permalink for bookmark searches
This commit is contained in:
@ -209,7 +209,7 @@ type Msg
|
|||||||
|
|
||||||
defaultPage : Flags -> Page
|
defaultPage : Flags -> Page
|
||||||
defaultPage _ =
|
defaultPage _ =
|
||||||
SearchPage
|
DashboardPage
|
||||||
|
|
||||||
|
|
||||||
getUiLanguage : Model -> UiLanguage
|
getUiLanguage : Model -> UiLanguage
|
||||||
|
@ -323,11 +323,11 @@ updateWithSub msg model =
|
|||||||
|
|
||||||
newModel =
|
newModel =
|
||||||
{ model
|
{ model
|
||||||
| showNewItemsArrived = isProcessItem && model.page /= SearchPage
|
| showNewItemsArrived = isProcessItem && not (Page.isSearchPage model.page)
|
||||||
, jobsWaiting = max 0 (model.jobsWaiting - 1)
|
, jobsWaiting = max 0 (model.jobsWaiting - 1)
|
||||||
}
|
}
|
||||||
in
|
in
|
||||||
if model.page == SearchPage && isProcessItem then
|
if Page.isSearchPage model.page && isProcessItem then
|
||||||
updateSearch texts Page.Search.Data.RefreshView newModel
|
updateSearch texts Page.Search.Data.RefreshView newModel
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -375,7 +375,7 @@ updateDashboard : Messages -> Page.Dashboard.Data.Msg -> Model -> ( Model, Cmd M
|
|||||||
updateDashboard texts lmsg model =
|
updateDashboard texts lmsg model =
|
||||||
let
|
let
|
||||||
( dbm, dbc, dbs ) =
|
( dbm, dbc, dbs ) =
|
||||||
Page.Dashboard.Update.update texts.dashboard model.flags lmsg model.dashboardModel
|
Page.Dashboard.Update.update texts.dashboard model.key model.flags lmsg model.dashboardModel
|
||||||
in
|
in
|
||||||
( { model | dashboardModel = dbm }
|
( { model | dashboardModel = dbm }
|
||||||
, Cmd.map DashboardMsg dbc
|
, Cmd.map DashboardMsg dbc
|
||||||
@ -572,16 +572,16 @@ updateLogin lmsg model =
|
|||||||
updateSearch : Messages -> Page.Search.Data.Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
|
updateSearch : Messages -> Page.Search.Data.Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
|
||||||
updateSearch texts lmsg model =
|
updateSearch texts lmsg model =
|
||||||
let
|
let
|
||||||
mid =
|
( mid, bmId ) =
|
||||||
case model.page of
|
case model.page of
|
||||||
SearchPage ->
|
SearchPage bId ->
|
||||||
Util.Maybe.fromString model.itemDetailModel.detail.item.id
|
( Util.Maybe.fromString model.itemDetailModel.detail.item.id, bId )
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
Nothing
|
( Nothing, Nothing )
|
||||||
|
|
||||||
result =
|
result =
|
||||||
Page.Search.Update.update mid model.key model.flags texts.search model.uiSettings lmsg model.searchModel
|
Page.Search.Update.update bmId mid model.key model.flags texts.search model.uiSettings lmsg model.searchModel
|
||||||
|
|
||||||
model_ =
|
model_ =
|
||||||
{ model | searchModel = result.model }
|
{ model | searchModel = result.model }
|
||||||
@ -628,7 +628,7 @@ initPage model_ page =
|
|||||||
Messages.get <| App.Data.getUiLanguage model
|
Messages.get <| App.Data.getUiLanguage model
|
||||||
in
|
in
|
||||||
case page of
|
case page of
|
||||||
SearchPage ->
|
SearchPage _ ->
|
||||||
Util.Update.andThen2
|
Util.Update.andThen2
|
||||||
[ updateSearch texts Page.Search.Data.Init
|
[ updateSearch texts Page.Search.Data.Init
|
||||||
, updateQueue Page.Queue.Data.StopRefresh
|
, updateQueue Page.Queue.Data.StopRefresh
|
||||||
|
@ -78,7 +78,7 @@ topNavUser auth model =
|
|||||||
[ class S.infoMessageBase
|
[ class S.infoMessageBase
|
||||||
, class "my-2 px-1 py-1 rounded-lg inline-block hover:opacity-50"
|
, class "my-2 px-1 py-1 rounded-lg inline-block hover:opacity-50"
|
||||||
, classList [ ( "hidden", not model.showNewItemsArrived ) ]
|
, classList [ ( "hidden", not model.showNewItemsArrived ) ]
|
||||||
, Page.href SearchPage
|
, Page.href (SearchPage Nothing)
|
||||||
, onClick ToggleShowNewItemsArrived
|
, onClick ToggleShowNewItemsArrived
|
||||||
]
|
]
|
||||||
[ i [ class "fa fa-exclamation-circle mr-1" ] []
|
[ i [ class "fa fa-exclamation-circle mr-1" ] []
|
||||||
@ -165,8 +165,8 @@ mainContent model =
|
|||||||
DashboardPage ->
|
DashboardPage ->
|
||||||
viewDashboard texts model
|
viewDashboard texts model
|
||||||
|
|
||||||
SearchPage ->
|
SearchPage bmId ->
|
||||||
viewSearch texts model
|
viewSearch texts bmId model
|
||||||
|
|
||||||
CollectiveSettingPage ->
|
CollectiveSettingPage ->
|
||||||
viewCollectiveSettings texts model
|
viewCollectiveSettings texts model
|
||||||
@ -298,7 +298,7 @@ dataMenu texts _ model =
|
|||||||
]
|
]
|
||||||
, div [ class "py-1" ] [ hr [ class S.border ] [] ]
|
, div [ class "py-1" ] [ hr [ class S.border ] [] ]
|
||||||
, dataPageLink model
|
, dataPageLink model
|
||||||
SearchPage
|
(SearchPage Nothing)
|
||||||
[]
|
[]
|
||||||
[ Icons.searchIcon "w-6"
|
[ Icons.searchIcon "w-6"
|
||||||
, span [ class "ml-1" ]
|
, span [ class "ml-1" ]
|
||||||
@ -541,8 +541,8 @@ viewShareDetail texts shareId itemId model =
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
viewSearch : Messages -> Model -> List (Html Msg)
|
viewSearch : Messages -> Maybe String -> Model -> List (Html Msg)
|
||||||
viewSearch texts model =
|
viewSearch texts bmId model =
|
||||||
[ Html.map SearchMsg
|
[ Html.map SearchMsg
|
||||||
(Search.viewSidebar texts.search
|
(Search.viewSidebar texts.search
|
||||||
model.sidebarVisible
|
model.sidebarVisible
|
||||||
|
@ -42,10 +42,7 @@ import Comp.ItemDetail.Model
|
|||||||
, UpdateResult
|
, UpdateResult
|
||||||
, ViewMode(..)
|
, ViewMode(..)
|
||||||
, initSelectViewModel
|
, initSelectViewModel
|
||||||
, initShowQrModel
|
|
||||||
, isEditNotes
|
, isEditNotes
|
||||||
, isShowQrAttach
|
|
||||||
, isShowQrItem
|
|
||||||
, resultModel
|
, resultModel
|
||||||
, resultModelCmd
|
, resultModelCmd
|
||||||
, resultModelCmdSub
|
, resultModelCmdSub
|
||||||
@ -741,7 +738,7 @@ update key flags inav settings msg model =
|
|||||||
resultModelCmd ( model, Page.set key (ItemDetailPage id) )
|
resultModelCmd ( model, Page.set key (ItemDetailPage id) )
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
resultModelCmd ( model, Page.set key SearchPage )
|
resultModelCmd ( model, Page.set key (SearchPage Nothing) )
|
||||||
in
|
in
|
||||||
{ result_ | removedItem = Just removedId }
|
{ result_ | removedItem = Just removedId }
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ menuBar texts inav settings model =
|
|||||||
[ MB.CustomElement <|
|
[ MB.CustomElement <|
|
||||||
a
|
a
|
||||||
[ class S.secondaryBasicButton
|
[ class S.secondaryBasicButton
|
||||||
, Page.href SearchPage
|
, Page.href (SearchPage Nothing)
|
||||||
, title texts.backToSearchResults
|
, title texts.backToSearchResults
|
||||||
]
|
]
|
||||||
[ i [ class "fa fa-arrow-left" ] []
|
[ i [ class "fa fa-arrow-left" ] []
|
||||||
|
@ -35,6 +35,7 @@ type LinkTarget
|
|||||||
| LinkTag IdName
|
| LinkTag IdName
|
||||||
| LinkCustomField ItemFieldValue
|
| LinkCustomField ItemFieldValue
|
||||||
| LinkSource String
|
| LinkSource String
|
||||||
|
| LinkBookmark String
|
||||||
| LinkNone
|
| LinkNone
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ import Data.UiSettings exposing (UiSettings)
|
|||||||
import DatePicker exposing (DatePicker)
|
import DatePicker exposing (DatePicker)
|
||||||
import Html exposing (..)
|
import Html exposing (..)
|
||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
import Html.Events exposing (onClick, onInput)
|
import Html.Events exposing (onInput)
|
||||||
import Http
|
import Http
|
||||||
import Messages.Comp.SearchMenu exposing (Texts)
|
import Messages.Comp.SearchMenu exposing (Texts)
|
||||||
import Set exposing (Set)
|
import Set exposing (Set)
|
||||||
@ -385,6 +385,7 @@ type Msg
|
|||||||
| SetConcEquip IdName
|
| SetConcEquip IdName
|
||||||
| SetFolder IdName
|
| SetFolder IdName
|
||||||
| SetTag String
|
| SetTag String
|
||||||
|
| SetBookmark String
|
||||||
| SetCustomField ItemFieldValue
|
| SetCustomField ItemFieldValue
|
||||||
| CustomFieldMsg Comp.CustomFieldMultiInput.Msg
|
| CustomFieldMsg Comp.CustomFieldMultiInput.Msg
|
||||||
| SetSource String
|
| SetSource String
|
||||||
@ -432,6 +433,9 @@ linkTargetMsg linkTarget =
|
|||||||
Comp.LinkTarget.LinkSource str ->
|
Comp.LinkTarget.LinkSource str ->
|
||||||
Just <| ResetToSource str
|
Just <| ResetToSource str
|
||||||
|
|
||||||
|
Comp.LinkTarget.LinkBookmark id ->
|
||||||
|
Just <| SetBookmark id
|
||||||
|
|
||||||
|
|
||||||
type alias NextState =
|
type alias NextState =
|
||||||
{ model : Model
|
{ model : Model
|
||||||
@ -556,6 +560,22 @@ updateDrop ddm flags settings msg model =
|
|||||||
SetTag id ->
|
SetTag id ->
|
||||||
resetAndSet (TagSelectMsg (Comp.TagSelect.toggleTag id))
|
resetAndSet (TagSelectMsg (Comp.TagSelect.toggleTag id))
|
||||||
|
|
||||||
|
SetBookmark id ->
|
||||||
|
let
|
||||||
|
nextModel =
|
||||||
|
resetModel model
|
||||||
|
|
||||||
|
sel =
|
||||||
|
{ bookmarks = Set.singleton id
|
||||||
|
, shares = Set.empty
|
||||||
|
}
|
||||||
|
in
|
||||||
|
{ model = { nextModel | selectedBookmarks = sel }
|
||||||
|
, cmd = Cmd.none
|
||||||
|
, stateChange = sel /= model.selectedBookmarks
|
||||||
|
, dragDrop = DD.DragDropData ddm Nothing
|
||||||
|
}
|
||||||
|
|
||||||
GetAllTagsResp (Ok stats) ->
|
GetAllTagsResp (Ok stats) ->
|
||||||
let
|
let
|
||||||
tagSel =
|
tagSel =
|
||||||
@ -1064,7 +1084,7 @@ updateDrop ddm flags settings msg model =
|
|||||||
AllBookmarksResp (Ok bm) ->
|
AllBookmarksResp (Ok bm) ->
|
||||||
{ model = { model | allBookmarks = Comp.BookmarkChooser.init bm }
|
{ model = { model | allBookmarks = Comp.BookmarkChooser.init bm }
|
||||||
, cmd = Cmd.none
|
, cmd = Cmd.none
|
||||||
, stateChange = False
|
, stateChange = model.allBookmarks /= Comp.BookmarkChooser.init bm
|
||||||
, dragDrop = DD.DragDropData ddm Nothing
|
, dragDrop = DD.DragDropData ddm Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1082,7 +1102,7 @@ updateDrop ddm flags settings msg model =
|
|||||||
in
|
in
|
||||||
{ model = { model | allBookmarks = next, selectedBookmarks = sel }
|
{ model = { model | allBookmarks = next, selectedBookmarks = sel }
|
||||||
, cmd = Cmd.none
|
, cmd = Cmd.none
|
||||||
, stateChange = sel /= model.selectedBookmarks
|
, stateChange = sel /= model.selectedBookmarks || model.allBookmarks /= next
|
||||||
, dragDrop = DD.DragDropData ddm Nothing
|
, dragDrop = DD.DragDropData ddm Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ module Page exposing
|
|||||||
, hasSidebar
|
, hasSidebar
|
||||||
, href
|
, href
|
||||||
, isOpen
|
, isOpen
|
||||||
|
, isSearchPage
|
||||||
, isSecured
|
, isSecured
|
||||||
, loginPage
|
, loginPage
|
||||||
, loginPageReferrer
|
, loginPageReferrer
|
||||||
@ -51,7 +52,7 @@ emptyLoginData =
|
|||||||
|
|
||||||
|
|
||||||
type Page
|
type Page
|
||||||
= SearchPage
|
= SearchPage (Maybe String)
|
||||||
| LoginPage LoginData
|
| LoginPage LoginData
|
||||||
| ManageDataPage
|
| ManageDataPage
|
||||||
| CollectiveSettingPage
|
| CollectiveSettingPage
|
||||||
@ -72,7 +73,7 @@ isSecured page =
|
|||||||
DashboardPage ->
|
DashboardPage ->
|
||||||
True
|
True
|
||||||
|
|
||||||
SearchPage ->
|
SearchPage _ ->
|
||||||
True
|
True
|
||||||
|
|
||||||
LoginPage _ ->
|
LoginPage _ ->
|
||||||
@ -142,13 +143,23 @@ loginPage p =
|
|||||||
LoginPage { emptyLoginData | referrer = Just p }
|
LoginPage { emptyLoginData | referrer = Just p }
|
||||||
|
|
||||||
|
|
||||||
|
isSearchPage : Page -> Bool
|
||||||
|
isSearchPage page =
|
||||||
|
case page of
|
||||||
|
SearchPage _ ->
|
||||||
|
True
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
False
|
||||||
|
|
||||||
|
|
||||||
pageName : Page -> String
|
pageName : Page -> String
|
||||||
pageName page =
|
pageName page =
|
||||||
case page of
|
case page of
|
||||||
DashboardPage ->
|
DashboardPage ->
|
||||||
"dashboard"
|
"dashboard"
|
||||||
|
|
||||||
SearchPage ->
|
SearchPage _ ->
|
||||||
"Search"
|
"Search"
|
||||||
|
|
||||||
LoginPage _ ->
|
LoginPage _ ->
|
||||||
@ -236,8 +247,13 @@ pageToString page =
|
|||||||
DashboardPage ->
|
DashboardPage ->
|
||||||
"/app/dashboard"
|
"/app/dashboard"
|
||||||
|
|
||||||
SearchPage ->
|
SearchPage bmId ->
|
||||||
"/app/search"
|
case bmId of
|
||||||
|
Just id ->
|
||||||
|
"/app/search?bm=" ++ id
|
||||||
|
|
||||||
|
Nothing ->
|
||||||
|
"/app/search"
|
||||||
|
|
||||||
LoginPage data ->
|
LoginPage data ->
|
||||||
case data.referrer of
|
case data.referrer of
|
||||||
@ -329,7 +345,7 @@ parser =
|
|||||||
, s pathPrefix </> s "dashboard"
|
, s pathPrefix </> s "dashboard"
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
, Parser.map SearchPage (s pathPrefix </> s "search")
|
, Parser.map SearchPage (s pathPrefix </> s "search" <?> Query.string "bm")
|
||||||
, Parser.map LoginPage (s pathPrefix </> s "login" <?> loginPageParser)
|
, Parser.map LoginPage (s pathPrefix </> s "login" <?> loginPageParser)
|
||||||
, Parser.map ManageDataPage (s pathPrefix </> s "managedata")
|
, Parser.map ManageDataPage (s pathPrefix </> s "managedata")
|
||||||
, Parser.map CollectiveSettingPage (s pathPrefix </> s "csettings")
|
, Parser.map CollectiveSettingPage (s pathPrefix </> s "csettings")
|
||||||
|
@ -17,7 +17,7 @@ view texts _ model =
|
|||||||
div [ class "flex flex-col" ]
|
div [ class "flex flex-col" ]
|
||||||
[ div [ class "mt-2" ]
|
[ div [ class "mt-2" ]
|
||||||
[ menuLink [ onClick InitDashboard, href "#" ] (Icons.dashboardIcon "") "Dashboard"
|
[ menuLink [ onClick InitDashboard, href "#" ] (Icons.dashboardIcon "") "Dashboard"
|
||||||
, menuLink [ Page.href SearchPage ] (Icons.searchIcon "") "Items"
|
, menuLink [ Page.href (SearchPage Nothing) ] (Icons.searchIcon "") "Items"
|
||||||
]
|
]
|
||||||
, h3
|
, h3
|
||||||
[ class S.header3
|
[ class S.header3
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
module Page.Dashboard.Update exposing (update)
|
module Page.Dashboard.Update exposing (update)
|
||||||
|
|
||||||
|
import Browser.Navigation as Nav
|
||||||
import Comp.BookmarkChooser
|
import Comp.BookmarkChooser
|
||||||
import Comp.EquipmentManage
|
import Comp.EquipmentManage
|
||||||
import Comp.FolderManage
|
import Comp.FolderManage
|
||||||
@ -19,11 +20,13 @@ import Comp.SourceManage
|
|||||||
import Comp.TagManage
|
import Comp.TagManage
|
||||||
import Data.Flags exposing (Flags)
|
import Data.Flags exposing (Flags)
|
||||||
import Messages.Page.Dashboard exposing (Texts)
|
import Messages.Page.Dashboard exposing (Texts)
|
||||||
|
import Page exposing (Page(..))
|
||||||
import Page.Dashboard.Data exposing (..)
|
import Page.Dashboard.Data exposing (..)
|
||||||
|
import Set
|
||||||
|
|
||||||
|
|
||||||
update : Texts -> Flags -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
|
update : Texts -> Nav.Key -> Flags -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
|
||||||
update texts flags msg model =
|
update texts navKey flags msg model =
|
||||||
case msg of
|
case msg of
|
||||||
GetBookmarksResp list ->
|
GetBookmarksResp list ->
|
||||||
let
|
let
|
||||||
@ -43,9 +46,12 @@ update texts flags msg model =
|
|||||||
lm
|
lm
|
||||||
sideMenu.bookmarkChooser
|
sideMenu.bookmarkChooser
|
||||||
Comp.BookmarkChooser.emptySelection
|
Comp.BookmarkChooser.emptySelection
|
||||||
|
|
||||||
|
bmId =
|
||||||
|
Set.toList sel.bookmarks |> List.head
|
||||||
in
|
in
|
||||||
( { model | sideMenu = { sideMenu | bookmarkChooser = bm } }
|
( { model | sideMenu = { sideMenu | bookmarkChooser = bm } }
|
||||||
, Cmd.none
|
, Page.set navKey (SearchPage bmId)
|
||||||
, Sub.none
|
, Sub.none
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ update key flags inav settings msg model =
|
|||||||
Cmd.none
|
Cmd.none
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
Page.set key SearchPage
|
Page.set key (SearchPage Nothing)
|
||||||
in
|
in
|
||||||
{ model = { model | detail = result.model }
|
{ model = { model | detail = result.model }
|
||||||
, cmd = Cmd.batch [ pageSwitch, Cmd.map ItemDetailMsg result.cmd ]
|
, cmd = Cmd.batch [ pageSwitch, Cmd.map ItemDetailMsg result.cmd ]
|
||||||
|
@ -48,7 +48,6 @@ import Data.Items
|
|||||||
import Data.UiSettings exposing (UiSettings)
|
import Data.UiSettings exposing (UiSettings)
|
||||||
import Http
|
import Http
|
||||||
import Set exposing (Set)
|
import Set exposing (Set)
|
||||||
import Throttle exposing (Throttle)
|
|
||||||
import Util.Html exposing (KeyCode(..))
|
import Util.Html exposing (KeyCode(..))
|
||||||
import Util.ItemDragDrop as DD
|
import Util.ItemDragDrop as DD
|
||||||
|
|
||||||
@ -61,7 +60,6 @@ type alias Model =
|
|||||||
, searchOffset : Int
|
, searchOffset : Int
|
||||||
, moreAvailable : Bool
|
, moreAvailable : Bool
|
||||||
, moreInProgress : Bool
|
, moreInProgress : Bool
|
||||||
, throttle : Throttle Msg
|
|
||||||
, searchTypeDropdownValue : SearchType
|
, searchTypeDropdownValue : SearchType
|
||||||
, lastSearchType : SearchType
|
, lastSearchType : SearchType
|
||||||
, dragDropData : DD.DragDropData
|
, dragDropData : DD.DragDropData
|
||||||
@ -129,7 +127,6 @@ init flags viewMode =
|
|||||||
, searchOffset = 0
|
, searchOffset = 0
|
||||||
, moreAvailable = True
|
, moreAvailable = True
|
||||||
, moreInProgress = False
|
, moreInProgress = False
|
||||||
, throttle = Throttle.create 1
|
|
||||||
, searchTypeDropdownValue =
|
, searchTypeDropdownValue =
|
||||||
if Comp.SearchMenu.isFulltextSearch searchMenuModel then
|
if Comp.SearchMenu.isFulltextSearch searchMenuModel then
|
||||||
ContentOnlySearch
|
ContentOnlySearch
|
||||||
@ -199,6 +196,7 @@ editActive model =
|
|||||||
|
|
||||||
type Msg
|
type Msg
|
||||||
= Init
|
= Init
|
||||||
|
| DoNothing
|
||||||
| SearchMenuMsg Comp.SearchMenu.Msg
|
| SearchMenuMsg Comp.SearchMenu.Msg
|
||||||
| ResetSearch
|
| ResetSearch
|
||||||
| ItemCardListMsg Comp.ItemCardList.Msg
|
| ItemCardListMsg Comp.ItemCardList.Msg
|
||||||
@ -208,7 +206,6 @@ type Msg
|
|||||||
| ToggleSearchMenu
|
| ToggleSearchMenu
|
||||||
| ToggleSelectView
|
| ToggleSelectView
|
||||||
| LoadMore
|
| LoadMore
|
||||||
| UpdateThrottle
|
|
||||||
| SetBasicSearch String
|
| SetBasicSearch String
|
||||||
| ToggleSearchType
|
| ToggleSearchType
|
||||||
| KeyUpSearchbarMsg (Maybe KeyCode)
|
| KeyUpSearchbarMsg (Maybe KeyCode)
|
||||||
@ -310,10 +307,11 @@ doSearchDefaultCmd param model =
|
|||||||
|
|
||||||
createQuery : Model -> Maybe Q.ItemQuery
|
createQuery : Model -> Maybe Q.ItemQuery
|
||||||
createQuery model =
|
createQuery model =
|
||||||
Q.and
|
Debug.log "query" <|
|
||||||
[ Comp.SearchMenu.getItemQuery model.searchMenuModel
|
Q.and
|
||||||
, Maybe.map Q.Fragment model.powerSearchInput.input
|
[ Comp.SearchMenu.getItemQuery model.searchMenuModel
|
||||||
]
|
, Maybe.map Q.Fragment model.powerSearchInput.input
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
resultsBelowLimit : UiSettings -> Model -> Bool
|
resultsBelowLimit : UiSettings -> Model -> Bool
|
||||||
|
@ -35,8 +35,6 @@ import Process
|
|||||||
import Scroll
|
import Scroll
|
||||||
import Set exposing (Set)
|
import Set exposing (Set)
|
||||||
import Task
|
import Task
|
||||||
import Throttle
|
|
||||||
import Time
|
|
||||||
import Util.Html exposing (KeyCode(..))
|
import Util.Html exposing (KeyCode(..))
|
||||||
import Util.ItemDragDrop as DD
|
import Util.ItemDragDrop as DD
|
||||||
import Util.Update
|
import Util.Update
|
||||||
@ -50,8 +48,8 @@ type alias UpdateResult =
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
update : Maybe String -> Nav.Key -> Flags -> Texts -> UiSettings -> Msg -> Model -> UpdateResult
|
update : Maybe String -> Maybe String -> Nav.Key -> Flags -> Texts -> UiSettings -> Msg -> Model -> UpdateResult
|
||||||
update mId key flags texts settings msg model =
|
update bookmarkId mId key flags texts settings msg model =
|
||||||
case msg of
|
case msg of
|
||||||
Init ->
|
Init ->
|
||||||
let
|
let
|
||||||
@ -62,20 +60,28 @@ update mId key flags texts settings msg model =
|
|||||||
, offset = 0
|
, offset = 0
|
||||||
, scroll = True
|
, scroll = True
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setBookmark =
|
||||||
|
Maybe.map (\bmId -> SearchMenuMsg <| Comp.SearchMenu.SetBookmark bmId) bookmarkId
|
||||||
|
|> Maybe.withDefault DoNothing
|
||||||
in
|
in
|
||||||
makeResult <|
|
makeResult <|
|
||||||
Util.Update.andThen3
|
Util.Update.andThen3
|
||||||
[ update mId key flags texts settings (SearchMenuMsg Comp.SearchMenu.Init)
|
[ update bookmarkId mId key flags texts settings (SearchMenuMsg Comp.SearchMenu.Init)
|
||||||
|
, update bookmarkId mId key flags texts settings setBookmark
|
||||||
, doSearch searchParam
|
, doSearch searchParam
|
||||||
]
|
]
|
||||||
model
|
model
|
||||||
|
|
||||||
|
DoNothing ->
|
||||||
|
UpdateResult model Cmd.none Sub.none Nothing
|
||||||
|
|
||||||
ResetSearch ->
|
ResetSearch ->
|
||||||
let
|
let
|
||||||
nm =
|
nm =
|
||||||
{ model | searchOffset = 0, powerSearchInput = Comp.PowerSearchInput.init }
|
{ model | searchOffset = 0, powerSearchInput = Comp.PowerSearchInput.init }
|
||||||
in
|
in
|
||||||
update mId key flags texts settings (SearchMenuMsg Comp.SearchMenu.ResetForm) nm
|
update bookmarkId mId key flags texts settings (SearchMenuMsg Comp.SearchMenu.ResetForm) nm
|
||||||
|
|
||||||
SearchMenuMsg m ->
|
SearchMenuMsg m ->
|
||||||
let
|
let
|
||||||
@ -103,7 +109,7 @@ update mId key flags texts settings msg model =
|
|||||||
}
|
}
|
||||||
|
|
||||||
result =
|
result =
|
||||||
if nextState.stateChange && not model.searchInProgress then
|
if Debug.log "state" nextState.stateChange && not model.searchInProgress then
|
||||||
doSearch (SearchParam flags BasicSearch settings.itemSearchPageSize 0 False) newModel
|
doSearch (SearchParam flags BasicSearch settings.itemSearchPageSize 0 False) newModel
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -121,7 +127,7 @@ update mId key flags texts settings msg model =
|
|||||||
SetLinkTarget lt ->
|
SetLinkTarget lt ->
|
||||||
case linkTargetMsg lt of
|
case linkTargetMsg lt of
|
||||||
Just m ->
|
Just m ->
|
||||||
update mId key flags texts settings m model
|
update bookmarkId mId key flags texts settings m model
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
makeResult ( model, Cmd.none, Sub.none )
|
makeResult ( model, Cmd.none, Sub.none )
|
||||||
@ -193,7 +199,7 @@ update mId key flags texts settings msg model =
|
|||||||
in
|
in
|
||||||
makeResult <|
|
makeResult <|
|
||||||
Util.Update.andThen3
|
Util.Update.andThen3
|
||||||
[ update mId key flags texts settings (ItemCardListMsg (Comp.ItemCardList.SetResults list))
|
[ update bookmarkId mId key flags texts settings (ItemCardListMsg (Comp.ItemCardList.SetResults list))
|
||||||
, if scroll then
|
, if scroll then
|
||||||
scrollToCard mId
|
scrollToCard mId
|
||||||
|
|
||||||
@ -215,7 +221,7 @@ update mId key flags texts settings msg model =
|
|||||||
, moreAvailable = list.groups /= []
|
, moreAvailable = list.groups /= []
|
||||||
}
|
}
|
||||||
in
|
in
|
||||||
update mId key flags texts settings (ItemCardListMsg (Comp.ItemCardList.AddResults list)) m
|
update bookmarkId mId key flags texts settings (ItemCardListMsg (Comp.ItemCardList.AddResults list)) m
|
||||||
|
|
||||||
ItemSearchAddResp (Err _) ->
|
ItemSearchAddResp (Err _) ->
|
||||||
withSub
|
withSub
|
||||||
@ -319,30 +325,23 @@ update mId key flags texts settings msg model =
|
|||||||
else
|
else
|
||||||
withSub ( model, Cmd.none )
|
withSub ( model, Cmd.none )
|
||||||
|
|
||||||
UpdateThrottle ->
|
|
||||||
let
|
|
||||||
( newThrottle, cmd ) =
|
|
||||||
Throttle.update model.throttle
|
|
||||||
in
|
|
||||||
withSub ( { model | throttle = newThrottle }, cmd )
|
|
||||||
|
|
||||||
SetBasicSearch str ->
|
SetBasicSearch str ->
|
||||||
let
|
let
|
||||||
smMsg =
|
smMsg =
|
||||||
SearchMenuMsg (Comp.SearchMenu.SetTextSearch str)
|
SearchMenuMsg (Comp.SearchMenu.SetTextSearch str)
|
||||||
in
|
in
|
||||||
update mId key flags texts settings smMsg model
|
update bookmarkId mId key flags texts settings smMsg model
|
||||||
|
|
||||||
ToggleSearchType ->
|
ToggleSearchType ->
|
||||||
case model.searchTypeDropdownValue of
|
case model.searchTypeDropdownValue of
|
||||||
BasicSearch ->
|
BasicSearch ->
|
||||||
update mId key flags texts settings (SearchMenuMsg Comp.SearchMenu.SetFulltextSearch) model
|
update bookmarkId mId key flags texts settings (SearchMenuMsg Comp.SearchMenu.SetFulltextSearch) model
|
||||||
|
|
||||||
ContentOnlySearch ->
|
ContentOnlySearch ->
|
||||||
update mId key flags texts settings (SearchMenuMsg Comp.SearchMenu.SetNamesSearch) model
|
update bookmarkId mId key flags texts settings (SearchMenuMsg Comp.SearchMenu.SetNamesSearch) model
|
||||||
|
|
||||||
KeyUpSearchbarMsg (Just Enter) ->
|
KeyUpSearchbarMsg (Just Enter) ->
|
||||||
update mId key flags texts settings (DoSearch model.searchTypeDropdownValue) model
|
update bookmarkId mId key flags texts settings (DoSearch model.searchTypeDropdownValue) model
|
||||||
|
|
||||||
KeyUpSearchbarMsg _ ->
|
KeyUpSearchbarMsg _ ->
|
||||||
withSub ( model, Cmd.none )
|
withSub ( model, Cmd.none )
|
||||||
@ -653,7 +652,8 @@ update mId key flags texts settings msg model =
|
|||||||
{ model | viewMode = nextView }
|
{ model | viewMode = nextView }
|
||||||
in
|
in
|
||||||
if result.outcome == Comp.ItemMerge.OutcomeMerged then
|
if result.outcome == Comp.ItemMerge.OutcomeMerged then
|
||||||
update mId
|
update bookmarkId
|
||||||
|
mId
|
||||||
key
|
key
|
||||||
flags
|
flags
|
||||||
texts
|
texts
|
||||||
@ -733,7 +733,8 @@ update mId key flags texts settings msg model =
|
|||||||
{ model | viewMode = nextView }
|
{ model | viewMode = nextView }
|
||||||
in
|
in
|
||||||
if result.outcome == Comp.PublishItems.OutcomeDone then
|
if result.outcome == Comp.PublishItems.OutcomeDone then
|
||||||
update mId
|
update bookmarkId
|
||||||
|
mId
|
||||||
key
|
key
|
||||||
flags
|
flags
|
||||||
texts
|
texts
|
||||||
@ -853,7 +854,7 @@ update mId key flags texts settings msg model =
|
|||||||
model_ =
|
model_ =
|
||||||
{ model | viewMode = viewMode }
|
{ model | viewMode = viewMode }
|
||||||
in
|
in
|
||||||
update mId key flags texts settings (DoSearch model.lastSearchType) model_
|
update bookmarkId mId key flags texts settings (DoSearch model.lastSearchType) model_
|
||||||
|
|
||||||
SearchStatsResp result ->
|
SearchStatsResp result ->
|
||||||
let
|
let
|
||||||
@ -863,7 +864,7 @@ update mId key flags texts settings msg model =
|
|||||||
stats =
|
stats =
|
||||||
Result.withDefault model.searchStats result
|
Result.withDefault model.searchStats result
|
||||||
in
|
in
|
||||||
update mId key flags texts settings lm { model | searchStats = stats }
|
update bookmarkId mId key flags texts settings lm { model | searchStats = stats }
|
||||||
|
|
||||||
TogglePreviewFullWidth ->
|
TogglePreviewFullWidth ->
|
||||||
let
|
let
|
||||||
@ -905,16 +906,16 @@ update mId key flags texts settings msg model =
|
|||||||
makeResult ( model_, cmd_, Sub.map PowerSearchMsg result.subs )
|
makeResult ( model_, cmd_, Sub.map PowerSearchMsg result.subs )
|
||||||
|
|
||||||
Comp.PowerSearchInput.SubmitSearch ->
|
Comp.PowerSearchInput.SubmitSearch ->
|
||||||
update mId key flags texts settings (DoSearch model_.searchTypeDropdownValue) model_
|
update bookmarkId mId key flags texts settings (DoSearch model_.searchTypeDropdownValue) model_
|
||||||
|
|
||||||
KeyUpPowerSearchbarMsg (Just Enter) ->
|
KeyUpPowerSearchbarMsg (Just Enter) ->
|
||||||
update mId key flags texts settings (DoSearch model.searchTypeDropdownValue) model
|
update bookmarkId mId key flags texts settings (DoSearch model.searchTypeDropdownValue) model
|
||||||
|
|
||||||
KeyUpPowerSearchbarMsg _ ->
|
KeyUpPowerSearchbarMsg _ ->
|
||||||
withSub ( model, Cmd.none )
|
withSub ( model, Cmd.none )
|
||||||
|
|
||||||
RemoveItem id ->
|
RemoveItem id ->
|
||||||
update mId key flags texts settings (ItemCardListMsg (Comp.ItemCardList.RemoveItem id)) model
|
update bookmarkId mId key flags texts settings (ItemCardListMsg (Comp.ItemCardList.RemoveItem id)) model
|
||||||
|
|
||||||
TogglePublishCurrentQueryView ->
|
TogglePublishCurrentQueryView ->
|
||||||
case createQuery model of
|
case createQuery model of
|
||||||
@ -1146,18 +1147,14 @@ doSearch param model =
|
|||||||
|
|
||||||
searchCmd =
|
searchCmd =
|
||||||
doSearchCmd param_ model
|
doSearchCmd param_ model
|
||||||
|
|
||||||
( newThrottle, cmd ) =
|
|
||||||
Throttle.try searchCmd model.throttle
|
|
||||||
in
|
in
|
||||||
withSub
|
withSub
|
||||||
( { model
|
( { model
|
||||||
| searchInProgress = cmd /= Cmd.none
|
| searchInProgress = True
|
||||||
, searchOffset = 0
|
, searchOffset = 0
|
||||||
, throttle = newThrottle
|
|
||||||
, lastSearchType = param.searchType
|
, lastSearchType = param.searchType
|
||||||
}
|
}
|
||||||
, cmd
|
, searchCmd
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -1190,9 +1187,7 @@ withSub ( m, c ) =
|
|||||||
makeResult
|
makeResult
|
||||||
( m
|
( m
|
||||||
, c
|
, c
|
||||||
, Throttle.ifNeeded
|
, Sub.none
|
||||||
(Time.every 500 (\_ -> UpdateThrottle))
|
|
||||||
m.throttle
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ renderSuccessMsg texts public model =
|
|||||||
[ text texts.successBox.line1
|
[ text texts.successBox.line1
|
||||||
, a
|
, a
|
||||||
[ class S.successMessageLink
|
[ class S.successMessageLink
|
||||||
, Page.href SearchPage
|
, Page.href (SearchPage Nothing)
|
||||||
]
|
]
|
||||||
[ text texts.successBox.itemsPage
|
[ text texts.successBox.itemsPage
|
||||||
]
|
]
|
||||||
|
Reference in New Issue
Block a user