Commit 9c72ed97 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'dev' into testing

parents a28f0a42 cec8c0ec
Pipeline #5920 failed with stage
in 0 seconds
{
"name": "Gargantext",
"version": "0.0.6.9.9.9.6.7.1",
"version": "0.0.6.9.9.9.8.1",
"scripts": {
"generate-purs-packages-nix": "./nix/generate-purs-packages.nix",
"generate-psc-packages-nix": "./nix/generate-packages-json.bash",
......
......@@ -6,8 +6,16 @@
* @param {string} querySelector
* @unpure {Object} window.$
*/
export function _show(window, querySelector) {
window.$(querySelector).modal('show');
export function _show(window, querySelector, events) {
let $modal = window.$(querySelector);
$modal.modal('show');
console.log('events', events);
if(events.onHide) {
$modal.on('hidden.bs.modal', events.onHide());
}
if(events.onShow) {
$modal.on('shown.bs.modal', events.onShow());
}
}
/**
* @function hide
......
......@@ -10,7 +10,7 @@ import Data.Foldable (intercalate)
import Data.Maybe (Maybe(..))
import Data.UUID as UUID
import Effect (Effect)
import Effect.Uncurried (EffectFn2, runEffectFn2)
import Effect.Uncurried (EffectFn2, EffectFn3, runEffectFn2, runEffectFn3)
import Gargantext.Components.Bootstrap.IconButton (iconButton)
import Gargantext.Components.Bootstrap.Types (Elevation(..), ModalSizing(..))
import Gargantext.Hooks.UpdateEffect (useUpdateEffect1')
......@@ -20,16 +20,29 @@ import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
foreign import _show :: EffectFn2
here :: R2.Here
here = R2.here "Gargantext.Components.Bootstrap.BaseModal"
type ModalCallback = Unit -> Effect Unit
type ModalEvents =
( onHide :: ModalCallback
, onShow :: ModalCallback )
foreign import _show :: EffectFn3
Window
String
(Record ModalEvents)
Unit
showModal ::
Window
-> String
-> Record ModalEvents
-> Effect Unit
showModal = runEffectFn2 _show
showModal = runEffectFn3 _show
foreign import _hide :: EffectFn2
Window
......@@ -118,9 +131,13 @@ component = R.memo' $ R.hooksComponent componentName cpt where
-- | Hooks
-- |
let modalEvents = {
onHide: \_ -> T.write_ false isVisibleBox
, onShow: \_ -> T.write_ true isVisibleBox
}
useUpdateEffect1' isVisible
if isVisible
then showModal window selector
then showModal window selector modalEvents
else hideModal window selector
-- | Behaviors
......@@ -138,7 +155,7 @@ component = R.memo' $ R.hooksComponent componentName cpt where
, tabIndex: "-1"
, key: id
, data:
{ keyboard: "false"
{ keyboard: "true"
, backdrop: hasCollapsibleBackground ?
"true" $
"static"
......
......@@ -6,7 +6,6 @@ import DOM.Simple as DOM
import Effect (Effect)
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (Elevation(..))
import Gargantext.Components.Forest.Tree.Node.Tools (prettyNodeType)
import Gargantext.Types (ID, Name)
import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2
......@@ -57,7 +56,7 @@ nodePopupViewCpt = here.component "nodePopupView" cpt where
[
H.span { className: GT.fldr nodeType true} [] -- TODO fix names
,
B.span' { className: "ml-1 h5" } $ prettyNodeType nodeType
B.span' { className: "ml-1 h5" } $ GT.prettyNodeType nodeType
]
,
B.wad
......
......@@ -8,7 +8,7 @@ import Data.Array as A
import Data.Int (fromString)
import Data.Maybe (Maybe(..), fromMaybe)
import Data.String (Pattern(..), split)
import Gargantext.Components.App.Store (Boxes)
import Gargantext.Components.App.Store as Store
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.GraphQL.Endpoints (getBreadcrumb)
import Gargantext.Components.GraphQL.Tree (BreadcrumbInfo, TreeNode)
......@@ -30,7 +30,7 @@ import Toestand as T
here :: R2.Here
here = R2.here "Gargantext.Components.Forest.Breadcrumb"
type PropsBoxes = ( boxes :: Boxes )
type PropsBoxes = ( boxes :: Store.Boxes )
type Props =
( nodeId :: Int
......@@ -232,10 +232,16 @@ breadcrumbItemCpt = here.component "breadcrumbItemCpt" cpt where
, format
} _ = do
boxes@{ forestOpen } <- Store.use
url <- R.unsafeHooksEffect GU.href
let sid = sessionId session
let rootId = treeId session
let currentNodeIdFromUrl = mkNodeId session linkId
R.unsafeHooksEffect $ T.modify_ (openNodesInsert (currentNodeIdFromUrl)) forestOpen
pure $
if format == "text"
......
......@@ -4,7 +4,8 @@ import Gargantext.Prelude
import Data.Array as A
import Data.Array as Array
import Data.Maybe (Maybe(..), isJust)
import Data.Maybe (fromMaybe, Maybe(..), isJust)
import Data.String (Pattern(..), split)
import Data.Traversable (intercalate, traverse, traverse_)
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
......@@ -154,6 +155,7 @@ getNodeTreeFirstLevel session nodeId = get session $ GR.TreeFirstLevel (Just nod
tree :: R2.Leaf TreeProps
tree props = R.createElement treeCpt props []
treeCpt :: R.Component TreeProps
treeCpt = here.component "tree" cpt where
cpt p@{ frontends
......@@ -167,6 +169,12 @@ treeCpt = here.component "tree" cpt where
folderOpen <- useOpenNodesMemberBox nodeId forestOpen
folderOpen' <- T.useLive T.unequal folderOpen
R.useEffect' do
selectedLeaf <- R2.querySelector ".mainleaf--selected"
case selectedLeaf of
Nothing -> pure unit
Just el -> R2.scrollIntoView el
pure $
H.div
......@@ -218,7 +226,6 @@ treeCpt = here.component "tree" cpt where
pub (LNode n@{ nodeType: t }) = LNode (n { nodeType = publicize t })
blankTree :: R2.Leaf ()
blankTree = R2.leaf blankTreeCpt
blankTreeCpt :: R.Component ()
......
......@@ -405,9 +405,3 @@ checkboxesListGroupCpt = here.component "checkboxesListGroup" cpt
]
pure $ R.fragment $ map one $ Set.toUnfoldable options'
prettyNodeType :: GT.NodeType -> String
prettyNodeType
= S.replace (S.Pattern "Node") (S.Replacement " ")
<<< S.replace (S.Pattern "Folder") (S.Replacement " ")
<<< show
......@@ -19,8 +19,7 @@ here = R2.here "Gargantext.Components.Lang"
-- Language used for search
allLangs :: Array Lang
allLangs = [ Universal
, No_extraction
allLangs = [ No_extraction
, DE
, EL
, EN
......@@ -50,7 +49,6 @@ derive instance Generic Lang _
derive instance Ord Lang
instance Show Lang where
show Universal = "All"
show No_extraction = "Nothing"
show s = genericShow s
......
......@@ -234,7 +234,7 @@ divDropdownLeftCpt = here.component "divDropdownLeft" cpt
, text : "API documentation"
}
, LiNav { title : "Source code"
, href : "https://gitlab.iscpif.fr/gargantext/haskell-gargantext"
, href : "https://gitlab.iscpif.fr/gargantext/main"
, icon : "fa fa-code"
, text : "Source Code"
}
......
......@@ -205,6 +205,37 @@ instance Show NodeType where
show NodeFile = "NodeFile"
prettyNodeType :: NodeType -> String
prettyNodeType (NodePublic nt) = "Public " <> prettyNodeType nt
prettyNodeType Annuaire = "Annuaire"
prettyNodeType Calc = "Calc"
prettyNodeType Context = "Context"
prettyNodeType Corpus = "Corpus"
prettyNodeType Dashboard = "Dashboard"
prettyNodeType Error = "Error"
prettyNodeType Folder = "Folder"
prettyNodeType FolderPrivate = "Private folder"
prettyNodeType FolderPublic = "Public folder"
prettyNodeType FolderShared = "Shared folder"
prettyNodeType Graph = "Graph"
prettyNodeType Individu = "Individu"
prettyNodeType Node = "Node"
prettyNodeType NodeContact = "Contact"
prettyNodeType NodeFile = "File"
prettyNodeType NodeFrameNotebook = "Notebook"
prettyNodeType NodeFrameVisio = "Visio"
prettyNodeType NodeList = "Terms"
prettyNodeType NodeTexts = "Docs"
prettyNodeType NodeUser = "User"
prettyNodeType Nodes = "Nodes"
prettyNodeType Notes = "Notes"
prettyNodeType Phylo = "Phylo"
prettyNodeType Team = "Team"
prettyNodeType Tree = "Tree"
prettyNodeType Url_Document = "Document"
instance Read NodeType where
read "NodeUser" = Just NodeUser
read "NodeFolder" = Just Folder
......@@ -298,7 +329,7 @@ translateEN = case _ of
Url_Document -> "URL document"
--
NodeFile -> "File"
Calc -> "Calc"
Calc -> "Calc"
NodeFrameNotebook -> "Notebook"
Notes -> "Notes"
NodeFrameVisio -> "Visio"
......@@ -789,11 +820,6 @@ progressPercent (AsyncProgress { log }) = perc
---------------------------------------------------------------------------
-- | GarganText Internal Sugar
prettyNodeType :: NodeType -> String
prettyNodeType nt = S.replace (S.Pattern "Node") (S.Replacement " ")
$ S.replace (S.Pattern "Folder") (S.Replacement " ")
$ show nt
---------------------------------------------------------------------------
data SidePanelState = InitialClosed | Opened | Closed
......
......@@ -53,3 +53,12 @@ export function _keyCode(e) {
// https://www.w3schools.com/jsref/event_key_keycode.asp
return e.which || e.keyCode;
}
export function _scrollIntoView(el) {
return el.scrollIntoView({
behavior: 'smooth',
block: 'center',
inline: 'center'
});
}
\ No newline at end of file
......@@ -281,6 +281,11 @@ getElementById = (flip delay) h
where
h id = pure $ toMaybe $ document ... "getElementById" $ [id]
querySelector :: String -> Effect (Maybe DOM.Element)
querySelector = (flip delay) h
where
h selector = pure $ toMaybe $ document ... "querySelector" $ [selector]
-- We just assume it works, so make sure it's in the html
getPortalHost :: R.Hooks DOM.Element
getPortalHost = R.unsafeHooksEffect $ delay unit $ \_ -> pure $ document ... "getElementById" $ ["portal"]
......@@ -487,6 +492,12 @@ focus nEl = case toMaybe nEl of
Nothing -> pure unit
Just el -> el ... "focus" $ []
foreign import _scrollIntoView :: EffectFn1 DOM.Element Unit
scrollIntoView :: DOM.Element -> Effect Unit
scrollIntoView el = runEffectFn1 _scrollIntoView el
setIndeterminateCheckbox :: R.Element -> Boolean -> Effect R.Element
setIndeterminateCheckbox el val = pure $ (el .= "indeterminate") val
......
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