Skip to content

Commit

Permalink
Some improvements in multi assign form
Browse files Browse the repository at this point in the history
  • Loading branch information
SemaiCZE committed Feb 26, 2018
1 parent d1fb9a5 commit 5cff300
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/components/forms/MultiAssignForm/MultiAssignForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const MultiAssignForm = ({
handleSubmit,
submitFailed: hasFailed,
submitSucceeded: hasSucceeded,
asyncValidating,
invalid,
reset,
firstDeadline,
allowSecondDeadline,
groups,
Expand Down Expand Up @@ -175,8 +175,7 @@ const MultiAssignForm = ({
dirty={anyTouched}
hasSucceeded={hasSucceeded}
hasFailed={hasFailed}
handleSubmit={handleSubmit}
asyncValidating={asyncValidating}
handleSubmit={data => handleSubmit(data).then(() => reset())}
messages={{
submit: (
<FormattedMessage
Expand Down Expand Up @@ -209,8 +208,8 @@ MultiAssignForm.propTypes = {
submitting: PropTypes.bool,
submitFailed: PropTypes.bool,
submitSucceeded: PropTypes.bool,
asyncValidating: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
invalid: PropTypes.bool,
reset: PropTypes.func.isRequired,
firstDeadline: PropTypes.oneOfType([PropTypes.number, PropTypes.object]), // object == moment.js instance
allowSecondDeadline: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
groups: PropTypes.array.isRequired,
Expand Down Expand Up @@ -344,7 +343,6 @@ const validate = ({

export default reduxForm({
form: 'multiAssign',
validate,
enableReinitialize: true,
keepDirtyOnReinitialize: false
validate
})(MultiAssignForm);
5 changes: 4 additions & 1 deletion src/pages/Exercise/Exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ class Exercise extends Component {
let actions = [];

for (const groupId of groups) {
assignExercise(groupId).then(({ value: assigment }) => {
const groupPromise = assignExercise(
groupId
).then(({ value: assigment }) => {
let assignmentData = Object.assign({}, assigment, formData, {
firstDeadline: moment(formData.firstDeadline).unix(),
secondDeadline: moment(formData.secondDeadline).unix(),
Expand All @@ -150,6 +152,7 @@ class Exercise extends Component {

return editAssignment(assigment.id, assignmentData);
});
actions.push(groupPromise);
}

return Promise.all(actions);
Expand Down

0 comments on commit 5cff300

Please sign in to comment.