From 43f239c8530a787835334de70958dfa54098f806 Mon Sep 17 00:00:00 2001 From: Tom Russell Date: Wed, 14 Aug 2019 11:36:38 +0100 Subject: [PATCH] Render single section in view/edit --- app/src/frontend/building/building-edit.tsx | 32 ++++++++++--------- app/src/frontend/building/building-view.tsx | 34 ++++++++++++--------- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/app/src/frontend/building/building-edit.tsx b/app/src/frontend/building/building-edit.tsx index f3a0e65f..7743a16a 100644 --- a/app/src/frontend/building/building-edit.tsx +++ b/app/src/frontend/building/building-edit.tsx @@ -6,7 +6,7 @@ import ErrorBox from '../components/error-box'; import InfoBox from '../components/info-box'; import Sidebar from './sidebar'; import Tooltip from '../components/tooltip'; -import { SaveIcon } from '../components/icons'; +import { BackIcon, SaveIcon } from '../components/icons'; import CONFIG from './fields-config.json'; @@ -15,28 +15,27 @@ const BuildingEdit = (props) => { return } const cat = props.match.params.cat; - if (!props.building_id){ + const sections = CONFIG.filter((d) => d.slug === cat) + + if (!props.building_id || sections.length !== 1){ return ( - +
- Back to maps + Back to maps
); } + + const section = sections[0]; return ( - - { - CONFIG.map((section) => { - return - }) - } + + ); } @@ -237,6 +236,9 @@ class EditForm extends Component { // TODO: add proper types return (
+ + + { - if (!props.building_id){ + const cat = props.match.params.cat; + const sections = CONFIG.filter((d) => d.slug === cat) + + if (!props.building_id || sections.length !== 1){ return ( - +
- Back to maps + Back to categories
); } - const cat = props.match.params.cat; + + const section = sections[0]; return ( - - { - CONFIG.map(section => ( - - )) - } + + ); } @@ -102,6 +105,9 @@ class DataSection extends React.Component { // TODO: add proper types return (
+ + +