Commit 072a6f12 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge remote-tracking branch 'origin/dev-fix-for-nolist-serialization' into dev

parents 6b0b6e02 4c728d8c
...@@ -147,9 +147,9 @@ actionWriteNodesDocumentsWithLangsCpt = here.component "actionWriteNodesDocument ...@@ -147,9 +147,9 @@ actionWriteNodesDocumentsWithLangsCpt = here.component "actionWriteNodesDocument
type Params = type Params =
( id :: GT.ID ( id :: GT.ID
, selection :: ListSelection.Selection
, lang :: Lang , lang :: Lang
, paragraphs :: String , paragraphs :: String
, selection :: ListSelection.Selection
) )
documentsFromWriteNodesReq :: Session -> Record Params -> AffRESTError GT.AsyncTaskWithType documentsFromWriteNodesReq :: Session -> Record Params -> AffRESTError GT.AsyncTaskWithType
......
...@@ -9,24 +9,29 @@ import Data.Newtype (class Newtype) ...@@ -9,24 +9,29 @@ import Data.Newtype (class Newtype)
import Gargantext.Types (ID, ListId, NodeType) import Gargantext.Types (ID, ListId, NodeType)
import Simple.JSON as JSON import Simple.JSON as JSON
data Selection = MyListsFirst | OtherListsFirst | SelectedLists (Array ListId) | NoList
data Selection =
MyListsFirst
| OtherListsFirst
| SelectedLists (Array ListId)
| NoList
derive instance Generic Selection _ derive instance Generic Selection _
instance Show Selection where instance Show Selection where
show MyListsFirst = "My lists first" show MyListsFirst = "My lists first"
show OtherListsFirst = "Other lists first" show OtherListsFirst = "Other lists first"
show NoList = "NoList" show NoList = "NoList"
show (SelectedLists _) = "Selected lists" show (SelectedLists _) = "Selected lists"
instance Eq Selection where eq = genericEq instance Eq Selection where eq = genericEq
instance Read Selection where instance Read Selection where
read "My lists first" = Just MyListsFirst read "My lists first" = Just MyListsFirst
read "Other lists first" = Just OtherListsFirst read "Other lists first" = Just OtherListsFirst
read "Selected lists" = Just $ SelectedLists [] read "Selected lists" = Just $ SelectedLists []
read "NoList" = Just NoList read "NoList" = Just NoList
read _ = Nothing read _ = Nothing
instance JSON.WriteForeign Selection where instance JSON.WriteForeign Selection where
writeImpl MyListsFirst = JSON.writeImpl { "type": "MyListsFirst" } writeImpl MyListsFirst = JSON.writeImpl { "type": "MyListsFirst" }
writeImpl NoList = JSON.writeImpl { "type": "NoList" } writeImpl NoList = JSON.writeImpl { "type": "NoList", "makeList": true }
writeImpl OtherListsFirst = JSON.writeImpl { "type": "OtherListsFirst" } writeImpl OtherListsFirst = JSON.writeImpl { "type": "OtherListsFirst" }
writeImpl (SelectedLists ids) = JSON.writeImpl { "type": "SelectedLists", value: ids } writeImpl (SelectedLists ids) = JSON.writeImpl { "type": "SelectedLists", value: ids }
selectedListIds :: Selection -> Array ListId selectedListIds :: Selection -> Array ListId
......
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