diff --git a/src/components/Groups/GroupsTreeView/GroupsTreeList.js b/src/components/Groups/GroupsTreeView/GroupsTreeList.js
index 9b36459..50203b7 100644
--- a/src/components/Groups/GroupsTreeView/GroupsTreeList.js
+++ b/src/components/Groups/GroupsTreeView/GroupsTreeList.js
@@ -3,23 +3,46 @@ import PropTypes from 'prop-types';
import GroupsTreeNode from './GroupsTreeNode.js';
-const GroupsTreeList = React.memo(({ groups, isExpanded = false, addAttribute, removeAttribute, locale }) => (
-
|
diff --git a/src/components/forms/PlantTermGroupsForm/PlantTermGroupsForm.js b/src/components/forms/PlantTermGroupsForm/PlantTermGroupsForm.js
index ae1b2b5..0ca545e 100644
--- a/src/components/forms/PlantTermGroupsForm/PlantTermGroupsForm.js
+++ b/src/components/forms/PlantTermGroupsForm/PlantTermGroupsForm.js
@@ -2,237 +2,150 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Form, Field, FormSpy } from 'react-final-form';
import { FormattedMessage } from 'react-intl';
+import { Row, Col } from 'react-bootstrap';
+import { lruMemoize } from 'reselect';
-import { CloseIcon, LoadingIcon, SaveIcon } from '../../icons';
+import Icon, { CloseIcon } from '../../icons';
import Button, { TheButtonGroup } from '../../widgets/TheButton';
-import { TextField, StandaloneRadioField } from '../fields';
-import Explanation from '../../widgets/Explanation';
-import { lruMemoize } from 'reselect';
-import { EMPTY_OBJ } from '../../../helpers/common';
-import Callout from '../../widgets/Callout';
+import { TextField, TextAreaField } from '../fields';
-const empty = values => {
- const mode = values.mode === 'other' ? 'key' : values.mode;
- return !values[mode];
-};
+const validate = values => {
+ const errors = { cs: {}, en: {} };
-const validate = lruMemoize(attributes => values => {
- const errors = {};
- if (values.mode === 'course') {
- if (values.course && !/^[A-Z0-9]{3,9}$/.test(values.course)) {
- errors.course = (
-
- );
- }
- } else if (values.mode === 'term') {
- if (values.term && !/^20[0-9]{2}-[12]$/.test(values.term)) {
- errors.term = (
-
- );
- }
- } else if (values.mode === 'group') {
- if (values.group && !/^[a-zA-Z0-9]{8,16}$/.test(values.group)) {
- errors.group = (
-
- );
- }
- } else if (values.mode === 'other') {
- if (values.key && !/^[-_a-zA-Z0-9]+$/.test(values.key)) {
- errors.key = (
-
- );
- }
+ if (!values?.cs?.name?.trim()) {
+ errors.cs.name = (
+
+ );
}
-
- if (Object.keys(errors).length === 0) {
- const key = values.mode === 'other' ? values.key : values.mode;
- const value = values.mode === 'other' ? values.value : values[key];
- if (key && attributes && attributes[key] && attributes[key].includes(value)) {
- errors[values.mode === 'other' ? 'value' : key] = (
-
- );
- }
+ if (!values.cs?.description?.trim()) {
+ errors.cs.description = (
+
+ );
+ }
+ if (!values?.en?.name?.trim()) {
+ errors.en.name = (
+
+ );
+ }
+ if (!values?.en?.description?.trim()) {
+ errors.en.description = (
+
+ );
}
+
return errors;
-});
+};
-export const INITIAL_VALUES = {};
+export const initialValuesCreator = lruMemoize(term => {
+ const year = `${term.year}/${(term.year + 1).toString().slice(-2)}`;
+ const termLabels = { cs: { 1: 'ZS', 2: 'LS' }, en: { 1: 'Winter', 2: 'Summer' } };
+ const termNames = { cs: { 1: 'Zimní semestr', 2: 'Letní semestr' }, en: { 1: 'Winter term', 2: 'Summer term' } };
+ return {
+ cs: {
+ name: `${year} 1-${termLabels.cs[term.term]}`,
+ description: `${termNames.cs[term.term]} ${year}`,
+ },
+ en: {
+ name: `${year} 1-${termLabels.en[term.term]}`,
+ description: `${termNames.en[term.term]} ${year}`,
+ },
+ };
+});
-const PlantTermGroupsForm = ({ initialValues, onSubmit, onClose, attributes = EMPTY_OBJ }) => {
+const PlantTermGroupsForm = ({ initialValues, onSubmit, onClose }) => {
return (
|