Skip to content

Commit

Permalink
Merge pull request #441 from dhis2/fix/DHIS2-12286/data-integrity-dis…
Browse files Browse the repository at this point in the history
…playname

fix(data-integrity): use displayName instead of hard-coded translations
  • Loading branch information
Birkbjo authored Jan 5, 2023
2 parents 880d423 + a7dd832 commit 38ec421
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 104 deletions.
7 changes: 2 additions & 5 deletions src/components/FormFields/DataIntegrityChecksField.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import {
} from '@dhis2/ui'
import cx from 'classnames'
import { hooks } from '../Store'
import {
getCheckName,
severityMap,
} from '../../services/server-translations/dataIntegrityChecks'
import { severityMap } from '../../services/server-translations/dataIntegrityChecks'
import styles from './DataIntegrityChecksField.module.css'

const { Field, useField } = ReactFinalForm
Expand Down Expand Up @@ -45,7 +42,7 @@ const DataIntegrityChecksField = ({ label, name }) => {
.map((option) => ({
...option,
value: option.name,
label: getCheckName(option.name),
label: option.displayName,
severity: severityMap[option.severity],
}))
.sort((a, b) => a.label.localeCompare(b.label))
Expand Down
99 changes: 0 additions & 99 deletions src/services/server-translations/dataIntegrityChecks.js
Original file line number Diff line number Diff line change
@@ -1,101 +1,5 @@
import i18n from '@dhis2/d2-i18n'

const dataIntegrityChecksMap = {
program_indicators_with_invalid_expressions: i18n.t(
'Program indicators with invalid expressions'
),
data_elements_without_groups: i18n.t('Data elements without groups'),
indicators_with_invalid_numerator: i18n.t(
'Indicators with invalid numerator'
),
program_rule_actions_without_notification: i18n.t(
'Program rule actions without notification'
),
categories_one_default_category_combo: i18n.t(
'Only one "default" category combo should exist'
),
data_elements_without_data_sets: i18n.t('Data elements without data sets'),
category_combos_being_invalid: i18n.t('Category combos being invalid'),
indicators_with_identical_formulas: i18n.t(
'Indicators with identical formulas'
),
indicators_without_groups: i18n.t('Indicators without groups'),
data_elements_in_data_set_not_in_form: i18n.t(
'Data elements in data set not in form'
),
program_rules_without_priority: i18n.t('Program rules without priority'),
validation_rules_without_groups: i18n.t('Validation rules without groups'),
program_indicators_with_invalid_filters: i18n.t(
'Program indicators with invalid filters'
),
categories_no_options: i18n.t('Categories with no category options'),
program_rules_without_condition: i18n.t('Program rules without condition'),
program_rule_actions_without_stage: i18n.t(
'Program rule actions without stage'
),
categories_one_default_category: i18n.t(
'Only one "default" category should exist'
),
categories_unique_category_combo: i18n.t(
'Lists category combos that share a combination of categories with at least one other category combo'
),
org_units_with_cyclic_references: i18n.t(
'Org units with cyclic references'
),
program_rule_variables_without_data_element: i18n.t(
'Program rule variables without data element'
),
validation_rules_with_invalid_right_side_expression: i18n.t(
'Validation rules with invalid right side expression'
),
data_sets_not_assigned_to_org_units: i18n.t(
'Data sets not assigned to org units'
),
data_elements_violating_exclusive_group_sets: i18n.t(
'Data elements violating exclusive group sets'
),
org_unit_groups_without_group_sets: i18n.t(
'Org unit groups without group sets'
),
program_rule_variables_without_attribute: i18n.t(
'Program rule variables without attribute'
),
org_units_violating_exclusive_group_sets: i18n.t(
'Org units violating exclusive group sets'
),
program_rule_actions_without_data_object: i18n.t(
'Program rule actions without data object'
),
categories_one_default_category_option: i18n.t(
'Only one "default" category option should exist'
),
categories_one_default_category_option_combo: i18n.t(
'Only one "default" category option combo should exist'
),
org_units_without_groups: i18n.t('Org units without groups'),
program_indicators_without_expression: i18n.t(
'Program indicators without expression'
),
indicators_violating_exclusive_group_sets: i18n.t(
'Indicators violating exclusive group sets'
),
periods_duplicates: i18n.t('Periods duplicates'),
data_elements_assigned_to_data_sets_with_different_period_types: i18n.t(
'Data elements assigned to data sets with different period types'
),
program_rules_without_action: i18n.t('Program rules without action'),
org_units_being_orphaned: i18n.t('Org units being orphaned'),
validation_rules_with_invalid_left_side_expression: i18n.t(
'Validation rules with invalid left side expression'
),
indicators_with_invalid_denominator: i18n.t(
'Indicators with invalid denominator'
),
program_rule_actions_without_section: i18n.t(
'Program rule actions without section'
),
}

export const severityMap = {
WARNING: i18n.t('Warning'),
SEVERE: i18n.t('Severe'),
Expand All @@ -116,8 +20,5 @@ const snakeCaseToHumanReadable = (string) => {
.concat(` ${rest.join(' ')}`)
}

export const getCheckName = (name) =>
dataIntegrityChecksMap[name] || snakeCaseToHumanReadable(name)

export const getReportTypeLabel = (type) =>
reportTypeMap[type] || snakeCaseToHumanReadable(type)

1 comment on commit 38ec421

@dhis2-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.