@configuratorware/configurator-admingui 1.30.3 → 1.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/App/Reducers/Api/Actions.js +12 -1
  2. package/App/Reducers/Api/Reducer.js +6 -0
  3. package/Components/DefaultForm.js +3 -2
  4. package/Screens/Client/Containers/Edit.js +15 -4
  5. package/Screens/Client/Translations.js +3 -1
  6. package/Screens/Creator/Components/VisualizationAndMediaData/Components/ImageEditTools.js +78 -28
  7. package/Screens/Creator/Components/VisualizationAndMediaData/Translations.js +4 -2
  8. package/Screens/CurrentClient/Containers/Edit.js +15 -4
  9. package/Screens/CurrentClient/Reducers/Reducer.js +1 -4
  10. package/Screens/DefaultClient/Containers/Edit.js +15 -4
  11. package/Screens/DefaultClient/Reducers/Reducer.js +1 -4
  12. package/Screens/Group/Reducers/Actions.js +4 -2
  13. package/Screens/Item/Components/Variants/VariantsEditor.js +4 -2
  14. package/Screens/Item/Components/Variants/VariantsEditorPopup.js +34 -0
  15. package/Screens/Login/Reducers/Actions.js +4 -5
  16. package/package.json +2 -2
  17. package/src/App/Reducers/Api/Actions.js +6 -0
  18. package/src/App/Reducers/Api/Reducer.js +7 -0
  19. package/src/Components/DefaultForm.js +2 -1
  20. package/src/Components/TranslationFinder.js +1 -0
  21. package/src/Screens/Client/Containers/Edit.js +15 -2
  22. package/src/Screens/Client/Translations.js +3 -1
  23. package/src/Screens/Creator/Components/VisualizationAndMediaData/Components/ImageEditTools.js +65 -40
  24. package/src/Screens/Creator/Components/VisualizationAndMediaData/Translations.js +2 -0
  25. package/src/Screens/Creator/Components/VisualizationAndMediaData/VisualizationAndMediaData.js +1 -0
  26. package/src/Screens/Creator/Components/VisualizationAndMediaData/VisualizationAndMediaData.test.js +1 -0
  27. package/src/Screens/CurrentClient/Containers/Edit.js +15 -2
  28. package/src/Screens/CurrentClient/Reducers/Reducer.js +1 -1
  29. package/src/Screens/DefaultClient/Containers/Edit.js +15 -2
  30. package/src/Screens/DefaultClient/Reducers/Reducer.js +1 -1
  31. package/src/Screens/Group/Reducers/Actions.js +1 -1
  32. package/src/Screens/Item/Components/Variants/VariantsEditor.js +3 -2
  33. package/src/Screens/Item/Components/Variants/VariantsEditorPopup.js +11 -1
  34. package/src/Screens/Login/Reducers/Actions.js +1 -5
  35. package/Screens/Client/Components/TextFields.js +0 -163
  36. package/src/Screens/Client/Components/TextFields.js +0 -77
@@ -1,7 +1,6 @@
1
1
  import Actions, { REDUCER_NAME } from '../Reducers/Actions';
2
2
  import SimpleNestedData from '../../../Components/FormFragments/SimpleNestedData';
3
3
  import generateConnectedEdit from '../../../Components/DefaultConnectedForm';
4
- import TextFields from '../Components/TextFields';
5
4
  import ColorTextField from '../Components/ColorTextField';
6
5
  import { t } from '../../../App/i18n';
7
6
  import React from 'react';
@@ -139,8 +138,22 @@ const formFields = [
139
138
  dynamicDefaultLabel: false
140
139
  },
141
140
  {
142
- type: TextFields,
143
141
  name: 'texts',
142
+ label: 'termsAndConditionsLink',
143
+ type: 'intl',
144
+ intl: {
145
+ name: 'termsAndConditionsLink',
146
+ type: 'text',
147
+ },
148
+ },
149
+ {
150
+ name: 'texts',
151
+ label: 'dataPrivacyLink',
152
+ type: 'intl',
153
+ intl: {
154
+ name: 'dataPrivacyLink',
155
+ type: 'text',
156
+ },
144
157
  },
