Skip to content

Commit

Permalink
fix: fix padding/margin in form
Browse files Browse the repository at this point in the history
  • Loading branch information
Birkbjo committed Nov 22, 2024
1 parent b00cae2 commit a2e0a09
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
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
5 changes: 5 additions & 0 deletions src/pages/organisationUnits/form/GeometryFields.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.coordinateField > div {
display: flex;
flex-direction: column;
gap: var(--spacers-dp16);
}
2 changes: 2 additions & 0 deletions src/pages/organisationUnits/form/GeometryFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Field, InputField } from '@dhis2/ui'
import React from 'react'
import { useField } from 'react-final-form'
import { getConstantTranslation } from '../../../lib'
import css from './GeometryFields.module.css'

export function GeometryFields() {
const fieldName = 'geometry'
Expand All @@ -26,6 +27,7 @@ export function GeometryFields() {
return !input.value || input.value?.type === 'Point' ? (
<>
<Field
className={css.coordinateField}
name={fieldName}
error={meta.touched && !!meta.error}
validationText={
Expand Down

0 comments on commit a2e0a09

Please sign in to comment.