Skip to content

Commit

Permalink
Merge branch 'master' into feat/list-sharing-dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Birkbjo committed Mar 8, 2024
2 parents 6cc28ce + cd37a44 commit eafd564
Show file tree
Hide file tree
Showing 115 changed files with 3,350 additions and 398 deletions.
128 changes: 79 additions & 49 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-03-05T18:46:53.934Z\n"
"PO-Revision-Date: 2024-03-05T18:46:53.934Z\n"
"POT-Creation-Date: 2024-03-05T22:55:26.244Z\n"
"PO-Revision-Date: 2024-03-05T22:55:26.244Z\n"

msgid "schemas"
msgstr "schemas"
Expand Down Expand Up @@ -72,6 +72,30 @@ msgstr "Something went wrong when submitting the form"
msgid "Save and close"
msgstr "Save and close"

msgid "<No value>"
msgstr "<No value>"

msgid "Code"
msgstr "Code"

msgid "Description"
msgstr "Description"

msgid "A name should be concise and easy to recognize."
msgstr "A name should be concise and easy to recognize."

msgid "{{fieldLabel}} (required)"
msgstr "{{fieldLabel}} (required)"

msgid "Name"
msgstr "Name"

msgid "Often used in reports where space is limited"
msgstr "Often used in reports where space is limited"

msgid "Short name"
msgstr "Short name"

msgid "Failed to load {{label}}"
msgstr "Failed to load {{label}}"

Expand All @@ -87,12 +111,15 @@ msgstr "Category combo"
msgid "None"
msgstr "None"

msgid "Filter data element groups"
msgstr "Filter data element groups"

msgid "Filter data elements"
msgstr "Filter data elements"

msgid "Filter legend sets"
msgstr "Filter legend sets"

msgid "<No value>"
msgstr "<No value>"

msgid "Option set"
msgstr "Option set"

Expand Down Expand Up @@ -120,12 +147,6 @@ msgstr "An error occurred while loading the items."
msgid "{{modelName}} management"
msgstr "{{modelName}} management"

msgid "Short name"
msgstr "Short name"

msgid "Code"
msgstr "Code"

msgid "Created by"
msgstr "Created by"

Expand Down Expand Up @@ -621,9 +642,6 @@ msgstr "Favorite"
msgid "Domain type"
msgstr "Domain type"

msgid "Name"
msgstr "Name"

msgid "Sharing"
msgstr "Sharing"

Expand All @@ -648,6 +666,48 @@ msgstr "Custom attributes"
msgid "Exit without saving"
msgstr "Exit without saving"

msgid "Create data element group"
msgstr "Create data element group"

msgid "Compulsory"
msgstr "Compulsory"

msgid "Data dimension"
msgstr "Data dimension"

msgid "Selected data element groups"
msgstr "Selected data element groups"

msgid "Refresh list"
msgstr "Refresh list"

msgid "Add new"
msgstr "Add new"

msgid "Basic information"
msgstr "Basic information"

msgid "Set up the information for this data element group"
msgstr "Set up the information for this data element group"

msgid "Explain the purpose of this data element group."
msgstr "Explain the purpose of this data element group."

msgid "@TODO"
msgstr "@TODO"

msgid "Custom fields for your DHIS2 instance"
msgstr "Custom fields for your DHIS2 instance"

msgid "Selected data elements"
msgstr "Selected data elements"

msgid "Explain the purpose of this data element and how it's measured."
msgstr "Explain the purpose of this data element and how it's measured."

msgid "A data element name should be concise and easy to recognize."
msgstr "A data element name should be concise and easy to recognize."

msgid "Create data element"
msgstr "Create data element"

Expand All @@ -660,9 +720,6 @@ msgstr "The default way to aggregate this data element in analytics."
msgid "Disabled for the selected value type."
msgstr "Disabled for the selected value type."

msgid "{{fieldLabel}} (required)"
msgstr "{{fieldLabel}} (required)"

msgid "Aggregation type"
msgstr "Aggregation type"

Expand All @@ -676,18 +733,6 @@ msgstr ""
"A color and icon are helpful for identifying data elements in "
"information-dense screens."

msgid "Loading custom attributes"
msgstr "Loading custom attributes"

msgid "Something went wrong with retrieving the custom attributes"
msgstr "Something went wrong with retrieving the custom attributes"

msgid "Description"
msgstr "Description"

msgid "Explain the purpose of this data element and how it's measured."
msgstr "Explain the purpose of this data element and how it's measured."

msgid "Domain"
msgstr "Domain"

Expand All @@ -703,24 +748,15 @@ msgstr "Use a pattern to limit what information can be entered."
msgid "e.g. 999-000-0000"
msgstr "e.g. 999-000-0000"

msgid "StandardForm name"
msgstr "StandardForm name"
msgid "Form name"
msgstr "Form name"

msgid "An alternative name used in section or automatic data entry forms."
msgstr "An alternative name used in section or automatic data entry forms."

msgid "Selected legends"
msgstr "Selected legends"

msgid "Refresh list"
msgstr "Refresh list"

msgid "Add new"
msgstr "Add new"

msgid "A data element name should be concise and easy to recognize."
msgstr "A data element name should be concise and easy to recognize."

msgid "Option set comment"
msgstr "Option set comment"

Expand All @@ -730,9 +766,6 @@ msgstr "Choose a set of predefined comment for data entry"
msgid "Choose a set of predefined options for data entry"
msgstr "Choose a set of predefined options for data entry"

