@eeacms/volto-clms-theme 1.0.71 → 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,8 +4,36 @@ 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
+
17
+ #### [1.0.73](https://github.com/eea/volto-clms-theme/compare/1.0.72...1.0.73)
18
+
19
+ > 23 February 2022
20
+
21
+ - fix import [`#211`](https://github.com/eea/volto-clms-theme/pull/211)
22
+
23
+ #### [1.0.72](https://github.com/eea/volto-clms-theme/compare/1.0.71...1.0.72)
24
+
25
+ > 21 February 2022
26
+
27
+ - Develop [`#210`](https://github.com/eea/volto-clms-theme/pull/210)
28
+ - fix tests [`8d68b8d`](https://github.com/eea/volto-clms-theme/commit/8d68b8d9f013f469d6f1138f5301055175344ab6)
29
+ - add edit button for editors at documents listing [`7e81f0b`](https://github.com/eea/volto-clms-theme/commit/7e81f0b920db84c47f3354a9a6d5736213746dea)
30
+ - add default link if has no files to download [`f45842d`](https://github.com/eea/volto-clms-theme/commit/f45842d9a19cab1333cb31843fb5fe5b1e2b15db)
31
+
7
32
  #### [1.0.71](https://github.com/eea/volto-clms-theme/compare/1.0.70...1.0.71)
8
33
 
34
+ > 21 February 2022
35
+
36
+ - Taxonomy widget [`#209`](https://github.com/eea/volto-clms-theme/pull/209)
9
37
  - Taxonomy widget [`#208`](https://github.com/eea/volto-clms-theme/pull/208)
10
38
  - merge conflicts [`c714434`](https://github.com/eea/volto-clms-theme/commit/c714434f91ce01b9dc82014b32d2c9c34fbe1308)
11
39
  - add download link to technical library objects at listing [`455a6dc`](https://github.com/eea/volto-clms-theme/commit/455a6dc6c4cf38f5018582d11b90f156232f1d99)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-clms-theme",
3
- "version": "1.0.71",
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
+ });
@@ -4,6 +4,7 @@ import { ConditionalLink } from '@plone/volto/components';
4
4
  import { flattenToAppURL } from '@plone/volto/helpers';
5
5
 
6
6
  import { isInternalURL } from '@plone/volto/helpers/Url/Url';
7
+ import { useSelector } from 'react-redux';
7
8
 
8
9
  import CclCard from '@eeacms/volto-clms-theme/components/CclCard/CclCard';
9
10
 
@@ -11,7 +12,7 @@ const CclListingCards = (props) => {
11
12
  const { items, linkHref, linkTitle, isEditMode, variation = 'doc' } = props;
12
13
  let link = null;
13
14
  let href = linkHref?.[0]?.['@id'] || '';
14
-
15
+ const user = useSelector((state) => state.users.user);
15
16
  if (isInternalURL(href)) {
16
17
  link = (
17
18
  <ConditionalLink to={flattenToAppURL(href)} condition={!isEditMode}>
@@ -21,7 +22,6 @@ const CclListingCards = (props) => {
21
22
  } else if (href) {
22
23
  link = <a href={href}>{linkTitle || href}</a>;
23
24
  }
24
-
25
25
  let containerClass = '';
26
26
  if (['news', 'event'].includes(variation)) {
27
27
  containerClass = 'ccl-container';
@@ -33,7 +33,12 @@ const CclListingCards = (props) => {
33
33
  <div className={containerClass}>
34
34
  {items && items.length > 0
35
35
  ? items.map((item, index) => (
36
- <CclCard key={index} type={variation} card={item} />
36
+ <CclCard
37
+ key={index}
38
+ type={variation}
39
+ card={item}
40
+ showEditor={user?.roles?.includes('Manager')}
41
+ />
37
42
  ))
38
43
  : 'There are no items to display'}
39
44
  </div>
@@ -10,19 +10,26 @@ import configureStore from 'redux-mock-store';
10
10
  Enzyme.configure({ adapter: new Adapter() });
11
11
 
12
12
  const mockStore = configureStore();
13
+ const store = mockStore({
14
+ content: {
15
+ create: {},
16
+ data: {},
17
+ },
18
+ intl: {
19
+ locale: 'en',
20
+ messages: {},
21
+ },
22
+ users: {
23
+ user: {
24
+ roles: ['Manager'],
25
+ },
26
+ },
27
+ });
28
+ const internalLink = [{ '@id': '/news' }];
29
+ const externalLink = [{ '@id': 'https://wwww.google.com' }];
13
30
 
14
31
  describe('CclListingCards', () => {
15
32
  it('News listing card internal link', () => {
16
- const store = mockStore({
17
- content: {
18
- create: {},
19
- data: {},
20
- },
21
- intl: {
22
- locale: 'en',
23
- messages: {},
24
- },
25
- });
26
33
  const items = [
27
34
  {
28
35
  title: 'Card Title',
@@ -33,7 +40,6 @@ describe('CclListingCards', () => {
33
40
  },
34
41
  },
35
42
  ];
36
- const linkHref = [{ '@id': '/news' }];
37
43
  const linkTitle = 'More news';
38
44
  const isEditMode = true;
39
45
  const variation = 'CclCardsnews';
@@ -42,7 +48,7 @@ describe('CclListingCards', () => {
42
48
  <MemoryRouter>
43
49
  <CclListingCards
44
50
  items={items}
45
- linkHref={linkHref}
51
+ linkHref={internalLink}
46
52
  linkTitle={linkTitle}
47
53
  isEditMode={isEditMode}
48
54
  variation={variation}
@@ -53,16 +59,6 @@ describe('CclListingCards', () => {
53
59
  expect(component).toBeDefined();
54
60
  });
55
61
  it('Line-color listing card external link', () => {
56
- const store = mockStore({
57
- content: {
58
- create: {},
59
- data: {},
60
- },
61
- intl: {
62
- locale: 'en',
63
- messages: {},
64
- },
65
- });
66
62
  const items = [
67
63
  {
68
64
  title: 'Card Title',
@@ -73,7 +69,6 @@ describe('CclListingCards', () => {
73
69
  },
74
70
  },
75
71
  ];
76
- const linkHref = [{ '@id': 'https://wwww.google.com' }];
77
72
  const linkTitle = 'More line-color';
78
73
  const isEditMode = true;
79
74
  const variation = 'CclCardsline-color';
@@ -82,7 +77,7 @@ describe('CclListingCards', () => {
82
77
  <MemoryRouter>
83
78
  <CclListingCards
84
79
  items={items}
85
- linkHref={linkHref}
80
+ linkHref={externalLink}
86
81
  linkTitle={linkTitle}
87
82
  isEditMode={isEditMode}
88
83
  variation={variation}
@@ -93,16 +88,6 @@ describe('CclListingCards', () => {
93
88
  expect(component).toBeDefined();
94
89
  });
95
90
  it('line listing card external link', () => {
96
- const store = mockStore({
97
- content: {
98
- create: {},
99
- data: {},
100
- },
101
- intl: {
102
- locale: 'en',
103
- messages: {},
104
- },
105
- });
106
91
  const items = [
107
92
  {
108
93
  title: 'Card Title',
@@ -113,7 +98,6 @@ describe('CclListingCards', () => {
113
98
  },
114
99
  },
115
100
  ];
116
- const linkHref = [{ '@id': 'https://wwww.google.com' }];
117
101
  const linkTitle = 'More line';
118
102
  const isEditMode = true;
119
103
  const variation = 'CclCardsline';
@@ -122,7 +106,7 @@ describe('CclListingCards', () => {
122
106
  <MemoryRouter>
123
107
  <CclListingCards
124
108
  items={items}
125
- linkHref={linkHref}
109
+ linkHref={externalLink}
126
110
  linkTitle={linkTitle}
127
111
  isEditMode={isEditMode}
128
112
  variation={variation}
@@ -133,16 +117,6 @@ describe('CclListingCards', () => {
133
117
  expect(component).toBeDefined();
134
118
  });
135
119
  it('without linkHref', () => {
136
- const store = mockStore({
137
- content: {
138
- create: {},
139
- data: {},
140
- },
141
- intl: {
142
- locale: 'en',
143
- messages: {},
144
- },
145
- });
146
120
  const items = [
147
121
  {
148
122
  title: 'Card Title',
@@ -169,16 +143,6 @@ describe('CclListingCards', () => {
169
143
  expect(component).toBeDefined();
170
144
  });
171
145
  it('internal link without linkTitle', () => {
172
- const store = mockStore({
173
- content: {
174
- create: {},
175
- data: {},
176
- },
177
- intl: {
178
- locale: 'en',
179
- messages: {},
180
- },
181
- });
182
146
  const items = [
183
147
  {
184
148
  title: 'Card Title',
@@ -189,7 +153,6 @@ describe('CclListingCards', () => {
189
153
  },
190
154
  },
191
155
  ];
192
- const linkHref = [{ '@id': '/news' }];
193
156
  const isEditMode = true;
194
157
  const variation = 'CclCardsnews';
195
158
  const component = mount(
@@ -197,7 +160,7 @@ describe('CclListingCards', () => {
197
160
  <MemoryRouter>
198
161
  <CclListingCards
199
162
  items={items}
200
- linkHref={linkHref}
163
+ linkHref={internalLink}
201
164
  isEditMode={isEditMode}
202
165
  variation={variation}
203
166
  ></CclListingCards>
@@ -207,16 +170,6 @@ describe('CclListingCards', () => {
207
170
  expect(component).toBeDefined();
208
171
  });
209
172
  it('External link without linkTitle', () => {
210
- const store = mockStore({
211
- content: {
212
- create: {},
213
- data: {},
214
- },
215
- intl: {
216
- locale: 'en',
217
- messages: {},
218
- },
219
- });
220
173
  const items = [
221
174
  {
222
175
  title: 'Card Title',
@@ -227,7 +180,6 @@ describe('CclListingCards', () => {
227
180
  },
228
181
  },
229
182
  ];
230
- const linkHref = [{ '@id': 'https://www.google.com' }];
231
183
  const isEditMode = true;
232
184
  const variation = 'CclCardsnews';
233
185
  const component = mount(
@@ -235,7 +187,7 @@ describe('CclListingCards', () => {
235
187
  <MemoryRouter>
236
188
  <CclListingCards
237
189
  items={items}
238
- linkHref={linkHref}
190
+ linkHref={externalLink}
239
191
  isEditMode={isEditMode}
240
192
  variation={variation}
241
193
  ></CclListingCards>
@@ -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,
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect } from 'react';
2
2
 
3
3
  import CclButton from '@eeacms/volto-clms-theme/components/CclButton/CclButton';
4
- import { getBreadcrumbs } from '../../../../../../node_modules/@plone/volto/src/actions';
4
+ import { getBreadcrumbs } from '@plone/volto/actions';
5
5
  import { useDispatch } from 'react-redux';
6
6
  import { Label } from 'semantic-ui-react';
7
7
 
@@ -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';
@@ -9,15 +7,57 @@ import React from 'react';
9
7
  import { When } from '@plone/volto/components/theme/View/EventDatesInfo';
10
8
  import { Label } from 'semantic-ui-react';
11
9
  import { portal_types_labels } from '../Blocks/CustomTemplates/VoltoSearchBlock';
10
+ import penSVG from '@plone/volto/icons/pen.svg';
11
+ import { Icon } from '@plone/volto/components';
12
12
 
13
- function bytesToSize(bytes) {
14
- var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
15
- if (bytes === 0) return '0 Byte';
16
- var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
17
- return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
18
- }
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
+ };
19
59
  function CclCard(props) {
20
- const { type, children, card } = props;
60
+ const { type, children, card, showEditor = false } = props;
21
61
  let url = '/';
22
62
  let content_type = '';
23
63
  if (card) {
@@ -38,43 +78,27 @@ function CclCard(props) {
38
78
  >
39
79
  {conditional_types.includes(type) ? (
40
80
  <>
41
- {(type === 'doc' || type === 'globalSearch') && (
81
+ {type === 'doc' && (
42
82
  <>
43
- {type === 'globalSearch' && (
44
- <Label ribbon="right" color="olive">
45
- {content_type}
46
- </Label>
47
- )}
48
- <div className="card-doc-title">
49
- {card?.file?.download ? (
50
- <a href={card.file.download}>{card?.title}</a>
51
- ) : (
52
- card?.title
53
- )}
54
- </div>
55
- <div className="card-doc-text">
56
- <div className="doc-description">{card?.description}</div>
57
- {card?.file && (
58
- <div className="card-doc-size">
59
- {mime.extension(card?.file?.['content-type']).toUpperCase()}{' '}
60
- {bytesToSize(card?.file?.size) || ''}
61
- </div>
62
- )}
83
+ <DocCard card={card} url={url} showEditor={showEditor}>
63
84
  {children}
64
- </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>
65
96
  </>
66
97
  )}
67
98
  {(type === 'block' || type === 'threeColumns') && (
68
99
  <>
69
100
  <div className={`card-${type}-image`}>
70
- <img
71
- src={
72
- card?.image?.scales?.preview?.download ||
73
- card?.image?.download ||
74
- 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg'
75
- }
76
- alt={card?.image?.alt || 'Placeholder'}
77
- />
101
+ <CardImage card={card} size={'preview'} />
78
102
  </div>
79
103
  <div className="card-text">
80
104
  <div className="card-title">
@@ -88,21 +112,14 @@ function CclCard(props) {
88
112
  {type === 'news' && (
89
113
  <>
90
114
  <div className="card-news-image">
91
- <img
92
- src={
93
- card?.image?.scales?.mini?.download ||
94
- card?.image?.download ||
95
- 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg'
96
- }
97
- alt={card?.image?.alt || 'Placeholder'}
98
- />
115
+ <CardImage card={card} size={'mini'} />
99
116
  </div>
100
117
  <div className="card-news-text">
101
118
  <div className="card-news-title">
102
119
  <Link to={url}>{card?.title || 'Card default title'}</Link>
103
120
  </div>
104
121
  <div className="card-news-date">
105
- {new Date(card?.effective).toLocaleDateString()}
122
+ {new Date(card?.effective).toLocaleString()}
106
123
  </div>
107
124
  <p className="card-news-description">{card?.description}</p>
108
125
  </div>
@@ -117,19 +134,11 @@ function CclCard(props) {
117
134
  <div className="card-event-when">
118
135
  <FontAwesomeIcon icon={['far', 'calendar-alt']} />
119
136
  <div className="card-event-when-text">
120
- {card.whole_day ? (
121
- <When
122
- start={card.start}
123
- end={card.start}
124
- whole_day={card.whole_day}
125
- />
126
- ) : (
127
- <When
128
- start={card.start}
129
- end={card.end}
130
- whole_day={card.whole_day}
131
- />
132
- )}
137
+ <When
138
+ start={card.start}
139
+ end={card.whole_day ? card.start : card.end}
140
+ whole_day={card.whole_day}
141
+ />
133
142
  </div>
134
143
  </div>
135
144
  {card?.location ? (
@@ -152,14 +161,7 @@ function CclCard(props) {
152
161
  ) : (
153
162
  <>
154
163
  <div className="card-image">
155
- <img
156
- src={
157
- card?.image?.scales?.mini?.download ||
158
- card?.image?.download ||
159
- 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg'
160
- }
161
- alt={card?.image?.alt || 'Placeholder'}
162
- />
164
+ <CardImage card={card} size={'mini'} />
163
165
  </div>
164
166
  <div className={'card-text'}>
165
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,