Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plan name column to action dashboard export #429

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions components/dashboard/ActionStatusExport.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ async function exportActions(
const worksheet = workbook.addWorksheet(
t('actions', getActionTermContext(plan))
);
worksheet.columns = [
const planIds = new Set(actions.map((action) => action.plan.id));
const multiplePlans = planIds.size > 1;
const columns = [
{ header: t('action-identifier'), key: 'id', width: 10 },
{
header: t('action-name-title', getActionTermContext(plan)),
Expand Down Expand Up @@ -72,6 +74,16 @@ async function exportActions(
width: 20,
},
];
if (multiplePlans) {
columns.unshift({
header: t('plan'),
key: 'plan',
width: 20,
});
}
// When assigning to worksheet.columns, some magic happens and manipulating worksheet.columns afterwards does not
// yield the desired results. So we prepare the columns array separately before assigning it to worksheet.columns.
worksheet.columns = columns;
actions.forEach((act) => {
const status = cleanActionStatus(act, actionStatuses);
// Remove any soft hyphens in action name (due to `hyphenated: true` when querying the name) as Excel renders
Expand Down Expand Up @@ -126,7 +138,7 @@ async function exportActions(
.filter((p) => p.role === null)
.map(getOrgName);

worksheet.addRow([
const row = [
act.identifier,
actionName,
status?.name,
Expand All @@ -139,7 +151,11 @@ async function exportActions(
primaryResponsibleOrgs.join(';'),
collaboratorResponsibleOrgs.join(';'),
otherResponsibleOrgs.join(';'),
]);
];
if (multiplePlans) {
row.unshift(act.plan.name);
}
worksheet.addRow(row);
});

const today = new Date().toISOString().split('T')[0];
Expand Down
1 change: 1 addition & 0 deletions locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"page": "Page",
"page-not-found": "Page not found",
"percent-point-abbreviation": "p.p.",
"plan": "Plan",
"previous": "Previous",
"published-on": "Published on",
"read-more": "Read more",
Expand Down
Loading