Commit b1406873 authored by Fabien Maniere's avatar Fabien Maniere

Merge branch 'dev-graph-sidebard-copy-terms-to-clipboard' into 'dev'

[graph] add option to copy neighborhood terms to clipboard

See merge request !524
parents be93b32d 154e230a
Pipeline #7962 passed with stages
in 30 minutes and 19 seconds
......@@ -21,6 +21,7 @@ import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect.Aff (launchAff_)
import Effect.Class (liftEffect)
import Effect.Timer (setTimeout)
import Gargantext.Components.App.Store as AppStore
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Elevation(..), Variant(..))
......@@ -41,6 +42,7 @@ import Gargantext.Hooks.Sigmax.Types as SigmaxT
import Gargantext.Sessions (Session)
import Gargantext.Types (CTabNgramType, FrontendError(..), NodeID, SidePanelState(..), TabSubType(..), TabType(..), TermList(..), modeTabType)
import Gargantext.Utils (getter, nbsp, setter, (?))
import Gargantext.Utils.Clipboard (modalClipboard)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import Partial.Unsafe (unsafePartial)
......@@ -487,6 +489,9 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt
termCount /\ termCountBox <-
R2.useBox' 0
copied <- T.useBox false
copied' <- T.useLive T.unequal copied
-- | Computed
-- |
let
......@@ -520,6 +525,11 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt
T.write_ neighbours' termListBox
T.write_ false showMoreBox
R.useEffect' $ do
let
labels = (_.label) <$> termList
modalClipboard ".copy" (intercalate "\n" labels)
-- | Render
-- |
pure $
......@@ -541,6 +551,15 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt
[ "text-info", "d-inline" ] $
show termCount
, H.text $ nbsp 1 <> "related terms"
, B.iconButton
{ name: if copied' then "check" else "copy"
, title: if copied' then "Copied" else "Copy terms to clipboard"
, className: "copy copy-btn"
, callback: \_ -> do
T.write_ true copied
_ <- setTimeout 2000 (T.write_ false copied)
pure unit
}
,
-- Expand word cloud
B.iconButton
......
import ClipboardJS from "clipboard";
export function _modalClipboard(el, url) {
modal_id = document.getElementsByClassName("b-modal modal show")[0].id
modalEl = document.getElementsByClassName("b-modal modal show")[0]
return new ClipboardJS(el, {
container: document.getElementById(modal_id),
container: modalEl,
text: function(trigger) {
return url
}
......
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