Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assign exercise in more groups & other stuff #182

Merged
merged 5 commits into from
Feb 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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