Commit 19dc7dd2 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[dashboard] fix for the parentId decoding

parent da2abe0f
...@@ -56,7 +56,7 @@ dashboardLayoutWithKeyCpt = here.component "dashboardLayoutWithKey" cpt ...@@ -56,7 +56,7 @@ dashboardLayoutWithKeyCpt = here.component "dashboardLayoutWithKey" cpt
reload' <- T.useLive T.unequal reload reload' <- T.useLive T.unequal reload
useLoader {nodeId, reload: reload', session} DT.loadDashboardWithReload $ useLoader {nodeId, reload: reload', session} DT.loadDashboardWithReload $
\dashboardData@{hyperdata: DT.Hyperdata h, parentId} -> do \(DT.DashboardData dashboardData@{hyperdata: DT.Hyperdata h, parentId}) -> do
let { charts, fields } = h let { charts, fields } = h
dashboardLayoutLoaded { charts dashboardLayoutLoaded { charts
, corpusId: parentId , corpusId: parentId
......
...@@ -18,8 +18,8 @@ type Preferences = Maybe String ...@@ -18,8 +18,8 @@ type Preferences = Maybe String
newtype Hyperdata = newtype Hyperdata =
Hyperdata Hyperdata
{ charts :: Array P.PredefinedChart { charts :: Array P.PredefinedChart
, fields :: List.List FTField , fields :: List.List FTField
, preferences :: Preferences , preferences :: Preferences
} }
derive instance genericHyperdata :: Generic Hyperdata _ derive instance genericHyperdata :: Generic Hyperdata _
...@@ -56,8 +56,26 @@ saveDashboard {hyperdata, nodeId, session} = do ...@@ -56,8 +56,26 @@ saveDashboard {hyperdata, nodeId, session} = do
id_ <- (put session (NodeAPI Node (Just nodeId) "") hyperdata) :: Aff Int id_ <- (put session (NodeAPI Node (Just nodeId) "") hyperdata) :: Aff Int
pure unit pure unit
type DashboardData = newtype DashboardData =
{ id :: Int DashboardData
{ id :: Int
, hyperdata :: Hyperdata , hyperdata :: Hyperdata
, parentId :: Int , parentId :: Int
} }
derive instance genericDashboardData :: Generic DashboardData _
instance eqDashboardData :: Eq DashboardData where
eq = genericEq
instance decodeDashboardData :: DecodeJson DashboardData where
decodeJson json = do
obj <- decodeJson json
id <- obj .: "id"
hyperdata <- obj .: "hyperdata"
parentId <- obj .: "parent_id"
pure $ DashboardData { id, hyperdata, parentId }
instance encodeDashboardData :: EncodeJson DashboardData where
encodeJson (DashboardData { id, hyperdata, parentId }) = do
"id" := id
~> "hyperdata" := hyperdata
~> "parent_id" := parentId
~> jsonEmptyObject
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment