Commit a985e8bc authored by Nina Willems's avatar Nina Willems

[client/timeserie] station info fr/nl

parent 2eb49387
import { DIV, H2, SPAN } from 'sdi/components/elements';
import tr from 'sdi/locale';
import tr, { fromRecord } from 'sdi/locale';
import {
getSelectedKind,
getCurrentFeature
......@@ -7,6 +7,7 @@ import {
import { ParameterType } from 'timeserie/src/types';
import { Feature } from 'sdi/source';
import { getFeaturePropOption } from 'sdi/util';
import { Option } from 'fp-ts/lib/Option';
// const renderId = () =>
// getSelectedId().map(id =>
......@@ -196,22 +197,51 @@ const renderRefGW = (f: Feature) =>
SPAN({ className: 'station-info-item__value' }, `${prop}`)
)
);
const renderNameGW = (f: Feature) =>
getFeaturePropOption(f, 'nom_gw_ref').map(prop =>
DIV(
{ className: 'station-info-item' },
SPAN({ className: 'station-info-item__label' }, `${tr.ts('NomGWRef')}-fr: `),
SPAN({ className: 'station-info-item__value' }, `${prop}`)
)
);
const renderNameGWNl = (f: Feature) =>
getFeaturePropOption(f, 'naam_gw_ref').map(prop =>
DIV(
{ className: 'station-info-item' },
SPAN({ className: 'station-info-item__label' }, `${tr.ts('NomGWRef')}-nl: `),
SPAN({ className: 'station-info-item__value' }, `${prop}`)
)
const renderNameGW = (f: Feature) => {
const nameFr = unknownToStringOpt(getFeaturePropOption(f, 'nom_gw_ref'));
const nameNl = unknownToStringOpt(getFeaturePropOption(f, 'naam_gw_ref'));
return nameFr.fold(
//default if no fr-name
nameNl.fold(
//defautl if no name at all
DIV({}),
//if nl-name exists:
nl_rec =>
DIV(
{ className: 'station-info-item' },
SPAN({ className: 'station-info-item__label' }, `${tr.ts('NomGWRef')}: `),
SPAN({ className: 'station-info-item__value' }, fromRecord({ fr: '', nl: nl_rec })
)
)
),
//if there is an fr-name
fr_rec =>
DIV(
{ className: 'station-info-item' },
SPAN({ className: 'station-info-item__label' }, `${tr.ts('NomGWRef')}: `),
SPAN({ className: 'station-info-item__value' }, fromRecord({ fr: fr_rec, nl: nameNl.getOrElse('') })
)
)
);
}
// const renderNameGWFr = (f: Feature) =>
// getFeaturePropOption(f, 'nom_gw_ref').map(prop =>
// DIV(
// { className: 'station-info-item' },
// SPAN({ className: 'station-info-item__label' }, `${tr.ts('NomGWRef')}-fr: `),
// SPAN({ className: 'station-info-item__value' }, `${prop}`)
// )
// );
// const renderNameGWNl = (f: Feature) =>
// getFeaturePropOption(f, 'naam_gw_ref').map(prop =>
// DIV(
// { className: 'station-info-item' },
// SPAN({ className: 'station-info-item__label' }, `${tr.ts('NomGWRef')}-nl: `),
// SPAN({ className: 'station-info-item__value' }, `${prop}`)
// )
// );
const renderAdress = (f: Feature) => {
const cp = getFeaturePropOption(f, 'ref_cp').getOrElse('');
......@@ -339,22 +369,48 @@ const renderEUSite = (f: Feature) =>
SPAN({ className: 'station-info-item__value' }, `${prop}`)
)
);
const renderSiteFr = (f: Feature) =>
getFeaturePropOption(f, 'site_fr').map(prop =>
DIV(
{ className: 'station-info-item' },
SPAN({ className: 'station-info-item__label' }, `${tr.ts('StationName')} FR: `),
SPAN({ className: 'station-info-item__value' }, `${prop}`)
)
);
const renderSiteNl = (f: Feature) =>
getFeaturePropOption(f, 'site_nl').map(prop =>
DIV(
{ className: 'station-info-item' },
SPAN({ className: 'station-info-item__label' }, `${tr.ts('StationName')} NL: `),
SPAN({ className: 'station-info-item__value' }, `${prop}`)
)
const unknownToStringOpt = (prop: Option<unknown>) => prop.map(p => (typeof p === 'string') ? p : '');
const renderSite = (f: Feature) => {
const siteFR = unknownToStringOpt(getFeaturePropOption(f, 'site_fr'));
const siteNL = unknownToStringOpt(getFeaturePropOption(f, 'site_nl'));
return siteFR.fold(
//default if no fr-name
siteNL.fold(
//defautl if no name at all
DIV({}),
//if nl-name exists:
nl_rec =>
DIV(
{ className: 'station-info-item' },
SPAN({ className: 'station-info-item__label' }, `${tr.ts('StationName')}: `),
SPAN({ className: 'station-info-item__value' }, fromRecord({ fr: '', nl: nl_rec })
)
)
),
//if there is an fr-name
fr_rec =>
DIV(
{ className: 'station-info-item' },
SPAN({ className: 'station-info-item__label' }, `${tr.ts('StationName')}: `),
SPAN({ className: 'station-info-item__value' }, fromRecord({ fr: fr_rec, nl: siteNL.getOrElse('') })
)
)
);
}
// const renderSiteNl = (f: Feature) =>
// getFeaturePropOption(f, 'site_nl').map(prop =>
// DIV(
// { className: 'station-info-item' },
// SPAN({ className: 'station-info-item__label' }, `${tr.ts('StationName')} NL: `),
// SPAN({ className: 'station-info-item__value' }, `${prop}`)
// )
// );
// const renderAdressFR = (f: Feature) =>
// getFeaturePropOption(f, 'street_fr').map(prop =>
// DIV(
......@@ -401,8 +457,9 @@ const render = () =>
renderGidSite(f),
renderBECode(f),
renderName(f),
renderSiteFr(f),
renderSiteNl(f),
renderSite(f),
// renderSiteFr(f),
// renderSiteNl(f),
renderMes(f),
renderAdress(f),
// renderAdressFR(f),
......@@ -410,7 +467,7 @@ const render = () =>
renderCoord(f),
renderZCoord(f),
renderNameGW(f),
renderNameGWNl(f),
// renderNameGWNl(f),
renderNameGWBFR(f),
renderCodeGWB(f),
renderRefGW(f),
......
......@@ -104,7 +104,7 @@ const messages = {
nl: '', // nltodo
},
valueCount: {
fr: `valeurs`,
fr: `nb de valeurs`,
nl: '', // nltodo
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment