Skip to content

Commit e4be2a2

Browse files
author
Martin Krulis
committed
Minor handy tweaks of shadow assignment points edit form and adding forgotten translations.
1 parent 089e79b commit e4be2a2

File tree

7 files changed

+82
-12
lines changed

7 files changed

+82
-12
lines changed

src/components/Groups/ResultsTable/ResultsTable.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,18 @@ class ResultsTable extends Component {
192192
: this.closeDialog();
193193
};
194194

195+
removeShadowPoints = () => {
196+
if (this.state.dialogClosing) return;
197+
198+
const points = this.getDialogPoints();
199+
if (points && this.state.dialogUserId) {
200+
this.setState({ dialogClosing: true });
201+
return this.props.removeShadowPoints(this.state.dialogShadowId, this.state.dialogUserId, points.id).then(() => {
202+
this.setState({ dialogOpen: false, dialogClosing: false });
203+
});
204+
}
205+
};
206+
195207
prepareColumnDescriptors = defaultMemoize((assignments, shadowAssignments, loggedUser, locale) => {
196208
const {
197209
isAdmin,
@@ -443,6 +455,7 @@ class ResultsTable extends Component {
443455
initialValues={getPointsFormInitialValues(this.getDialogPoints(), this.state.dialogUserId)}
444456
onSubmit={this.submitPointsForm}
445457
maxPoints={this.getDialogShadowAssignment().maxPoints}
458+
onRemovePoints={this.removeShadowPoints}
446459
/>
447460
)}
448461
</React.Fragment>

src/components/forms/EditLimitsForm/EditLimitsForm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class EditLimitsForm extends Component {
4747
<div className="text-center">
4848
{dirty && (
4949
<span>
50-
<Button type="reset" onClick={reset} bsStyle={'danger'} className="btn-flat">
50+
<Button type="reset" onClick={reset} bsStyle={'danger'}>
5151
<RefreshIcon gapRight />
5252
<FormattedMessage id="generic.reset" defaultMessage="Reset" />
5353
</Button>

src/components/forms/EditShadowAssignmentPointsForm/EditShadowAssignmentPointsForm.js

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import { FormattedMessage } from 'react-intl';
44
import { reduxForm, Field } from 'redux-form';
5-
import { Form, Alert, Grid, Row, Col } from 'react-bootstrap';
5+
import { Form, FormGroup, Alert, Grid, Row, Col } from 'react-bootstrap';
66
import { defaultMemoize } from 'reselect';
77
import moment from 'moment';
88

99
import SubmitButton from '../SubmitButton';
1010
import { TextField, DatetimeField, NumericTextField } from '../Fields';
11+
import Button from '../../widgets/FlatButton';
12+
import Icon, { RefreshIcon, DeleteIcon } from '../../icons';
1113

1214
export const getPointsFormInitialValues = defaultMemoize((userPoints, awardeeId) => {
1315
return userPoints
@@ -34,6 +36,9 @@ export const transformPointsFormSubmitData = ({ pointsId = null, awardedAt, ...f
3436
});
3537

3638
const EditShadowAssignmentPointsForm = ({
39+
onRemovePoints = null,
40+
change,
41+
reset,
3742
submitting,
3843
handleSubmit,
3944
dirty,
@@ -54,7 +59,7 @@ const EditShadowAssignmentPointsForm = ({
5459

5560
<Grid fluid>
5661
<Row>
57-
<Col md={12} lg={6}>
62+
<Col md={12} lg={5}>
5863
<NumericTextField
5964
name="points"
6065
maxLength={6}
@@ -63,12 +68,33 @@ const EditShadowAssignmentPointsForm = ({
6368
label={<FormattedMessage id="app.editShadowAssignmentPointsForm.points" defaultMessage="Points:" />}
6469
/>
6570
</Col>
66-
<Col md={12} lg={6}>
67-
<Field
68-
name="awardedAt"
69-
component={DatetimeField}
70-
label={<FormattedMessage id="app.editShadowAssignmentPointsForm.awardedAt" defaultMessage="Awarded at:" />}
71-
/>
71+
<Col md={12} lg={7}>
72+
<table className="full-width">
73+
<tbody>
74+
<tr>
75+
<td>
76+
<Field
77+
name="awardedAt"
78+
component={DatetimeField}
79+
label={
80+
<FormattedMessage
81+
id="app.editShadowAssignmentPointsForm.awardedAt"
82+
defaultMessage="Awarded at:"
83+
/>
84+
}
85+
/>
86+
</td>
87+
<td className="valign-bottom shrink-col">
88+
<FormGroup>
89+
<Button onClick={() => change('awardedAt', moment().startOf('minute'))}>
90+
<Icon icon="history" gapRight />
91+
<FormattedMessage id="app.editShadowAssignmentPointsForm.setNow" defaultMessage="Now" />
92+
</Button>
93+
</FormGroup>
94+
</td>
95+
</tr>
96+
</tbody>
97+
</table>
7298
</Col>
7399
</Row>
74100
<Row>
@@ -88,6 +114,12 @@ const EditShadowAssignmentPointsForm = ({
88114
{warning && <Alert bsStyle="warning">{warning}</Alert>}
89115

90116
<div className="text-center">
117+
{dirty && (
118+
<Button type="reset" onClick={reset} bsStyle={'danger'}>
119+
<RefreshIcon gapRight />
120+
<FormattedMessage id="generic.reset" defaultMessage="Reset" />
121+
</Button>
122+
)}
91123
<SubmitButton
92124
id="shadow-assignment-points"
93125
handleSubmit={handleSubmit}
@@ -102,12 +134,25 @@ const EditShadowAssignmentPointsForm = ({
102134
success: <FormattedMessage id="generic.saved" defaultMessage="Saved" />,
103135
}}
104136
/>
137+
138+
{onRemovePoints && (
139+
<Button onClick={onRemovePoints} bsStyle="danger" className="em-margin-left">
140+
<DeleteIcon gapRight />
141+
<FormattedMessage
142+
id="app.editShadowAssignmentPointsForm.removePoints"
143+
defaultMessage="Remove Points Record"
144+
/>
145+
</Button>
146+
)}
105147
</div>
106148
</Form>
107149
);
108150

109151
EditShadowAssignmentPointsForm.propTypes = {
110152
maxPoints: PropTypes.number.isRequired,
153+
onRemovePoints: PropTypes.func,
154+
change: PropTypes.func.isRequired,
155+
reset: PropTypes.func.isRequired,
111156
handleSubmit: PropTypes.func.isRequired,
112157
submitFailed: PropTypes.bool,
113158
dirty: PropTypes.bool,

src/components/forms/Fields/DatetimeField.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ class DatetimeField extends Component {
5454
[styles.dirty]: dirty && !ignoreDirty && !error && !warning,
5555
[styles.active]: active,
5656
})}
57-
/>{' '}
58-
{error && <HelpBlock> {error} </HelpBlock>}
59-
{!error && warning && <HelpBlock> {warning} </HelpBlock>}
57+
/>
58+
{error && <HelpBlock>{error}</HelpBlock>}
59+
{!error && warning && <HelpBlock>{warning}</HelpBlock>}
6060
</FormGroup>
6161
);
6262
}

src/locales/cs.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@
438438
"app.editShadowAssignmentPointsForm.failed": "Nebylo možné uložit body stínové úlohy.",
439439
"app.editShadowAssignmentPointsForm.note": "Poznámka:",
440440
"app.editShadowAssignmentPointsForm.points": " Body:",
441+
"app.editShadowAssignmentPointsForm.removePoints": "Odstranit celý záznam",
442+
"app.editShadowAssignmentPointsForm.setNow": "Teď",
441443
"app.editShadowAssignmentPointsForm.validation.pointsOutOfRange": "Body jsou mimo běžný rozsah. Běžný rozsah je od 0 do {maxPoints}.",
442444
"app.editSisTerm.advertiseUntil": "Nabízet studentům tento semestr do:",
443445
"app.editSisTerm.beginning": "Začátek semestru:",
@@ -762,6 +764,7 @@
762764
"app.filterUsersListForm.searchName": "Vyhledat podle jména",
763765
"app.footer.copyright": "Copyright © 2016-{year} <a href='{website}' target='_blank'>ReCodEx</a>. Všechna práva vyhrazena.",
764766
"app.footer.version": "<strong>Verze</strong> {version} (<a href='{changelogUrl}' target='_blank'>log změn</a>)",
767+
"app.forkExerciseForm.confirmSubmit": "Tento proces vytvoří další kopii zvolené úlohy. Duplikace dává smysl pouze v případech, kdy se pokoušíte vytvořit novou úlohu, ale nechcete začínat zcela od píky. Prosím, neduplikujte úlohy, pokud je vašim cílem pouze jejich připojení do jiné domovské skupiny. Opravdu chcete provést duplikaci?",
765768
"app.forkExerciseForm.selectGroupFirst": "... nejprve vyberte domovskou skupinu ...",
766769
"app.forkExerciseForm.showForkedExerciseButton": "Ukázat zduplikovanou úlohu",
767770
"app.forkExerciseForm.submit": "Zduplikovat úlohu",
@@ -1196,6 +1199,7 @@
11961199
"app.solutionsTable.noSolutionsFound": "Zatím nebyla odevzdána žádná řešení.",
11971200
"app.solutionsTable.note": "Poznámka",
11981201
"app.solutionsTable.receivedPoints": "Body",
1202+
"app.solutionsTable.rowsCount": "Celkem záznamů: {count}",
11991203
"app.solutionsTable.solutionValidity": "Správnost",
12001204
"app.solutionsTable.submissionDate": "Datum odevzdání",
12011205
"app.solutionsTable.submitNewSolution": "Odevzdat nové řešení",

src/locales/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@
438438
"app.editShadowAssignmentPointsForm.failed": "Cannot save the shadow assignment points.",
439439
"app.editShadowAssignmentPointsForm.note": "Note:",
440440
"app.editShadowAssignmentPointsForm.points": "Points:",
441+
"app.editShadowAssignmentPointsForm.removePoints": "Remove Points Record",
442+
"app.editShadowAssignmentPointsForm.setNow": "Now",
441443
"app.editShadowAssignmentPointsForm.validation.pointsOutOfRange": "Points are out of regular range. Regular score for this assignment is between 0 and {maxPoints}.",
442444
"app.editSisTerm.advertiseUntil": "Advertise this term to students until:",
443445
"app.editSisTerm.beginning": "Beginning of the term:",
@@ -762,6 +764,7 @@
762764
"app.filterUsersListForm.searchName": "Search by name",
763765
"app.footer.copyright": "Copyright © 2016-{year} <a href='{website}' target='_blank'>ReCodEx</a>. All rights reserved.",
764766
"app.footer.version": "<strong>Version</strong> {version} (<a href='{changelogUrl}' target='_blank'>changelog</a>)",
767+
"app.forkExerciseForm.confirmSubmit": "Fork process will create another copy of the exercise. This only make sense if you need to create a different exercise and you do not want to start from scratch. Please, do not fork exercises just to attach them to a different groups of residence. Are you sure you would like to proceed with forking?",
765768
"app.forkExerciseForm.selectGroupFirst": "... select group of residence first ...",
766769
"app.forkExerciseForm.showForkedExerciseButton": "Show the Forked Exercise",
767770
"app.forkExerciseForm.submit": "Fork Exercise",
@@ -1196,6 +1199,7 @@
11961199
"app.solutionsTable.noSolutionsFound": "No solutions were submitted yet.",
11971200
"app.solutionsTable.note": "Note",
11981201
"app.solutionsTable.receivedPoints": "Points",
1202+
"app.solutionsTable.rowsCount": "Total records: {count}",
11991203
"app.solutionsTable.solutionValidity": "Validity",
12001204
"app.solutionsTable.submissionDate": "Date of submission",
12011205
"app.solutionsTable.submitNewSolution": "Submit New Solution",

src/locales/whitelist_en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@
438438
"app.editShadowAssignmentPointsForm.failed",
439439
"app.editShadowAssignmentPointsForm.note",
440440
"app.editShadowAssignmentPointsForm.points",
441+
"app.editShadowAssignmentPointsForm.removePoints",
442+
"app.editShadowAssignmentPointsForm.setNow",
441443
"app.editShadowAssignmentPointsForm.validation.pointsOutOfRange",
442444
"app.editSisTerm.advertiseUntil",
443445
"app.editSisTerm.beginning",
@@ -762,6 +764,7 @@
762764
"app.filterUsersListForm.searchName",
763765
"app.footer.copyright",
764766
"app.footer.version",
767+
"app.forkExerciseForm.confirmSubmit",
765768
"app.forkExerciseForm.selectGroupFirst",
766769
"app.forkExerciseForm.showForkedExerciseButton",
767770
"app.forkExerciseForm.submit",
@@ -1196,6 +1199,7 @@
11961199
"app.solutionsTable.noSolutionsFound",
11971200
"app.solutionsTable.note",
11981201
"app.solutionsTable.receivedPoints",
1202+
"app.solutionsTable.rowsCount",
11991203
"app.solutionsTable.solutionValidity",
12001204
"app.solutionsTable.submissionDate",
12011205
"app.solutionsTable.submitNewSolution",

0 commit comments

Comments
 (0)