Skip to content

Commit aff1dd2

Browse files
committed
feat: unique more info modal for all geomaps
1 parent 4eb8059 commit aff1dd2

File tree

3 files changed

+95
-23
lines changed

3 files changed

+95
-23
lines changed

vis/js/templates/modals/InfoModal.tsx

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,43 @@
11
// @ts-nocheck
22

33
import React from "react";
4-
import { connect } from "react-redux";
54
import { Modal } from "react-bootstrap";
5+
import { connect } from "react-redux";
66

7-
import { closeInfoModal } from "../../actions";
8-
import { STREAMGRAPH_MODE } from "../../reducers/chartType";
7+
import { useVisualizationType } from "@/hooks";
98

9+
import { closeInfoModal } from "../../actions";
1010
import BaseInfo from "./infomodal/BaseInfo";
1111
import CovisInfo from "./infomodal/CovisInfo";
1212
import DefaultKMInfo from "./infomodal/DefaultKMInfo";
1313
import DefaultSGInfo from "./infomodal/DefaultSGInfo";
14+
import OpenAireInfo from "./infomodal/OpenAireInfo";
15+
import OrcidInfo from "./infomodal/OrcidInfo";
1416
import PubMedInfo from "./infomodal/PubMedInfo";
1517
import TripleKMInfo from "./infomodal/TripleKMInfo";
1618
import TripleSGInfo from "./infomodal/TripleSGInfo";
1719
import ViperInfo from "./infomodal/ViperInfo";
18-
import OpenAireInfo from "./infomodal/OpenAireInfo";
19-
import OrcidInfo from "./infomodal/OrcidInfo";
2020

21+
const getInfoTemplate = (
22+
service: string,
23+
isStreamgraph: boolean,
24+
modalType: string,
25+
isGeomap: boolean,
26+
) => {
27+
if (isGeomap) {
28+
return BaseInfo;
29+
}
2130

22-
const getInfoTemplate = (service: string, isStreamgraph: boolean, modalType: string) => {
2331
switch (service) {
2432
case "base":
2533
return BaseInfo;
2634
case "pubmed":
2735
return PubMedInfo;
2836
case "openaire":
29-
if (modalType && modalType === 'openaire') {
37+
if (modalType && modalType === "openaire") {
3038
return OpenAireInfo;
31-
} else if (modalType && modalType === 'viper') {
39+
}
40+
if (modalType && modalType === "viper") {
3241
return ViperInfo;
3342
}
3443
return OpenAireInfo;
@@ -45,19 +54,25 @@ const getInfoTemplate = (service: string, isStreamgraph: boolean, modalType: str
4554
}
4655
};
4756

48-
const InfoModal = ({open, onClose, params, service, isStreamgraph, modalInfoType}) => {
49-
const InfoTemplate = getInfoTemplate(service, isStreamgraph, modalInfoType);
57+
const InfoModal = ({ open, onClose, params, service, modalInfoType }) => {
58+
const { isStreamgraph, isGeoMap } = useVisualizationType();
59+
60+
const InfoTemplate = getInfoTemplate(
61+
service,
62+
isStreamgraph,
63+
modalInfoType,
64+
isGeoMap,
65+
);
5066

5167
return (
52-
// html template starts here
53-
<Modal id="info_modal" show={open} onHide={onClose} animation>
54-
<InfoTemplate params={params} isStreamgraph={isStreamgraph}/>
55-
</Modal>
56-
// html template ends here
68+
// html template starts here
69+
<Modal id="info_modal" show={open} onHide={onClose} animation>
70+
<InfoTemplate params={params} isStreamgraph={isStreamgraph} />
71+
</Modal>
72+
// html template ends here
5773
);
5874
};
5975

60-
6176
const mapStateToProps = (state) => ({
6277
open: state.modals.openInfoModal,
6378
params: {
@@ -68,9 +83,8 @@ const mapStateToProps = (state) => ({
6883
author: state.author,
6984
},
7085
service: state.isCovis ? "covis" : state.service,
71-
isStreamgraph: state.chartType === STREAMGRAPH_MODE,
7286
// new parameter from config to render correct type of info modal window
73-
modalInfoType: state.modalInfoType
87+
modalInfoType: state.modalInfoType,
7488
});
7589

7690
const mapDispatchToProps = (dispatch) => ({

vis/js/templates/modals/infomodal/BaseInfo.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,27 @@
22

33
import React from "react";
44

5-
import baseLogo from "../../../../images/logos/base_logo.png";
5+
import { useVisualizationType } from "@/hooks";
66

7+
import baseLogo from "../../../../images/logos/base_logo.png";
8+
import { StandardGeomapInfo } from "./subcomponents/StandardGeomapInfo";
79
import StandardKMInfo from "./subcomponents/StandardKMInfo";
810
import StandardSGInfo from "./subcomponents/StandardSGInfo";
911

10-
const BaseInfo = ({ params, isStreamgraph }) => {
11-
const MainTemplate = isStreamgraph ? StandardSGInfo : StandardKMInfo;
12+
const BaseInfo = ({ params }) => {
13+
const { isGeoMap, isStreamgraph } = useVisualizationType();
14+
15+
let MainTemplate = StandardKMInfo;
16+
17+
if (isStreamgraph) {
18+
MainTemplate = StandardSGInfo;
19+
}
20+
21+
if (isGeoMap) {
22+
MainTemplate = StandardGeomapInfo;
23+
}
1224

1325
return (
14-
// html template starts here
1526
<MainTemplate
1627
serviceName="BASE"
1728
serviceDesc={
@@ -31,7 +42,6 @@ const BaseInfo = ({ params, isStreamgraph }) => {
3142
}
3243
params={params}
3344
/>
34-
// html template ends here
3545
);
3646
};
3747

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { FC } from "react";
2+
import { Modal } from "react-bootstrap";
3+
4+
import { queryConcatenator } from "@/js/utils/data";
5+
import { unescapeHTML } from "@/js/utils/unescapeHTMLentities";
6+
7+
import AboutSoftware from "./AboutSoftware";
8+
9+
interface StandardGeomapInfoProps {
10+
params: {
11+
query: string;
12+
customTitle: string;
13+
q_advanced: string;
14+
};
15+
}
16+
17+
export const StandardGeomapInfo: FC<StandardGeomapInfoProps> = ({ params }) => {
18+
const { query, customTitle, q_advanced: queryAdvanced } = params;
19+
20+
const queryAfterConcatenate = queryConcatenator([query, queryAdvanced]);
21+
const saveCustomTitle = customTitle && unescapeHTML(customTitle);
22+
23+
return (
24+
<>
25+
<Modal.Header closeButton>
26+
<Modal.Title id="info-title">What's this?</Modal.Title>
27+
</Modal.Header>
28+
<Modal.Body id="info-body">
29+
{(!!saveCustomTitle || !!query || !!queryAdvanced) && (
30+
<p>
31+
This geo map presents you with an overview of{" "}
32+
<strong className="hs-strong">
33+
{saveCustomTitle ? saveCustomTitle : queryAfterConcatenate}
34+
</strong>
35+
</p>
36+
)}
37+
{!!saveCustomTitle && (
38+
<p>
39+
This map has a custom title and was created using the following
40+
query:{" "}
41+
<strong className="hs-strong">{queryAfterConcatenate}</strong>
42+
</p>
43+
)}
44+
<AboutSoftware />
45+
</Modal.Body>
46+
</>
47+
);
48+
};

0 commit comments

Comments
 (0)