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

Fix/ub include closedprojects #558

Merged
merged 2 commits into from
Dec 12, 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
7 changes: 5 additions & 2 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-11-20T15:06:33.223Z\n"
"PO-Revision-Date: 2024-11-20T15:06:33.223Z\n"
"POT-Creation-Date: 2024-12-11T14:02:52.077Z\n"
"PO-Revision-Date: 2024-12-11T14:02:52.077Z\n"

msgid "Validating Project"
msgstr ""
Expand Down Expand Up @@ -1027,6 +1027,9 @@ msgstr ""
msgid "Next Value"
msgstr ""

msgid "Blank"
msgstr ""

msgid "Editable New"
msgstr ""

Expand Down
2 changes: 1 addition & 1 deletion src/data/common/D2ApiProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class D2ApiProject {
return Project.getList(
this.api,
this.config,
{ countryIds: [countryId], onlyActive: true },
{ countryIds: [countryId] },
{ field: "created", order: "desc" },
{ page: page, pageSize: 50 }
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { TextField, Tooltip, Typography } from "@material-ui/core";
import { ObjectsTable, TableConfig, useObjectsTable } from "@eyeseetea/d2-ui-components";
import { ObjectsTable, TableConfig } from "@eyeseetea/d2-ui-components";

import {
IndicatorCalculation,
Expand All @@ -16,7 +16,7 @@ export type IndicatorValidationTableProps = {

type IndicatorCalculationColumns = IndicatorCalculationAttrs & { total: number };

export const IndicatorValidationTable = (props: IndicatorValidationTableProps) => {
export const IndicatorValidationTable = React.memo((props: IndicatorValidationTableProps) => {
const { data, onRowChange } = props;

const previousValueLabel = i18n.t("Previous Value");
Expand All @@ -32,7 +32,9 @@ export const IndicatorValidationTable = (props: IndicatorValidationTableProps) =
sortable: false,
getValue(row) {
const hasChanged = IndicatorCalculation.hasChanged(row);
const tooltipTitle = `${previousValueLabel}: ${row.previousValue} -> ${nextValueLabel}: ${row.nextValue}`;
const tooltipTitle = `${previousValueLabel}: ${
row.previousValue ?? i18n.t("Blank")
} -> ${nextValueLabel}: ${row.nextValue}`;
return (
<Tooltip title={hasChanged ? tooltipTitle : ""}>
<Typography color={hasChanged ? "secondary" : "initial"}>
Expand Down Expand Up @@ -122,18 +124,19 @@ export const IndicatorValidationTable = (props: IndicatorValidationTableProps) =
};
}, [data, nextValueLabel, previousValueLabel, onRowChange]);

const tableConfig = useObjectsTable<IndicatorCalculationColumns>(
config,
React.useCallback(() => {
return Promise.resolve({
objects: mapCalculationToTableRows(data),
pager: { page: 1, pageCount: 1, total: data.length, pageSize: data.length },
});
}, [data])
);
const rows = mapCalculationToTableRows(data);

return <ObjectsTable {...tableConfig} onChangeSearch={undefined} />;
};
return (
<ObjectsTable
columns={config.columns}
actions={config.actions}
sorting={config.initialSorting}
paginationOptions={config.paginationOptions}
rows={rows}
onChangeSearch={undefined}
/>
);
});

function mapCalculationToTableRows(data: IndicatorCalculation[]): IndicatorCalculationColumns[] {
return data.map(item => ({
Expand Down
Loading