Skip to content

Commit

Permalink
feat(DHIS2-16132): add ability to transpose/pivot a section form
Browse files Browse the repository at this point in the history
  • Loading branch information
kabaros committed Feb 20, 2024
1 parent f54e9a0 commit daa42bb
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,8 @@
"href": ".."
}
}
},
"engines": {
"node": "14"
}
}
35 changes: 34 additions & 1 deletion src/EditModel/SectionDialog.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class SectionDialog extends React.Component {

this.state = {
categoryCombo: false,
disableDataElementAutoGroup: false
disableDataElementAutoGroup: false,
transposeSection: false,
groupTransposedSection: false
};
dataElementStore.setState([]);
assignedDataElementStore.setState([]);
Expand Down Expand Up @@ -85,6 +87,8 @@ class SectionDialog extends React.Component {
description: props.sectionModel.description,
showRowTotals: props.sectionModel.showRowTotals,
showColumnTotals: props.sectionModel.showColumnTotals,
transposeSection: props.sectionModel.transposeSection,
groupTransposedSection: props.sectionModel.groupTransposedSection,
disableDataElementAutoGroup: props.sectionModel.disableDataElementAutoGroup,
filterText: '',
filterDataElementIds,
Expand Down Expand Up @@ -129,6 +133,17 @@ class SectionDialog extends React.Component {
this.setState({ disableDataElementAutoGroup: value })
}

handleTransposeSectionChange = (e, value) => {
this.setState({
transposeSection: value,
groupTransposedSection: !value ? false : this.state.groupTransposedSection
})
}

handleGroupTransposedSectionChange = (e, value) => {
this.setState({ groupTransposedSection: value })
}

handleFilterChange = (e) => {
this.setState({ filterText: e.target.value });
}
Expand Down Expand Up @@ -216,6 +231,8 @@ class SectionDialog extends React.Component {
description: this.state.description,
showRowTotals: this.state.showRowTotals,
showColumnTotals: this.state.showColumnTotals,
transposeSection: this.state.transposeSection,
groupTransposedSection: this.state.groupTransposedSection,
disableDataElementAutoGroup: this.state.disableDataElementAutoGroup,
dataElements: assignedDataElementStore.state.map(de => ({ id: de })),
indicators: assignedIndicatorStore.state.map(i => ({ id: i })),
Expand Down Expand Up @@ -396,6 +413,22 @@ class SectionDialog extends React.Component {
style={{ margin: '16px 0' }}
onCheck={this.handleDisableDataElementAutoGroupChange}
/>
<label>
{ this.getTranslation('section_config_options')}
</label>
<Checkbox
label={this.getTranslation('transpose_section')}
checked={this.state.transposeSection}
style={{ margin: '16px 0' }}
onCheck={this.handleTransposeSectionChange}
/>
<Checkbox
label={this.getTranslation('transpose_group_by_data_element')}
checked={this.state.groupTransposedSection}
style={{ margin: '16px 0' }}
disabled={!this.state.transposeSection}
onCheck={this.handleGroupTransposedSectionChange}
/>
{this.renderFilters()}
{this.renderAvailableOptions()}
</Dialog>
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/i18n_module_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1779,6 +1779,9 @@ att_opt_combo=Complete registration att opt combo
open_user_guide=Open user guide
section_id=Section ID
show_row_totals=Show row totals
transpose_section=Pivot section (transpose)
transpose_group_by_data_element=Group pivoted section by data element
section_config_options=Section configuration options
show_column_totals=Show column totals
category_combo_filter=Category combo filter
no_filter=<No filter>
Expand Down

0 comments on commit daa42bb

Please sign in to comment.