Skip to content

Commit

Permalink
Add species list mappings to ROPs data dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
lennym committed Sep 10, 2021
1 parent 63848f9 commit ec3de7d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 4 additions & 2 deletions pages/rops/download/dictionary/index.js
@@ -1,10 +1,11 @@
const { page } = require('@asl/service/ui');
const { pick, merge, flatten, uniq } = require('lodash');
const { pick, merge, flatten, uniq, omit } = require('lodash');
const getRopsSchema = require('@asl/pages/pages/rops/update/schema');
const getProceduresSchema = require('@asl/pages/pages/rops/procedures/schema');
const { fields: ropsFields } = require('@asl/pages/pages/rops/update/content');
const proceduresContent = require('@asl/pages/pages/rops/procedures/content');
const proceduresCreateContent = require('@asl/pages/pages/rops/procedures/create/content');
const { projectSpecies } = require('@asl/constants');

const proceduresFields = merge({}, proceduresContent.fields, proceduresCreateContent.fiels);

Expand Down Expand Up @@ -45,7 +46,8 @@ module.exports = () => {
};
const ropsSchema = getRopsSchema(params);
const proceduresSchema = getProceduresSchema(params);
console.log(getAllKeys(proceduresSchema));

res.locals.static.species = flatten(Object.values(omit(projectSpecies, 'deprecated')));
res.locals.static.ropsFields = pick(ropsFields, getAllKeys(ropsSchema));
res.locals.static.proceduresFields = pick(proceduresFields, getAllKeys(proceduresSchema));
next();
Expand Down
13 changes: 12 additions & 1 deletion pages/rops/download/dictionary/views/index.jsx
Expand Up @@ -27,7 +27,7 @@ function Field({ name, field }) {
}

export default function Dictionary() {
const { ropsFields, proceduresFields } = useSelector(state => state.static, shallowEqual);
const { ropsFields, proceduresFields, species } = useSelector(state => state.static, shallowEqual);

return (
<Fragment>
Expand All @@ -42,6 +42,17 @@ export default function Dictionary() {
{
map(proceduresFields, (field, name) => <Field key={name} field={field} name={name} />)
}
<h1>Species</h1>
<dl>
{
map(species, (s) => (
<Fragment key={s.value}>
<dt>{ s.value }</dt>
<dd>{ s.label }</dd>
</Fragment>
))
}
</dl>
</Fragment>
);
}

0 comments on commit ec3de7d

Please sign in to comment.