-
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.
Merge branch 'master' into feat/list-sharing-dialog
- Loading branch information
Showing
115 changed files
with
3,350 additions
and
398 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
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,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); | ||
} |
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,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> | ||
</> | ||
) | ||
} |
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,2 @@ | ||
export { CustomAttributes } from './CustomAttributes' | ||
export { useCustomAttributesQuery } from './useCustomAttributesQuery' |
Oops, something went wrong.