Skip to content

Commit

Permalink
chore: resolve merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Chisomchima committed Nov 12, 2024
2 parents 6fd1423 + 9d306d5 commit ff8e76b
Show file tree
Hide file tree
Showing 23 changed files with 525 additions and 67 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# [0.12.0](https://github.com/dhis2/maintenance-app-beta/compare/v0.11.0...v0.12.0) (2024-11-07)


### Features

* add dataset lists ([de9f34d](https://github.com/dhis2/maintenance-app-beta/commit/de9f34d9d4a9ed42d92ab50ce0eeb8d08d4bb166))
* add org unit edit form ([#430](https://github.com/dhis2/maintenance-app-beta/issues/430)) ([79a1892](https://github.com/dhis2/maintenance-app-beta/commit/79a18921c876a36d357edee88f38114bc412a0a9))

# [0.11.0](https://github.com/dhis2/maintenance-app-beta/compare/v0.10.2...v0.11.0) (2024-11-05)


### Features

* category option group sets ([#427](https://github.com/dhis2/maintenance-app-beta/issues/427)) ([37b4051](https://github.com/dhis2/maintenance-app-beta/commit/37b4051e7ff081a43a2fd399ee94272922808d98))

## [0.10.2](https://github.com/dhis2/maintenance-app-beta/compare/v0.10.1...v0.10.2) (2024-10-30)


Expand Down
39 changes: 33 additions & 6 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-11T12:39:32.386Z\n"
"PO-Revision-Date: 2024-11-11T12:39:32.387Z\n"
"POT-Creation-Date: 2024-11-05T07:23:15.731Z\n"
"PO-Revision-Date: 2024-11-05T07:23:15.732Z\n"

msgid "schemas"
msgstr "schemas"
Expand Down Expand Up @@ -822,6 +822,27 @@ msgstr "GeoJSON"
msgid "Disaggregation"
msgstr "Disaggregation"

msgid "Point"
msgstr "Point"

msgid "MultiPoint"
msgstr "MultiPoint"

msgid "LineString"
msgstr "LineString"

msgid "MultiLineString"
msgstr "MultiLineString"

msgid "Polygon"
msgstr "Polygon"

msgid "MultiPolygon"
msgstr "MultiPolygon"

msgid "GeometryCollection"
msgstr "GeometryCollection"

msgid "Aggregation type"
msgstr "Aggregation type"

Expand Down Expand Up @@ -1094,6 +1115,12 @@ msgstr ""
"included. PHU will still be available for the PHU level, but not included "
"in the aggregations to the levels above."

msgid "Longitude"
msgstr "Longitude"

msgid "{{type}} coordinates are not editable"
msgstr "{{type}} coordinates are not editable"

msgid "Upload an image"
msgstr "Upload an image"

Expand Down Expand Up @@ -1143,8 +1170,8 @@ msgstr "Location"
msgid "Set up the organisation unit location."
msgstr "Set up the organisation unit location."

msgid "Latitude"
msgstr "Latitude"
msgid "Reference assignment"
msgstr "Reference assignment"

msgid "Longitude"
msgstr "Longitude"
Expand Down Expand Up @@ -1179,8 +1206,8 @@ msgstr "Filter available programs"
msgid "Filter selected programs"
msgstr "Filter selected programs"

msgid "New organisation unit will be created inside {{displayName}}"
msgstr "New organisation unit will be created inside {{displayName}}"
msgid "Organisation unit will be positioned inside {{displayName}}"
msgstr "Organisation unit will be positioned inside {{displayName}}"

msgid "Creating first organisation unit"
msgstr "Creating first organisation unit"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maintenance-app",
"version": "0.10.2",
"version": "0.12.0",
"description": "",
"license": "BSD-3-Clause",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion src/components/form/DefaultFormErrorNotice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const ErrorList = ({ errors }: { errors: Record<string, string> }) => {
>
{labels.get(key) || key}:
</span>
<span>{value}</span>
<span>{JSON.stringify(value)}</span>
</li>
)
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const BaseModelTransfer = <TModel extends DisplayableModel>(
[queryResult.data, modelName]
)

const selectedOptions = selected.map(toDisplayOption)
const selectedOptions = selected ? selected?.map(toDisplayOption) : []
const loadedOptions = Array.from(allDataMap.values()).map(toDisplayOption)
// always include selected options
const allOptions = selectedOptions.concat(loadedOptions || [])
Expand Down
11 changes: 11 additions & 0 deletions src/lib/constants/translatedModelConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,22 @@ export const DATA_DIMENSION_TYPE = {
ATTRIBUTE: i18n.t('Attribute'),
}

export const GEOMETRY_TYPE = {
POINT: i18n.t('Point'),
MULTIPOINT: i18n.t('MultiPoint'),
LINESTRING: i18n.t('LineString'),
MULTILINESTRING: i18n.t('MultiLineString'),
POLYGON: i18n.t('Polygon'),
MULTIPOLYGON: i18n.t('MultiPolygon'),
GEOMETRYCOLLECTION: i18n.t('GeometryCollection'),
}

const allConstantTranslations: Record<string, string> = {
...AGGREGATION_TYPE,
...DOMAIN_TYPE,
...VALUE_TYPE,
...DATA_DIMENSION_TYPE,
...GEOMETRY_TYPE,
}

export const getConstantTranslation = (constant: string): string => {
Expand Down
3 changes: 2 additions & 1 deletion src/lib/form/createJsonPatchOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ type PatchAttributeValue = {
value: AttributeValue['value']
}

type ModelWithAttributeValues = IdentifiableObject & {
export type ModelWithAttributeValues = {
id?: string
attributeValues?: PatchAttributeValue[]
}

Expand Down
27 changes: 23 additions & 4 deletions src/lib/form/useOnSubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { useNavigate } from 'react-router-dom'
import { ModelSection } from '../../types'
import { IdentifiableObject } from '../../types/generated'
import { getSectionPath, useNavigateWithSearchState } from '../routeUtils'
import { createJsonPatchOperations } from './createJsonPatchOperations'
import {
createJsonPatchOperations,
ModelWithAttributeValues,
} from './createJsonPatchOperations'
import { useCreateModel } from './useCreateModel'
import { usePatchModel } from './usePatchModel'

Expand Down Expand Up @@ -57,9 +60,25 @@ export const useOnSubmitEdit = <TFormValues extends IdentifiableObject>({
)
}

export const useOnSubmitNew = <TFormValues>({
export const defaultNewValueFormatter = <
TFormValues extends ModelWithAttributeValues
>(
values: TFormValues
) => {
if (values.attributeValues) {
return {
...values,
attributeValues: values.attributeValues.filter(
({ value }) => !!value
),
}
}
return values
}

export const useOnSubmitNew = <TFormValues extends ModelWithAttributeValues>({
section,
valueFormatter,
valueFormatter = defaultNewValueFormatter,
}: {
section: ModelSection
valueFormatter?: (values: TFormValues) => Record<string, unknown>
Expand Down Expand Up @@ -96,6 +115,6 @@ export const useOnSubmitNew = <TFormValues>({
})
navigate(`/${getSectionPath(section)}`)
},
[createModel, saveAlert, navigate, section]
[createModel, saveAlert, navigate, section, valueFormatter]
)
}
13 changes: 13 additions & 0 deletions src/lib/sectionList/listViews/sectionListViewsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ export const modelListViewsConfig = {
default: ['indicatorType'],
},
},
categoryOptionGroupSet: {
columns: {
default: [
'name',
'dataDimensionType',
DESCRIPTORS.publicAccess,
'lastUpdated',
],
},
filters: {
default: ['dataDimensionType'],
},
},
categoryOptionGroup: {
columns: {
default: [
Expand Down
62 changes: 62 additions & 0 deletions src/pages/categoryOptionGroupSets/Edit.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React from 'react'
import { useQuery } from 'react-query'
import { useParams } from 'react-router-dom'
import { DefaultEditFormContents, FormBase } from '../../components'
import {
ATTRIBUTE_VALUES_FIELD_FILTERS,
DEFAULT_FIELD_FILTERS,
SECTIONS_MAP,
useOnSubmitEdit,
} from '../../lib'
import { useBoundResourceQueryFn } from '../../lib/query/useBoundQueryFn'
import { PickWithFieldFilters } from '../../types/generated'
import { CategoryOptionGroupSet } from '../../types/models'
import CategoryOptionGroupSetFormFields from './form/CategoryOptionGroupSetFormFields'
import { validate } from './form/categoryOptionGroupSetSchema'

const fieldFilters = [
...DEFAULT_FIELD_FILTERS,
...ATTRIBUTE_VALUES_FIELD_FILTERS,
'name',
'shortName',
'code',
'description',
'categoryOptionGroups[id,displayName]',
'dataDimension',
'dataDimensionType',
] as const

export type CategoryOptionGroupSetFormValues = PickWithFieldFilters<
CategoryOptionGroupSet,
typeof fieldFilters
>

export const Component = () => {
const section = SECTIONS_MAP.categoryOptionGroupSet
const queryFn = useBoundResourceQueryFn()
const modelId = useParams().id as string
const query = {
resource: 'categoryOptionGroupSets',
id: modelId,
params: {
fields: fieldFilters.concat(),
},
}
const categoryOptionGroupSetQuery = useQuery({
queryKey: [query],
queryFn: queryFn<CategoryOptionGroupSetFormValues>,
})

return (
<FormBase
onSubmit={useOnSubmitEdit({ section, modelId })}
section={section}
initialValues={categoryOptionGroupSetQuery.data}
validate={validate}
>
<DefaultEditFormContents section={section}>
<CategoryOptionGroupSetFormFields />
</DefaultEditFormContents>
</FormBase>
)
}
4 changes: 4 additions & 0 deletions src/pages/categoryOptionGroupSets/List.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import React from 'react'
import { DefaultSectionList } from '../DefaultSectionList'

export const Component = () => <DefaultSectionList />
23 changes: 23 additions & 0 deletions src/pages/categoryOptionGroupSets/New.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react'
import { FormBase } from '../../components'
import { DefaultNewFormContents } from '../../components/form/DefaultFormContents'
import { SECTIONS_MAP, useOnSubmitNew } from '../../lib'
import CategoryOptionGroupSetFormFields from './form/CategoryOptionGroupSetFormFields'
import { initialValues, validate } from './form/categoryOptionGroupSetSchema'

const section = SECTIONS_MAP.categoryOptionGroupSet

export const Component = () => {
return (
<FormBase
section={section}
onSubmit={useOnSubmitNew({ section })}
initialValues={initialValues}
validate={validate}
>
<DefaultNewFormContents section={section}>
<CategoryOptionGroupSetFormFields />
</DefaultNewFormContents>
</FormBase>
)
}
Loading

0 comments on commit ff8e76b

Please sign in to comment.