msgid "Often used in reports where space is limited"
msgstr "Often used in reports where space is limited"

msgid "Url"
msgstr "Url"

Expand All @@ -752,12 +785,12 @@ msgstr ""
msgid "Store zero data values"
msgstr "Store zero data values"

msgid "Basic information"
msgstr "Basic information"

msgid "Set up the information for this data element"
msgstr "Set up the information for this data element"

msgid "Explain the purpose of this data element."
msgstr "Explain the purpose of this data element."

msgid "Disaggregation and Option sets"
msgstr "Disaggregation and Option sets"

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

msgid "Custom fields for your DHIS2 instance"
msgstr "Custom fields for your DHIS2 instance"

msgid "Metadata management"
msgstr "Metadata management"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type OnFilterChange = ({ value }: { value: string }) => void
interface SearchableSingleSelectPropTypes {
onChange: OnChange
onFilterChange: OnFilterChange
onEndReached: () => void
onEndReached?: () => void
onRetryClick: () => void
dense?: boolean
options: Option[]
Expand Down Expand Up @@ -103,7 +103,7 @@ export const SearchableSingleSelect = ({
const [{ isIntersecting }] = entries

if (isIntersecting) {
onEndReached()
onEndReached?.()
}
},
{ threshold: 0.8 }
Expand Down Expand Up @@ -141,6 +141,7 @@ export const SearchableSingleSelect = ({
<div className={classes.searchInput}>
<Input
dense
initialFocus
value={filter}
onChange={({ value }) => setFilterValue(value ?? '')}
placeholder={i18n.t('Filter options')}
Expand Down
15 changes: 15 additions & 0 deletions src/components/form/DefaultFormContents.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.form {
background: var(--colors-white);
padding: var(--spacers-dp16);
padding-bottom: var(--spacers-dp32);
}

.formActions {
position: fixed;
left: 0;
bottom: 0;
width: 100vw;
padding: var(--spacers-dp16);
box-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
background: var(--colors-white);
}
58 changes: 58 additions & 0 deletions src/components/form/DefaultFormContents.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import i18n from '@dhis2/d2-i18n'
import { NoticeBox } from '@dhis2/ui'
import React, { useEffect, useRef } from 'react'
import { useNavigate } from 'react-router-dom'
import { getSectionPath } from '../../lib'
import { ModelSection } from '../../types'
import { StandardFormSection, StandardFormActions } from '../standardForm'
import classes from './DefaultFormContents.module.css'

export function DefaultFormContents({
children,
section,
submitError,
submitting,
}: {
children: React.ReactNode
section: ModelSection
submitting: boolean
submitError?: string
}) {
const formErrorRef = useRef<HTMLDivElement | null>(null)
const navigate = useNavigate()

const listPath = getSectionPath(section)
useEffect(() => {
if (submitError) {
formErrorRef.current?.scrollIntoView({ behavior: 'smooth' })
}
}, [submitError])

return (
<>
<div className={classes.form}>{children}</div>
{submitError && (
<StandardFormSection>
<div ref={formErrorRef}>
<NoticeBox
error
title={i18n.t(
'Something went wrong when submitting the form'
)}
>
{submitError}
</NoticeBox>
</div>
</StandardFormSection>
)}
<div className={classes.formActions}>
<StandardFormActions
cancelLabel={i18n.t('Cancel')}
submitLabel={i18n.t('Save and close')}
submitting={submitting}
onCancelClick={() => navigate(listPath)}
/>
</div>
</>
)
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import i18n from '@dhis2/d2-i18n'
import {
InputFieldFF,
NoticeBox,
SingleSelectFieldFF,
TextAreaFieldFF,
} from '@dhis2/ui'
import { InputFieldFF, SingleSelectFieldFF, TextAreaFieldFF } from '@dhis2/ui'
import * as React from 'react'
import { Field as FieldRFF } from 'react-final-form'
import { StandardFormSection } from '../../../components'
import { Attribute } from '../../../types/generated'
import { useCustomAttributesQuery } from './useCustomAttributesQuery'
import { Field as FieldRFF, useFormState } from 'react-final-form'
import { StandardFormSection } from '../..'
import { Attribute, AttributeValue } from '../../../types/generated'

const inputWidth = '440px'

type ValuesWithAttributes = {
attributeValues: AttributeValue[]
}

type CustomAttributeProps = {
attribute: Attribute
index: number
Expand Down Expand Up @@ -81,30 +79,17 @@ function CustomAttribute({ attribute, index }: CustomAttributeProps) {
}

export function CustomAttributes() {
const customAttributes = useCustomAttributesQuery()
const loading = customAttributes.loading
const error = customAttributes.error

if (loading) {
return <>{i18n.t('Loading custom attributes')}</>
}
const formState = useFormState<ValuesWithAttributes>({
subscription: { initialValues: true },
})

if (error) {
return (
<NoticeBox
error
title={i18n.t(
'Something went wrong with retrieving the custom attributes'
)}
>
{error.toString()}
</NoticeBox>
)
}
const customAttributes = formState.initialValues.attributeValues?.map(
(av) => av.attribute
)

return (
<>
{customAttributes.data?.map((customAttribute, index) => {
{customAttributes?.map((customAttribute, index) => {
return (
<CustomAttribute
key={customAttribute.id}
Expand Down
2 changes: 2 additions & 0 deletions src/components/form/attributes/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { CustomAttributes } from './CustomAttributes'
export { useCustomAttributesQuery } from './useCustomAttributesQuery'
Loading

0 comments on commit eafd564

Please sign in to comment.