Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 111 additions & 15 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: 2026-03-16T18:45:52.560Z\n"
"PO-Revision-Date: 2026-03-16T18:45:52.560Z\n"
"POT-Creation-Date: 2026-03-20T08:09:24.158Z\n"
"PO-Revision-Date: 2026-03-20T08:09:24.158Z\n"

msgid "schemas"
msgstr "schemas"
Expand Down Expand Up @@ -2095,6 +2095,12 @@ msgstr "Factor"
msgid "Program name"
msgstr "Program name"

msgid "Category Combination (PI Disaggregation)"
msgstr "Category Combination (PI Disaggregation)"

msgid "Attribute Combination (PI Disaggregation)"
msgstr "Attribute Combination (PI Disaggregation)"

msgid "Decimals in data output"
msgstr "Decimals in data output"

Expand Down Expand Up @@ -3466,6 +3472,66 @@ msgstr "No indicators available. Remove one from source."
msgid "What should happen to the source indicators after the merge is complete?"
msgstr "What should happen to the source indicators after the merge is complete?"

msgid "Set up the basic information for this legend."
msgstr "Set up the basic information for this legend."

msgid "Legend items"
msgstr "Legend items"

msgid "Create legend items to define value ranges and associated colors."
msgstr "Create legend items to define value ranges and associated colors."

msgid "End value must be greater than start value"
msgstr "End value must be greater than start value"

msgid "Legend items must not overlap"
msgstr "Legend items must not overlap"

msgid "Legend items must not have gaps"
msgstr "Legend items must not have gaps"

msgid "Name is required"
msgstr "Name is required"

msgid "Must be greater than start value"
msgstr "Must be greater than start value"

msgid "Add legend item"
msgstr "Add legend item"

msgid "Edit legend item"
msgstr "Edit legend item"

msgid "Start value"
msgstr "Start value"

msgid "End value"
msgstr "End value"

msgid "Add"
msgstr "Add"

msgid "Number of legend items"
msgstr "Number of legend items"

msgid "Color scale"
msgstr "Color scale"

msgid "Create legend items"
msgstr "Create legend items"

msgid "Replace existing items?"
msgstr "Replace existing items?"

msgid "This will replace all existing legend items."
msgstr "This will replace all existing legend items."

msgid "Proceed"
msgstr "Proceed"

msgid "No legend items yet. Add items manually or use the generator above."
msgstr "No legend items yet. Add items manually or use the generator above."

msgid "Exit without saving"
msgstr "Exit without saving"

Expand Down Expand Up @@ -3770,6 +3836,9 @@ msgstr ""
" ' and '\n"
" )}"

msgid "Add a unit inside"
msgstr "Add a unit inside"

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

Expand Down Expand Up @@ -4944,6 +5013,9 @@ msgstr "External"
msgid "Group"
msgstr "Group"

msgid "Set up how users can access program data outside their capture scope."
msgstr "Set up how users can access program data outside their capture scope."

msgid "Organisation unit access"
msgstr "Organisation unit access"

Expand All @@ -4953,6 +5025,40 @@ msgstr "Role access"
msgid "Save the program first to set up sharing."
msgstr "Save the program first to set up sharing."

msgid "Open"
msgstr "Open"

msgid "Users can open tracked entities in their search or capture scope."
msgstr "Users can open tracked entities in their search or capture scope."

msgid "Audited"
msgstr "Audited"

msgid ""
"Users can open tracked entities in their search or capture scope. Opening "
"outside capture scope is logged."
msgstr ""
"Users can open tracked entities in their search or capture scope. Opening "
"outside capture scope is logged."

msgid "Protected"
msgstr "Protected"

msgid ""
"Users can open tracked entities in their capture scope. To open outside "
"capture scope (but within search scope), users must give a reason for "
"temporary access. All access is logged."
msgstr ""
"Users can open tracked entities in their capture scope. To open outside "
"capture scope (but within search scope), users must give a reason for "
"temporary access. All access is logged."

msgid "Closed"
msgstr "Closed"

msgid "Users can only open tracked entities in their capture scope."
msgstr "Users can only open tracked entities in their capture scope."

msgid "Notifications"
msgstr "Notifications"

Expand Down Expand Up @@ -5534,6 +5640,9 @@ msgstr "Restore stage"
msgid "Add a program stage"
msgstr "Add a program stage"

msgid "Access Level"
msgstr "Access Level"

msgid "Relationship entity constraint"
msgstr "Relationship entity constraint"

Expand Down Expand Up @@ -5577,9 +5686,6 @@ msgstr "Initiating side constraint"
msgid "Receiving side constraint"
msgstr "Receiving side constraint"

msgid "Name is required"
msgstr "Name is required"

msgid "Relationship name seen from initiating entity is required"
msgstr "Relationship name seen from initiating entity is required"

Expand Down Expand Up @@ -5612,16 +5718,6 @@ msgstr ""
"Searches using these operators return no results. Use this to prevent "
"inefficient searches."

msgid "Confidential"
msgstr "Confidential"

