@eeacms/volto-eea-website-theme 1.4.2 → 1.5.1

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.
@@ -0,0 +1,86 @@
1
+ /**
2
+ * View image block.
3
+ * @module components/manage/Blocks/Image/View
4
+ */
5
+
6
+ import React from 'react';
7
+ import PropTypes from 'prop-types';
8
+ import { UniversalLink } from '@plone/volto/components';
9
+ import cx from 'classnames';
10
+ import { Copyright } from '@eeacms/volto-eea-design-system/ui';
11
+ import './style.less';
12
+ import { Icon } from 'semantic-ui-react';
13
+ import { flattenToAppURL } from '@plone/volto/helpers';
14
+
15
+ /**
16
+ * View image block class.
17
+ * @class View
18
+ * @extends Component
19
+ */
20
+ const View = ({ data, properties }) => {
21
+ const { copyright, copyrightIcon, copyrightPosition } = data;
22
+
23
+ return (
24
+ <p
25
+ className={cx(
26
+ 'block image align',
27
+ {
28
+ center: !Boolean(data.align),
29
+ },
30
+ data.align,
31
+ )}
32
+ >
33
+ {properties.image && (
34
+ <>
35
+ {(() => {
36
+ const image = (
37
+ <div className="image-block">
38
+ <img
39
+ className={cx({ 'full-width': data.align === 'full' })}
40
+ src={flattenToAppURL(properties.image.download)}
41
+ alt={properties.image_caption || ''}
42
+ />
43
+ <div className="copyright-image">
44
+ {copyright ? (
45
+ <Copyright copyrightPosition={copyrightPosition}>
46
+ <Copyright.Icon>
47
+ <Icon className={copyrightIcon} />
48
+ </Copyright.Icon>
49
+ <Copyright.Text>{copyright}</Copyright.Text>
50
+ </Copyright>
51
+ ) : (
52
+ ''
53
+ )}
54
+ </div>
55
+ </div>
56
+ );
57
+ if (data.href) {
58
+ return (
59
+ <UniversalLink
60
+ href={data.href}
61
+ openLinkInNewTab={data.openLinkInNewTab}
62
+ >
63
+ {image}
64
+ </UniversalLink>
65
+ );
66
+ } else {
67
+ return image;
68
+ }
69
+ })()}
70
+ </>
71
+ )}
72
+ </p>
73
+ );
74
+ };
75
+
76
+ /**
77
+ * Property types.
78
+ * @property {Object} propTypes Property types.
79
+ * @static
80
+ */
81
+ View.propTypes = {
82
+ data: PropTypes.objectOf(PropTypes.any).isRequired,
83
+ properties: PropTypes.objectOf(PropTypes.any).isRequired,
84
+ };
85
+
86
+ export default View;
@@ -0,0 +1,12 @@
1
+ .image-block {
2
+ position: relative;
3
+ }
4
+
5
+ .copyright-image {
6
+ position: absolute;
7
+ z-index: 1000;
8
+ top: 90%;
9
+ width: 100%;
10
+ padding-right: 10px;
11
+ padding-left: 10px;
12
+ }
@@ -201,6 +201,8 @@ class Form extends Component {
201
201
  selected: selectedBlock,
202
202
  multiSelected: [],
203
203
  isClient: false,
204
+ // Ensure focus remain in field after change
205
+ inFocus: {},
204
206
  };
205
207
  this.onChangeField = this.onChangeField.bind(this);
206
208
  this.onSelectBlock = this.onSelectBlock.bind(this);
@@ -324,6 +326,13 @@ class Form extends Component {
324
326
  [id]:
325
327
  value || (value !== undefined && isBoolean(value)) ? value : null,
326
328
  },
329
+ // Changing the form data re-renders the select widget which causes the
330
+ // focus to get lost. To circumvent this, we set the focus back to
331
+ // the input.
332
+ // This could fix other widgets too but currently targeted
333
+ // against the select widget only.
334
+ // Ensure field to be in focus after the change
335
+ inFocus: { [id]: true },
327
336
  };
328
337
  });
329
338
  }
@@ -441,7 +450,11 @@ class Form extends Component {
441
450
  () => {
442
451
  Object.keys(errors).forEach((err) =>
443
452
  toast.error(
444
- <Toast error title={err} content={errors[err].join(', ')} />,
453
+ <Toast
454
+ error
455
+ title={this.props.schema.properties[err].title || err}
456
+ content={errors[err].join(', ')}
457
+ />,
445
458
  ),
446
459
  );
447
460
  },
@@ -603,7 +616,7 @@ class Form extends Component {
603
616
  id={field}
604
617
  fieldSet={item.title.toLowerCase()}
605
618
  formData={this.state.formData}
606
- focus={false}
619
+ focus={this.state.inFocus[field]}
607
620
  value={this.state.formData?.[field]}
608
621
  required={schema.required.indexOf(field) !== -1}
609
622
  onChange={this.onChangeField}
@@ -53,7 +53,8 @@ const EEAHeader = ({ pathname, token, items, history, subsite }) => {
53
53
  (__CLIENT__ && document.body.classList.contains('homepage-inverse'));
54
54
  return (
55
55
  has_home_layout &&
56
- (pathname === router_pathname || router_pathname.endsWith('/edit'))
56
+ (removeTrailingSlash(pathname) === router_pathname ||
57
+ router_pathname.endsWith('/edit'))
57
58
  );
58
59
  });
59
60