Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5311584
add multi text support
eperedo Aug 27, 2025
98eb6e0
add option to disable dataElements and fixed columns
eperedo Aug 28, 2025
fe47aee
add configuration for columns positions
eperedo Aug 29, 2025
4f7cb49
add support for groups and subgroups in grid view
eperedo Sep 3, 2025
d3664c3
remove zIndex to avoid unfreeze group/subgroup columns
eperedo Sep 3, 2025
57bf4f9
show scrollbars for the table at both the top and bottom
eperedo Sep 4, 2025
3f9b14a
fix scrollbar bug and add custom color for section title
eperedo Sep 4, 2025
2fa88fc
Merge branch 'development' of github.com:EyeSeeTea/d2-autogen-forms i…
eperedo Sep 7, 2025
2aaa88f
add support to hide/show columns in viewType grid
eperedo Sep 7, 2025
b3e703d
add support for hide/show tabs
eperedo Sep 7, 2025
3d36b93
update default color for section title
eperedo Sep 7, 2025
68bb923
update default color for section title
eperedo Sep 7, 2025
4983c3f
update json schema with new values
eperedo Sep 8, 2025
9ee9906
add new viewType to have dataElements and one category as columns
eperedo Sep 13, 2025
51f69f9
update locales
eperedo Sep 13, 2025
193d2ea
add row id and configuration to hide cells
eperedo Sep 13, 2025
a1e98c1
fixed parent columns
eperedo Sep 16, 2025
663d8b6
add fixed rows and topscroll for grid with categories-columns
eperedo Sep 18, 2025
042285f
allow using a constant for row names
eperedo Sep 18, 2025
8b15d4b
fixed condition for empty row names
eperedo Sep 19, 2025
39c0ddd
custom width for first column in grid viewType
eperedo Oct 1, 2025
8ec759e
custom width for first column in grid viewType
eperedo Oct 1, 2025
369c931
fix totals for grid with category columns, increase zindex for single…
eperedo Oct 6, 2025
f257087
added support for compulsory data values
eperedo Oct 7, 2025
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: 2025-08-27T03:27:08.033Z\n"
"PO-Revision-Date: 2025-08-27T03:27:08.033Z\n"
"POT-Creation-Date: 2025-09-13T17:01:13.807Z\n"
"PO-Revision-Date: 2025-09-13T17:01:13.807Z\n"

msgid "<No value>"
msgstr ""
Expand Down Expand Up @@ -44,6 +44,9 @@ msgstr ""
msgid "Period"
msgstr ""

msgid "Totals"
msgstr ""

msgid "Occupation"
msgstr ""

Expand Down
5 changes: 4 additions & 1 deletion i18n/es.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: i18next-conv\n"
"POT-Creation-Date: 2025-08-27T03:27:08.033Z\n"
"POT-Creation-Date: 2025-09-13T17:01:13.807Z\n"
"PO-Revision-Date: 2018-10-25T09:02:35.143Z\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -44,6 +44,9 @@ msgstr ""
msgid "Period"
msgstr ""

msgid "Totals"
msgstr ""

msgid "Occupation"
msgstr "Ocupación"

Expand Down
5 changes: 4 additions & 1 deletion i18n/fr.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: i18next-conv\n"
"POT-Creation-Date: 2025-08-27T03:27:08.033Z\n"
"POT-Creation-Date: 2025-09-13T17:01:13.807Z\n"
"PO-Revision-Date: 2018-10-25T09:02:35.143Z\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -44,6 +44,9 @@ msgstr ""
msgid "Period"
msgstr ""

msgid "Totals"
msgstr ""

msgid "Occupation"
msgstr "Profession"