msgid ""
"Prevent searching or viewing in analytics. Available only when system "
"encryption is enabled."
msgstr ""
"Prevent searching or viewing in analytics. Available only when system "
"encryption is enabled."

msgid "Inherit values from tracked entities linked by a relationship"
msgstr "Inherit values from tracked entities linked by a relationship"

Expand Down
1 change: 1 addition & 0 deletions src/lib/form/createJsonPatchOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const complexKeys = [
'programStageDataElements',
'programRuleActions',
'programStages',
'legends',
] as const
export const sanitizeDirtyValueKeys = (dirtyKeys: string[]) => {
const complexChanges = complexKeys.filter((complexKey) =>
Expand Down
48 changes: 48 additions & 0 deletions src/pages/legendSets/Edit.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { useQuery } from '@tanstack/react-query'
import React from 'react'
import { useParams } from 'react-router-dom'
import { DefaultEditFormContents, FormBase } from '../../components'
import { SECTIONS_MAP } from '../../lib'
import { useBoundResourceQueryFn } from '../../lib/query/useBoundQueryFn'
import { LegendSet, PickWithFieldFilters } from '../../types/generated'
import { LegendSetFormFields } from './form/LegendSetFormFields'
import { fieldFilters } from './form/fieldFilters'

Check failure on line 9 in src/pages/legendSets/Edit.tsx

View workflow job for this annotation

GitHub Actions / lint

`./form/fieldFilters` import should occur before import of `./form/LegendSetFormFields`
import { validate } from './form/legendSetFormSchema'
import { useOnSubmitEditLegendSet } from './form/useOnSubmitLegendSet'

type LegendSetEditFormValues = PickWithFieldFilters<
LegendSet,
typeof fieldFilters
>

const section = SECTIONS_MAP.legendSet

export const Component = () => {
const queryFn = useBoundResourceQueryFn()
const modelId = useParams().id as string

const query = {
resource: 'legendSets',
id: modelId,
params: {
fields: fieldFilters.concat(),
},
}

const legendSetQuery = useQuery({
queryKey: [query],
queryFn: queryFn<LegendSetEditFormValues>,
})

return (
<FormBase
onSubmit={useOnSubmitEditLegendSet(modelId)}
initialValues={legendSetQuery.data}
validate={validate}
>
<DefaultEditFormContents section={section}>
<LegendSetFormFields />
</DefaultEditFormContents>
</FormBase>
)
}
23 changes: 23 additions & 0 deletions src/pages/legendSets/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 } from '../../lib'
import { LegendSetFormFields } from './form/LegendSetFormFields'
import { initialValues, validate } from './form/legendSetFormSchema'
import { useOnSubmitNewLegendSet } from './form/useOnSubmitLegendSet'

const section = SECTIONS_MAP.legendSet

export const Component = () => {
return (
<FormBase
onSubmit={useOnSubmitNewLegendSet()}
initialValues={initialValues}
validate={validate}
>
<DefaultNewFormContents section={section}>
<LegendSetFormFields />
</DefaultNewFormContents>
</FormBase>
)
}
54 changes: 54 additions & 0 deletions src/pages/legendSets/form/LegendSetFormFields.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import i18n from '@dhis2/d2-i18n'
import React from 'react'
import {
CustomAttributesSection,
StandardFormField,
StandardFormSection,
StandardFormSectionDescription,
StandardFormSectionTitle,
} from '../../../components'
import { CodeField } from '../../../components/form/fields/CodeField'
import { NameField } from '../../../components/form/fields/NameField'
import { SECTIONS_MAP } from '../../../lib'
import { LegendsField } from './legends/LegendsField'

const section = SECTIONS_MAP.legendSet

export function LegendSetFormFields() {
return (
<>
<StandardFormSection>
<StandardFormSectionTitle>
{i18n.t('Basic information')}
</StandardFormSectionTitle>
<StandardFormSectionDescription>
{i18n.t(
'Set up the basic information for this legend.'
)}
</StandardFormSectionDescription>

<StandardFormField>
<NameField schemaSection={section} />
</StandardFormField>

<StandardFormField>
<CodeField schemaSection={section} />
</StandardFormField>
</StandardFormSection>

<StandardFormSection>
<StandardFormSectionTitle>
{i18n.t('Legend items')}
</StandardFormSectionTitle>
<StandardFormSectionDescription>
{i18n.t(
'Create legend items to define value ranges and associated colors.'
)}
</StandardFormSectionDescription>
<LegendsField />
</StandardFormSection>

<CustomAttributesSection schemaSection={section} />
</>
)
}
12 changes: 12 additions & 0 deletions src/pages/legendSets/form/fieldFilters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {
DEFAULT_FIELD_FILTERS,
ATTRIBUTE_VALUES_FIELD_FILTERS,
} from '../../../lib'

export const fieldFilters = [
...DEFAULT_FIELD_FILTERS,
...ATTRIBUTE_VALUES_FIELD_FILTERS,
'name',
'code',
'legends[id,name,startValue,endValue,color]',
] as const
Loading
Loading