Permalink
Browse files

Group in carbon copy

  • Loading branch information...
1 parent a50453e commit 38cb0adab46717e085ae7ee002d34d901a21951c @SamuelHassine SamuelHassine committed Jan 11, 2017
@@ -5,7 +5,7 @@ import {injectIntl} from 'react-intl'
const MenuItemLinkIntl = (props) => (
<MenuItem
- primaryText={props.intl.formatMessage({id: props.label})}
+ primaryText={props.label ? props.intl.formatMessage({id: props.label}) : ""}
containerElement={<Link to={props.to}/>}
disabled={props.disabled}
value={props.value}
@@ -290,7 +290,7 @@ const filterDryinjectsProcessed = (dryinjects, dryrunId) => {
let dryinjectsFilterAndSorting = R.pipe(
R.values,
R.filter(n => n.dryinject_dryrun.dryrun_id === dryrunId && (n.dryinject_status.status_name === 'SUCCESS' || n.dryinject_status.status_name === 'PARTIAL' || n.dryinject_status.status_name === 'ERROR' )),
- R.sort((a, b) => a.dryinject_date < b.dryinject_date)
+ R.sort((a, b) => timeDiff(a.dryinject_date, b.dryinject_date))
)
return dryinjectsFilterAndSorting(dryinjects)
}
@@ -331,7 +331,7 @@ const filterInjectsProcessed = (state, ownProps) => {
n.inject_status.status_name === 'ERROR' ||
n.inject_status.status_name === 'PARTIAL')
),
- R.sort((a, b) => a.inject_date > b.inject_date),
+ R.sort((a, b) => timeDiff(a.inject_date, b.inject_date))
)
return injectsFilterAndSorting(injects)
}
@@ -1,6 +1,7 @@
import React, {Component, PropTypes} from 'react'
import {connect} from 'react-redux'
import {updateExercise, deleteExercise} from '../../../../actions/Exercise'
+import {fetchGroups} from '../../../../actions/Group'
import {redirectToHome} from '../../../../actions/Application'
import {Paper} from '../../../../components/Paper'
import {Button, FlatButton} from '../../../../components/Button'
@@ -41,6 +42,10 @@ class Index extends Component {
this.state = {openDelete: false, openGallery: false}
}
+ componentDidMount() {
+ this.props.fetchGroups()
+ }
+
onUpdate(data) {
let tzData = R.pipe( //Need to convert date to ISO format with timezone
R.assoc('exercise_start_date', dateToISO(data.exercise_start_date)),
@@ -93,9 +98,20 @@ class Index extends Component {
let initPipe = R.pipe(
R.assoc('exercise_start_date', dateFormat(R.path(['exercise', 'exercise_start_date'], this.props))),
R.assoc('exercise_end_date', dateFormat(R.path(['exercise', 'exercise_end_date'], this.props))),
- R.pick(['exercise_name', 'exercise_description', 'exercise_subtitle', 'exercise_start_date', 'exercise_end_date', 'exercise_message_header', 'exercise_message_footer'])
+ R.assoc('exercise_animation_group', R.path(['exercise', 'exercise_animation_group', 'group_id'], this.props)),
+ R.pick([
+ 'exercise_name',
+ 'exercise_description',
+ 'exercise_subtitle',
+ 'exercise_start_date',
+ 'exercise_end_date',
+ 'exercise_message_header',
+ 'exercise_message_footer',
+ 'exercise_animation_group'])
)
+
const informationValues = exercise !== undefined ? initPipe(exercise) : undefined
+ console.log(informationValues)
const image = R.pathOr(null, ['exercise_image', 'file_url'], exercise)
return (
@@ -111,7 +127,7 @@ class Index extends Component {
<Paper type={Constants.PAPER_TYPE_SETTINGS} zDepth={2}>
<div style={styles.PaperContent}>
<h2><T>Messages template</T></h2>
- <TemplateForm ref="templateForm" onSubmit={this.onUpdate.bind(this)} initialValues={informationValues}/>
+ <TemplateForm ref="templateForm" onSubmit={this.onUpdate.bind(this)} initialValues={informationValues} groups={this.props.groups}/>
<br />
<Button type="submit" label="Update" onClick={this.submitTemplate.bind(this)}/>
</div>
@@ -131,7 +147,8 @@ class Index extends Component {
<Paper type={Constants.PAPER_TYPE_SETTINGS} zDepth={2}>
<div style={styles.PaperContent}>
<h2><T>Delete</T></h2>
- <p><T>Deleting an exercise will result in deleting all its content, including objectives, events, incidents, injects and audience. We do not recommend you do this.</T></p>
+ <p><T>Deleting an exercise will result in deleting all its content, including objectives, events, incidents,
+ injects and audience. We do not recommend you do this.</T></p>
<Button label="Delete" onClick={this.handleOpenDelete.bind(this)}/>
<Dialog title="Confirmation" modal={false} open={this.state.openDelete}
onRequestClose={this.handleCloseDelete.bind(this)}
@@ -153,14 +170,17 @@ Index.propTypes = {
updateExercise: PropTypes.func,
redirectToHome: PropTypes.func,
deleteExercise: PropTypes.func,
+ fetchGroups: PropTypes.func,
+ groups: PropTypes.array
}
const select = (state, ownProps) => {
let exerciseId = ownProps.params.exerciseId
return {
id: exerciseId,
exercise: R.prop(exerciseId, state.referential.entities.exercises),
+ groups: R.values(state.referential.entities.groups)
}
}
-export default connect(select, {updateExercise, redirectToHome, deleteExercise})(Index)
+export default connect(select, {updateExercise, redirectToHome, deleteExercise, fetchGroups})(Index)
@@ -1,12 +1,16 @@
import React, {Component, PropTypes} from 'react'
import {reduxForm, change} from 'redux-form'
import {FormField} from '../../../../components/Field'
+import {SelectField} from '../../../../components/SelectField'
+import {MenuItemLink} from '../../../../components/menu/MenuItem'
import {i18nRegister} from '../../../../utils/Messages'
+import {T} from '../../../../components/I18n'
i18nRegister({
fr: {
'Messages header': 'En-tête des messages',
- 'Messages footer': 'Pied des messages'
+ 'Messages footer': 'Pied des messages',
+ 'Group in carbon copy': 'Groupe en copie conforme'
}
})
@@ -16,6 +20,12 @@ class TemplateForm extends Component {
<form onSubmit={this.props.handleSubmit(this.props.onSubmit)}>
<FormField name="exercise_message_header" fullWidth={true} type="text" label="Messages header"/>
<FormField name="exercise_message_footer" fullWidth={true} type="text" label="Messages footer"/>
+ <SelectField label={<T>Group in carbon copy (animation)</T>} name="exercise_animation_group" fullWidth={true}>
+ <MenuItemLink value={null} label=""/>
+ {this.props.groups.map(data => {
+ return (<MenuItemLink key={data.group_id} value={data.group_id} label={data.group_name}/>)
+ })}
+ </SelectField>
</form>
)
}
@@ -27,7 +37,8 @@ TemplateForm.propTypes = {
submitting: PropTypes.bool,
onSubmit: PropTypes.func.isRequired,
handleSubmit: PropTypes.func,
- change: PropTypes.func
+ change: PropTypes.func,
+ groups: PropTypes.array
}
export default reduxForm({form: 'TemplateForm'}, null, {change})(TemplateForm)

0 comments on commit 38cb0ad

Please sign in to comment.