145
158
  {
146
159
  name: 'channels',
@@ -5,6 +5,7 @@ require('../../App/i18n').use(
5
5
  Users: 'Users',
6
6
  'Theme - Highlight color': 'Theme - Highlight color',
7
7
  termsAndConditionsLink: 'Terms and conditions link',
8
+ dataPrivacyLink: 'Data privacy Link',
8
9
  themeColorError: 'Please enter a valid hex color (e.g. #0000ff)"',
9
10
  client: {
10
11
  addButtonLabel: 'Add Client',
@@ -21,7 +22,8 @@ require('../../App/i18n').use(
21
22
  Users: 'Benutzer',
22
23
  'Theme - Highlight color': 'Theme - Highlightfarbe',
23
24
  'Theme - Font': 'Theme - Font',
24
- termsAndConditionsLink: 'Terms and conditions link',
25
+ termsAndConditionsLink: 'Link zu den Nutzungsbedingungen',
26
+ dataPrivacyLink: 'Link zu den Datenschutzbestimmungen',
25
27
  'Clientname / Shopname': 'Bezeichner/ Shopname',
26
28
  'E-mail (contact)': 'E-Mail (Kontakt)',
27
29
  'Street / no': 'Straße / Hausnummer',
@@ -7,8 +7,10 @@ import { t } from '../../../../../App/i18n';
7
7
  import ConfirmDelete from './ConfirmDelete';
8
8
  import Api from '../../../../../App/Api';
9
9
  import { networkError } from '../../../../../App/Reducers/Api/Actions';
10
+ import { showErrorMessage, cancelErrorMessage } from '../../../../../App/Reducers/Frame/Actions';
10
11
  import { useDispatch } from 'react-redux';
11
12
  import { Tooltip } from '@material-ui/core';
13
+ import FileDrop from 'react-file-drop';
12
14
 
13
15
  const ImageEditTools = withStyles({
14
16
  root: {
@@ -17,18 +19,32 @@ const ImageEditTools = withStyles({
17
19
  fileInput: {
18
20
  display: 'none',
19
21
  },
22
+ fileDrop: {
23
+ position: 'absolute',
24
+ top: 0,
25
+ left: '50%',
26
+ width: 150,
27
+ marginLeft: -75,
28
+ height: 100,
29
+ },
20
30
  })(({ classes, className, deleteEnabled, uploadUrl, removeUrl, onUpdate }) => {
21
31
  const fileInputRef = useRef(null);
22
32
  const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
23
33
  const dispatch = useDispatch();
24
34
 
25
35
  const uploadImage = async image => {
36
+ const allowedFormats = ['image/jpeg', 'image/jpg', 'image/png'];
37
+
26
38
  if (!uploadUrl) {
27
39
  throw new Error('uploadUrl is not provided!');
28
40
  }
41
+ if (allowedFormats.indexOf(image.type) === -1) {
42
+ return dispatch(showErrorMessage(t('visualizationAndMediaData.unsupportedFileTypeError')));
43
+ }
29
44
  try {
30
45
  const data = new FormData();
31
46
  data.append('file', image);
47
+ dispatch(cancelErrorMessage());
32
48
  return await Api.request({ method: 'post', url: uploadUrl, data });
33
49
  } catch (e) {
34
50
  dispatch(networkError('image', 'image', e));
@@ -46,47 +62,56 @@ const ImageEditTools = withStyles({
46
62
  };
47
63
 
48
64
  return (
49
- <div className={`${classes.root} ${className}`}>
50
- <input
51
- ref={fileInputRef}
52
- type="file"
53
- accept="image/jpeg, image/png"
54
- className={classes.fileInput}
55
- onChange={async evt => {
56
- if (evt.target.files.length) {
57
- await uploadImage(evt.target.files[0]);
58
- onUpdate && onUpdate();
59
- }
60
- }}
61
- />
62
- <label>
63
- <Tooltip title={t('visualizationAndMediaData.imageAddTooltip')}>
64
- <IconButton onClick={() => fileInputRef.current.click()}>
65
- <ImageSearchIcon />
66
- </IconButton>
67
- </Tooltip>
68
- </label>
69
- {deleteEnabled && (
70
- <Tooltip title={t('visualizationAndMediaData.imageDeleteTooltip')}>
71
- <IconButton onClick={() => setShowDeleteConfirm(true)}>
72
- <DeleteIcon />
73
- </IconButton>
74
- </Tooltip>
75
- )}
65
+ <FileDrop
66
+ className={classes.fileDrop}
67
+ onDrop={async files => {
68
+ await uploadImage(files[0]);
69
+ onUpdate && onUpdate();
70
+ }}
71
+ multiple={false}
72
+ >
73
+ <div className={`${classes.root} ${className}`}>
74
+ <input
75
+ ref={fileInputRef}
76
+ type="file"
77
+ accept="image/jpeg, image/png"
78
+ className={classes.fileInput}
79
+ onChange={async evt => {
80
+ if (evt.target.files.length) {
81
+ await uploadImage(evt.target.files[0]);
82
+ onUpdate && onUpdate();
83
+ }
84
+ }}
85
+ />
86
+ <label>
87
+ <Tooltip title={t('visualizationAndMediaData.imageAddTooltip')}>
88
+ <IconButton onClick={() => fileInputRef.current.click()}>
89
+ <ImageSearchIcon />
90
+ </IconButton>
91
+ </Tooltip>
92
+ </label>
93
+ {deleteEnabled && (
94
+ <Tooltip title={t('visualizationAndMediaData.imageDeleteTooltip')}>
95
+ <IconButton onClick={() => setShowDeleteConfirm(true)}>
96
+ <DeleteIcon />
97
+ </IconButton>
98
+ </Tooltip>
99
+ )}
76
100
 
77
- <ConfirmDelete
78
- open={showDeleteConfirm}
79
- onCancel={() => setShowDeleteConfirm(false)}
80
- onConfirm={async () => {
81
- await removeImage();
82
- setShowDeleteConfirm(false);
83
- onUpdate && onUpdate();
84
- }}
85
- title={t('visualizationAndMediaData.imageDeleteConfirm.title')}
86
- message={t('visualizationAndMediaData.imageDeleteConfirm.message')}
87
- />
88
- </div>
101
+ <ConfirmDelete
102
+ open={showDeleteConfirm}
103
+ onCancel={() => setShowDeleteConfirm(false)}
104
+ onConfirm={async () => {
105
+ await removeImage();
106
+ setShowDeleteConfirm(false);
107
+ onUpdate && onUpdate();
108
+ }}
109
+ title={t('visualizationAndMediaData.imageDeleteConfirm.title')}
110
+ message={t('visualizationAndMediaData.imageDeleteConfirm.message')}
111
+ />
112
+ </div>
113
+ </FileDrop>
89
114
  );
90
115
  });
91
116
 
92
- export default ImageEditTools;
117
+ export default ImageEditTools;
@@ -44,6 +44,7 @@ require('../../../../App/i18n').use(
44
44
  title: 'Delete image',
45
45
  message: 'Do you really want to delete this image?',
46
46
  },
47
+ unsupportedFileTypeError: 'Unsupported file format',
47
48
  },
48
49
  },
49
50
  de: {
@@ -92,6 +93,7 @@ require('../../../../App/i18n').use(
92
93
  title: 'Bild löschen',
93
94
  message: 'Möchtest du dieses Bild wirklich löschen?',
94
95
  },
96
+ unsupportedFileTypeError: 'Nicht unterstütztes Dateiformat',
95
97
  },
96
98
  },
97
99
  },
@@ -70,6 +70,7 @@ const ImageTile = withStyles(theme => ({
70
70
  return (
71
71
  <div className={classes.imageTile}>
72
72
  {expectedSrc ? <PathStructure path={expectedSrc} /> : <Image src={src} />}
73
+
73
74
  {uploadUrl && removeUrl && (
74
75
  <ImageEditTools
75
76
  className={classes.imageEditTools}
@@ -3,6 +3,7 @@ import { act } from 'react-dom/test-utils';
3
3
  import { VisualizationAndMediaData } from './VisualizationAndMediaData';
4
4
  import { mount, render } from 'enzyme';
5
5
  import FormControl from '@material-ui/core/FormControl';
6
+ jest.mock('react-file-drop', () => props => <div>{props.children}</div>);
6
7
 
7
8
  const mockDispatch = jest.fn();
8
9
  jest.mock('react-redux', () => ({
@@ -1,7 +1,6 @@
1
1
  import Actions, { REDUCER_NAME } from '../Reducers/Actions';
2
2
  import SimpleNestedData from '../../../Components/FormFragments/SimpleNestedData';
3
3
  import generateConnectedEdit from '../../../Components/DefaultConnectedForm';
4
- import TextFields from '../../Client/Components/TextFields';
5
4
  import { withLoadAction } from '../../../Components/withLoadAction';
6
5
  import { t } from '../../../App/i18n';
7
6
  import { CallToActionField } from '../../../Components/CallToActionField';
@@ -108,8 +107,22 @@ const formFields = [
108
107
  dynamicDefaultLabel: false
109
108
  },
110
109
  {
111
- type: TextFields,
112
110
  name: 'texts',
111
+ label: 'termsAndConditionsLink',
112
+ type: 'intl',
113
+ intl: {
114
+ name: 'termsAndConditionsLink',
115
+ type: 'text',
116
+ },
117
+ },
118
+ {
119
+ name: 'texts',
120
+ label: 'Title',
121
+ type: 'dataPrivacyLink',
122
+ intl: {
123
+ name: 'dataPrivacyLink',
124
+ type: 'text',
125
+ },
113
126
  },
114
127
  {
115
128
  name: 'customCss',
@@ -7,7 +7,7 @@ const initialState = {
7
7
  ...getDefaultEntityState(
8
8
  {
9
9
  id: null,
10
- texts: { value: [], constraints: { presence: true } },
10
+ texts: { value: [] },
11
11
  theme: {
12
12
  value: {},
13
13
  schema: {
@@ -3,7 +3,6 @@ import generateConnectedEdit from '../../../Components/DefaultConnectedForm';
3
3
  import { withLoadAction } from '../../../Components/withLoadAction';
4
4
  import SimpleNestedData from '../../../Components/FormFragments/SimpleNestedData';
5
5
  import { t, T } from '../../../App/i18n';
6
- import TextFields from '../../Client/Components/TextFields';
7
6
  import PdfMarkDownField from '../../Client/Components/PdfMarkdownField';
8
7
 
9
8
  const formFields = [
@@ -124,8 +123,22 @@ const formFields = [
124
123
  ],
125
124
  },
126
125
  {
127
- type: TextFields,
128
126
  name: 'texts',
127
+ label: 'termsAndConditionsLink',
128
+ type: 'intl',
129
+ intl: {
130
+ name: 'termsAndConditionsLink',
131
+ type: 'text',
132
+ },
133
+ },
134
+ {
135
+ name: 'texts',
136
+ label: 'dataPrivacyLink',
137
+ type: 'intl',
138
+ intl: {
139
+ name: 'dataPrivacyLink',
140
+ type: 'text',
141
+ },
129
142
  },
130
143
  {
131
144
  name: 'customCss',
@@ -12,7 +12,7 @@ const initialState = {
12
12
  theme: {
13
13
  value: {},
14
14
  schema: {
15
- highlightColor: { value: '', constraints: { presence: true } },
15
+ highlightColor: { value: '' },
16
16
  logo: { value: '' },
17
17
  font: { value: '' },
18
18
  },
@@ -7,6 +7,6 @@ import { generateDefaultActions } from '../../../App/Reducers/Entity/Actions';
7
7
 
8
8
  const actions = generateDefaultActions(LIST_KEY, DATA_KEY, REDUCER_NAME, GROUPS_URL);
9
9
 
10
- export const { hideDetails, loadEntity } = actions;
10
+ export const { hideDetails, loadEntity, postData } = actions;
11
11
 
12
12
  export default actions;
@@ -8,6 +8,7 @@ import TableHead from '@material-ui/core/TableHead';
8
8
  import TableRow from '@material-ui/core/TableRow';
9
9
  import Checkbox from '@material-ui/core/Checkbox/Checkbox';
10
10
  import TablePagination from '@material-ui/core/TablePagination';
11
+ import uniq from 'lodash/uniq';
11
12
  import { addReduxListener, removeReduxListener } from '../../../../App/ReduxListener';
12
13
  import { t } from '../../../../App/i18n';
13
14
  import Actions, { ITEM_REDUCER_NAME } from '../../Reducers/Actions';
@@ -64,7 +65,7 @@ const getGroupsFromChildren = children => {
64
65
  }
65
66
  }
66
67
 
67
- return { groups, groupIdsInOrder };
68
+ return { groups, groupIdsInOrder: uniq(groupIdsInOrder) };
68
69
  };
69
70
 
70
71
  const prepareDataForRendering = children => {
@@ -222,7 +223,7 @@ class VariantsEditor extends Component {
222
223
 
223
224
  this.setState({
224
225
  groups,
225
- groupIdsInOrder,
226
+ groupIdsInOrder: uniq(groupIdsInOrder),
226
227
  });
227
228
  };
228
229
 
@@ -8,6 +8,7 @@ import * as GroupActions from '../../../Group/Reducers/Actions';
8
8
  import * as GroupEntryActions from '../../../GroupEntry/Reducers/Actions';
9
9
 
10
10
  import { T } from '../../../../App/i18n';
11
+ import { resetDidInvalidate } from '../../../../App/Reducers/Api/Actions';
11
12
 
12
13
  export class VariantsEditorPopup extends React.Component {
13
14
  render() {
@@ -21,7 +22,11 @@ export class VariantsEditorPopup extends React.Component {
21
22
  open={showGroupEditor}
22
23
  scroll={'paper'}
23
24
  >
24
- <GroupEdit onCancel={this.props.cancelGroup} closeAfterSave />
25
+ <GroupEdit
26
+ customPostData={this.props.customPostData}
27
+ onCancel={this.props.cancelGroup}
28
+ closeAfterSave
29
+ />
25
30
  </Dialog>
26
31
 
27
32
  <Dialog
@@ -51,6 +56,11 @@ const renderDispatchToProps = dispatch => ({
51
56
  cancelGroup: () => {
52
57
  dispatch(GroupActions.hideDetails(false));
53
58
  },
59
+ customPostData: async () => {
60
+ await dispatch(GroupActions.postData(true));
61
+ // need to reset didInvalidate flag as it is set on save of group which is blocking to reloadList
62
+ dispatch(resetDidInvalidate(GroupActions.GROUPS_URL));
63
+ },
54
64
  cancelGroupEntry: () => {
55
65
  dispatch(GroupEntryActions.hideDetails(false));
56
66
  },
@@ -49,11 +49,7 @@ const errorHandler = dispatch => error => {
49
49
  };
50
50
 
51
51
  export const postLoginData = (username, password) => dispatch => {
52
- const data = new ObjectFormData({
53
- _username: username,
54
- _password: password,
55
- });
56
- return dispatchPostData(dispatch)(LOGIN_DATA_KEY, 'login_check', data).then(apiAction => {
52
+ return dispatchPostData(dispatch)(LOGIN_DATA_KEY, 'login_check', {username, password}).then(apiAction => {
57
53
  return dispatch(apiActionHandler(apiAction, receiveHandler, errorHandler));
58
54
  });
59
55
  };
@@ -1,163 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _react = _interopRequireWildcard(require("react"));
11
-
12
- var _find = _interopRequireDefault(require("lodash/find"));
13
-
14
- var _TextField = _interopRequireDefault(require("@material-ui/core/TextField/TextField"));
15
-
16
- var _Typography = _interopRequireDefault(require("@material-ui/core/Typography/Typography"));
17
-
18
- var _i18n = require("../../../App/i18n");
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
-
22
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
-
24
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
-
26
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
27
-
28
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
29
-
30
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
31
-
32
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
33
-
34
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
35
-
36
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
37
-
38
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
39
-
40
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
41
-
42
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
43
-
44
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
45
-
46
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
47
-
48
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
49
-
50
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
51
-
52
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
53
-
54
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
55
-
56
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
57
-
58
- var TextFields = /*#__PURE__*/function (_Component) {
59
- _inherits(TextFields, _Component);
60
-
61
- var _super = _createSuper(TextFields);
62
-
63
- function TextFields() {
64
- var _this;
65
-
66
- _classCallCheck(this, TextFields);
67
-
68
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
69
- args[_key] = arguments[_key];
70
- }
71
-
72
- _this = _super.call.apply(_super, [this].concat(args));
73
-
74
- _defineProperty(_assertThisInitialized(_this), "onTextChange", function (textId) {
75
- return function (_ref) {
76
- var termsAndConditionsLink = _ref.target.value;
77
- var _this$props = _this.props,
78
- texts = _this$props.value,
79
- name = _this$props.name,
80
- onChange = _this$props.onChange;
81
- var newTexts = texts.map(function (text) {
82
- if (text.id !== textId) {
83
- return text;
84
- }
85
-
86
- return _objectSpread(_objectSpread({}, text), {}, {
87
- termsAndConditionsLink: termsAndConditionsLink
88
- });
89
- });
90
- onChange(name, newTexts);
91
- };
92
- });
93
-
94
- _defineProperty(_assertThisInitialized(_this), "getGroupedTexts", function () {
95
- var value = _this.props.value;
96
- var groupedTexts = [];
97
-
98
- var _iterator = _createForOfIteratorHelper(value),
99
- _step;
100
-
101
- try {
102
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
103
- var text = _step.value;
104
- var group = (0, _find["default"])(groupedTexts, {
105
- id: text.channel.id
106
- });
107
-
108
- if (!group) {
109
- group = {
110
- id: text.channel.id,
111
- identifier: text.channel.identifier,
112
- texts: []
113
- };
114
- groupedTexts.push(group);
115
- }
116
-
117
- group.texts.push({
118
- id: text.id,
119
- language: text.language,
120
- termsAndConditionsLink: text.termsAndConditionsLink
121
- });
122
- }
123
- } catch (err) {
124
- _iterator.e(err);
125
- } finally {
126
- _iterator.f();
127
- }
128
-
129
- return groupedTexts;
130
- });
131
-
132
- return _this;
133
- }
134
-
135
- _createClass(TextFields, [{
136
- key: "render",
137
- value: function render() {
138
- var _this2 = this;
139
-
140
- var groupedTexts = this.getGroupedTexts();
141
- return groupedTexts.length ? /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_Typography["default"], null, (0, _i18n.t)('Texts')), groupedTexts.map(function (group, groupIndex) {
142
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, {
143
- key: groupIndex
144
- }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
145
- variant: "overline"
146
- }, group.identifier), group.texts.map(function (text, textIndex) {
147
- return /*#__PURE__*/_react["default"].createElement(_TextField["default"], {
148
- key: textIndex,
149
- label: "".concat((0, _i18n.t)('termsAndConditionsLink'), " ").concat(text.language),
150
- onChange: _this2.onTextChange(text.id),
151
- value: text.termsAndConditionsLink || '',
152
- fullWidth: true,
153
- margin: "normal"
154
- });
155
- }));
156
- })) : null;
157
- }
158
- }]);
159
-
160
- return TextFields;
161
- }(_react.Component);
162
-
163
- exports["default"] = TextFields;
@@ -1,77 +0,0 @@
1
- import React, { Component } from 'react';
2
- import find from 'lodash/find';
3
- import TextField from '@material-ui/core/TextField/TextField';
4
- import Typography from '@material-ui/core/Typography/Typography';
5
- import { t } from '../../../App/i18n';
6
-
7
- export default class TextFields extends Component {
8
- onTextChange = textId => ({ target: { value: termsAndConditionsLink } }) => {
9
- const { value: texts, name, onChange } = this.props;
10
-
11
- const newTexts = texts.map(text => {
12
- if (text.id !== textId) {
13
- return text;
14
- }
15
-
16
- return {
17
- ...text,
18
- termsAndConditionsLink,
19
- };
20
- });
21
-
22
- onChange(name, newTexts);
23
- };
24
-
25
- getGroupedTexts = () => {
26
- const { value } = this.props;
27
-
28
- const groupedTexts = [];
29
-
30
- for (const text of value) {
31
- let group = find(groupedTexts, { id: text.channel.id });
32
-
33
- if (!group) {
34
- group = {
35
- id: text.channel.id,
36
- identifier: text.channel.identifier,
37
- texts: [],
38
- };
39
-
40
- groupedTexts.push(group);
41
- }
42
-
43
- group.texts.push({
44
- id: text.id,
45
- language: text.language,
46
- termsAndConditionsLink: text.termsAndConditionsLink,
47
- });
48
- }
49
-
50
- return groupedTexts;
51
- };
52
-
53
- render() {
54
- const groupedTexts = this.getGroupedTexts();
55
-
56
- return groupedTexts.length ? (
57
- <div>
58
- <Typography>{t('Texts')}</Typography>
59
- {groupedTexts.map((group, groupIndex) => (
60
- <React.Fragment key={groupIndex}>
61
- <Typography variant="overline">{group.identifier}</Typography>
62
- {group.texts.map((text, textIndex) => (
63
- <TextField
64
- key={textIndex}
65
- label={`${t('termsAndConditionsLink')} ${text.language}`}
66
- onChange={this.onTextChange(text.id)}
67
- value={text.termsAndConditionsLink || ''}
68
- fullWidth
69
- margin="normal"
70
- />
71
- ))}
72
- </React.Fragment>
73
- ))}
74
- </div>
75
- ) : null;
76
- }
77
- }