@eeacms/volto-clms-theme 1.0.73 → 1.0.74

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.
package/CHANGELOG.md CHANGED
@@ -4,9 +4,21 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ #### [1.0.74](https://github.com/eea/volto-clms-theme/compare/1.0.73...1.0.74)
8
+
9
+ - fix [`3d683f2`](https://github.com/eea/volto-clms-theme/commit/3d683f241799aaeb9034652f1839b34bc8662003)
10
+ - add husky installer script to package.json [`071706f`](https://github.com/eea/volto-clms-theme/commit/071706f2c65333aba82c0ec9b545095479bb5348)
11
+ - remove fullobjects and show images with generated url [`0bfbc00`](https://github.com/eea/volto-clms-theme/commit/0bfbc0080a6a9be4b63bfd3eb7ed8f65856382a2)
12
+ - stop re-requesting on re-rendering of relatedListing view [`27bd33c`](https://github.com/eea/volto-clms-theme/commit/27bd33cdbb65686a37b0591e8a023aa155f2539d)
13
+ - date format [`e61e6f1`](https://github.com/eea/volto-clms-theme/commit/e61e6f1a655914d5ecadc7b8cfe51cfa6d19a7cb)
14
+ - fix related Listing block portal_type selector [`02228f9`](https://github.com/eea/volto-clms-theme/commit/02228f98e3032a9af436dedc6e5e6a5ac7d863fa)
15
+ - feedback received on demo fixed [`52530c0`](https://github.com/eea/volto-clms-theme/commit/52530c0deea9ba855816350041cb285adde03035)
16
+
7
17
  #### [1.0.73](https://github.com/eea/volto-clms-theme/compare/1.0.72...1.0.73)
8
18
 
9
- - fix import [`9d7f118`](https://github.com/eea/volto-clms-theme/commit/9d7f1189984066d9f53b46ead0b32c232bd73463)
19
+ > 23 February 2022
20
+
21
+ - fix import [`#211`](https://github.com/eea/volto-clms-theme/pull/211)
10
22
 
11
23
  #### [1.0.72](https://github.com/eea/volto-clms-theme/compare/1.0.71...1.0.72)
12
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-clms-theme",
3
- "version": "1.0.73",
3
+ "version": "1.0.74",
4
4
  "description": "volto-clms-theme: Volto theme for CLMS site",
5
5
  "main": "src/index.js",
6
6
  "author": "CodeSyntax for the European Environment Agency",
@@ -121,6 +121,7 @@
121
121
  "cypress:run": "NODE_ENV=production CYPRESS_API=plone ../../../node_modules/cypress/bin/cypress run",
122
122
  "cypress:open": "NODE_ENV=production CYPRESS_API=plone ../../../node_modules/cypress/bin/cypress open",
123
123
  "precommit": "yarn stylelint && yarn prettier && yarn lint",
124
+ "husky": "husky install",
124
125
  "test": "docker run -it --rm -v $(pwd):/opt/frontend/my-volto-project/src/addons/volto-clms-theme -e GIT_NAME=volto-clms-theme -e NAMESPACE=@eeacms plone/volto-addon-ci"
125
126
  }
126
127
  }
@@ -9,7 +9,10 @@ const CclRelatedListingEdit = (props) => {
9
9
  const schema = config.blocks.blocksConfig['relatedListing'].blockSchema;
10
10
  const searchSubrequests = useSelector((state) => state.search.subrequests);
11
11
  const types = useSelector((state) => state.types.types);
12
- const types_schema = types.map((type) => [type.title, type.title]);
12
+ const types_schema = types.map((type) => [
13
+ type['@id'].split('/').pop(),
14
+ type.title,
15
+ ]);
13
16
  let libraries = searchSubrequests?.[props.id]?.items || [];
14
17
  const variationsConfig =
15
18
  config.blocks.blocksConfig['relatedListing'].variations;
@@ -3,13 +3,16 @@ import { useDispatch, useSelector } from 'react-redux';
3
3
  import React from 'react';
4
4
  import config from '@plone/volto/registry';
5
5
  import { searchContent } from '@plone/volto/actions';
6
+ import { Segment } from 'semantic-ui-react';
6
7
 
7
8
  const CclRelatedListingView = (props) => {
8
9
  const { data, id, properties, metadata } = props;
9
10
  const dispatch = useDispatch();
10
- const searchSubrequests = useSelector((state) => state.search.subrequests);
11
+ const searchSubrequests = useSelector(
12
+ (state) => state.search.subrequests?.[props.id],
13
+ );
11
14
  const uid = metadata ? metadata['UID'] : properties['UID'];
12
- let libraries = searchSubrequests?.[props.id]?.items || [];
15
+ let libraries = searchSubrequests?.items || [];
13
16
  const variationsConfig =
14
17
  config.blocks.blocksConfig['relatedListing'].variations;
15
18
  let TemplateView = '';
@@ -43,27 +46,31 @@ const CclRelatedListingView = (props) => {
43
46
 
44
47
  React.useEffect(() => {
45
48
  uid &&
49
+ !searchSubrequests?.loading &&
50
+ !searchSubrequests?.loaded &&
51
+ !searchSubrequests?.error &&
46
52
  dispatch(
47
53
  searchContent(
48
- '',
54
+ '/',
49
55
  {
50
- fullobjects: 1,
51
56
  portal_type: data.content_type || 'News Item',
52
- path: '/',
53
57
  associated_products: uid,
58
+ metadata_fields: '_all',
54
59
  },
55
60
  id,
56
61
  ),
57
62
  );
58
- }, [data, id, uid, dispatch]);
63
+ // eslint-disable-next-line react-hooks/exhaustive-deps
64
+ }, [data, id, uid, dispatch, searchSubrequests]);
59
65
 
60
66
  return (
61
67
  <>
62
- {libraries.length > 0 ? (
68
+ {searchSubrequests?.loaded && libraries.length > 0 ? (
63
69
  <TemplateView items={libraries} variation={template_id} />
64
70
  ) : (
65
71
  <p>There are no related {data.content_type} items.</p>
66
72
  )}
73
+ {searchSubrequests?.loading && <Segment loading></Segment>}
67
74
  </>
68
75
  );
69
76
  };
@@ -0,0 +1,37 @@
1
+ import { SubscriptionView } from '@eeacms/volto-clms-theme/components/CLMSSubscriptionView';
2
+ import { SidebarPortal } from '@plone/volto/components';
3
+ import { SubscriptionSchema } from './schema';
4
+ import InlineForm from '@plone/volto/components/manage/Form/InlineForm';
5
+
6
+ const SubscriptionBlockEdit = (props) => {
7
+ const { block, data, onChangeBlock, selected } = props;
8
+
9
+ return (
10
+ <>
11
+ <div className="ccl-block-editor-header">
12
+ <legend
13
+ onClick={() => {
14
+ props.setSidebarTab(1);
15
+ }}
16
+ aria-hidden="true"
17
+ />
18
+ </div>
19
+ <SubscriptionView type={data.type || 'events'} />
20
+ <SidebarPortal selected={selected}>
21
+ <InlineForm
22
+ schema={SubscriptionSchema()}
23
+ title="Product card block"
24
+ onChangeField={(id, value) => {
25
+ onChangeBlock(block, {
26
+ ...data,
27
+ [id]: value,
28
+ });
29
+ }}
30
+ formData={data}
31
+ />
32
+ </SidebarPortal>
33
+ </>
34
+ );
35
+ };
36
+
37
+ export default SubscriptionBlockEdit;
@@ -0,0 +1,9 @@
1
+ import { SubscriptionView } from '@eeacms/volto-clms-theme/components/CLMSSubscriptionView';
2
+
3
+ const SubscriptionBlockView = (props) => {
4
+ const { data } = props;
5
+
6
+ return <SubscriptionView type={data.type || 'events'} />;
7
+ };
8
+
9
+ export default SubscriptionBlockView;
@@ -0,0 +1,21 @@
1
+ export const SubscriptionSchema = () => ({
2
+ title: 'Subscription block',
3
+ fieldsets: [
4
+ {
5
+ id: 'default',
6
+ title: 'Default',
7
+ fields: ['type'],
8
+ },
9
+ ],
10
+ properties: {
11
+ type: {
12
+ title: 'Subscription type',
13
+ choices: [
14
+ ['news', 'news'],
15
+ ['events', 'events'],
16
+ ['newsletter', 'newsletter'],
17
+ ],
18
+ },
19
+ },
20
+ required: ['product'],
21
+ });
@@ -7,15 +7,15 @@ import { Link } from 'react-router-dom';
7
7
  const messages = defineMessages({
8
8
  ProcurementNo: {
9
9
  id: 'ProcurementNo',
10
- defaultMessage: 'Procurement No:',
10
+ defaultMessage: 'Procurement No: ',
11
11
  },
12
12
  ReferenceNo: {
13
13
  id: 'ReferenceNo',
14
- defaultMessage: 'Reference No:',
14
+ defaultMessage: 'Reference No: ',
15
15
  },
16
16
  SubmissionDeadline: {
17
17
  id: 'SubmissionDeadline',
18
- defaultMessage: 'Submission deadline:',
18
+ defaultMessage: 'Submission deadline: ',
19
19
  },
20
20
  });
21
21
 
@@ -50,7 +50,7 @@ const CclWorkOpportunity = (props) => {
50
50
  <span className="card-work-deadline-title">
51
51
  {intl.formatMessage(messages.SubmissionDeadline)}
52
52
  </span>
53
- {new Date(item.submission_deadline).toLocaleDateString()}
53
+ {new Date(item.submission_deadline).toLocaleString()}
54
54
  </div>
55
55
  </div>
56
56
  );
@@ -56,6 +56,8 @@ import RelatedListingSchema from '@eeacms/volto-clms-theme/components/Blocks/Ccl
56
56
  import { TABS_BLOCK } from '@eeacms/volto-tabs-block/constants';
57
57
  import TextLinkCarouselEdit from '@eeacms/volto-clms-theme/components/Blocks/CclTextLinkCarouselBlock/CclTextLinkCarouselEdit';
58
58
  import TextLinkCarouselView from '@eeacms/volto-clms-theme/components/Blocks/CclTextLinkCarouselBlock/CclTextLinkCarouselView';
59
+ import SubscriptionBlockView from '@eeacms/volto-clms-theme/components/Blocks/CclSubscriptionBlock/SubscriptionView';
60
+ import SubscriptionBlockEdit from '@eeacms/volto-clms-theme/components/Blocks/CclSubscriptionBlock/SubscriptionEdit';
59
61
  import cardSVG from '@plone/volto/icons/indent.svg';
60
62
  import containerSVG from '@plone/volto/icons/apps.svg';
61
63
  import customIdFieldSchema from '@eeacms/volto-clms-theme/components/Blocks/CustomTemplates/VoltoFormBlock/customIdFieldSchema';
@@ -85,7 +87,6 @@ function listingVariation(id, isDefault, title, template, isWO = false) {
85
87
  isWO ? CclListingWorkOpportunities : CclListingCards,
86
88
  template,
87
89
  ),
88
- fullobjects: true,
89
90
  };
90
91
  }
91
92
 
@@ -443,6 +444,22 @@ const customBlocks = (config) => ({
443
444
  view: [], // Future proof (not implemented yet) view user role(s)
444
445
  },
445
446
  },
447
+ subscriptionBlock: {
448
+ id: 'subscriptionBlock', // The name (id) of the block
449
+ title: 'Subscription Block', // The display name of the block
450
+ icon: homeBand, // The icon used in the block chooser
451
+ group: 'ccl_blocks', // The group (blocks can be grouped, displayed in the chooser)
452
+ view: SubscriptionBlockView, // The view mode component
453
+ edit: SubscriptionBlockEdit, // The edit mode component
454
+ restricted: false, // If the block is restricted, it won't show in the chooser
455
+ mostUsed: false, // A meta group `most used`, appearing at the top of the chooser
456
+ blockHasOwnFocusManagement: false, // Set this to true if the block manages its own focus
457
+ sidebarTab: 1, // The sidebar tab you want to be selected when selecting the block
458
+ security: {
459
+ addPermission: [], // Future proof (not implemented yet) add user permission role(s)
460
+ view: [], // Future proof (not implemented yet) view user role(s)
461
+ },
462
+ },
446
463
  form: {
447
464
  ...config.blocks.blocksConfig.form,
448
465
  fieldSchema: customIdFieldSchema,
@@ -73,10 +73,6 @@ export const CLMSMeetingView = (props) => {
73
73
  id: 'meetingtype',
74
74
  defaultMessage: 'Type',
75
75
  },
76
- meetinglevel: {
77
- id: 'meetinglevel',
78
- defaultMessage: 'Level',
79
- },
80
76
  hosting_organisation: {
81
77
  id: 'hosting_organisation',
82
78
  defaultMessage: 'Hosting organisation',
@@ -330,19 +326,6 @@ export const CLMSMeetingView = (props) => {
330
326
  </>
331
327
  )}
332
328
 
333
- {content.meeting_level && (
334
- <>
335
- <div className="dataset-info-field">
336
- <div className="dataset-field-title">
337
- <Header>{intl.formatMessage(messages.meetinglevel)}</Header>
338
- </div>
339
- <div className="dataset-field-description">
340
- {content.meeting_level.title}
341
- </div>
342
- </div>
343
- </>
344
- )}
345
-
346
329
  {content.hosting_organisation && (
347
330
  <>
348
331
  <div className="dataset-info-field">
@@ -8,7 +8,7 @@ const CLMSNewsItemView = (props) => {
8
8
  <h1 className="page-title">{content.title}</h1>
9
9
  <div className="news-detail">
10
10
  <div className="news-detail-date">
11
- {new Date(content?.effective).toLocaleDateString()}
11
+ {new Date(content?.effective).toLocaleString()}
12
12
  </div>
13
13
  {content?.image && (
14
14
  <figure className="news-detail-image">
@@ -1,7 +1,5 @@
1
1
  import './cards.less';
2
2
 
3
- import * as mime from 'react-native-mime-types';
4
-
5
3
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
6
4
  import { Link } from 'react-router-dom';
7
5
  import PropTypes from 'prop-types';
@@ -12,12 +10,52 @@ import { portal_types_labels } from '../Blocks/CustomTemplates/VoltoSearchBlock'
12
10
  import penSVG from '@plone/volto/icons/pen.svg';
13
11
  import { Icon } from '@plone/volto/components';
14
12
 
15
- function bytesToSize(bytes) {
16
- var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
17
- if (bytes === 0) return '0 Byte';
18
- var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
19
- return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
20
- }
13
+ const CardImage = ({ card, size = 'preview' }) => {
14
+ return card?.image_field ? (
15
+ <img
16
+ src={`${card.getURL}/@@images/${card?.image_field}/${size}`}
17
+ alt={card?.image?.alt || 'Placeholder'}
18
+ />
19
+ ) : (
20
+ <img
21
+ src={
22
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg'
23
+ }
24
+ alt={card?.image?.alt || 'Placeholder'}
25
+ />
26
+ );
27
+ };
28
+
29
+ const DocCard = ({ card, url, showEditor, children }) => {
30
+ return (
31
+ <>
32
+ <div className="card-doc-title">
33
+ {card?.Type === 'TechnicalLibrary' ? (
34
+ <a href={`${card['@id']}/@@download/file`}>{card?.title}</a>
35
+ ) : (
36
+ <Link to={url}>{card?.title}</Link>
37
+ )}
38
+ {card?.Type === 'TechnicalLibrary' && showEditor && (
39
+ <Link to={`${url}/edit`}>
40
+ <Icon
41
+ name={penSVG}
42
+ size="15px"
43
+ className="circled"
44
+ title={'Edit'}
45
+ />
46
+ </Link>
47
+ )}
48
+ </div>
49
+ <div className="card-doc-text">
50
+ <div className="doc-description">{card?.description}</div>
51
+ {card?.Type === 'TechnicalLibrary' && (
52
+ <div className="card-doc-size">{card.getObjSize || ''}</div>
53
+ )}
54
+ {children}
55
+ </div>
56
+ </>
57
+ );
58
+ };
21
59
  function CclCard(props) {
22
60
  const { type, children, card, showEditor = false } = props;
23
61
  let url = '/';
@@ -40,53 +78,27 @@ function CclCard(props) {
40
78
  >
41
79
  {conditional_types.includes(type) ? (
42
80
  <>
43
- {(type === 'doc' || type === 'globalSearch') && (
81
+ {type === 'doc' && (
44
82
  <>
45
- {type === 'globalSearch' && (
46
- <Label ribbon="right" color="olive">
47
- {content_type}
48
- </Label>
49
- )}
50
- <div className="card-doc-title">
51
- {card?.file?.download ? (
52
- <a href={card.file.download}>{card?.title}</a>
53
- ) : (
54
- <Link to={url}>{card?.title}</Link>
55
- )}
56
- {card?.file?.download && showEditor && (
57
- <Link to={`${url}/edit`}>
58
- <Icon
59
- name={penSVG}
60
- size="15px"
61
- className="circled"
62
- title={'Edit'}
63
- />
64
- </Link>
65
- )}
66
- </div>
67
- <div className="card-doc-text">
68
- <div className="doc-description">{card?.description}</div>
69
- {card?.file && (
70
- <div className="card-doc-size">
71
- {mime.extension(card?.file?.['content-type']).toUpperCase()}{' '}
72
- {bytesToSize(card?.file?.size) || ''}
73
- </div>
74
- )}
83
+ <DocCard card={card} url={url} showEditor={showEditor}>
75
84
  {children}
76
- </div>
85
+ </DocCard>
86
+ </>
87
+ )}
88
+ {type === 'globalSearch' && (
89
+ <>
90
+ <Label ribbon="right" color="olive">
91
+ {content_type}
92
+ </Label>
93
+ <DocCard card={card} url={url} showEditor={showEditor}>
94
+ {children}
95
+ </DocCard>
77
96
  </>
78
97
  )}
79
98
  {(type === 'block' || type === 'threeColumns') && (
80
99
  <>
81
100
  <div className={`card-${type}-image`}>
82
- <img
83
- src={
84
- card?.image?.scales?.preview?.download ||
85
- card?.image?.download ||
86
- 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg'
87
- }
88
- alt={card?.image?.alt || 'Placeholder'}
89
- />
101
+ <CardImage card={card} size={'preview'} />
90
102
  </div>
91
103
  <div className="card-text">
92
104
  <div className="card-title">
@@ -100,21 +112,14 @@ function CclCard(props) {
100
112
  {type === 'news' && (
101
113
  <>
102
114
  <div className="card-news-image">
103
- <img
104
- src={
105
- card?.image?.scales?.mini?.download ||
106
- card?.image?.download ||
107
- 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg'
108
- }
109
- alt={card?.image?.alt || 'Placeholder'}
110
- />
115
+ <CardImage card={card} size={'mini'} />
111
116
  </div>
112
117
  <div className="card-news-text">
113
118
  <div className="card-news-title">
114
119
  <Link to={url}>{card?.title || 'Card default title'}</Link>
115
120
  </div>
116
121
  <div className="card-news-date">
117
- {new Date(card?.effective).toLocaleDateString()}
122
+ {new Date(card?.effective).toLocaleString()}
118
123
  </div>
119
124
  <p className="card-news-description">{card?.description}</p>
120
125
  </div>
@@ -129,19 +134,11 @@ function CclCard(props) {
129
134
  <div className="card-event-when">
130
135
  <FontAwesomeIcon icon={['far', 'calendar-alt']} />
131
136
  <div className="card-event-when-text">
132
- {card.whole_day ? (
133
- <When
134
- start={card.start}
135
- end={card.start}
136
- whole_day={card.whole_day}
137
- />
138
- ) : (
139
- <When
140
- start={card.start}
141
- end={card.end}
142
- whole_day={card.whole_day}
143
- />
144
- )}
137
+ <When
138
+ start={card.start}
139
+ end={card.whole_day ? card.start : card.end}
140
+ whole_day={card.whole_day}
141
+ />
145
142
  </div>
146
143
  </div>
147
144
  {card?.location ? (
@@ -164,14 +161,7 @@ function CclCard(props) {
164
161
  ) : (
165
162
  <>
166
163
  <div className="card-image">
167
- <img
168
- src={
169
- card?.image?.scales?.mini?.download ||
170
- card?.image?.download ||
171
- 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg'
172
- }
173
- alt={card?.image?.alt || 'Placeholder'}
174
- />
164
+ <CardImage card={card} size={'mini'} />
175
165
  </div>
176
166
  <div className={'card-text'}>
177
167
  <div className="card-title">
package/src/index.js CHANGED
@@ -40,7 +40,6 @@ const applyConfig = (config) => {
40
40
  ...config.contentTypesViews,
41
41
  DataSet: CLMSDatasetDetailView,
42
42
  'News Item': CLMSNewsItemView,
43
- TechnicalLibrary: CLMSDownloadableFileView,
44
43
  File: CLMSDownloadableFileView,
45
44
  'eea.meeting': CLMSMeetingView,
46
45
  'eea.meeting.subscribers': CLMSMeetingSubscribersView,