From 0dd15c0055a02c9eb93979ef706268bf78b2dd9d Mon Sep 17 00:00:00 2001 From: Flaminia Cavallo Date: Mon, 4 Nov 2024 14:26:09 +0100 Subject: [PATCH] feat: minor fixes --- i18n/en.pot | 29 ++++++++++++++++--- .../form/DefaultFormErrorNotice.tsx | 2 +- src/lib/constants/translatedModelConstants.ts | 10 +++++++ src/pages/organisationUnits/Edit.tsx | 10 ++----- .../organisationUnits/form/GeometryFields.tsx | 25 +++++++++------- .../form/organisationUnitSchema.ts | 16 ++++++++-- 6 files changed, 67 insertions(+), 25 deletions(-) diff --git a/i18n/en.pot b/i18n/en.pot index b151bf35..e1c67243 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -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-10-28T13:53:29.437Z\n" -"PO-Revision-Date: 2024-10-28T13:53:29.437Z\n" +"POT-Creation-Date: 2024-11-04T08:55:34.983Z\n" +"PO-Revision-Date: 2024-11-04T08:55:34.985Z\n" msgid "schemas" msgstr "schemas" @@ -819,6 +819,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" @@ -1173,8 +1194,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" diff --git a/src/components/form/DefaultFormErrorNotice.tsx b/src/components/form/DefaultFormErrorNotice.tsx index c5102749..9ba043bc 100644 --- a/src/components/form/DefaultFormErrorNotice.tsx +++ b/src/components/form/DefaultFormErrorNotice.tsx @@ -87,7 +87,7 @@ const ErrorList = ({ errors }: { errors: Record }) => { > {labels.get(key) || key}: - {value} + {JSON.stringify(value)} ) })} diff --git a/src/lib/constants/translatedModelConstants.ts b/src/lib/constants/translatedModelConstants.ts index e3ed1315..cd238e57 100644 --- a/src/lib/constants/translatedModelConstants.ts +++ b/src/lib/constants/translatedModelConstants.ts @@ -69,6 +69,16 @@ 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 = { ...AGGREGATION_TYPE, ...DOMAIN_TYPE, diff --git a/src/pages/organisationUnits/Edit.tsx b/src/pages/organisationUnits/Edit.tsx index 945e4d51..1a8affb3 100644 --- a/src/pages/organisationUnits/Edit.tsx +++ b/src/pages/organisationUnits/Edit.tsx @@ -11,11 +11,7 @@ import { } from '../../lib' import { useBoundResourceQueryFn } from '../../lib/query/useBoundQueryFn' import { OrganisationUnit, PickWithFieldFilters } from '../../types/generated' -import { - FormValues, - OrganisationUnitFormField, - organisationUnitSchema, -} from './form' +import { OrganisationUnitFormField, organisationUnitSchema } from './form' const fieldFilters = [ ...DEFAULT_FIELD_FILTERS, @@ -71,8 +67,8 @@ export const Component = () => { modelId, })} section={section} - initialValues={orgUnit.data as FormValues} - validate={(values: FormValues) => { + initialValues={orgUnit.data as OrgUnitFormValues} + validate={(values: OrgUnitFormValues) => { return validate(organisationUnitSchema, values) }} > diff --git a/src/pages/organisationUnits/form/GeometryFields.tsx b/src/pages/organisationUnits/form/GeometryFields.tsx index 143d5626..931caf19 100644 --- a/src/pages/organisationUnits/form/GeometryFields.tsx +++ b/src/pages/organisationUnits/form/GeometryFields.tsx @@ -2,6 +2,7 @@ import i18n from '@dhis2/d2-i18n' import { Field, InputField } from '@dhis2/ui' import React from 'react' import { useField } from 'react-final-form' +import { getConstantTranslation } from '../../../lib' export function GeometryFields() { const fieldName = 'geometry' @@ -11,8 +12,8 @@ export function GeometryFields() { longitude, latitude, }: { - longitude?: string - latitude?: string + longitude?: number + latitude?: number }) => { const geometry = { type: 'Point', @@ -26,21 +27,23 @@ export function GeometryFields() { <> handleChange({ - longitude: e.value, - latitude: input.value.coordinates?.[1], + longitude: e.value + ? parseFloat(e.value) + : undefined, + latitude: input.value?.coordinates?.[1], }) } label={i18n.t('Longitude')} inputWidth="400px" name="longitude" type="number" - value={input.value.coordinates?.[0].toString()} + value={input.value.coordinates?.[0]?.toString()} min="-90" max="90" step="any" @@ -48,15 +51,15 @@ export function GeometryFields() { handleChange({ - longitude: input.value.coordinates?.[0], - latitude: e.value, + longitude: input.value?.coordinates?.[0], + latitude: e.value ? parseFloat(e.value) : undefined, }) } inputWidth="400px" label={i18n.t('Longitude')} name="latitude" type="number" - value={input.value.coordinates?.[1].toString()} + value={input.value?.coordinates?.[1]?.toString()} min="-180" max="180" step="any" @@ -66,7 +69,7 @@ export function GeometryFields() { ) : (