Skip to content

Commit

Permalink
fix search
Browse files Browse the repository at this point in the history
  • Loading branch information
soad003 committed Apr 11, 2024
1 parent f0dddc3 commit 27e46d5
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 10 deletions.
7 changes: 7 additions & 0 deletions src/Effect.elm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Effect.Search as Search
import Http
import Model exposing (Effect(..), Msg(..))
import Msg.Graph as Graph
import Msg.Pathfinder as Pathfinder
import Msg.Search as Search
import Plugin.Effects as Plugin exposing (Plugins)
import Ports
Expand Down Expand Up @@ -89,6 +90,12 @@ perform plugins key statusbarToken apiKey effect =
cmd
|> Cmd.map PathfinderMsg

Pathfinder.SearchEffect e ->
handleSearchEffect apiKey
Nothing
(Pathfinder.SearchMsg >> PathfinderMsg)
e

GraphEffect eff ->
case eff of
Graph.ApiEffect apiEff ->
Expand Down
6 changes: 6 additions & 0 deletions src/Effect/Pathfinder.elm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Effect.Pathfinder exposing (..)

import Effect.Api as Api
import Effect.Search as Search
import Msg.Pathfinder exposing (Msg(..))
import Plugin.Msg as Plugin
import Route.Pathfinder exposing (Route)
Expand All @@ -11,6 +12,7 @@ type Effect
| PluginEffect (Cmd Plugin.Msg)
| ApiEffect (Api.Effect Msg)
| CmdEffect (Cmd Msg)
| SearchEffect Search.Effect


perform : Effect -> Cmd Msg
Expand All @@ -30,3 +32,7 @@ perform eff =
-- managed in Effect.elm
ApiEffect _ ->
Cmd.none

-- managed in Effect.elm
SearchEffect _ ->
Cmd.none
11 changes: 11 additions & 0 deletions src/Update.elm
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ update plugins uc msg model =
updateByUrl plugins uc url model

BrowserGotStatistics stats ->
let
pf =
model.pathfinder

pfs =
pf.search

up =
{ pf | search = { pfs | searchType = Search.initSearchAll (Just stats) } }
in
updateByUrl plugins
uc
model.url
Expand All @@ -92,6 +102,7 @@ update plugins uc msg model =
model.search
|> s_searchType
(Search.initSearchAll (Just stats))
, pathfinder = up
}

BrowserGotEntityTaxonomy concepts ->
Expand Down
24 changes: 20 additions & 4 deletions src/Update/Pathfinder.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Update.Pathfinder exposing (update)

import Config.Update as Update
import Effect exposing (n)
import Effect.Pathfinder exposing (Effect(..))
import Effect.Pathfinder as Pathfinder exposing (Effect(..))
import Init.Pathfinder
import Log
import Model.Graph exposing (Dragging(..))
Expand All @@ -11,12 +11,15 @@ import Model.Graph.Transform as Transform
import Model.Locale exposing (State(..))
import Model.Pathfinder exposing (..)
import Model.Pathfinder.History.Entry as Entry
import Model.Search as Search
import Msg.Pathfinder as Msg exposing (Msg(..))
import Msg.Search as Search
import Plugin.Update as Plugin exposing (Plugins)
import Route.Pathfinder as Route
import Update.Graph exposing (draggingToClick)
import Update.Graph.History as History
import Update.Graph.Transform as Transform
import Update.Search as Search
import Util.Pathfinder.History as History


Expand All @@ -37,9 +40,21 @@ updateByMsg plugins uc msg model =
NoOp ->
n model

-- TODO: Implement
SearchMsg _ ->
n model
SearchMsg m ->
let
( search, eff ) =
case m of
Search.UserClicksResultLine ->
Search.update m model.search

_ ->
Search.update m model.search
in
( { model
| search = search
}
, List.map Pathfinder.SearchEffect eff
)

UserClosedDetailsView ->
n (closeDetailsView model)
Expand All @@ -53,6 +68,7 @@ updateByMsg plugins uc msg model =
UserClickedRestart ->
n Init.Pathfinder.init

-- TODO: Implement
UserClickedUndo ->
n model

Expand Down
3 changes: 3 additions & 0 deletions src/Update/Statusbar.elm
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ messageFromEffect model effect =
Model.PathfinderEffect (Pathfinder.NavPushRouteEffect _) ->
Nothing

Model.PathfinderEffect (Pathfinder.SearchEffect _) ->
Nothing


isOutgoingToString : Bool -> String
isOutgoingToString isOutgoing =
Expand Down
7 changes: 1 addition & 6 deletions src/View/Pathfinder.elm
Original file line number Diff line number Diff line change
Expand Up @@ -415,12 +415,7 @@ inOutIndicator : Maybe Int -> Int -> Int -> Html Msg
inOutIndicator mnr inNr outNr =
let
prefix =
case mnr of
Just nr ->
String.join " " [ String.fromInt nr, "(" ]

Nothing ->
"("
String.trim (String.join " " [ mnr |> Maybe.map String.fromInt |> Maybe.withDefault "", "(" ])
in
span [ [ Css.ch 0.5 |> Css.paddingLeft ] |> HA.css ] [ Html.text prefix, inIcon, Html.text (String.fromInt inNr), Html.text ",", outIcon, Html.text (String.fromInt outNr), Html.text ")" ]

Expand Down

0 comments on commit 27e46d5

Please sign in to comment.