-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3827: Sdg indicators->add table notice message + sdg metadata downloa…
…d links (#3854) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
b251d23
commit 70d7143
Showing
19 changed files
with
229 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@import 'src/client/style/partials'; | ||
|
||
.title-hints { | ||
display: flex; | ||
align-items: center; | ||
gap: $spacing-xs; | ||
} |
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,94 @@ | ||
import './Hints.scss' | ||
import React from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { Objects } from 'utils/objects' | ||
|
||
import { ApiEndPoint } from 'meta/api/endpoint' | ||
import { CountryIso } from 'meta/area' | ||
import { SubSectionHints, SubSections } from 'meta/assessment' | ||
|
||
import { useCycle } from 'client/store/assessment' | ||
import { useCycleRouteParams, useSectionRouteParams } from 'client/hooks/useRouteParams' | ||
import DefinitionLink from 'client/components/DefinitionLink' | ||
import { Props } from 'client/pages/Section/Title/props' | ||
|
||
type Hint = { | ||
document: string | ||
key: keyof SubSectionHints | ||
labelKey: string | ||
} | ||
|
||
const HINTS: Array<Hint> = [ | ||
{ document: 'tad', key: 'definitions', labelKey: 'definition.definitionLabel' }, | ||
{ document: 'faq', key: 'faqs', labelKey: 'definition.faqLabel' }, | ||
{ document: 'rn', key: 'notes', labelKey: 'definition.seeReportingNotes' }, | ||
] | ||
|
||
export const HintsSustainableDevelopment: React.FC<Props> = () => { | ||
const { t } = useTranslation() | ||
|
||
const routeParams = useSectionRouteParams<CountryIso>() | ||
const searchParams = new URLSearchParams(routeParams) | ||
|
||
return ( | ||
<div className="title-hints"> | ||
{['Metadata-15-01-01', 'Metadata-15-02-01'].map((key) => { | ||
searchParams.set('key', key) | ||
|
||
return ( | ||
<a | ||
key={key} | ||
className="definition-link no-print" | ||
href={`${ApiEndPoint.File.sdgMetadata()}?${searchParams.toString()}`} | ||
rel="noreferrer" | ||
target="_blank" | ||
> | ||
{t(`fra.sustainableDevelopment.${key}`)} | ||
</a> | ||
) | ||
})} | ||
</div> | ||
) | ||
} | ||
|
||
const Hints: React.FC<Props> = (props) => { | ||
const { subSection } = props | ||
const { hints: sectionHints } = subSection.props | ||
|
||
const { i18n, t } = useTranslation() | ||
const { assessmentName, cycleName } = useCycleRouteParams() | ||
const cycle = useCycle() | ||
|
||
const anchor = SubSections.getAnchor({ cycle, subSection }) | ||
const hints = sectionHints?.[cycle.uuid] ?? {} | ||
|
||
if (Objects.isEmpty(hints)) return null | ||
|
||
return ( | ||
<div className="title-hints"> | ||
{HINTS.map((hint) => { | ||
const { document, key, labelKey } = hint | ||
const show = Boolean(hints?.[key]) | ||
|
||
if (show) { | ||
return ( | ||
<DefinitionLink | ||
key={key} | ||
anchor={anchor} | ||
assessmentName={assessmentName} | ||
cycleName={cycleName} | ||
document={document} | ||
lang={i18n.resolvedLanguage} | ||
title={t(labelKey)} | ||
/> | ||
) | ||
} | ||
|
||
return null | ||
})} | ||
</div> | ||
) | ||
} | ||
|
||
export default Hints |
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 { default } from './Hints' | ||
export { HintsSustainableDevelopment } from './Hints' |
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 |
---|---|---|
|
@@ -5,7 +5,3 @@ | |
grid-row-gap: $spacing-xxxs; | ||
margin-bottom: $spacing-xs; | ||
} | ||
|
||
.title-hint__link { | ||
margin-right: $spacing-xs; | ||
} |
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
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
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,18 @@ | ||
import { Response } from 'express' | ||
|
||
import { CycleDataRequest } from 'meta/api/request' | ||
import { Lang } from 'meta/lang' | ||
|
||
import { FileRepository, fileTypes } from 'server/service/file' | ||
import { Requests } from 'server/utils' | ||
|
||
type Request = CycleDataRequest<{ key: 'Metadata-15-01-01' | 'Metadata-15-02-01' }> | ||
|
||
export const getSdgMetadata = async (req: Request, res: Response) => { | ||
try { | ||
const { key } = req.query | ||
FileRepository.download(res, fileTypes.sdgMetadata(key), Lang.en) | ||
} catch (err) { | ||
Requests.sendErr(res, err) | ||
} | ||
} |
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,28 @@ | ||
import { Assessment, Cycle, Row, RowProps, Table } from 'meta/assessment' | ||
|
||
import { BaseProtocol, DB, Schemas } from 'server/db' | ||
import { RowAdapter } from 'server/repository/adapter' | ||
|
||
type Props = { | ||
assessment: Assessment | ||
cycles: Array<Cycle> | ||
table: Table | ||
rowProps: RowProps | ||
} | ||
|
||
export const create = async (props: Props, client: BaseProtocol = DB): Promise<Row> => { | ||
const { assessment, cycles, table } = props | ||
|
||
const rolProps = { ...props.rowProps, cycles: cycles.map(({ uuid }) => uuid) } | ||
|
||
const schemaName = Schemas.getName(assessment) | ||
|
||
return client.one<Row>( | ||
` | ||
insert into ${schemaName}.row (props, table_id) | ||
values ($1::jsonb, $2) | ||
returning *`, | ||
[JSON.stringify(rolProps), +table.id], | ||
RowAdapter | ||
) | ||
} |
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { getManyCache } from './getManyCache' | ||
import { getOne } from './getOne' | ||
import { getVariablesCache } from './getVariablesCache' | ||
import { create } from 'server/repository/assessment/row/create' | ||
import { getManyCache } from 'server/repository/assessment/row/getManyCache' | ||
import { getOne } from 'server/repository/assessment/row/getOne' | ||
import { getVariablesCache } from 'server/repository/assessment/row/getVariablesCache' | ||
|
||
export const RowRepository = { | ||
getOne, | ||
create, | ||
getManyCache, | ||
getOne, | ||
getVariablesCache, | ||
} |
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
Binary file not shown.
Binary file not shown.
Oops, something went wrong.