Skip to content

Commit

Permalink
Merge pull request #558 from EyeSeeTea/fix/ub-include-closedprojects
Browse files Browse the repository at this point in the history
Fix/ub include closedprojects
  • Loading branch information
Ramon-Jimenez authored Dec 12, 2024
2 parents a5e915b + fe28205 commit 28fba06
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
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

0 comments on commit 28fba06

Please sign in to comment.