Skip to content

Commit

Permalink
feat: merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
flaminic committed Dec 9, 2024
2 parents bdd76bf + bc062b8 commit 9040a0c
Show file tree
Hide file tree
Showing 21 changed files with 66 additions and 46 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## [0.19.3](https://github.com/dhis2/maintenance-app-beta/compare/v0.19.2...v0.19.3) (2024-12-05)


### Bug Fixes

* **categoryOptionGroup:** remove dataDimension field ([#460](https://github.com/dhis2/maintenance-app-beta/issues/460)) ([276e4ab](https://github.com/dhis2/maintenance-app-beta/commit/276e4abc4ec378afafa7414d8333aec1208f00e5))

## [0.19.2](https://github.com/dhis2/maintenance-app-beta/compare/v0.19.1...v0.19.2) (2024-12-05)


### Bug Fixes

* date field to format date before displaying, org unit filters ([#456](https://github.com/dhis2/maintenance-app-beta/issues/456)) ([8537bce](https://github.com/dhis2/maintenance-app-beta/commit/8537bceb284d098500eed2497292c9ab033ebff0))
* refresh list view on close of dialog ([#461](https://github.com/dhis2/maintenance-app-beta/issues/461)) ([c10d79f](https://github.com/dhis2/maintenance-app-beta/commit/c10d79ffba8383e9559906f98bb858e6113bba83))
* **categoryCombo:** validation and load optionSize on initial load [skip release] ([#457](https://github.com/dhis2/maintenance-app-beta/issues/457)) ([a1a6110](https://github.com/dhis2/maintenance-app-beta/commit/a1a611021f8e9db17bf87c3e28a32ccc1dcbf691))
* **categoryOption:** load formName [skip release] ([#458](https://github.com/dhis2/maintenance-app-beta/issues/458)) ([bb3baee](https://github.com/dhis2/maintenance-app-beta/commit/bb3baee8c14ac44554e75d48abd0d80113d8e8cf))
* **categoryOptionGroups:** add custom attributesection to group/groupset [skip release] ([#459](https://github.com/dhis2/maintenance-app-beta/issues/459)) ([5c853bc](https://github.com/dhis2/maintenance-app-beta/commit/5c853bc995886b1d6ee97be447f87ba3c0df76dd))

## [0.19.1](https://github.com/dhis2/maintenance-app-beta/compare/v0.19.0...v0.19.1) (2024-12-03)


Expand Down
6 changes: 4 additions & 2 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-12-04T10:11:21.431Z\n"
"PO-Revision-Date: 2024-12-04T10:11:21.431Z\n"
"POT-Creation-Date: 2024-12-05T06:06:51.471Z\n"
"PO-Revision-Date: 2024-12-05T06:06:51.471Z\n"
"POT-Creation-Date: 2024-12-03T07:31:45.454Z\n"
"PO-Revision-Date: 2024-12-03T07:31:45.455Z\n"

msgid "schemas"
msgstr "schemas"
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.19.1",
"version": "0.19.3",
"description": "",
"license": "BSD-3-Clause",
"private": true,
Expand Down
11 changes: 7 additions & 4 deletions src/components/form/fields/DateField.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import i18n from '@dhis2/d2-i18n'
import { CalendarInput, CalendarInputProps } from '@dhis2/ui'
import React, { useState } from 'react'
import React, { useEffect, useState } from 'react'

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

View workflow job for this annotation

GitHub Actions / lint

'useEffect' is defined but never used
import { useField } from 'react-final-form'
import { selectedLocale, useSystemSetting } from '../../../lib'

Expand All @@ -16,7 +16,7 @@ type DateFieldProps = Omit<
type ValidationProps = {
error: boolean
validationText?: string
valid?: boolean
valid: boolean
validationCode?: string
}
export function DateField({
Expand All @@ -29,9 +29,12 @@ export function DateField({
const locale = selectedLocale
const [validation, setValidation] = useState<ValidationProps>({
error: false,
valid: true,
})

const { input, meta } = useField<string | undefined>(name)
const { input } = useField<string | undefined>(name, {
format: (value) => (value ? value.substring(0, 10) : ''),
})

const handleChange: CalendarInputProps['onDateSelect'] = (
payload: {
Expand All @@ -47,7 +50,7 @@ export function DateField({
validationText: i18n.t('Required'),
})
} else {
setValidation(payload?.validation || { error: false })
setValidation(payload?.validation || { error: false, valid: true })
}
input.onChange(payload?.calendarDateString || '')
input.onBlur()
Expand Down
7 changes: 2 additions & 5 deletions src/components/form/fields/DescriptionField.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import i18n from '@dhis2/d2-i18n'
import { TextAreaFieldFF } from '@dhis2/ui'
import { createMaxCharacterLength, TextAreaFieldFF } from '@dhis2/ui'
import React from 'react'
import { Field as FieldRFF } from 'react-final-form'
import { SchemaSection, useCheckMaxLengthFromSchema } from '../../../lib'

Check warning on line 5 in src/components/form/fields/DescriptionField.tsx

View workflow job for this annotation

GitHub Actions / lint

'useCheckMaxLengthFromSchema' is defined but never used
Expand All @@ -11,10 +11,7 @@ export function DescriptionField({
helpText?: string
schemaSection: SchemaSection
}) {
const validate = useCheckMaxLengthFromSchema(
schemaSection.name,
'description'
)
const validate = createMaxCharacterLength(2000)

return (
<FieldRFF
Expand Down
7 changes: 6 additions & 1 deletion src/components/sectionList/SectionListWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ export const SectionListWrapper = ({
BaseListModel | undefined
>(undefined)

const onSharingDialogClose = () => {
setSharingDialogId(undefined)
refetch()
}

const SectionListMessage = () => {
if (error) {
console.log(error.details || error)
Expand Down Expand Up @@ -159,7 +164,7 @@ export const SectionListWrapper = ({
but it works if you pass the correct type*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type={schema.singular as any}
onClose={() => setSharingDialogId(undefined)}
onClose={() => onSharingDialogClose()}
/>
)}
{translationDialogModel && (
Expand Down
1 change: 1 addition & 0 deletions src/components/sectionList/listView/useModelListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export const useModelListView = () => {

const columns = selectedView.columns
const filters = selectedView.filters

return { view: selectedView, columns, filters, query }
}

Expand Down
1 change: 1 addition & 0 deletions src/lib/sectionList/listViews/sectionListViewsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export const modelListViewsConfig = {
},
filters: {
default: [],
overrideDefaultAvailable: true,
},
},
categoryOption: {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/sectionList/useSectionListSortOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const isValidSortPathForSchema = (schema: Schema, path: string) => {
const schemaProperty = getSchemaPropertyForPath(schema, path)

// sorting for metadata-API only works on simple and persisted properties
if (schemaProperty && schemaProperty.simple && schemaProperty.persisted) {
if (schemaProperty && schemaProperty.simple) {
return true
}
return false
Expand Down
2 changes: 1 addition & 1 deletion src/pages/categories/form/categorySchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { z } from 'zod'
import { getDefaults, createFormValidate, modelFormSchemas } from '../../../lib'
import { Category } from '../../../types/generated'

/* Note that this describes what we send to the server,
/* Note that this describes what we send to the server,
and not what is stored in the form. */
const { identifiable, referenceCollection, withAttributeValues } =
modelFormSchemas
Expand Down
2 changes: 1 addition & 1 deletion src/pages/categoryCombos/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const fieldFilters = [
...DEFAULT_FIELD_FILTERS,
'name',
'code',
'categories[id,displayName]',
'categories[id,displayName,categoryOptions~size~rename(categoryOptionsSize)],',
'skipTotal',
'dataDimensionType',
] as const
Expand Down
5 changes: 4 additions & 1 deletion src/pages/categoryCombos/form/CategoryComboFormFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import i18n from '@dhis2/d2-i18n'
import { CheckboxFieldFF, RadioFieldFF } from '@dhis2/ui'
import React from 'react'
import { Field } from 'react-final-form'
import { useParams } from 'react-router-dom'
import {
StandardFormField,
StandardFormSection,
StandardFormSectionTitle,
StandardFormSectionDescription,
HorizontalFieldGroup,
ModelTransferField,
NameField,
CodeField,
} from '../../../components'
Expand All @@ -18,6 +18,7 @@ import { CategoriesField } from './CategoriesField'
const section = SECTIONS_MAP.categoryCombo

export const CategoryComboFormFields = () => {
const isNewForm = useParams().id === undefined
return (
<>
<StandardFormSection>
Expand Down Expand Up @@ -55,13 +56,15 @@ export const CategoryComboFormFields = () => {
label={i18n.t('Disaggregation')}
type="radio"
value={'DISAGGREGATION'}
disabled={!isNewForm}
/>
<Field<string | undefined>
name="dataDimensionType"
component={RadioFieldFF}
label={i18n.t('Attribute')}
type="radio"
value={'ATTRIBUTE'}
disabled={!isNewForm}
/>
</HorizontalFieldGroup>
</StandardFormField>
Expand Down
1 change: 1 addition & 0 deletions src/pages/categoryCombos/form/categoryComboSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const categoryComboSchema = identifiable
categoryOptionsSize: z.number(),
})
)
.min(1, i18n.t('At least one category is required'))
.refine(
(categories) => {
const generatedCocsCount = categories.reduce(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { RadioFieldFF, CheckboxFieldFF } from '@dhis2/ui'
import React from 'react'
import { Field } from 'react-final-form'
import {
CustomAttributesSection,
DefaultIdentifiableFields,
DescriptionField,
HorizontalFieldGroup,
Expand Down Expand Up @@ -112,6 +113,7 @@ function CategoryOptionGroupSetFormFields() {
</StandardFormField>
</StandardFormField>
</StandardFormSection>
<CustomAttributesSection schemaSection={section} />
</>
)
}
Expand Down
1 change: 0 additions & 1 deletion src/pages/categoryOptionGroups/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const fieldFilters = [
'code',
'description',
'categoryOptions[id,displayName]',
'dataDimension',
'dataDimensionType',
] as const

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { RadioFieldFF, CheckboxFieldFF } from '@dhis2/ui'
import React from 'react'
import { Field } from 'react-final-form'
import {
CustomAttributesSection,
DefaultIdentifiableFields,
DescriptionField,
HorizontalFieldGroup,
Expand Down Expand Up @@ -65,17 +66,6 @@ function CategoryOptionGroupFormFields() {
/>
</HorizontalFieldGroup>
</StandardFormField>
<StandardFormField>
<Field
name="dataDimension"
type="checkbox"
component={CheckboxFieldFF}
label={i18n.t('Use as data dimension')}
helpText={i18n.t(
'Category option group will be available to the analytics as another dimension'
)}
/>
</StandardFormField>
</StandardFormSection>

<StandardFormSection>
Expand Down Expand Up @@ -110,6 +100,7 @@ function CategoryOptionGroupFormFields() {
/>
</StandardFormField>
</StandardFormField>
<CustomAttributesSection schemaSection={section} />
</StandardFormSection>
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const categoryOptionGroupSchema = identifiable
dataDimensionType: z
.nativeEnum(CategoryOptionGroup.dataDimensionType)
.default(CategoryOptionGroup.dataDimensionType.DISAGGREGATION),
dataDimension: z.boolean().default(true),
categoryOptions: referenceCollection
.min(1, 'At least one category option is required')
.default([]),
Expand Down
1 change: 1 addition & 0 deletions src/pages/categoryOptions/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const fieldFilters = [
...DEFAULT_FIELD_FILTERS,
...ATTRIBUTE_VALUES_FIELD_FILTERS,
'name',
'formName',
'code',
'shortName',
'description',
Expand Down
6 changes: 5 additions & 1 deletion src/pages/organisationUnits/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import {
} from '../../lib'
import { useBoundResourceQueryFn } from '../../lib/query/useBoundQueryFn'
import { OrganisationUnit, PickWithFieldFilters } from '../../types/generated'
import { OrganisationUnitFormField, validate } from './form'
import {
OrganisationUnitFormField,
organisationUnitSchema,
validate,
} from './form'

const fieldFilters = [
...DEFAULT_FIELD_FILTERS,
Expand Down
5 changes: 3 additions & 2 deletions src/pages/organisationUnits/form/OrganisationUnitSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export function OrganisationUnitSelector() {
const fieldName = 'parent'
const { input, meta } = useField(fieldName, { format: (value) => value })
const userRootOrgUnits = useCurrentUserRootOrgUnits()
const userRootOrgUnitsIds = userRootOrgUnits.map((unit) => `/${unit.id}`)
const userRootOrgUnitsIds = userRootOrgUnits.map((unit) => unit.id)
const userRootOrgUnitsPaths = userRootOrgUnits.map((unit) => unit.path)
const [selected, setSelected] = useState<[string] | []>(
input.value?.path ? [input.value.path] : []
)
Expand Down Expand Up @@ -44,7 +45,7 @@ export function OrganisationUnitSelector() {
roots={userRootOrgUnitsIds}
selected={selected}
initiallyExpanded={[
...userRootOrgUnitsIds,
...userRootOrgUnitsPaths,
...selected,
]}
/>
Expand Down
18 changes: 5 additions & 13 deletions src/pages/organisationUnits/form/organisationUnitSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,7 @@ export const organisationUnitSchema = identifiable
.extend({
shortName: z.string().trim().default(''),
code: z.string().trim().optional(),
description: z
.string()
.trim()
.max(2147483647, {
message: i18n.t('Should not exceed {{maxLength}} characters', {
maxLength: 2147483647,
}),
})
.optional(),
description: z.string().trim().optional(),
image: z.object({ id: z.string() }).optional(),
phoneNumber: z
.string()
Expand All @@ -33,7 +25,7 @@ export const organisationUnitSchema = identifiable
}),
})
.optional(),
openingDate: z.string().date(),
openingDate: z.coerce.date(),
email: z.string().email().optional(),
address: z
.string()
Expand All @@ -47,12 +39,12 @@ export const organisationUnitSchema = identifiable
.string()
.url({ message: i18n.t('Must be a valid url') })
.optional(),
closedDate: z.string().date().optional(),
closedDate: z.coerce.date().optional(),
comment: z
.string()
.max(2147483647, {
.max(2000, {
message: i18n.t('Should not exceed {{maxLength}} characters', {
maxLength: 2147483647,
maxLength: 2000,
}),
})
.optional(),
Expand Down

0 comments on commit 9040a0c

Please sign in to comment.