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 ((/\)) ...@@ -21,6 +21,7 @@ import Data.Tuple.Nested ((/\))
import Effect (Effect) import Effect (Effect)
import Effect.Aff (launchAff_) import Effect.Aff (launchAff_)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Effect.Timer (setTimeout)
import Gargantext.Components.App.Store as AppStore import Gargantext.Components.App.Store as AppStore
import Gargantext.Components.Bootstrap as B import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Elevation(..), Variant(..)) import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Elevation(..), Variant(..))
...@@ -41,6 +42,7 @@ import Gargantext.Hooks.Sigmax.Types as SigmaxT ...@@ -41,6 +42,7 @@ import Gargantext.Hooks.Sigmax.Types as SigmaxT
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (CTabNgramType, FrontendError(..), NodeID, SidePanelState(..), TabSubType(..), TabType(..), TermList(..), modeTabType) import Gargantext.Types (CTabNgramType, FrontendError(..), NodeID, SidePanelState(..), TabSubType(..), TabType(..), TermList(..), modeTabType)
import Gargantext.Utils (getter, nbsp, setter, (?)) import Gargantext.Utils (getter, nbsp, setter, (?))
import Gargantext.Utils.Clipboard (modalClipboard)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
import Partial.Unsafe (unsafePartial) import Partial.Unsafe (unsafePartial)
...@@ -487,6 +489,9 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt ...@@ -487,6 +489,9 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt
termCount /\ termCountBox <- termCount /\ termCountBox <-
R2.useBox' 0 R2.useBox' 0
copied <- T.useBox false
copied' <- T.useLive T.unequal copied
-- | Computed -- | Computed
-- | -- |
let let
...@@ -520,6 +525,11 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt ...@@ -520,6 +525,11 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt
T.write_ neighbours' termListBox T.write_ neighbours' termListBox
T.write_ false showMoreBox T.write_ false showMoreBox
R.useEffect' $ do
let
labels = (_.label) <$> termList
modalClipboard ".copy" (intercalate "\n" labels)
-- | Render -- | Render
-- | -- |
pure $ pure $
...@@ -541,6 +551,15 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt ...@@ -541,6 +551,15 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt
[ "text-info", "d-inline" ] $ [ "text-info", "d-inline" ] $
show termCount show termCount
, H.text $ nbsp 1 <> "related terms" , 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 -- Expand word cloud
B.iconButton B.iconButton
......
import ClipboardJS from "clipboard"; import ClipboardJS from "clipboard";
export function _modalClipboard(el, url) { 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, { return new ClipboardJS(el, {
container: document.getElementById(modal_id), container: modalEl,
text: function(trigger) { text: function(trigger) {
return url 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