Skip to content

Commit 14f1da7

Browse files
committed
Updating add attribute form to support for-term attributes directly.
1 parent 6731432 commit 14f1da7

3 files changed

Lines changed: 38 additions & 2 deletions

File tree

src/components/forms/AddAttributeForm/AddAttributeForm.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ import { FormattedMessage } from 'react-intl';
55

66
import { CloseIcon, LoadingIcon, SaveIcon } from '../../icons';
77
import Button, { TheButtonGroup } from '../../widgets/TheButton';
8-
import { TextField, StandaloneRadioField } from '../fields';
8+
import { TextField, SelectField, StandaloneRadioField } from '../fields';
99
import Explanation from '../../widgets/Explanation';
1010
import { lruMemoize } from 'reselect';
1111
import { EMPTY_OBJ } from '../../../helpers/common';
1212
import Callout from '../../widgets/Callout';
1313

14+
const termOptions = [
15+
{ name: <FormattedMessage id="app.terms.form.term.winter" defaultMessage="1-Winter" />, key: '1' },
16+
{ name: <FormattedMessage id="app.terms.form.term.summer" defaultMessage="2-Summer" />, key: '2' },
17+
];
18+
1419
const empty = values => {
1520
const mode = values.mode === 'other' ? 'key' : values.mode;
1621
return !values[mode];
@@ -75,6 +80,7 @@ const validate = lruMemoize(attributes => values => {
7580
export const INITIAL_VALUES = {
7681
mode: 'course',
7782
course: '',
83+
'for-term': '1',
7884
term: '',
7985
group: '',
8086
key: '',
@@ -121,6 +127,32 @@ const AddAttributeForm = ({ initialValues, onSubmit, onClose, attributes = EMPTY
121127
</td>
122128
</tr>
123129

130+
<tr className={mode === 'for-term' ? 'bg-success bg-opacity-10' : ''}>
131+
<td className="align-middle ps-3">
132+
<StandaloneRadioField name="mode" value="for-term" />
133+
</td>
134+
<td colSpan={2} className="w-100 px-3">
135+
<Field
136+
component={SelectField}
137+
name="for-term"
138+
options={termOptions}
139+
ignoreDirty
140+
disabled={mode !== 'for-term'}
141+
label={
142+
<>
143+
<FormattedMessage id="app.addAttributeForm.for-term" defaultMessage="Plant term" />
144+
<Explanation id="for-term-explanation">
145+
<FormattedMessage
146+
id="app.addAttributeForm.for-term.explanation"
147+
defaultMessage="Helper attribute that accompanies the course identifier and marks the group suitable for planting term groups for a specific semester (i.e., in which term the course is taught)."
148+
/>
149+
</Explanation>
150+
</>
151+
}
152+
/>
153+
</td>
154+
</tr>
155+
124156
<tr className={mode === 'term' ? 'bg-success bg-opacity-10' : ''}>
125157
<td className="align-middle ps-3">
126158
<StandaloneRadioField name="mode" value="term" />

src/locales/cs.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"app.addAttributeForm.course": "Předmět",
33
"app.addAttributeForm.course.explanation": "Přídání atributu předmětu umožní vazby a vytváření skupin pro SIS události tohoto předmětu v celém podstromu.",
4+
"app.addAttributeForm.for-term": "Osazovat termíny",
5+
"app.addAttributeForm.for-term.explanation": "Pomocný atribut, který se používá v kombinaci s atributem předmětu a označuje skupinu jako vhodnou pro osazování skupin pro konkrétní semestr (tj. ve kterém semestru je předmět vyučován).",
46
"app.addAttributeForm.group": "SIS Rozvrhový lístek",
57
"app.addAttributeForm.group.explanation": "Navazování rozvrhových lístků se obvykle řešeí na stránce Vytváření skupin. Vytvoření zde umožnuje obejít tradiční kontroly, takže jakýkoli SIS rozvrhový lístek může být spojen s touto skupinou. Prosíme, zacházejte s tímto s extrémní opatrností.",
68
"app.addAttributeForm.key": "Vlastní klíč",
@@ -255,4 +257,4 @@
255257
"generic.operationFailed": "Operace selhala",
256258
"generic.reset": "Resetovat",
257259
"generic.save": "Uložit"
258-
}
260+
}

src/locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"app.addAttributeForm.course": "Course",
33
"app.addAttributeForm.course.explanation": "Associating course identifier enables bindings and group creations for SIS events of that course in the whole sub-tree.",
4+
"app.addAttributeForm.for-term": "Plant term",
5+
"app.addAttributeForm.for-term.explanation": "Helper attribute that accompanies the course identifier and marks the group suitable for planting term groups for a specific semester (i.e., in which term the course is taught).",
46
"app.addAttributeForm.group": "SIS Scheduling Event",
57
"app.addAttributeForm.group.explanation": "Association between groups and SIS events is usually done by binding or creating new groups from SIS events. This circumvents traditional checks, so any SIS event ID can be associated with this group. Please, handle with extreme care.",
68
"app.addAttributeForm.key": "Custom Key",

0 commit comments

Comments
 (0)