Expand Down
42 changes: 36 additions & 6 deletions src/data/common/Dhis2DataElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const dataElementFields = {
categories: {
id: true,
name: true,
code: true,
categoryOptions: {
id: true,
code: true,
Expand Down Expand Up @@ -75,7 +76,13 @@ type D2DataElement = MetadataPick<{
dataElements: { fields: typeof dataElementFields };
}>["dataElements"][number];

function makeCocOrderArray(namesArray: string[][]): string[] {
type D2DataElementTypes = D2DataElement["valueType"] | "MULTI_TEXT";

type D2DataElementNewType = Omit<D2DataElement, "valueType"> & {
valueType: D2DataElementTypes;
};

export function makeCocOrderArray(namesArray: string[][]): string[] {
return namesArray.reduce((prev, current) => {
return prev
.map(prevValue => {
Expand All @@ -90,6 +97,7 @@ function makeCocOrderArray(namesArray: string[][]): string[] {
}

function getCocOrdered(categoryCombo: D2DataElement["categoryCombo"], config: Dhis2DataStoreDataForm) {
const keyName = config.categoryCombinationsConfig[categoryCombo.code]?.viewType || "formName";
const allCategoryOptions = categoryCombo.categories
.map(c => {
return c.categoryOptions.flatMap(co => ({
Expand All @@ -113,9 +121,13 @@ function getCocOrdered(categoryCombo: D2DataElement["categoryCombo"], config: Dh
return coc.name === cocOrdered;
});

const optionsNames = match?.categoryOptions.map(co => co.displayName);
const optionsShortNames = match?.categoryOptions.map(co => co.displayShortName);
const optionsFormNames = match?.categoryOptions.map(co => co.displayFormName);
const orderedOptions = categoryCombo.categories.map(category => {
return match?.categoryOptions.find(co => category.categoryOptions.some(catOpt => catOpt.id === co.id));
});

const optionsNames = orderedOptions.map(co => co?.displayName);
const optionsShortNames = orderedOptions.map(co => co?.displayShortName);
const optionsFormNames = orderedOptions.map(co => co?.displayFormName);

const categoryOption =
categoryCombo.categories.length === 1
Expand All @@ -136,11 +148,10 @@ function getCocOrdered(categoryCombo: D2DataElement["categoryCombo"], config: Dh
: [];
});

const keyName = config.categoryCombinationsConfig[categoryCombo.code]?.viewType || "formName";
return result.map(x => ({ ...x, name: x[keyName] || x.name || "" }));
}

function getDataElement(dataElement: D2DataElement, config: Dhis2DataStoreDataForm): DataElement | null {
function getDataElement(dataElement: D2DataElementNewType, config: Dhis2DataStoreDataForm): DataElement | null {
const { valueType } = dataElement;
const deConfig = config.dataElementsConfig[dataElement.code];
const optionSetFromDataElement = dataElement.optionSet
Expand All @@ -157,6 +168,22 @@ function getDataElement(dataElement: D2DataElement, config: Dhis2DataStoreDataFo
const categoryCombination = {
id: dataElement.categoryCombo?.id,
name: dataElement.categoryCombo?.name,
categories: dataElement.categoryCombo?.categories.map(cat => {
const keyName = config.categoryCombinationsConfig[dataElement.categoryCombo.code]?.viewType || "formName";
return {
...cat,
categoryOptions: cat.categoryOptions.map(co => {
const record = {
id: co.id,
name: co.displayName,
formName: co.displayFormName,
shortName: co.displayShortName,
code: co.code,
};
return { id: record.id, code: co.code, name: record[keyName] ?? record.name };
}),
};
}),
categoryOptionCombos: getCocOrdered(dataElement.categoryCombo, config),
};
const categoryOptionCombos = dataElement.categoryCombo.categoryOptionCombos;
Expand All @@ -173,12 +200,15 @@ function getDataElement(dataElement: D2DataElement, config: Dhis2DataStoreDataFo
: undefined,
rules: [],
htmlText: undefined,
disabled: deConfig?.disabled || false,
};

switch (valueType) {
case "TEXT":
case "LONG_TEXT":
return { type: "TEXT", related: undefined, ...base };
case "MULTI_TEXT":
return { type: "MULTI_TEXT", related: undefined, ...base };
case "INTEGER":
case "INTEGER_NEGATIVE":
case "INTEGER_POSITIVE":
Expand Down
63 changes: 59 additions & 4 deletions src/data/common/Dhis2DataFormRepository.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import _ from "lodash";

import { Code, getId, Id } from "../../domain/common/entities/Base";
import { CompulsoryDataValue } from "../../domain/common/entities/CompulsoryDataValue";
import { DataElement } from "../../domain/common/entities/DataElement";
import {
DataElementRuleOptions,
Expand All @@ -11,7 +12,7 @@ import {
SectionTotalRule,
TotalRules,
} from "../../domain/common/entities/DataElementRule";
import { DataForm, defaultTexts, Section, SectionBase } from "../../domain/common/entities/DataForm";
import { DataForm, defaultTexts, RowConfigDetails, Section, SectionBase } from "../../domain/common/entities/DataForm";
import { Period } from "../../domain/common/entities/DataValue";
import { Indicator } from "../../domain/common/entities/Indicator";
import { SectionStyle } from "../../domain/common/entities/SectionStyle";
Expand Down Expand Up @@ -54,6 +55,9 @@ export class Dhis2DataFormRepository implements DataFormRepository {
texts: dataSetConfig.texts,
options: { dataElements: dataElementsOptions },
totalRules: totalRules,
compulsoryDataValues: dataSet.compulsoryDataElementOperands.map(
operand => new CompulsoryDataValue(operand.dataElement.id, operand.categoryOptionCombo.id)
),
};
}

Expand Down Expand Up @@ -109,7 +113,7 @@ export class Dhis2DataFormRepository implements DataFormRepository {
texts: config?.texts || defaultTexts,
tabs:
config?.tabs && config.tabs.active
? { active: true, order: config.tabs.order.toString() }
? { active: true, order: config.tabs.order.toString(), rules: config.tabs.rules }
: { active: false },
sortRowsBy: config?.sortRowsBy || "",
disableComments: config?.disableComments ?? false,
Expand Down Expand Up @@ -151,9 +155,24 @@ export class Dhis2DataFormRepository implements DataFormRepository {
toggleMultiple: config?.toggleMultiple
? buildToggleMultiple(config.toggleMultiple, dataElements)
: undefined,
fixedHeaders: config?.fixedHeaders || false,
enableTopScroll: config?.enableTopScroll || false,
fixedRowNames: config?.fixedRowNames || false,
};

if (!config) return { viewType: "table", calculateTotals: undefined, ...base };
if (!config)
return {
viewType: "table",
calculateTotals: undefined,
...base,
fixedHeaders: false,
columnsOrder: undefined,
enableGroups: false,
fixedRowNames: false,
enableTopScroll: false,
columnsConfig: undefined,
firstColumnConfig: undefined,
};

const base2 = getSectionBaseWithToggle(config, base, dataElements);

Expand All @@ -163,7 +182,15 @@ export class Dhis2DataFormRepository implements DataFormRepository {
case "table":
case "grid":
case "grid-with-totals":
return { viewType: config.viewType, calculateTotals: config.calculateTotals, ...base2 };
return {
viewType: config.viewType,
calculateTotals: config.calculateTotals,
columnsOrder: config.columnsOrder,
enableGroups: config.enableGroups || false,
columnsConfig: config.columnsConfig,
firstColumnConfig: config.firstColumnConfig,
...base2,
};
case "grid-with-subnational-ous":
return {
viewType: config.viewType,
Expand Down Expand Up @@ -193,6 +220,33 @@ export class Dhis2DataFormRepository implements DataFormRepository {
}),
...base2,
};
case "grid-category-columns": {
const rowsConfigWithTexts = _(config.rowsConfig)
.map((rowConfig, key): [string, RowConfigDetails] => {
const constant = configDataForm.constants.find(
c => c.code === rowConfig.rowNameConstant
);

return [
key,
{
cellsVisible: rowConfig.cellsVisible ?? true,
rowName: constant?.displayDescription,
},
];
})
.fromPairs()
.value();

return {
...base2,
viewType: config.viewType,
showCalculatedTotals: config.showCalculatedTotals,
categoriesColumns: config.categoriesColumns,
rowsConfig: rowsConfigWithTexts ?? undefined,
singleCategoryInColumns: config.singleCategoryInColumns ?? false,
};
}
default:
return { viewType: config.viewType, ...base2 };
}
Expand Down Expand Up @@ -480,6 +534,7 @@ function getMetadataQuery(options: { dataSetId: Id }) {
id: true,
code: true,
expiryDays: true,
compulsoryDataElementOperands: { dataElement: { id: true }, categoryOptionCombo: { id: true } },
dataInputPeriods: {
closingDate: true,
openingDate: true,
Expand Down
Loading
Loading