Skip to content

Commit

Permalink
Merge branch 'master' into new_submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
SemaiCZE committed Nov 17, 2017
2 parents 385c683 + 7f931d1 commit b070bb0
Show file tree
Hide file tree
Showing 17 changed files with 635 additions and 448 deletions.
10 changes: 9 additions & 1 deletion src/components/forms/Fields/SelectField.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const SelectField = ({
meta: { touched, error },
label,
options,
addEmptyOption = false,
emptyOptionCaption = '...',
...props
}) =>
<FormGroup
Expand All @@ -24,6 +26,10 @@ const SelectField = ({
{label}
</ControlLabel>
<FormControl {...input} {...props} componentClass="select">
{addEmptyOption &&
<option value={''} key={'-1'}>
{emptyOptionCaption}
</option>}
{options.map(({ key, name }, i) =>
<option value={key} key={i}>
{name}
Expand Down Expand Up @@ -51,7 +57,9 @@ SelectField.propTypes = {
PropTypes.string,
PropTypes.shape({ type: PropTypes.oneOf([FormattedMessage]) })
]).isRequired,
options: PropTypes.array.isRequired
options: PropTypes.array.isRequired,
addEmptyOption: PropTypes.bool,
emptyOptionCaption: PropTypes.string
};

export default SelectField;
16 changes: 10 additions & 6 deletions src/components/forms/SisBindGroupForm/SisBindGroupForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import FormBox from '../../widgets/FormBox';
import { SelectField } from '../Fields';
import SubmitButton from '../SubmitButton';

import { getLocalizedName } from '../../../helpers/getLocalizedData';
import { getGroupCanonicalLocalizedName } from '../../../helpers/getLocalizedData';

const SisBindGroupForm = ({
invalid,
Expand All @@ -18,6 +18,7 @@ const SisBindGroupForm = ({
submitting,
hasSucceeded,
groups,
groupsAccessor,
intl: { locale }
}) =>
<FormBox
Expand All @@ -27,7 +28,8 @@ const SisBindGroupForm = ({
defaultMessage="Bind existing ReCodEx group to SIS"
/>
}
type={hasSucceeded ? 'success' : undefined}
succeeded={hasSucceeded}
dirty={anyTouched}
footer={
<div className="text-center">
<SubmitButton
Expand Down Expand Up @@ -80,12 +82,13 @@ const SisBindGroupForm = ({
defaultMessage="Group:"
/>
}
options={[{ key: '', name: '...' }].concat(
groups.map(group => ({
options={groups
.map(group => ({
key: group.id,
name: getLocalizedName(group, locale)
name: getGroupCanonicalLocalizedName(group, groupsAccessor, locale)
}))
)}
.sort((a, b) => a.name.localeCompare(b.name, locale))}
addEmptyOption
/>
</FormBox>;

Expand All @@ -98,6 +101,7 @@ SisBindGroupForm.propTypes = {
hasSucceeded: PropTypes.bool,
submitFailed: PropTypes.bool,
groups: PropTypes.array,
groupsAccessor: PropTypes.func.isRequired,
intl: PropTypes.shape({ locale: PropTypes.string.isRequired }).isRequired
};

Expand Down
171 changes: 93 additions & 78 deletions src/components/forms/SisCreateGroupForm/SisCreateGroupForm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { reduxForm, Field } from 'redux-form';
import { FormattedMessage, injectIntl } from 'react-intl';
Expand All @@ -7,86 +7,100 @@ import { Alert } from 'react-bootstrap';
import FormBox from '../../widgets/FormBox';
import { SelectField } from '../Fields';
import SubmitButton from '../SubmitButton';
import { getLocalizedName } from '../../../helpers/getLocalizedData';
import { getGroupCanonicalLocalizedName } from '../../../helpers/getLocalizedData';

const SisCreateGroupForm = ({
invalid,
anyTouched,
handleSubmit,
submitFailed: hasFailed,
submitting,
hasSucceeded,
groups,
intl: { locale }
}) =>
<FormBox
title={
<FormattedMessage
id="app.sisCreateGroupForm.title"
defaultMessage="Create ReCodEx group from SIS"
/>
}
type={hasSucceeded ? 'success' : undefined}
footer={
<div className="text-center">
<SubmitButton
id="sisCreateGroup"
invalid={invalid}
submitting={submitting}
dirty={anyTouched}
hasSucceeded={hasSucceeded}
hasFailed={hasFailed}
handleSubmit={handleSubmit}
messages={{
submit: (
<FormattedMessage
id="app.sisCreateGroupForm.submit"
defaultMessage="Create"
/>
),
submitting: (
<FormattedMessage
id="app.sisCreateGroupForm.submitting"
defaultMessage="Creating ..."
/>
),
success: (
<FormattedMessage
id="app.sisCreateGroupForm.success"
defaultMessage="The group was created."
/>
)
}}
/>
</div>
}
>
{hasFailed &&
<Alert bsStyle="danger">
<FormattedMessage
id="app.sisCreateGroupForm.failed"
defaultMessage="Creating group failed. Please try again later."
/>
</Alert>}
class SisCreateGroupForm extends Component {
render() {
const {
invalid,
anyTouched,
handleSubmit,
submitFailed: hasFailed,
submitting,
hasSucceeded,
groups,
groupsAccessor,
intl: { locale }
} = this.props;

<Field
name="parentGroupId"
required
component={SelectField}
label={
<FormattedMessage
id="app.sisCreateGroupForm.parentGroup"
defaultMessage="Parent group:"
return (
<FormBox
title={
<FormattedMessage
id="app.sisCreateGroupForm.title"
defaultMessage="Create ReCodEx group from SIS"
/>
}
succeeded={hasSucceeded}
dirty={anyTouched}
footer={
<div className="text-center">
<SubmitButton
id="sisCreateGroup"
invalid={invalid}
submitting={submitting}
dirty={anyTouched}
hasSucceeded={hasSucceeded}
hasFailed={hasFailed}
handleSubmit={handleSubmit}
messages={{
submit: (
<FormattedMessage
id="app.sisCreateGroupForm.submit"
defaultMessage="Create"
/>
),
submitting: (
<FormattedMessage
id="app.sisCreateGroupForm.submitting"
defaultMessage="Creating ..."
/>
),
success: (
<FormattedMessage
id="app.sisCreateGroupForm.success"
defaultMessage="The group was created."
/>
)
}}
/>
</div>
}
>
{hasFailed &&
<Alert bsStyle="danger">
<FormattedMessage
id="app.sisCreateGroupForm.failed"
defaultMessage="Creating group failed. Please try again later."
/>
</Alert>}

<Field
name="parentGroupId"
required
component={SelectField}
label={
<FormattedMessage
id="app.sisCreateGroupForm.parentGroup"
defaultMessage="Parent group:"
/>
}
options={groups
.map(group => ({
key: group.id,
name: getGroupCanonicalLocalizedName(
group,
groupsAccessor,
locale
)
}))
.sort((a, b) => a.name.localeCompare(b.name, locale))}
addEmptyOption
/>
}
options={[{ key: '', name: '...' }].concat(
groups.map(group => ({
key: group.id,
name: getLocalizedName(group, locale)
}))
)}
/>
</FormBox>;
</FormBox>
);
}
}

SisCreateGroupForm.propTypes = {
onSubmit: PropTypes.func.isRequired,
Expand All @@ -97,6 +111,7 @@ SisCreateGroupForm.propTypes = {
hasSucceeded: PropTypes.bool,
submitFailed: PropTypes.bool,
groups: PropTypes.array,
groupsAccessor: PropTypes.func.isRequired,
intl: PropTypes.shape({ locale: PropTypes.string.isRequired }).isRequired
};

Expand Down
28 changes: 17 additions & 11 deletions src/containers/SisIntegrationContainer/SisIntegrationContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Button from '../../components/widgets/FlatButton';
import { LinkContainer } from 'react-router-bootstrap';
import Icon from 'react-fontawesome';

import UsersNameContainer from '../UsersNameContainer';
import { fetchSisStatusIfNeeded } from '../../redux/modules/sisStatus';
import { fetchSisSubscribedGroups } from '../../redux/modules/sisSubscribedGroups';
import { sisStateSelector } from '../../redux/selectors/sisStatus';
Expand Down Expand Up @@ -93,8 +94,8 @@ class SisIntegrationContainer extends Component {
</th>
<th>
<FormattedMessage
id="app.sisIntegration.groupExtId"
defaultMessage="SIS ID"
id="app.sisIntegration.groupAdmins"
defaultMessage="Group Administrators"
/>
</th>
<th />
Expand All @@ -108,9 +109,12 @@ class SisIntegrationContainer extends Component {
{getLocalizedName(group, locale)}
</td>
<td>
<code>
{group.externalId}
</code>
{group.primaryAdminsIds.map(id =>
<UsersNameContainer
key={id}
userId={id}
/>
)}
</td>
<td className="text-right">
<span>
Expand Down Expand Up @@ -140,12 +144,14 @@ class SisIntegrationContainer extends Component {
</tbody>
</Table>
: <div className="text-center">
<b>
<FormattedMessage
id="app.sisIntegration.noSisGroups"
defaultMessage="Currently there are no ReCodEx groups matching your SIS subjects for this time period."
/>
</b>
<p>
<b>
<FormattedMessage
id="app.sisIntegration.noSisGroups"
defaultMessage="Currently there are no ReCodEx groups matching your SIS subjects for this time period."
/>
</b>
</p>
</div>}
</div>}
</ResourceRenderer>
Expand Down
Loading

0 comments on commit b070bb0

Please sign in to comment.