Skip to content

Commit

Permalink
preserve propertybox table when switching things, #422
Browse files Browse the repository at this point in the history
  • Loading branch information
myrho committed Dec 11, 2023
1 parent c5ddf11 commit 5912cd3
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/Init/Graph.elm
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import Init.Graph.Transform as Transform
import IntDict
import Model.Graph exposing (..)
import Model.Graph.Tool exposing (Toolbox(..))
import Route.Graph


init : UserSettings -> Int -> Model
init us now =
{ config = Config.init us.addressLabel us.edgeLabel us.showClusterShadowLinks us.showAddressShadowLinks us.showDatesInUserLocale us.showZeroValueTxs
, layers = IntDict.empty
, route = Route.Graph.rootRoute
, browser = Browser.init now
, adding = Adding.init
, dragging = NoDragging
Expand Down
2 changes: 2 additions & 0 deletions src/Model/Graph.elm
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ import Model.Graph.Search as Search
import Model.Graph.Tag as Tag
import Model.Graph.Tool as Tool
import Model.Graph.Transform as Transform
import Route.Graph


type alias Model =
{ config : Config
, layers : IntDict Layer
, route : Route.Graph.Route
, browser : Browser.Model
, adding : Adding.Model
, dragging : Dragging
Expand Down
36 changes: 36 additions & 0 deletions src/Route/Graph.elm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ module Route.Graph exposing
, blockRoute
, entityRoute
, entitylinkRoute
, getAddressTable
, getAddresslinkTable
, getEntityTable
, labelRoute
, parser
, pluginRoute
Expand Down Expand Up @@ -579,3 +582,36 @@ thing =
|> P.questionMark (Q.string tableQuery |> Q.map (Maybe.andThen stringToAddresslinkTable))
|> map Entitylink
]


getAddressTable : Route -> Maybe AddressTable
getAddressTable route =
case route of
Currency _ (Address _ table _) ->
table

_ ->
Nothing


getEntityTable : Route -> Maybe EntityTable
getEntityTable route =
case route of
Currency _ (Entity _ table _) ->
table

_ ->
Nothing


getAddresslinkTable : Route -> Maybe AddresslinkTable
getAddresslinkTable route =
case route of
Currency _ (Entitylink _ _ _ _ table) ->
table

Currency _ (Addresslink _ _ _ _ table) ->
table

_ ->
Nothing
14 changes: 9 additions & 5 deletions src/Update/Graph.elm
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ updateByMsg plugins uc msg model =
Route.addressRoute
{ currency = Id.currency id
, address = Id.addressId id
, table = Nothing
, table = Route.getAddressTable model.route
, layer = Id.layer id |> Just
}
|> NavPushRouteEffect
Expand Down Expand Up @@ -575,7 +575,7 @@ updateByMsg plugins uc msg model =
, Route.entityRoute
{ currency = Id.currency id
, entity = Id.entityId id
, table = Nothing
, table = Route.getEntityTable model.route
, layer = Id.layer id |> Just
}
|> NavPushRouteEffect
Expand Down Expand Up @@ -644,7 +644,7 @@ updateByMsg plugins uc msg model =
, srcLayer = first id |> Id.layer
, dst = second id |> Id.entityId
, dstLayer = second id |> Id.layer
, table = Nothing
, table = Route.getAddresslinkTable model.route
}
|> NavPushRouteEffect
|> List.singleton
Expand Down Expand Up @@ -672,7 +672,7 @@ updateByMsg plugins uc msg model =
, srcLayer = first id |> Id.layer
, dst = second id |> Id.addressId
, dstLayer = second id |> Id.layer
, table = Nothing
, table = Route.getAddresslinkTable model.route
}
|> NavPushRouteEffect
|> List.singleton
Expand Down Expand Up @@ -2407,7 +2407,11 @@ hideContextmenu model =


updateByRoute : Plugins -> Route.Route -> Model -> ( Model, List Effect )
updateByRoute plugins route model =
updateByRoute plugins route mo =
let
model =
{ mo | route = route }
in
case route |> Log.log "route" of
Route.Root ->
deselect model
Expand Down

0 comments on commit 5912cd3

Please sign in to comment.