Skip to content

Commit

Permalink
fix(newform): default catcombo as init value
Browse files Browse the repository at this point in the history
  • Loading branch information
Birkbjo committed Oct 25, 2023
1 parent 7234277 commit f517683
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/lib/constants/categoryConstants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* Might seem wrong to hardcode this, but it makes things simpler
these IDs are hardcoded in the backend
see
https://github.com/dhis2/dhis2-core/blob/master/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultCategoryService.java#L472
and
https://github.com/dhis2/dhis2-core/blob/master/dhis-2/dhis-services/dhis-service-administration/src/main/resources/data-integrity-checks/categories/categories_one_default_category_combo.yaml
*/

export const DEFAULT_CATEGORY_OPTION_ID = 'xYerKDKCefk'
export const DEFAULT_CATEGORY_ID = 'GLevLNI9wkl'
export const DEFAULT_CATEGORY_COMBO_ID = 'bjDvmb4bfuf'
export const DEFAULT_CATEGORY_OPTION_COMBO_ID = 'HllvX50cXC0'
1 change: 1 addition & 0 deletions src/lib/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './sectionListViewsConfig'
export * from './sections'
export * from './translatedModelConstants'
export * from './translatedModelProperties'
export * from './categoryConstants'
9 changes: 7 additions & 2 deletions src/pages/dataElements/New.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import React, { useEffect, useMemo, useRef } from 'react'
import { Form } from 'react-final-form'
import { useNavigate } from 'react-router-dom'
import { StandardFormActions, StandardFormSection } from '../../components'
import { SCHEMA_SECTIONS, getSectionPath, useSchemas } from '../../lib'
import {
DEFAULT_CATEGORY_COMBO_ID,
SCHEMA_SECTIONS,
getSectionPath,
useSchemas,
} from '../../lib'
import { Attribute } from '../../types/generated'
import {
DataElementFormFields,
Expand Down Expand Up @@ -44,7 +49,7 @@ function useInitialValues(customAttributes: Attribute[]) {
aggregationType:
schemas.dataElement.properties.aggregationType.constants?.[0],
style: { icon: '', color: '' },
categoryCombo: { id: '' },
categoryCombo: { id: DEFAULT_CATEGORY_COMBO_ID },
optionSet: { id: '' },
commentOptionSet: { id: '' },
legendSets: [],
Expand Down

0 comments on commit f517683

Please sign in to comment.