-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extract common identifiablefields
- Loading branch information
Showing
17 changed files
with
139 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react' | ||
import { useSchemaSectionHandleOrThrow } from '../../lib' | ||
import { StandardFormField } from '../standardForm' | ||
import { CodeField } from './CodeField' | ||
import { DescriptionField } from './DescriptionField' | ||
import { NameField } from './NameField' | ||
import { ShortNameField } from './ShortNameField' | ||
|
||
export const DefaultIdentifiableFields = () => { | ||
const schemaSection = useSchemaSectionHandleOrThrow() | ||
|
||
return ( | ||
<> | ||
<StandardFormField> | ||
<NameField schemaSection={schemaSection} /> | ||
</StandardFormField> | ||
|
||
<StandardFormField> | ||
<ShortNameField schemaSection={schemaSection} /> | ||
</StandardFormField> | ||
|
||
<StandardFormField> | ||
<CodeField schemaSection={schemaSection} /> | ||
</StandardFormField> | ||
|
||
<StandardFormField> | ||
<DescriptionField schemaSection={schemaSection} /> | ||
</StandardFormField> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import i18n from '@dhis2/d2-i18n' | ||
import { TextAreaFieldFF } from '@dhis2/ui' | ||
import React from 'react' | ||
import { Field as FieldRFF } from 'react-final-form' | ||
import { SchemaSection, useCheckMaxLengthFromSchema } from '../../lib' | ||
|
||
export function DescriptionField({ | ||
helpText, | ||
schemaSection, | ||
}: { | ||
helpText?: string | ||
schemaSection: SchemaSection | ||
}) { | ||
const validate = useCheckMaxLengthFromSchema(schemaSection.name, 'formName') | ||
|
||
const helpString = | ||
helpText || | ||
i18n.t( | ||
"Explain the purpose of this data element and how it's measured." | ||
) | ||
|
||
return ( | ||
<FieldRFF | ||
component={TextAreaFieldFF} | ||
dataTest="formfields-description" | ||
inputWidth="400px" | ||
name="description" | ||
label={i18n.t('Description')} | ||
helpText={helpString} | ||
validate={validate} | ||
validateFields={[]} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export { DefaultIdentifiableFields } from './DefaultIdentifibleFIelds' | ||
export { NameField } from './NameField' | ||
export { ShortNameField } from './ShortNameField' | ||
export { CodeField } from './CodeField' | ||
export { DescriptionField } from './DescriptionField' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.