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
bab9f124
Commit
bab9f124
authored
Aug 25, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[search] some refactorings for search input box
parent
39a3fdef
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
51 deletions
+84
-51
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+45
-24
Components.purs
src/Gargantext/Components/NgramsTable/Components.purs
+39
-27
No files found.
src/Gargantext/Components/NgramsTable.purs
View file @
bab9f124
...
@@ -273,6 +273,33 @@ loadedNgramsTable :: R2.Component PropsNoReload
...
@@ -273,6 +273,33 @@ loadedNgramsTable :: R2.Component PropsNoReload
loadedNgramsTable = R.createElement loadedNgramsTableCpt
loadedNgramsTable = R.createElement loadedNgramsTableCpt
loadedNgramsTableCpt :: R.Component PropsNoReload
loadedNgramsTableCpt :: R.Component PropsNoReload
loadedNgramsTableCpt = here.component "loadedNgramsTable" cpt where
loadedNgramsTableCpt = here.component "loadedNgramsTable" cpt where
cpt props@{ path } _ = do
searchQuery <- T.useFocused (_.searchQuery) (\a b -> b { searchQuery = a }) path
pure $ R.fragment $
[ loadedNgramsTableHeader { searchQuery } []
, loadedNgramsTableBody props [] ]
type LoadedNgramsTableHeaderProps =
( searchQuery :: T.Box SearchQuery )
loadedNgramsTableHeader :: R2.Component LoadedNgramsTableHeaderProps
loadedNgramsTableHeader = R.createElement loadedNgramsTableHeaderCpt
loadedNgramsTableHeaderCpt :: R.Component LoadedNgramsTableHeaderProps
loadedNgramsTableHeaderCpt = here.component "loadedNgramsTableHeader" cpt where
cpt { searchQuery } _ = do
pure $ R.fragment
[ H.h4 {style: {textAlign : "center"}}
[ H.span {className: "fa fa-hand-o-down"} []
, H.text "Extracted Terms" ]
, NTC.searchInput { key: "search-input"
, searchQuery }
]
loadedNgramsTableBody :: R2.Component PropsNoReload
loadedNgramsTableBody = R.createElement loadedNgramsTableBodyCpt
loadedNgramsTableBodyCpt :: R.Component PropsNoReload
loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where
cpt { afterSync
cpt { afterSync
, boxes: { errors
, boxes: { errors
, tasks }
, tasks }
...
@@ -370,14 +397,8 @@ loadedNgramsTableCpt = here.component "loadedNgramsTable" cpt where
...
@@ -370,14 +397,8 @@ loadedNgramsTableCpt = here.component "loadedNgramsTable" cpt where
<<< _Just
<<< _Just
) =<< ngramsParent
) =<< ngramsParent
pure $ R.fragment $
pure $ R.fragment
autoUpdate path' <>
[ TT.table
[ H.h4 {style: {textAlign : "center"}}
[ H.span {className: "fa fa-hand-o-down"} []
, H.text "Extracted Terms" ]
, NTC.searchInput { key: "search-input"
, searchQuery }
, TT.table
{ colNames
{ colNames
, container: tableContainer
, container: tableContainer
{ dispatch: performAction
{ dispatch: performAction
...
...
src/Gargantext/Components/NgramsTable/Components.purs
View file @
bab9f124
...
@@ -25,7 +25,6 @@ import Gargantext.Components.NgramsTable.Core
...
@@ -25,7 +25,6 @@ import Gargantext.Components.NgramsTable.Core
( Action(..), Dispatch, NgramsElement, NgramsTable, NgramsTablePatch, NgramsTerm
( Action(..), Dispatch, NgramsElement, NgramsTable, NgramsTablePatch, NgramsTerm
, _NgramsElement, _NgramsRepoElement, _PatchMap, _children, _list
, _NgramsElement, _NgramsRepoElement, _PatchMap, _children, _list
, _ngrams, _occurrences, ngramsTermText, replace, setTermListA )
, _ngrams, _occurrences, ngramsTermText, replace, setTermListA )
import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table as Tbl
import Gargantext.Components.Table as Tbl
import Gargantext.Types as T
import Gargantext.Types as T
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
...
@@ -38,38 +37,51 @@ type SearchInputProps =
...
@@ -38,38 +37,51 @@ type SearchInputProps =
, searchQuery :: T.Box String
, searchQuery :: T.Box String
)
)
searchInput :: R
ecord SearchInputProps -> R.Element
searchInput :: R
2.Leaf SearchInputProps
searchInput props = R.createElement searchInputCpt props []
searchInput props = R.createElement searchInputCpt props []
searchInputCpt :: R.Component SearchInputProps
searchInputCpt :: R.Component SearchInputProps
searchInputCpt = here.component "searchInput" cpt
searchInputCpt = here.component "searchInput" cpt
where
where
cpt { searchQuery } _ = do
cpt { searchQuery } _ = do
searchQuery' <- T.useLive T.unequal searchQuery
pure $ R2.row [
pure $ R2.row [
H.div { className: "col-12" } [
H.div { className: "col-12" } [
H.div { className: "input-group" }
H.div { className: "input-group" }
[ searchButton
searchQuery'
[ searchButton
{ searchQuery } []
,
fieldInput searchQuery'
,
searchFieldInput { searchQuery } []
]
]
]
]
]
]
where
searchButton searchQuery' =
type SearchButtonProps =
H.div { className: "input-group-prepend" }
( searchQuery :: T.Box String
)
searchButton :: R2.Component SearchButtonProps
searchButton = R.createElement searchButtonCpt
searchButtonCpt :: R.Component SearchButtonProps
searchButtonCpt = here.component "searchButton" cpt where
cpt { searchQuery } _ = do
searchQuery' <- T.useLive T.unequal searchQuery
pure $ H.div { className: "input-group-prepend" }
[ if searchQuery' /= ""
[ if searchQuery' /= ""
then removeButton
then
else H.span { className: "fa fa-search input-group-text" } []
]
removeButton =
H.button { className: "btn btn-danger"
H.button { className: "btn btn-danger"
, on: {click: \e
-> T.write "" searchQuery}}
, on: {click: \_
-> T.write "" searchQuery}}
[ H.span {className: "fa fa-times"} []]
[ H.span {className: "fa fa-times"} []]
else H.span { className: "fa fa-search input-group-text" } []
]
type SearchFieldInputProps =
( searchQuery :: T.Box String
)
fieldInput searchQuery' =
searchFieldInput :: R2.Component SearchFieldInputProps
H.input { className: "form-control"
searchFieldInput = R.createElement searchFieldInputCpt
, defaultValue: searchQuery'
searchFieldInputCpt :: R.Component SearchFieldInputProps
searchFieldInputCpt = here.component "searchFieldInput" cpt where
cpt { searchQuery } _ = do
pure $ H.input { className: "form-control"
, name: "search"
, name: "search"
, on: { input: \e -> T.write (R.unsafeEventValue e) searchQuery }
, on: { input: \e -> T.write (R.unsafeEventValue e) searchQuery }
, placeholder: "Search"
, placeholder: "Search"
...
...
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