Permalink
Browse files

Ordering events/incidents

1 parent e8b79bd commit 13282799b8582f39591cecd4f9f81bf4fe7a77f4 @SamuelHassine SamuelHassine committed Jan 11, 2017
@@ -373,7 +373,7 @@ class IndexExercise extends Component {
{this.props.events.map(event => {
const incidents = R.pipe(
R.map(data => R.pathOr({incident_title: ''}, ['incidents', data.incident_id], this.props)),
- R.sort((a, b) => a.incident_title.localeCompare(b.incident_title))
+ R.sort((a, b) => a.incident_order > b.incident_order)
)(event.event_incidents)
let nestedItems = incidents.map(incident => {
@@ -557,7 +557,7 @@ const filterEvents = (events, exerciseId) => {
let eventsFilterAndSorting = R.pipe(
R.values,
R.filter(n => n.event_exercise.exercise_id === exerciseId),
- R.sort((a, b) => a.event_title.localeCompare(b.event_title))
+ R.sort((a, b) => a.event_order > b.event_order)
)
return eventsFilterAndSorting(events)
}
@@ -79,7 +79,7 @@ const filteredEvents = (events, exerciseId) => {
let eventsFilterAndSorting = R.pipe(
R.values,
R.filter(n => n.event_exercise.exercise_id === exerciseId),
- R.sort((a, b) => a.event_title.localeCompare(b.event_title))
+ R.sort((a, b) => a.event_order > b.event_order)
)
return eventsFilterAndSorting(events)
}
@@ -37,16 +37,8 @@ class CreateEvent extends Component {
render() {
const actions = [
- <FlatButton
- label="Cancel"
- primary={true}
- onTouchTap={this.handleClose.bind(this)}
- />,
- <FlatButton
- label="Create"
- primary={true}
- onTouchTap={this.submitForm.bind(this)}
- />,
+ <FlatButton label="Cancel" primary={true} onTouchTap={this.handleClose.bind(this)}/>,
+ <FlatButton label="Create" primary={true} onTouchTap={this.submitForm.bind(this)}/>,
]
return (
@@ -6,7 +6,8 @@ import {i18nRegister} from '../../../../../utils/Messages'
i18nRegister({
fr: {
'Title': 'Titre',
- 'Description': 'Description'
+ 'Description': 'Description',
+ 'Order': 'Ordre',
}
})
@@ -27,6 +28,7 @@ class EventForm extends Component {
<form onSubmit={this.props.handleSubmit(this.props.onSubmit)}>
<FormField name="event_title" fullWidth={true} type="text" label="Title"/>
<FormField name="event_description" fullWidth={true} type="text" label="Description"/>
+ <FormField name="event_order" fullWidth={true} type="text" label="Order"/>
</form>
)
}
@@ -108,7 +108,7 @@ class EventPopover extends Component {
/>,
]
- let initialValues = R.pick(['event_title', 'event_description'], this.props.event)
+ let initialValues = R.pick(['event_title', 'event_description', 'event_order'], this.props.event)
return (
<div style={style}>
<IconButton onClick={this.handlePopoverOpen.bind(this)}>
@@ -17,6 +17,7 @@ i18nRegister({
'Medium': 'Moyen',
'Major': 'Majeur',
'Significance': 'Importance',
+ 'Order': 'Ordre'
}
})
@@ -53,6 +54,7 @@ class IncidentForm extends Component {
})}
</SelectField>
<FormField name="incident_story" fullWidth={true} multiLine={true} rows={3} type="text" label="Story"/>
+ <FormField name="incident_order" fullWidth={true} type="text" label="Order"/>
</form>
)
}
@@ -156,7 +156,7 @@ class IncidentPopover extends Component {
<FlatButton label="Delete" primary={true} onTouchTap={this.submitDelete.bind(this)}/>,
]
- let initialValues = R.pick(['incident_title', 'incident_story', 'incident_type', 'incident_weight'], this.props.incident)
+ let initialValues = R.pick(['incident_title', 'incident_story', 'incident_type', 'incident_weight', 'incident_order'], this.props.incident)
return (
<div style={styles.container}>
@@ -374,7 +374,7 @@ const filterIncidents = (incidents, eventId) => {
let incidentsFilterAndSorting = R.pipe(
R.values,
R.filter(n => n.incident_event.event_id === eventId),
- R.sort((a, b) => a.incident_title.localeCompare(b.incident_title))
+ R.sort((a, b) => a.incident_order > b.incident_order)
)
return incidentsFilterAndSorting(incidents)
}
@@ -199,7 +199,8 @@ class InjectPopover extends Component {
}
onCopySubmit(data) {
- let incident = R.find(a => a.incident_id === data.incident_id)(this.props.incidents)
+ let incident = R.find(i => i.incident_id === data.incident_id)(this.props.incidents)
+ let audiencesList = R.map(a => a.audience_id, this.props.inject.inject_audiences)
let new_inject = R.pipe(
R.dissoc('inject_id'),
R.dissoc('inject_event'),
@@ -208,9 +209,12 @@ class InjectPopover extends Component {
R.dissoc('inject_status'),
R.dissoc('inject_user'),
R.dissoc('inject_users_number'),
- R.assoc('inject_title', this.props.inject.inject_title + ' (copy)')
+ R.assoc('inject_title', this.props.inject.inject_title + ' (copy)'),
+ R.assoc('inject_audiences', audiencesList)
)(this.props.inject)
+ console.log(new_inject)
+
this.props.addInject(this.props.exerciseId, incident.incident_event.event_id, data.incident_id, new_inject).then(() => {
this.props.fetchIncident(this.props.exerciseId, incident.incident_event.event_id, data.incident_id).then(() => {
this.props.redirectToEvent(this.props.exerciseId, incident.incident_event.event_id)

0 comments on commit 1328279

Please sign in to comment.