Skip to content

Commit bd800ea

Browse files
committed
Merge branch 'develop' into fix/500-error-edition-not-found
2 parents 10a6a04 + e3ee410 commit bd800ea

File tree

14 files changed

+240
-218
lines changed

14 files changed

+240
-218
lines changed

package-lock.json

Lines changed: 105 additions & 105 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/actions/datasetVersion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const getFormData = (formData) => {
101101
release_minutes: formData.get("release-date-minutes"),
102102
usage_notes: parsedUsageNotes,
103103
alerts: parsedAlerts,
104-
distributions: [ JSON.parse(formData.get("dataset-upload-value")) ],
104+
distributions: JSON.parse(formData.get("dataset-upload-value")),
105105
release_date: null,
106106
type: "static",
107107
};

src/components/design-system/summary-mapper.js

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const getBaseSummaryModel = (groupID) => {
1515
};
1616

1717
// map a <Summary> component row
18-
const mapRow = (itemName, value, multiValue, hasAction, actionURL, actionAnchorIDPrefix, rows) => {
18+
const mapRow = (itemName, value, multiValue, action, rows) => {
1919
const slugifyLowerCase = (string) => {
2020
return slugify(string, {lower: true});
2121
};
@@ -40,14 +40,15 @@ const mapRow = (itemName, value, multiValue, hasAction, actionURL, actionAnchorI
4040
]
4141
};
4242

43-
if (hasAction) {
43+
if (action) {
4444
item.rowItems[0].actions = [
4545
{
46-
id: `edit-${slugifyLowerCase(itemName)}`,
47-
dataTestId: `edit-${slugifyLowerCase(itemName)}`,
48-
text: "Edit",
49-
visuallyHiddenText: `Edit ${itemName}`,
50-
url: `${actionURL}#${actionAnchorIDPrefix}${slugifyLowerCase(itemName)}`
46+
id: `action-link-${slugifyLowerCase(itemName)}`,
47+
dataTestId: `action-link-${slugifyLowerCase(itemName)}`,
48+
text: action.text,
49+
visuallyHiddenText: `${action.text} ${itemName}`,
50+
url: action.url ? `${action.url}#${action.anchorIDPrefix}${slugifyLowerCase(itemName)}` : "#",
51+
onClick: action.onClick ? (e) => { action.onClick(e, itemName); } : null
5152
}
5253
];
5354
}
@@ -57,49 +58,73 @@ const mapRow = (itemName, value, multiValue, hasAction, actionURL, actionAnchorI
5758
const mapSeriesSummary = (data, editBaseURL, topicTitles) => {
5859
const contentBody = getBaseSummaryModel("series-metadata");
5960
const rows = contentBody[0].groups[0].rows;
60-
const actionAnchorIDPrefix = "dataset-series-";
61+
const action = {
62+
url: editBaseURL,
63+
onClick: null,
64+
anchorIDPrefix: "dataset-series-",
65+
text: "Edit"
66+
}
6167
const contacts = [];
6268
data.contacts.forEach(contact => {
6369
contacts.push(contact.name);
6470
});
6571

66-
mapRow("Series ID", data.id, false, false, editBaseURL, actionAnchorIDPrefix, rows);
67-
mapRow("Type", data.type, false, false, editBaseURL, actionAnchorIDPrefix, rows);
68-
mapRow("Title", data.title, false, true, editBaseURL, actionAnchorIDPrefix, rows);
69-
mapRow("Description", data.description, false, true, editBaseURL, actionAnchorIDPrefix, rows);
72+
mapRow("Series ID", data.id, null, null, rows);
73+
mapRow("Type", data.type, null, null, rows);
74+
mapRow("Title", data.title, null, action, rows);
75+
mapRow("Description", data.description, null, action, rows);
7076

7177
if (topicTitles && topicTitles.length > 0) {
72-
mapRow("Topics", topicTitles, true, true, editBaseURL, actionAnchorIDPrefix, rows);
78+
mapRow("Topics", topicTitles, true, action, rows);
7379
}
7480

75-
mapRow("Last updated", formatDate(data.last_updated), false, false, editBaseURL, actionAnchorIDPrefix, rows);
76-
mapRow("Licence", data.license, false, false, editBaseURL, actionAnchorIDPrefix, rows);
77-
mapRow("Next release", data.next_release, false, false, editBaseURL, actionAnchorIDPrefix, rows);
81+
mapRow("Last updated", formatDate(data.last_updated), null, null, rows);
82+
mapRow("Licence", data.license, null, null, rows);
83+
mapRow("Next release", data.next_release, null, null, rows);
7884

7985
if (data.keywords && data.keywords.length > 0) {
80-
mapRow("Keywords", data.keywords, true, true, editBaseURL, actionAnchorIDPrefix, rows);
86+
mapRow("Keywords", data.keywords, true, action, rows);
8187
}
8288

83-
mapRow("QMI", data.qmi?.href, false, true, editBaseURL, actionAnchorIDPrefix, rows);
89+
mapRow("QMI", data.qmi?.href, null, action, rows);
8490

8591
if (data.publisher?.name) {
86-
mapRow("Publisher", data.publisher.name, false, false, editBaseURL, actionAnchorIDPrefix, rows);
92+
mapRow("Publisher", data.publisher.name, null, null, rows);
8793
}
88-
mapRow("Contacts", contacts, true, true, editBaseURL, actionAnchorIDPrefix, rows);
89-
94+
mapRow("Contacts", contacts, true, action, rows);
9095
return contentBody;
9196
};
9297

9398
const mapEditionSummary = (edition, editBaseURL) => {
9499
const contentBody = getBaseSummaryModel("edition-metadata");
95100
const rows = contentBody[0].groups[0].rows;
96-
const actionAnchorIDPrefix = "";
101+
const action = {
102+
url: editBaseURL,
103+
onClick: null,
104+
anchorIDPrefix: "",
105+
text: "Edit"
106+
}
97107
const isPublished = edition?.state === "published";
98108

99-
mapRow("Edition ID", edition.edition, false, !isPublished, editBaseURL, actionAnchorIDPrefix, rows);
100-
mapRow("Edition title", edition.edition_title, false, true, editBaseURL, actionAnchorIDPrefix, rows);
101-
mapRow("Release date", formatDate(edition.release_date), false, false, editBaseURL, actionAnchorIDPrefix, rows);
109+
mapRow("Edition ID", edition.edition, null, !isPublished ? action : null, rows);
110+
mapRow("Edition title", edition.edition_title, null, action, rows);
111+
mapRow("Release date", formatDate(edition.release_date), null, null, rows);
102112
return contentBody;
103113
};
104114

105-
export { mapSeriesSummary, mapEditionSummary };
115+
const mapUploadedFilesSummary = (files, actionOnClick) => {
116+
const contentBody = getBaseSummaryModel("uploaded-files-list");
117+
const rows = contentBody[0].groups[0].rows;
118+
const action = {
119+
url: null,
120+
onClick: actionOnClick,
121+
anchorIDPrefix: null,
122+
text: "Delete file"
123+
}
124+
files.forEach(file => {
125+
mapRow(file.title, " ", null, action, rows)
126+
});
127+
return contentBody;
128+
}
129+
130+
export { mapSeriesSummary, mapEditionSummary, mapUploadedFilesSummary };

0 commit comments

Comments
 (0)