Skip to content

Commit

Permalink
Updated version in package json
Browse files Browse the repository at this point in the history
  • Loading branch information
hdf1996 committed Oct 29, 2019
2 parents 339cb14 + 77ef477 commit 57a9d2b
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 19 deletions.
3 changes: 2 additions & 1 deletion app/actions/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ export const syncStart = () => async (dispatch, getState) => {
(acc, current) => acc.then(() => dispatch(current())),
Promise.resolve()
)
.then(() => dispatch({ type: SYNC_FINISH })),
.then(() => dispatch({ type: SYNC_FINISH }))
.catch(() => dispatch({ type: SYNC_FINISH })),
300
);
};
Expand Down
18 changes: 16 additions & 2 deletions app/components/AntibioticList.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,22 @@ class AntibioticList extends Component<Props, State> {
prevPage={antibiotics.prevPage}
nextPage={antibiotics.nextPage}
onReload={() => this.loadAntibiotics()}
columns={['Name', 'Strength Value', 'Strength Unit', 'Form', 'Brand']}
fields={['name', 'strengthValue', 'strengthUnit', 'form', 'brand']}
columns={[
'Name',
'Strength Value',
'Strength Unit',
'Form',
'Pack Size',
'Brand'
]}
fields={[
'name',
'strengthValue',
'strengthUnit',
'form',
'packSize',
'brand'
]}
onClick={({ id }) => history.push(`/antibiotics/${id}`)}
search={value => {
this.setState({ searchText: value });
Expand Down
37 changes: 33 additions & 4 deletions app/components/DropZone.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react';
import MaterialIcon from '@material/react-material-icon';
import TextField, { Input } from '@material/react-text-field';
import { remote } from 'electron';
import XlsxManager from '../utils/xlsxManager';
import styles from './DropZone.scss';

type Props = {
Expand Down Expand Up @@ -44,11 +45,32 @@ class DropZone extends Component<Props, State> {
const { onChange } = this.props;
e.preventDefault();
this.setState({ dragging: false });

onChange({ file: e.dataTransfer.files[0] });
this.parseSheet({ file: e.dataTransfer.files[0] });
};

parseSheet = ({ file }) => {
const sheet = new XlsxManager(file.path);

this.setState({
maxRow: sheet.maxRow
});
};

handleChange = (field, e) => {
const { onChange } = this.props;
const { value, min, max } = e.target;
const val =
value === ''
? ''
: Math.max(Number(min), Math.min(Number(max), Number(value)));

onChange({ [field]: val });
};

render() {
const { dragging } = this.state;
const { dragging, maxRow } = this.state;
const {
file,
headerRow,
Expand Down Expand Up @@ -87,26 +109,32 @@ class DropZone extends Component<Props, State> {
<div className={styles.fileLimits}>
<TextField label="Header row" className="full-width">
<Input
className={styles.input}
type="number"
min="0"
max={maxRow}
value={headerRow}
onChange={e => onChange({ headerRow: e.target.value })}
onChange={e => this.handleChange('headerRow', e)}
/>
</TextField>
<TextField label="Data rows from">
<Input
type="number"
className={styles.input}
min={parseInt(headerRow, 10) || 0 + 1}
max={maxRow}
value={dataRowsFrom}
onChange={e => onChange({ dataRowsFrom: e.target.value })}
onChange={e => this.handleChange('dataRowsFrom', e)}
/>
</TextField>
<TextField label="Data rows to">
<Input
type="number"
className={styles.input}
min={parseInt(dataRowsFrom, 10) || 0 + 1}
max={maxRow}
value={dataRowsTo}
onChange={e => onChange({ dataRowsTo: e.target.value })}
onChange={e => this.handleChange('dataRowsTo', e)}
/>
</TextField>
</div>
Expand All @@ -125,6 +153,7 @@ class DropZone extends Component<Props, State> {
if (!files) return;
console.log(files);
onChange({ file: { name: files[0], path: files[0] } });
this.parseSheet({ file: { name: files[0], path: files[0] } });
}}
>
Browse
Expand Down
4 changes: 4 additions & 0 deletions app/components/DropZone.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
margin-bottom: 12px;
}

.input {
min-width: 178px;
}

.fileLimits {
display: flex;
justify-content: space-between;
Expand Down
3 changes: 2 additions & 1 deletion app/components/PatientEntriesForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ class PatientEntriesForm extends Component<Props, State> {
{ value: 'geriatric', label: 'Geriatric' },
{ value: 'ent', label: 'Ear, Nose Throat (ENT)' },
{ value: 'eye', label: 'Eye' },
{ value: 'not_mentioned', label: 'Not mentioned' }
{ value: 'not_mentioned', label: 'Not mentioned' },
{ value: 'other', label: 'Other' }
]}
/>
</Cell>
Expand Down
13 changes: 10 additions & 3 deletions app/components/ProtectedHealthInformationStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class ProtectedHealthInformationStep extends Component<Props> {
falseValue = false
) => e => {
const { importData, onChange } = this.props;

onChange({
[type]: values({
...importData[type],
Expand All @@ -44,10 +43,10 @@ class ProtectedHealthInformationStep extends Component<Props> {
const { importData, onChange } = this.props;

onChange({
[type]: {
[type]: values({
...importData[type],
[column]: e.target.value
}
})
});
};

Expand Down Expand Up @@ -166,8 +165,16 @@ class ProtectedHealthInformationStep extends Component<Props> {
onChange={this.handleSelectChange('date', index)}
>
<Option value="DDMMMYYYY">DDMMMYYYY</Option>
<Option value="DDMMMYY">DDMMMYY</Option>
<Option value="DD/MM/YYYY">DD/MM/YYYY</Option>
<Option value="DD/MM/YY">DD/MM/YY</Option>
<Option value="MM/DD/YYYY">MM/DD/YYYY</Option>
<Option value="MM/DD/YY">MM/DD/YY</Option>
<Option value="DD-MM-YYYY">DD-MM-YYYY</Option>
<Option value="DD-MM-YY">DD-MM-YY</Option>
<Option value="MM-DD-YYYY">MM-DD-YYYY</Option>
<Option value="MM-DD-YY">MM-DD-YY</Option>
<Option value="YYYY-MM-DD">YYYY-MM-DD</Option>
</Select>
) : (
''
Expand Down
2 changes: 1 addition & 1 deletion app/components/ReviewStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ReviewStep extends Component<Props> {
} = importData;
const sheet = new XlsxManager(file.path);
const headerRow = sheet.row(importData.headerRow - 1);
let rows = sheet.rows(dataRowsFrom - 1, dataRowsTo - 1);
let rows = sheet.rows(dataRowsFrom - 1, dataRowsTo);
const columnsToKeep = headerRow.reduce((acc, current, index) => {
if (patientOrLabRecordId[index] || phi[index] || date[index])
acc.push(index);
Expand Down
8 changes: 2 additions & 6 deletions app/containers/App.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// @flow
import * as React from 'react';

import { Cell, Grid, Row } from '@material/react-layout-grid';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import type { ContextRouter } from 'react-router';
import { syncStart } from '../actions/sync';
import { Dispatch } from '../reducers/types';
import styles from './App.scss';

import NavBar from '../components/NavBar';

Expand Down Expand Up @@ -34,11 +34,7 @@ class App extends React.Component<Props> {
return (
<div>
{user.auth && <NavBar />}
<Grid align="middle" className="app">
<Row>
<Cell columns={12}>{children}</Cell>
</Row>
</Grid>
<div className={styles.Content}>{children}</div>
</div>
);
}
Expand Down
3 changes: 3 additions & 0 deletions app/containers/App.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.Content {
margin-bottom: 100px;
}
4 changes: 4 additions & 0 deletions app/utils/xlsxManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class XlsxManager {
};
}

get maxRow() {
return this.range.end.row + 1;
}

encodeCol = colNumber => xlsx.utils.encode_col(colNumber);

rows(rowNumberFrom, rowNumberTo) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "maap-collector",
"productName": "Maap Collector",
"version": "0.17.9",
"version": "0.17.10",
"description": "Electron application boilerplate based on React, React Router, Webpack, React Hot Loader for rapid application development",
"scripts": {
"build": "concurrently \"yarn build-main\" \"yarn build-renderer\"",
Expand Down

0 comments on commit 57a9d2b

Please sign in to comment.