Skip to content

Commit

Permalink
Merge branch 'master' of github-chisom:dhis2/maintenance-app-beta int…
Browse files Browse the repository at this point in the history
…o DHIS2-18142/category-option-group-forms
  • Loading branch information
Chisomchima committed Nov 28, 2024
2 parents 9f6ecd9 + 3c78f90 commit babb167
Show file tree
Hide file tree
Showing 26 changed files with 850 additions and 521 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# [0.17.0](https://github.com/dhis2/maintenance-app-beta/compare/v0.16.1...v0.17.0) (2024-11-27)


### Features

* add format validation to date fields and to dates in schemas ([#451](https://github.com/dhis2/maintenance-app-beta/issues/451)) ([4ea1d3c](https://github.com/dhis2/maintenance-app-beta/commit/4ea1d3c22133b2f9b63bc58cbf69b3d09e70e2a9))

## [0.16.1](https://github.com/dhis2/maintenance-app-beta/compare/v0.16.0...v0.16.1) (2024-11-25)


### Bug Fixes

* address feedback from org unit new form ([#447](https://github.com/dhis2/maintenance-app-beta/issues/447)) ([958563e](https://github.com/dhis2/maintenance-app-beta/commit/958563e5805fcb7d942749aabb82964f80492bc7))

# [0.16.0](https://github.com/dhis2/maintenance-app-beta/compare/v0.15.0...v0.16.0) (2024-11-25)


### Features

* add indicator list type list view ([#433](https://github.com/dhis2/maintenance-app-beta/issues/433)) ([2668c68](https://github.com/dhis2/maintenance-app-beta/commit/2668c683fcda0807f34cb3c2a92f405d5ff66578))
* upgrade ui library to latest version ([#448](https://github.com/dhis2/maintenance-app-beta/issues/448)) ([ba73ad8](https://github.com/dhis2/maintenance-app-beta/commit/ba73ad8f9b8114203b3c874f6d8e055fe83856e2))

# [0.15.0](https://github.com/dhis2/maintenance-app-beta/compare/v0.14.0...v0.15.0) (2024-11-22)


Expand Down
41 changes: 34 additions & 7 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ 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-21T14:53:27.430Z\n"
"PO-Revision-Date: 2024-11-21T14:53:27.430Z\n"
"POT-Creation-Date: 2024-11-27T08:30:38.416Z\n"
"PO-Revision-Date: 2024-11-27T08:30:38.417Z\n"
"POT-Creation-Date: 2024-11-26T14:06:00.934Z\n"
"PO-Revision-Date: 2024-11-26T14:06:00.934Z\n"

msgid "schemas"
msgstr "schemas"
Expand Down Expand Up @@ -102,6 +104,9 @@ msgstr "Set up information for the attributes assigned to {{modelName}}"
msgid "Code"
msgstr "Code"

msgid "Required"
msgstr "Required"

msgid "Description"
msgstr "Description"

Expand Down Expand Up @@ -891,6 +896,9 @@ msgstr "This field requires a unique value, please choose another one"
msgid "{{label}} (required)"
msgstr "{{label}} (required)"

msgid "Should not exceed {{maxLength}} characters"
msgstr "Should not exceed {{maxLength}} characters"

msgid "No changes to be saved"
msgstr "No changes to be saved"

Expand All @@ -903,12 +911,12 @@ msgstr "Cannot save empty object"
msgid "Created successfully"
msgstr "Created successfully"

msgid "Required"
msgstr "Required"

msgid "Period type"
msgstr "Period type"

msgid "Factor"
msgstr "Factor"

msgid "Basic information"
msgstr "Basic information"

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

msgid "Set up the basic information for this Indicator Type."
msgstr "Set up the basic information for this Indicator Type."

msgid "Longitude"
msgstr "Longitude"

Expand Down Expand Up @@ -1235,8 +1246,8 @@ msgstr ""
"Choose where this new organisation unit should be placed in the existing "
"hierarchy"

msgid "Set up the basic information for this organisation unit."
msgstr "Set up the basic information for this organisation unit."
msgid "Set up the basic information for this organisation unit"
msgstr "Set up the basic information for this organisation unit"

msgid "Opening date"
msgstr "Opening date"
Expand Down Expand Up @@ -1305,6 +1316,22 @@ msgstr ""
"This is the first organisation unit and will be created as the root of the "
"hierarchy."

msgid "Must be a valid mobile number"
msgstr "Must be a valid mobile number"

msgid "Must be a valid url"
msgstr "Must be a valid url"

msgid ""
"Longitude should be between -90 and 90. Latitude should be between -180 and "
"180"
msgstr ""
"Longitude should be between -90 and 90. Latitude should be between -180 and "
"180"

msgid "Parent organisation unit cannot be itself or a descendant of itself."
msgstr "Parent organisation unit cannot be itself or a descendant of itself."

msgid "No organisation units available"
msgstr "No organisation units available"

Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maintenance-app",
"version": "0.15.0",
"version": "0.17.0",
"description": "",
"license": "BSD-3-Clause",
"private": true,
Expand Down Expand Up @@ -39,8 +39,8 @@
},
"dependencies": {
"@dhis2/app-runtime": "^3.9.3",
"@dhis2/multi-calendar-dates": "^2.0.0-alpha.5",
"@dhis2/ui": "^10.0.0",
"@dhis2/multi-calendar-dates": "^2.0.0",
"@dhis2/ui": "^10.1.3",
"@tanstack/react-table": "^8.16.0",
"@types/lodash": "^4.14.198",
"lodash": "^4.17.21",
Expand All @@ -55,7 +55,7 @@
},
"resolutions": {
"eslint": "^8",
"@dhis2/multi-calendar-dates": "^2.0.0-alpha.5",
"@dhis2/ui": "^10.0.0"
"@dhis2/multi-calendar-dates": "^2.0.0",
"@dhis2/ui": "^10.1.3"
}
}
1 change: 1 addition & 0 deletions src/components/form/FormBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useCustomAttributesQuery } from './attributes'

type MaybeModelWithAttributes = {
id?: string
name?: string
attributeValues?: PartialAttributeValue[] | undefined
}

Expand Down
17 changes: 9 additions & 8 deletions src/components/form/attributes/CustomAttributes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { InputFieldFF, SingleSelectFieldFF, TextAreaFieldFF } from '@dhis2/ui'
import * as React from 'react'
import { Field as FieldRFF, useFormState } from 'react-final-form'
import {
StandardFormField,
StandardFormSection,
StandardFormSectionDescription,
StandardFormSectionTitle,
Expand Down Expand Up @@ -38,7 +39,7 @@ function CustomAttribute({ attribute, index }: CustomAttributeProps) {
}

return (
<StandardFormSection key={attribute.id}>
<StandardFormField key={attribute.id}>
<FieldRFF
component={SingleSelectFieldFF}
required={required}
Expand All @@ -47,49 +48,49 @@ function CustomAttribute({ attribute, index }: CustomAttributeProps) {
name={name}
options={options}
/>
</StandardFormSection>
</StandardFormField>
)
}

if (attribute.valueType === 'TEXT') {
return (
<StandardFormSection key={attribute.id}>
<StandardFormField key={attribute.id}>
<FieldRFF
component={InputFieldFF}
required={required}
inputWidth={inputWidth}
label={attribute.displayFormName}
name={name}
/>
</StandardFormSection>
</StandardFormField>
)
}

if (attribute.valueType === 'LONG_TEXT') {
return (
<StandardFormSection key={attribute.id}>
<StandardFormField key={attribute.id}>
<FieldRFF
component={TextAreaFieldFF}
required={required}
inputWidth={inputWidth}
label={attribute.displayFormName}
name={name}
/>
</StandardFormSection>
</StandardFormField>
)
}

if (attribute.valueType === 'GEOJSON') {
return (
<StandardFormSection key={attribute.id}>
<StandardFormField key={attribute.id}>
<FieldRFF
component={TextAreaFieldFF}
required={required}
inputWidth={inputWidth}
label={attribute.displayFormName}
name={name}
/>
</StandardFormSection>
</StandardFormField>
)
}
// @TODO: Verify that all value types have been covered!
Expand Down
51 changes: 36 additions & 15 deletions src/components/form/fields/DateField.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import i18n from '@dhis2/d2-i18n'
import { CalendarInput, CalendarInputProps } from '@dhis2/ui'
import React from 'react'
import React, { useState } from 'react'
import { useField } from 'react-final-form'
import { selectedLocale, useSystemSetting } from '../../../lib'

Expand All @@ -12,6 +13,12 @@ type DateFieldProps = Omit<
label?: string
required?: boolean
}
type ValidationProps = {
error: boolean
validationText?: string
valid?: boolean
validationCode?: string
}
export function DateField({
name,
label,
Expand All @@ -20,35 +27,49 @@ export function DateField({
}: DateFieldProps) {
const calendar = useSystemSetting('keyCalendar')
const locale = selectedLocale
const { meta, input } = useField<string | undefined>(name, {
format: (value) => {
if (value) {
return value.slice(0, 10)
}
return value
},
const [validation, setValidation] = useState<ValidationProps>({
error: false,
})

const handleChange: CalendarInputProps['onDateSelect'] = (payload) => {
input.onChange(payload?.calendarDateString)
const { input, meta } = useField<string | undefined>(name)

Check warning on line 34 in src/components/form/fields/DateField.tsx

View workflow job for this annotation

GitHub Actions / lint

'meta' is assigned a value but never used

const handleChange: CalendarInputProps['onDateSelect'] = (
payload: {
calendarDateString: string
validation?: ValidationProps
} | null
) => {
if (!payload?.calendarDateString && required) {
setValidation({
error: true,
valid: false,
validationCode: 'EMPTY',
validationText: i18n.t('Required'),
})
} else {
setValidation(payload?.validation || { error: false })
}
input.onChange(payload?.calendarDateString || '')
input.onBlur()
}

return (
<div style={{ width: '400px' }}>
{/* TODO: we can remove style above, once inputWidth for CalendarInput is fixed */}
<div>
<CalendarInput
inputWidth={'400px'}
date={input.value}
name={name}
required={required}
calendar={calendar as CalendarInputProps['calendar']}
onDateSelect={handleChange}
timeZone={'utc'}
locale={locale}
error={!!(meta.touched && meta.invalid && meta.error)}
validationText={meta.touched ? meta.error : undefined}
format={'YYYY-MM-DD'}
onBlur={(_, e) => input.onBlur(e)}
clearable
label={required ? `${label} *` : label}
label={required ? `${label} (required)` : label}
{...validation}
valid={validation?.valid && input?.value !== ''}
{...calendarInputProps}
/>
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/components/sectionList/bulk/Bulk.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
flex-shrink: 0;
flex-basis: 160px;
flex-grow: 1;
max-width: 250px;
min-width: 250px;
max-width: 300px;
}

.subtitle {
Expand All @@ -27,7 +28,7 @@
flex-basis: 160px;
flex-grow: 1;
flex-shrink: 0;
max-width: 250px;
max-width: 225px;
}

.addActionButton {
Expand Down
9 changes: 7 additions & 2 deletions src/lib/form/modelFormSchemas.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import i18n from '@dhis2/d2-i18n'
import { z } from 'zod'

/* Note that these schemas describes validations for what we send to the server,
/* Note that these schemas describes validations for what we send to the server,
and not what is stored in the form. Unknown keys are stripped by default. */

const modelReference = z.object({ id: z.string() })
Expand All @@ -15,7 +16,11 @@ const identifiable = z.object({
const attributeValues = z
.array(
z.object({
value: z.string(),
value: z.string().max(230, {
message: i18n.t('Should not exceed {{maxLength}} characters', {
maxLength: 230,
}),
}),
attribute: z.object({
id: z.string(),
}),
Expand Down
27 changes: 26 additions & 1 deletion src/lib/sectionList/listViews/sectionListViewsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,37 @@ export const modelListViewsConfig = {
},
indicator: {
columns: {
default: ['name', DESCRIPTORS.publicAccess, 'lastUpdated'],
default: [
'name',
{ label: i18n.t('Indicator Type'), path: 'indicatorType' },
DESCRIPTORS.publicAccess,
'lastUpdated',
],
},
filters: {
default: ['indicatorType'],
},
},
indicatorType: {
columns: {
default: [
'name',
{ label: i18n.t('Factor'), path: 'factor' },
'lastUpdated',
],
available: [
'code',
'created',
'createdBy',
'href',
'id',
'lastUpdatedBy',
],
},
filters: {
default: [],
},
},
categoryOptionGroupSet: {
columns: {
default: [
Expand Down
Loading

0 comments on commit babb167

Please sign in to comment.