Skip to content

Commit

Permalink
Merge pull request #309 from qccoders/fix-daily-event
Browse files Browse the repository at this point in the history
Prevent Users from creating Daily Events on the fly from the Scanner UI
  • Loading branch information
wburklund authored Dec 13, 2018
2 parents 586923d + 668ce57 commit eda3750
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 6 deletions.
22 changes: 22 additions & 0 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 26 additions & 2 deletions web/src/events/EventDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const styles = {
marginTop: 50,
height: 'fit-content',
},
deleteButton: {
leftButton: {
marginRight: 'auto',
},
spinner: {
Expand Down Expand Up @@ -117,6 +117,20 @@ class EventDialog extends Component {
this.setState({ confirmDialog: { open: true }});
}

handleDailyEventClick = () => {
let start = moment().startOf('day').add(8, 'hours');
let end = moment().startOf('day').add(8, 'hours').add(7, 'hours');

this.setState({
event: {
name: 'Daily Event for ' + start.format('M/DD/YY'),
startDate: start.format(),
endDate: end.format(),
},
validation: { ...initialState.validation },
});
}

handleDeleteConfirmClick = () => {
return this.execute(
() => this.props.context.api.delete('/v1/events/' + this.state.event.id),
Expand Down Expand Up @@ -264,13 +278,23 @@ class EventDialog extends Component {
<Button
onClick={this.handleDeleteClick}
color="primary"
className={classes.deleteButton}
className={classes.leftButton}
disabled={executing}
>
{deleting && <CircularProgress size={20} style={styles.spinner}/>}
Delete
</Button>
}
{intent === 'add' &&
<Button
onClick={this.handleDailyEventClick}
color="primary"
className={classes.leftButton}
disabled={executing}
>
Daily Event
</Button>
}
<Button
onClick={this.handleCancelClick}
color="primary"
Expand Down
3 changes: 2 additions & 1 deletion web/src/events/EventList.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const EventList = (props) => {

return (
<List>
{events.sort(sortByProp('startDate')).map((e, index) =>
{events.sort(sortByProp('startDate', 'desc')).map((e, index) =>
<ListItem
key={index}
button={onItemClick !== undefined}
Expand All @@ -48,6 +48,7 @@ const EventList = (props) => {
/>
</ListItem>
)}
{events.length === 0 && <ListItem><ListItemText primary='No Events have been scheduled.'/></ListItem>}
</List>
);
};
Expand Down
2 changes: 1 addition & 1 deletion web/src/events/Events.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Events extends Component {

refresh = (apiType) => {
this.setState({ [apiType]: { ...this.state[apiType], isExecuting: true }}, () => {
this.props.context.api.get('/v1/events?offset=0&limit=100&orderBy=ASC')
this.props.context.api.get('/v1/events?offset=0&limit=100&orderBy=DESC')
.then(response => {
this.setState({
events: response.data,
Expand Down
3 changes: 2 additions & 1 deletion web/src/scans/Scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { CHECKIN_SERVICE_ID } from '../constants';
import { isMobileAttached, initiateMobileScan } from '../mobile';
import { withContext } from '../shared/ContextProvider';
import { getScanResult } from './scannerUtil';
import { userCanView } from '../util';
import ServiceList from '../services/ServiceList';
import ScannerMenu from './ScannerMenu';
import ScanDisplay from './ScanDisplay';
Expand Down Expand Up @@ -294,7 +295,7 @@ class Scanner extends Component {
let dailyEvent = this.getDailyEvent();
let dailyEventExists = events.find(e => e.name === dailyEvent.name);

if (dailyEventExists === undefined) {
if (dailyEventExists === undefined && userCanView()) {
events = events.concat(dailyEvent);
}

Expand Down
1 change: 1 addition & 0 deletions web/src/services/ServiceList.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const ServiceList = (props) => {
/>
</ListItem>
)}
{services.length === 0 && <ListItem><ListItemText primary='No Services have been added.'/></ListItem>}
</List>
);
};
Expand Down
2 changes: 1 addition & 1 deletion web/src/services/Services.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Services extends Component {

refresh = (apiType) => {
this.setState({ [apiType]: { ...this.state[apiType], isExecuting: true}}, () => {
this.props.context.api.get('/v1/services?offset=0&limit=5000&orderBy=ASC')
this.props.context.api.get('/v1/services?offset=0&limit=100&orderBy=ASC')
.then(response => {
this.setState({
services: response.data,
Expand Down
1 change: 1 addition & 0 deletions web/src/veterans/VeteranList.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const VeteranList = (props) => {
/>
</ListItem>
)}
{veterans.length === 0 && <ListItem><ListItemText primary='No Veterans have been added.'/></ListItem>}
</List>
);
};
Expand Down

0 comments on commit eda3750

Please sign in to comment.