Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
24be1255
Commit
24be1255
authored
Feb 06, 2022
by
Karen Konou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Corpus header] conect field reneaming to backend
parent
b2e461e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
22 deletions
+102
-22
Types.purs
src/Gargantext/Components/Nodes/Corpus/Types.purs
+20
-0
Table.purs
src/Gargantext/Components/Table.purs
+82
-22
No files found.
src/Gargantext/Components/Nodes/Corpus/Types.purs
View file @
24be1255
...
...
@@ -56,3 +56,23 @@ getCorpusInfo (FTFieldList as) = case List.head (List.filter isJSON as) of
, authors:""
, totalRecords: 0
}
saveCorpusInfo :: CorpusInfo -> FTFieldList -> FTFieldList
saveCorpusInfo (CorpusInfo i) (FTFieldList fields) =
FTFieldList $ List.snoc (List.filter (not isJSON) fields) (Field {name: oName, typ: JSON { authors: i.authors
, desc: i.desc
, query: i.query
, title: i.title
, tag: oTag
}})
where
oName = case o of
Just (Field {name}) -> name
_ -> ""
oTag = case o of
Just (Field {typ: JSON {tag}}) -> tag
_ -> ""
o = List.head (List.filter isJSON fields)
src/Gargantext/Components/Table.purs
View file @
24be1255
...
...
@@ -3,12 +3,17 @@ module Gargantext.Components.Table where
import Gargantext.Prelude
import Data.Array as A
import Data.Either (Either(..))
import Data.Maybe (Maybe(..))
import Data.Sequence as Seq
import Effect (Effect)
import Effect.Aff (launchAff_)
import Effect.Class (liftEffect)
import Gargantext.Components.FolderView as FV
import Gargantext.Components.Nodes.Corpus.Types (CorpusInfo(..), Hyperdata(..), getCorpusInfo)
import Gargantext.Components.Nodes.Corpus (saveCorpus)
import Gargantext.Components.Nodes.Corpus.Types (CorpusInfo(..), Hyperdata(..), getCorpusInfo, saveCorpusInfo)
import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Nodes.Types (FTFieldList)
import Gargantext.Components.Renameable (renameable)
import Gargantext.Components.Search (SearchType(..))
import Gargantext.Components.Table.Types (ColumnName, OrderBy, OrderByDirection(..), Params, Props, TableContainerProps, columnName)
...
...
@@ -55,12 +60,22 @@ type TableHeaderLayoutProps = (
)
type TableHeaderWithRenameLayoutProps = (
cacheState :: T.Box NT.CacheState
, session :: Session
, hyperdata :: Hyperdata
, nodeId :: NodeID
, date :: String
, key :: String
cacheState :: T.Box NT.CacheState
, session :: Session
, hyperdata :: Hyperdata
, nodeId :: NodeID
, date :: String
, key :: String
)
type TableHeaderWithRenameBoxedLayoutProps = (
cacheState :: T.Box NT.CacheState
, session :: Session
, hyperdata :: Hyperdata
, nodeId :: NodeID
, date :: String
, key :: String
, corpusInfoS :: T.Box CorpusInfo
)
initialParams :: Params
...
...
@@ -73,15 +88,27 @@ tableHeaderWithRenameLayout = R.createElement tableHeaderWithRenameLayoutCpt
tableHeaderWithRenameLayoutCpt :: R.Component TableHeaderWithRenameLayoutProps
tableHeaderWithRenameLayoutCpt = here.component "tableHeaderWithRenameLayoutCpt" cpt
where
cpt { hyperdata: Hyperdata h, nodeId, session, cacheState, date } _ = do
cpt { hyperdata: Hyperdata h, nodeId, session, cacheState, date, key } _ = do
let corpusInfo = getCorpusInfo h.fields
corpusInfoS <- T.useBox corpusInfo
pure $ tableHeaderWithRenameBoxedLayout {hyperdata: Hyperdata h, nodeId, session, cacheState, date, corpusInfoS, key} []
tableHeaderWithRenameBoxedLayout :: R2.Component TableHeaderWithRenameBoxedLayoutProps
tableHeaderWithRenameBoxedLayout = R.createElement tableHeaderWithRenameBoxedLayoutCpt
tableHeaderWithRenameBoxedLayoutCpt :: R.Component TableHeaderWithRenameBoxedLayoutProps
tableHeaderWithRenameBoxedLayoutCpt = here.component "tableHeaderWithRenameBoxedLayoutCpt" cpt
where
cpt { hyperdata: Hyperdata h, nodeId, session, cacheState, date, corpusInfoS} _ = do
cacheState' <- T.useLive T.unequal cacheState
let CorpusInfo { authors, desc, query, title} = getCorpusInfo h.fields
CorpusInfo {title, desc, query, authors} <- T.read corpusInfoS
pure $ R.fragment
[ R2.row [FV.backButton {} []]
,
R2.row
[ H.div {className: "col-md-3"} [ H.h3 {} [renameable {text: title, onRename: onRename
Dummy
} []] ]
[ H.div {className: "col-md-3"} [ H.h3 {} [renameable {text: title, onRename: onRename
Title
} []] ]
, H.div {className: "col-md-9"}
[ H.hr {style: {height: "2px", backgroundColor: "black"}} ]
]
...
...
@@ -89,11 +116,11 @@ tableHeaderWithRenameLayoutCpt = here.component "tableHeaderWithRenameLayoutCpt"
[ H.div {className: "col-md-8 content"}
[ H.p {}
[ H.span {className: "fa fa-globe"} []
, renameable {text: " " <> desc, onRename: onRenameD
ummy
} []
, renameable {text: " " <> desc, onRename: onRenameD
esc
} []
]
, H.p {}
[ H.span {className: "fa fa-search-plus"} []
, renameable {text: " " <> query, onRename: onRename
Dumm
y} []
, renameable {text: " " <> query, onRename: onRename
Quer
y} []
]
, H.p { className: "cache-toggle"
, on: { click: cacheClick cacheState } }
...
...
@@ -103,16 +130,41 @@ tableHeaderWithRenameLayoutCpt = here.component "tableHeaderWithRenameLayoutCpt"
]
, H.div {className: "col-md-4 content"}
[ H.p {}
[ H.span {className: "fa fa-
calenda
r"} []
, renameable {text: " " <>
date, onRename: onRenameDummy
} []
[ H.span {className: "fa fa-
use
r"} []
, renameable {text: " " <>
authors, onRename: onRenameAuthors
} []
]
, H.p {}
[ H.span {className: "fa fa-
use
r"} []
,
renameable {text: " " <> authors, onRename: onRenameDummy} []
[ H.span {className: "fa fa-
calenda
r"} []
,
H.text $ " " <> date
]
]
]
]
where
onRenameTitle newTitle = do
_ <- T.modify (\(CorpusInfo c) -> CorpusInfo $ c {title = newTitle}) corpusInfoS
corpusInfo <- T.read corpusInfoS
let newFields = saveCorpusInfo corpusInfo h.fields
save {fields: newFields, session, nodeId}
onRenameDesc newDesc = do
_ <- T.modify (\(CorpusInfo c) -> CorpusInfo $ c {desc = newDesc}) corpusInfoS
corpusInfo <- T.read corpusInfoS
let newFields = saveCorpusInfo corpusInfo h.fields
save {fields: newFields, session, nodeId}
onRenameQuery newQuery = do
_ <- T.modify (\(CorpusInfo c) -> CorpusInfo $ c {query = newQuery}) corpusInfoS
corpusInfo <- T.read corpusInfoS
let newFields = saveCorpusInfo corpusInfo h.fields
save {fields: newFields, session, nodeId}
onRenameAuthors newAuthors = do
_ <- T.modify (\(CorpusInfo c) -> CorpusInfo $ c {authors = newAuthors}) corpusInfoS
corpusInfo <- T.read corpusInfoS
let newFields = saveCorpusInfo corpusInfo h.fields
save {fields: newFields, session, nodeId}
cacheToggle NT.CacheOn = "fa-toggle-on"
cacheToggle NT.CacheOff = "fa-toggle-off"
...
...
@@ -126,8 +178,16 @@ tableHeaderWithRenameLayoutCpt = here.component "tableHeaderWithRenameLayoutCpt"
cacheStateToggle NT.CacheOn = NT.CacheOff
cacheStateToggle NT.CacheOff = NT.CacheOn
onRenameDummy _ = do
pure unit
save :: {fields :: FTFieldList, session :: Session, nodeId :: Int} -> Effect Unit
save {fields, session, nodeId} = do
launchAff_ do
res <- saveCorpus $ {hyperdata: Hyperdata {fields}, session, nodeId}
liftEffect $ do
_ <- case res of
Left err -> here.log2 "[corpusLayoutView] onClickSave RESTError" err
_ -> pure unit
pure unit
tableHeaderLayout :: R2.Component TableHeaderLayoutProps
tableHeaderLayout = R.createElement tableHeaderLayoutCpt
...
...
@@ -163,13 +223,13 @@ tableHeaderLayoutCpt = here.component "tableHeaderLayout" cpt
]
, H.div {className: "col-md-4 content"}
[ H.p {}
[ H.span {className: "fa fa-calendar"} []
, H.text $ " " <> date
]
, H.p {}
[ H.span {className: "fa fa-user"} []
, H.text $ " " <> user
]
, H.p {}
[ H.span {className: "fa fa-calendar"} []
, H.text $ " " <> date
]
]
]
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment