Commit 5302939d authored by arturo's avatar arturo

>>> continue: sync task XHR

parent c024c3b6
Pipeline #2003 failed with stage
......@@ -3,6 +3,7 @@ module Gargantext.Components.DocsTable where
import Gargantext.Prelude
import DOM.Simple.Console (log2)
import DOM.Simple.Event as DE
import Data.Array as A
import Data.Either (Either)
......@@ -28,7 +29,7 @@ import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ComponentStatus(..))
import Gargantext.Components.Category (rating)
import Gargantext.Components.Category.Types (Star(..))
import Gargantext.Components.DocsTable.DocumentFormCreation (documentFormCreation)
import Gargantext.Components.DocsTable.DocumentFormCreation as DFC
import Gargantext.Components.DocsTable.Types (DocumentsView(..), Hyperdata(..), LocalUserScore, Query, Response(..), Year, sampleData)
import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Nodes.Texts.Types as TextsT
......@@ -148,11 +149,21 @@ docViewCpt = here.component "docView" cpt where
-- @WIP: remote business for document creation
createDocumentCallback <- pure $ \fdata -> launchAff_ do
liftEffect $ T.write_ true onDocumentCreationPendingBox
-- liftEffect $ T.write_ true onDocumentCreationPendingBox
delay $ Milliseconds 2000.0
-- delay $ Milliseconds 2000.0
-- liftEffect $ T.write_ false onDocumentCreationPendingBox
liftEffect $
T.write_ true onDocumentCreationPendingBox
res <- DFC.create session nodeId fdata
liftEffect do
log2 "RESULT" res
T.write_ false onDocumentCreationPendingBox
liftEffect $ T.write_ false onDocumentCreationPendingBox
-- Render
pure $
......@@ -203,7 +214,7 @@ docViewCpt = here.component "docView" cpt where
, hasCollapsibleBackground: false
}
[
documentFormCreation
DFC.documentFormCreation
{ callback: createDocumentCallback
, status: onDocumentCreationPending ? Deferred $ Enabled
}
......
module Gargantext.Components.DocsTable.DocumentFormCreation
( documentFormCreation
, FormData
, create
) where
import Gargantext.Prelude
......@@ -9,11 +10,16 @@ import DOM.Simple.Console (log3)
import Data.Either (Either(..))
import Data.Foldable (foldl, intercalate)
import Effect (Effect)
import Effect.Aff (Aff)
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ComponentStatus(..))
import Gargantext.Config.REST (RESTError)
import Gargantext.Hooks.FormValidation (VForm, useFormValidation)
import Gargantext.Hooks.FormValidation.Unboxed as FV
import Gargantext.Hooks.StateRecord (useStateRecord)
import Gargantext.Routes as GR
import Gargantext.Sessions (Session, post)
import Gargantext.Types as GT
import Gargantext.Utils (nbsp, (?))
import Gargantext.Utils.Reactix as R2
import Reactix as R
......@@ -197,3 +203,13 @@ documentFormValidation r = foldl append mempty rules
, FV.nonEmpty "source" r.source
, FV.nonEmpty "authors" r.authors
]
---------------------------------------------------
create ::
Session
-> GT.ID
-> Record FormData
-> Aff (Either RESTError GT.ID)
create session id = post session $ GR.NodeDocument id
......@@ -195,7 +195,8 @@ sessionPath (R.ChartHash { chartType, listId, tabType } i) =
<> "&listType=" <> show MapTerm -- listId
<> defaultListAddMaybe listId
-- sessionPath (R.NodeAPI (NodeContact s a i) i) = sessionPath $ "annuaire/" <> show a <> "/contact/" <> show i
sessionPath (R.NodeAPI Phylo pId p) = "phyloscape?nodeId=" <> (show $ fromMaybe 0 pId) <> p
sessionPath (R.NodeDocument id) = "node/" <> (show id) <> "/document/upload/async"
------- misc routing stuff
......
......@@ -57,6 +57,7 @@ data SessionRoute
| CorpusMetricsHash { listId :: ListId, tabType :: TabType } (Maybe Id)
| Chart ChartOpts (Maybe Id)
| ChartHash { chartType :: ChartType, listId :: Maybe ListId, tabType :: TabType } (Maybe Id)
| NodeDocument Id
-- | AnnuaireContact AnnuaireId DocId
instance Show AppRoute where
......
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