Skip to content

Commit 51bff26

Browse files
committed
Merge branch 'refactor/geomap-refinements' into refactor/geomap-refinements-review
2 parents a57f643 + 52e25d2 commit 51bff26

6 files changed

Lines changed: 101 additions & 42 deletions

File tree

server/services/searchAQUANAVI.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@
2222
$post_params["time_range"] = "user-defined";
2323

2424
// And some others...
25-
$params_array = ["from", "to", "document_types", "sorting", "min_descsize", "lang_id"];
25+
$params_array = ["from", "to", "document_types", "sorting", "min_descsize", "lang_id", "vis_type"];
2626

27-
$is_custom_array_set = isset($post_params["custom_title"]);
28-
if ($is_custom_array_set) {
29-
$params_array[] = "custom_title";
27+
// Optional keys must be listed here so packParamsJSON() includes them in vis_params (see searchBASE.php).
28+
$optional_params = ["custom_title", "q_advanced"];
29+
foreach ($optional_params as $param) {
30+
if (isset($post_params[$param])) {
31+
$params_array[] = $param;
32+
}
3033
}
3134

3235
$result = search("aquanavi", $query, $post_params, $params_array, true, true, null, $precomputed_id, false);

vis/js/i18n/localization.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@ export interface Localization {
7474
filter_by_label: string;
7575
cite_title_km: string;
7676
cite_title_sg: string;
77+
cite_title_geomap: string;
7778
citation_template: string;
7879
cite_vis_km: string;
7980
cite_vis_sg: string;
81+
cite_vis_geomap: string;
8082
cite_paper: string;
8183
export_paper: string;
8284
download: string;
@@ -221,10 +223,12 @@ export const localization: {
221223
filter_by_label: "show: ",
222224
cite_title_km: "Cite this visualization",
223225
cite_title_sg: "Cite this visualization",
226+
cite_title_geomap: "Cite this geo map",
224227
citation_template:
225228
"Open Knowledge Maps (${year}). ${type} for research on ${query}. Retrieved from ${source} [${date}].",
226229
cite_vis_km: "Please cite this knowledge map as follows",
227230
cite_vis_sg: "Please cite this streamgraph as follows",
231+
cite_vis_geomap: "Please cite this geo map as follows",
228232
cite_paper: "Cite this resource as",
229233
export_paper: "Export this resource",
230234
download: "Download",
@@ -313,10 +317,12 @@ export const localization: {
313317
cite: "Cite",
314318
cite_title_km: "Zitieren Sie diese Wissenskarte",
315319
cite_title_sg: "Cite this visualization",
320+
cite_title_geomap: "Cite this geo map",
316321
citation_template:
317322
"Open Knowledge Maps (${year}). ${type} for research on ${query}. Retrieved from ${source} [${date}].",
318323
cite_vis_km: "Please cite this knowledge map as follows",
319324
cite_vis_sg: "Please cite this streamgraph as follows",
325+
cite_vis_geomap: "Please cite this geo map as follows",
320326
cite_paper: "Cite this resource as",
321327
export_paper: "Export this resource",
322328
download: "Download",

vis/js/templates/buttons/CitationButton.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import { connect } from "react-redux";
55

66
import { openCitationModal } from "../../actions";
77
import { useLocalizationContext } from "../../components/LocalizationProvider";
8-
import { STREAMGRAPH_MODE } from "../../reducers/chartType";
8+
import { GEOMAP_MODE, STREAMGRAPH_MODE } from "../../reducers/chartType";
99
import useMatomo from "../../utils/useMatomo";
1010

1111
const CitationButton = ({
12+
isGeomap,
1213
isStreamgraph,
1314
onClick,
1415
}: {
16+
isGeomap: boolean;
1517
isStreamgraph: boolean;
1618
onClick: () => void;
1719
}) => {
@@ -23,16 +25,21 @@ const CitationButton = ({
2325
trackEvent("Added components", "Open cite modal", "Cite button");
2426
};
2527

28+
let citeButtonTitle: string;
29+
if (isGeomap) {
30+
citeButtonTitle = localization.cite_title_geomap;
31+
} else if (isStreamgraph) {
32+
citeButtonTitle = localization.cite_title_sg;
33+
} else {
34+
citeButtonTitle = localization.cite_title_km;
35+
}
36+
2637
return (
2738
// html template starts here
2839
<div>
2940
<button
3041
className="btn btn-primary"
31-
title={
32-
isStreamgraph
33-
? localization.cite_title_sg
34-
: localization.cite_title_km
35-
}
42+
title={citeButtonTitle}
3643
onClick={handleClick}
3744
>
3845
<span id="citationlink">
@@ -46,6 +53,7 @@ const CitationButton = ({
4653
};
4754

4855
const mapStateToProps = (state) => ({
56+
isGeomap: state.chartType === GEOMAP_MODE,
4957
isStreamgraph: state.chartType === STREAMGRAPH_MODE,
5058
});
5159

vis/js/templates/modals/CitationModal.tsx

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

33
import React from "react";
4+
import { Modal } from "react-bootstrap";
45
import { connect } from "react-redux";
56

6-
import { Modal } from "react-bootstrap";
77
import { closeCitationModal } from "../../actions";
8-
98
import { 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";
1111
import { getDateFromTimestamp } from "../../utils/dates";
1212
import { formatString, removeEmbedParam } from "../../utils/string";
13-
import CopyButton from "../CopyButton";
13+
import { unescapeHTML } from "../../utils/unescapeHTMLentities";
1414
import useMatomo from "../../utils/useMatomo";
15-
import { queryConcatenator } from "../../utils/data";
16-
import {unescapeHTML} from "../../utils/unescapeHTMLentities";
15+
import CopyButton from "../CopyButton";
1716

1817
const 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 = ({
89109
const 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,
Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FC } from "react";
1+
import { FC, PropsWithChildren } from "react";
22
import { Modal } from "react-bootstrap";
33

44
import { queryConcatenator } from "@/js/utils/data";
@@ -20,29 +20,46 @@ export const StandardGeomapInfo: FC<StandardGeomapInfoProps> = ({ params }) => {
2020
const queryAfterConcatenate = queryConcatenator([query, queryAdvanced]);
2121
const saveCustomTitle = customTitle && unescapeHTML(customTitle);
2222

23+
const hasQuery = queryAfterConcatenate.length > 0;
24+
const hasCustomTitle = Boolean(saveCustomTitle);
25+
2326
return (
2427
<>
2528
<Modal.Header closeButton>
2629
<Modal.Title id="info-title">What's this?</Modal.Title>
2730
</Modal.Header>
2831
<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>
32+
{hasQuery && !hasCustomTitle && (
33+
<OverviewParagraph>{queryAfterConcatenate}</OverviewParagraph>
34+
)}
35+
{!hasQuery && hasCustomTitle && (
36+
<OverviewParagraph>{saveCustomTitle}</OverviewParagraph>
37+
)}
38+
{!hasQuery && !hasCustomTitle && (
39+
<OverviewParagraph>{null}</OverviewParagraph>
3640
)}
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>
41+
{hasQuery && hasCustomTitle && (
42+
<>
43+
<OverviewParagraph>{saveCustomTitle}</OverviewParagraph>
44+
<CustomTitleParagraph>{queryAfterConcatenate}</CustomTitleParagraph>
45+
</>
4346
)}
4447
<AboutSoftware />
4548
</Modal.Body>
4649
</>
4750
);
4851
};
52+
53+
const OverviewParagraph: FC<PropsWithChildren> = ({ children }) => (
54+
<p>
55+
This geo map presents you with an overview of{" "}
56+
<strong className="hs-strong">{children}</strong>.
57+
</p>
58+
);
59+
60+
const CustomTitleParagraph: FC<PropsWithChildren> = ({ children }) => (
61+
<p>
62+
This map has a custom title and was created using the following query:{" "}
63+
<strong className="hs-strong">{children}</strong>
64+
</p>
65+
);

vis/test/component/citationmodal.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ const getMockStoreData = (isStreamgraph: boolean) => {
3333
localization: {
3434
cite_title_km: "Cite this knowledge map",
3535
cite_title_sg: "Cite this streamgraph",
36+
cite_title_geomap: "Cite this geo map",
3637
citation_template:
3738
"Open Knowledge Maps (${year}). ${type} for research on ${query}. Retrieved from ${source} [${date}].",
39+
cite_vis_km: "Please cite this knowledge map as follows",
40+
cite_vis_sg: "Please cite this streamgraph as follows",
41+
cite_vis_geomap: "Please cite this geo map as follows",
3842
},
3943
};
4044
};

0 commit comments

Comments
 (0)