Skip to content

Commit

Permalink
Merge pull request #182 from ReCodEx/assign-all
Browse files Browse the repository at this point in the history
Assign exercise in more groups & other stuff
  • Loading branch information
SemaiCZE committed Feb 24, 2018
2 parents f839378 + 5b2adef commit fccb2bc
Show file tree
Hide file tree
Showing 10 changed files with 720 additions and 68 deletions.
31 changes: 17 additions & 14 deletions src/components/forms/EditGroupForm/EditGroupForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const EditGroupForm = ({
hasThreshold,
collapsable = false,
isOpen = true,
reset
reset,
isSuperAdmin
}) =>
<FormBox
title={
Expand Down Expand Up @@ -91,18 +92,19 @@ const EditGroupForm = ({
isGroup={true}
/>

<Field
name="externalId"
tabIndex={2}
component={TextField}
required
label={
<FormattedMessage
id="app.createGroup.externalId"
defaultMessage="External ID of the group (e. g. ID of the group in the school IS):"
/>
}
/>
{isSuperAdmin &&
<Field
name="externalId"
tabIndex={2}
component={TextField}
required
label={
<FormattedMessage
id="app.createGroup.externalId"
defaultMessage="External ID of the group (e. g. ID of the group in the school IS):"
/>
}
/>}
<Row>
<Col lg={6}>
<Field
Expand Down Expand Up @@ -182,7 +184,8 @@ EditGroupForm.propTypes = {
createNew: PropTypes.bool,
collapsable: PropTypes.bool,
isOpen: PropTypes.bool,
reset: PropTypes.func
reset: PropTypes.func,
isSuperAdmin: PropTypes.bool
};

const validate = ({ localizedTexts = [], hasThreshold, threshold }) => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/forms/ForkExerciseForm/ForkExerciseForm.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.formSpace {
padding-left: 10px;
.forkForm {
padding-left: 0px;
display: flex;
}
15 changes: 10 additions & 5 deletions src/components/forms/ForkExerciseForm/ForkExerciseForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { SuccessIcon } from '../../../components/icons';
import { forkStatuses } from '../../../redux/modules/exercises';
import { getFork } from '../../../redux/selectors/exercises';
import ResourceRenderer from '../../helpers/ResourceRenderer';
import { getLocalizedName } from '../../../helpers/getLocalizedData';
import { getGroupCanonicalLocalizedName } from '../../../helpers/getLocalizedData';

import withLinks from '../../../helpers/withLinks';

Expand Down Expand Up @@ -41,6 +41,7 @@ class ForkExerciseForm extends Component {
submitSucceeded,
invalid,
groups,
groupsAccessor,
intl: { locale }
} = this.props;

Expand Down Expand Up @@ -70,7 +71,7 @@ class ForkExerciseForm extends Component {
defaultMessage="Saving failed. Please try again later."
/>
</Alert>}
<Form inline className="formSpace">
<Form inline className="forkForm">
<ResourceRenderer resource={groups.toArray()}>
{(...groups) =>
<Field
Expand All @@ -79,12 +80,15 @@ class ForkExerciseForm extends Component {
label={''}
options={[{ key: '', name: '_Public_' }].concat(
groups
.sort((a, b) => a.name.localeCompare(b.name, locale))
.filter((item, pos, arr) => arr.indexOf(item) === pos)
.map(group => ({
key: group.id,
name: getLocalizedName(group, locale)
name: getGroupCanonicalLocalizedName(
group,
groupsAccessor,
locale
)
}))
.sort((a, b) => a.name.localeCompare(b.name, locale))
)}
/>}
</ResourceRenderer>
Expand Down Expand Up @@ -140,6 +144,7 @@ ForkExerciseForm.propTypes = {
push: PropTypes.func.isRequired,
links: PropTypes.object,
groups: ImmutablePropTypes.map,
groupsAccessor: PropTypes.func.isRequired,
intl: PropTypes.shape({ locale: PropTypes.string.isRequired }).isRequired
};

Expand Down
Loading

0 comments on commit fccb2bc

Please sign in to comment.