11// @ts -nocheck
22
33import React from "react" ;
4+ import { Modal } from "react-bootstrap" ;
45import { connect } from "react-redux" ;
56
6- import { Modal } from "react-bootstrap" ;
77import { closeCitationModal } from "../../actions" ;
8-
98import { useLocalizationContext } from "../../components/LocalizationProvider" ;
10- import { STREAMGRAPH_MODE } from "../../reducers/chartType" ;
9+ import { GEOMAP_MODE , STREAMGRAPH_MODE } from "../../reducers/chartType" ;
10+ import { queryConcatenator } from "../../utils/data" ;
1111import { getDateFromTimestamp } from "../../utils/dates" ;
1212import { formatString , removeEmbedParam } from "../../utils/string" ;
13- import CopyButton from "../CopyButton " ;
13+ import { unescapeHTML } from "../../utils/unescapeHTMLentities " ;
1414import useMatomo from "../../utils/useMatomo" ;
15- import { queryConcatenator } from "../../utils/data" ;
16- import { unescapeHTML } from "../../utils/unescapeHTMLentities" ;
15+ import CopyButton from "../CopyButton" ;
1716
1817const CitationModal = ( {
1918 open,
2019 onClose,
2120 isStreamgraph,
21+ isGeomap,
2222 query,
2323 customTitle,
2424 timestamp,
@@ -37,24 +37,44 @@ const CitationModal = ({
3737
3838 let customQuery = queryConcatenator ( [ query , q_advanced ] ) ;
3939 if ( customQuery . length > 100 ) {
40- customQuery = customQuery . substr ( 0 , 100 ) + " [..]" ;
40+ customQuery = ` ${ customQuery . substr ( 0 , 100 ) } [..]` ;
4141 }
4242 if ( customTitle ) {
4343 customQuery = unescapeHTML ( customTitle ) ;
4444 }
4545
4646 const date = getDateFromTimestamp ( timestamp ) ;
47+ const year = new Date ( ) . getFullYear ( ) ;
48+ const link = removeEmbedParam ( window . location . href ) ;
49+
50+ let citeModalTitle : string ;
51+ let citeModalInstruction : string ;
52+ if ( isGeomap ) {
53+ citeModalTitle = loc . cite_title_geomap ;
54+ citeModalInstruction = loc . cite_vis_geomap ;
55+ } else if ( isStreamgraph ) {
56+ citeModalTitle = loc . cite_title_sg ;
57+ citeModalInstruction = loc . cite_vis_sg ;
58+ } else {
59+ citeModalTitle = loc . cite_title_km ;
60+ citeModalInstruction = loc . cite_vis_km ;
61+ }
4762
48- let citationText = formatString ( loc . citation_template , {
49- year : new Date ( ) . getFullYear ( ) ,
50- type : isStreamgraph ? "Streamgraph" : "Knowledge Map" ,
51- query : customQuery ,
52- source : removeEmbedParam ( window . location . href ) ,
53- date,
54- } ) ;
63+ let citationText ;
64+ if ( isGeomap ) {
65+ citationText = `Open Knowledge Maps ${ year } . Geo Map of ${ customQuery } . Retrieved from ${ link } .` ;
66+ } else {
67+ citationText = formatString ( loc . citation_template , {
68+ year,
69+ type : isStreamgraph ? "Streamgraph" : "Knowledge Map" ,
70+ query : customQuery ,
71+ source : link ,
72+ date,
73+ } ) ;
5574
56- if ( ! date ) {
57- citationText = citationText . replace ( " []." , "." ) ;
75+ if ( ! date ) {
76+ citationText = citationText . replace ( " []." , "." ) ;
77+ }
5878 }
5979
6080 return (
@@ -66,11 +86,11 @@ const CitationModal = ({
6686 className = "cite-modal-title"
6787 style = { { fontSize : 20 } }
6888 >
69- { isStreamgraph ? loc . cite_title_sg : loc . cite_title_km }
89+ { citeModalTitle }
7090 </ Modal . Title >
7191 </ Modal . Header >
7292 < Modal . Body id = "cite-body" className = "modal-body" >
73- < p > { isStreamgraph ? loc . cite_vis_sg : loc . cite_vis_km } : </ p >
93+ < p > { ` ${ citeModalInstruction } :` } </ p >
7494 < div id = "copy-map-citation" className = "citation" >
7595 { citationText }
7696 </ div >
@@ -89,6 +109,7 @@ const CitationModal = ({
89109const mapStateToProps = ( state ) => ( {
90110 open : state . modals . openCitationModal ,
91111 isStreamgraph : state . chartType === STREAMGRAPH_MODE ,
112+ isGeomap : state . chartType === GEOMAP_MODE ,
92113 query : state . query . text ,
93114 customTitle :
94115 state . heading . titleStyle === "custom" ? state . heading . customTitle : null ,
0 commit comments