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