From 71ce915e35f365e98c82cafffbfc6a007d3d8c3e Mon Sep 17 00:00:00 2001 From: Jakub Flaska Date: Wed, 18 Dec 2019 12:28:32 -0500 Subject: [PATCH 1/2] preselect --- src/modules/list/components/list.component.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/list/components/list.component.tsx b/src/modules/list/components/list.component.tsx index cb26dae..e553c50 100644 --- a/src/modules/list/components/list.component.tsx +++ b/src/modules/list/components/list.component.tsx @@ -40,7 +40,7 @@ class List extends React.Component< ous: null }; let ouPromise = orgUnits.init().then((ous)=>{ - this.setState({ous: ous}) + this.setState({ous: ous}); this.preselectOu(ous); }); @@ -64,7 +64,7 @@ class List extends React.Component< preselectOu(ous){ this.setFilterFromUrl('ou'); - if (ous.length===1) this.setFilter('ou', ous[0].id); + this.setFilter('ou', ous[0].id); } fetchMechanisms(){ setTimeout(()=>{ From d7b223739cf66de3e36176ac1fdbb54de4dab9a2 Mon Sep 17 00:00:00 2001 From: Jakub Flaska Date: Wed, 18 Dec 2019 15:19:39 -0500 Subject: [PATCH 2/2] loading --- .gitignore | 2 +- package.json | 2 +- .../action/components/action.component.tsx | 3 ++- .../mechanism/form/formContent.component.tsx | 3 ++- .../mechanism/mechanismTabs.component.tsx | 3 ++- .../action/components/step/step.component.tsx | 3 ++- src/modules/list/components/list.component.tsx | 5 +++-- .../shared/components/loading.component.tsx | 17 +++++++++++++++++ 8 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 src/modules/shared/components/loading.component.tsx diff --git a/.gitignore b/.gitignore index 9d8d073..57797bb 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ # build & output /build -approvals.zip +Data-Approval.zip # WebStorm ide files /cypress/.idea diff --git a/package.json b/package.json index 3fb874e..03d6169 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "scripts": { "start": "react-scripts start", "build:react": "react-scripts build", - "build:zip": "(rm -f approvals.zip && cd build && zip ../approvals.zip -r .)", + "build:zip": "(rm -f Data-Approval.zip && cd build && zip ../Data-Approval.zip -r .)", "build": "npm run build:react && npm run build:zip", "test": "node_modules/cypress/bin/cypress open" }, diff --git a/src/modules/action/components/action.component.tsx b/src/modules/action/components/action.component.tsx index 3323249..bcfb4be 100644 --- a/src/modules/action/components/action.component.tsx +++ b/src/modules/action/components/action.component.tsx @@ -12,6 +12,7 @@ import WorkflowPeriodService from "../../shared/services/workflowsPeriods.servic import {getWorkflowNameById} from "../../shared/services/workflowService"; import "../css/action.component.css"; +import Loading from "../../shared/components/loading.component"; const styles = { progress: { @@ -99,7 +100,7 @@ export default class Action extends React.Component< renderAction(){ - if (this.state.processing) return ; + if (this.state.processing) return ; return ; } diff --git a/src/modules/action/components/mechanism/form/formContent.component.tsx b/src/modules/action/components/mechanism/form/formContent.component.tsx index 693c4a9..ba59cef 100644 --- a/src/modules/action/components/mechanism/form/formContent.component.tsx +++ b/src/modules/action/components/mechanism/form/formContent.component.tsx @@ -3,6 +3,7 @@ import FormRender from "./formRender.component"; import {MechanismMeta} from "../../../../shared/models/mechanism.model"; import getFormContent from "../../../services/formContent.service"; import {LinearProgress} from "@material-ui/core"; +import Loading from "../../../../shared/components/loading.component"; export default class FormContent extends React.Component< {workflow: string, period: string, userOu: string, dataSet: string, mechanismMetas: MechanismMeta[]}, @@ -31,7 +32,7 @@ export default class FormContent extends React.Component< } render() { - if (!this.state.formHtml) return ; + if (!this.state.formHtml) return ;; return ; } } \ No newline at end of file diff --git a/src/modules/action/components/mechanism/mechanismTabs.component.tsx b/src/modules/action/components/mechanism/mechanismTabs.component.tsx index dece1b5..262eaaa 100644 --- a/src/modules/action/components/mechanism/mechanismTabs.component.tsx +++ b/src/modules/action/components/mechanism/mechanismTabs.component.tsx @@ -3,6 +3,7 @@ import {LinearProgress, Paper, Tab, Tabs, Typography} from "@material-ui/core"; import MechanismInfo from "./mechanismInfo.component"; import MechanismModel, {MechanismState} from "../../../shared/models/mechanism.model"; import FormSelect from "./form/formSelect.component"; +import Loading from "../../../shared/components/loading.component"; function lengthWarning(mechanismsLength: number, clicks: number){ @@ -52,7 +53,7 @@ function renderMechanismOverview(openTab:number, workflow:string, period:string, export default function MechanismTabs({workflow, period, userOu, mechanisms, mechanismState}:{workflow: string, period: string, userOu: string, mechanisms: MechanismModel[], mechanismState: MechanismState}){ const [openTab, setOpenTab] = React.useState(0); const [clicks, userClicked] = React.useState(0); - if (!mechanisms[0].info) return ; + if (!mechanisms[0].info) return ; return setOpenTab(tabIndex)} variant="scrollable" onClick={()=>userClicked(clicks+1)}> {renderOverviewTab(mechanisms.length)} diff --git a/src/modules/action/components/step/step.component.tsx b/src/modules/action/components/step/step.component.tsx index f76323c..26c4f08 100644 --- a/src/modules/action/components/step/step.component.tsx +++ b/src/modules/action/components/step/step.component.tsx @@ -3,6 +3,7 @@ import {Stepper, StepLabel, makeStyles, Theme, createStyles, LinearProgress} fro import MuiStep from "@material-ui/core/Step"; import {getWorkflowTypeById} from "../../../shared/services/workflowService"; import {MechanismState} from "../../../shared/models/mechanism.model"; +import Loading from "../../../shared/components/loading.component"; const useStyles = makeStyles((theme: Theme) => @@ -64,7 +65,7 @@ function getStepNr(status: string, workflowType: string){ export default function Step({workflow, mechanismState, userType}:{workflow: string, mechanismState: MechanismState, userType: string}){ const classes = useStyles(); - if (!mechanismState) return ; + if (!mechanismState) return ;; if (!userType) return null; const workflowType = getWorkflowTypeById(workflow); return( diff --git a/src/modules/list/components/list.component.tsx b/src/modules/list/components/list.component.tsx index e553c50..8ab644f 100644 --- a/src/modules/list/components/list.component.tsx +++ b/src/modules/list/components/list.component.tsx @@ -12,6 +12,7 @@ import ListAction from "./listAction.component"; import WorkflowPeriodService from "../../shared/services/workflowsPeriods.service"; import {idNameList} from "../../shared/models/idNameList.model"; import {fetchMechanisms} from "../services/mechanisms.service"; +import Loading from "../../shared/components/loading.component"; class List extends React.Component< {history: any, urlSearchOptions: Filters}, @@ -100,7 +101,7 @@ class List extends React.Component< } renderFilters(){ - if (this.state.loading.filters) return ; + if (this.state.loading.filters) return ; return ; + if (this.state.loading.mechanisms) return ; if (!this.state.mechanisms) return null; if (this.state.mechanisms.length===0) return No mechanisms found return ; diff --git a/src/modules/shared/components/loading.component.tsx b/src/modules/shared/components/loading.component.tsx new file mode 100644 index 0000000..44cb36e --- /dev/null +++ b/src/modules/shared/components/loading.component.tsx @@ -0,0 +1,17 @@ +import React from 'react'; +import {LinearProgress, Typography} from "@material-ui/core"; +import { TextAlignProperty } from 'csstype'; + +const styles = { + message: { + textAlign: 'center' as TextAlignProperty + } +}; + +export default function Loading({message}:{message:string}) { + return + +
+ {message} +
; +} \ No newline at end of file