@eeacms/volto-eea-website-policy 0.3.2 → 0.4.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.
package/CHANGELOG.md CHANGED
@@ -4,106 +4,89 @@ 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
- #### [0.3.2](https://github.com/eea/volto-eea-website-policy/compare/0.3.1...0.3.2)
7
+ ### [0.3.3](https://github.com/eea/volto-eea-website-policy/compare/0.3.2...0.3.3) - 5 September 2022
8
8
 
9
- - Safely get data - refs #153018 [`aefc689`](https://github.com/eea/volto-eea-website-policy/commit/aefc68979f6aad86ea02952f82e639dfe8c566f2)
10
- - Customize Blocks helper - copy unchanged from @plone/volto 16.alpha.12 [`368ffa8`](https://github.com/eea/volto-eea-website-policy/commit/368ffa8c9ebfc54d364d7bf13b60f4016f1c90e8)
9
+ #### :hammer_and_wrench: Others
11
10
 
12
- #### [0.3.1](https://github.com/eea/volto-eea-website-policy/compare/0.3.0...0.3.1)
11
+ - override(ContentTypeLayout): Enable volto.blocks.editable.layout - refs #153858 [Alin Voinea - [`a07d3f5`](https://github.com/eea/volto-eea-website-policy/commit/a07d3f5f175925fdcd600e3c99620b4c0f42cb69)]
12
+ - override(ContentTypeLayout) - from @plone/volto 16 alpha 12 [Alin Voinea - [`777068d`](https://github.com/eea/volto-eea-website-policy/commit/777068d4b41d4c94863e2c34ea274f150ead7875)]
13
+ ### [0.3.2](https://github.com/eea/volto-eea-website-policy/compare/0.3.1...0.3.2) - 10 August 2022
13
14
 
14
- > 1 August 2022
15
+ #### :hammer_and_wrench: Others
15
16
 
16
- - feature(navigation): addde context navigation block [`#14`](https://github.com/eea/volto-eea-website-policy/pull/14)
17
+ - Safely get data - refs #153018 [Alin Voinea - [`aefc689`](https://github.com/eea/volto-eea-website-policy/commit/aefc68979f6aad86ea02952f82e639dfe8c566f2)]
18
+ - Customize Blocks helper - copy unchanged from @plone/volto 16.alpha.12 [Alin Voinea - [`368ffa8`](https://github.com/eea/volto-eea-website-policy/commit/368ffa8c9ebfc54d364d7bf13b60f4016f1c90e8)]
19
+ ### [0.3.1](https://github.com/eea/volto-eea-website-policy/compare/0.3.0...0.3.1) - 1 August 2022
17
20
 
18
- #### [0.3.0](https://github.com/eea/volto-eea-website-policy/compare/0.2.6...0.3.0)
21
+ ### [0.3.0](https://github.com/eea/volto-eea-website-policy/compare/0.2.6...0.3.0) - 6 July 2022
19
22
 
20
- > 6 July 2022
23
+ #### :nail_care: Enhancements
21
24
 
22
- - change(teaser): enabled theming for icon and text color [`#13`](https://github.com/eea/volto-eea-website-policy/pull/13)
23
- - change(package): bump release version [`1b00439`](https://github.com/eea/volto-eea-website-policy/commit/1b0043933442bb73c1042dce644a2c09e5f210f4)
24
- - change(item): enable theming for icon and text color and added tertiary option [`58c2d28`](https://github.com/eea/volto-eea-website-policy/commit/58c2d2864fe94c9e7808064b61d3b6c4e6fccbb1)
25
- - change(item): commented sizes too small for item icons and enabled tertiary theme [`0f02d7d`](https://github.com/eea/volto-eea-website-policy/commit/0f02d7d6204b068b78c3f977a561782a19b6f79e)
25
+ - change(package): bump release version [David Ichim - [`1b00439`](https://github.com/eea/volto-eea-website-policy/commit/1b0043933442bb73c1042dce644a2c09e5f210f4)]
26
+ - change(item): enable theming for icon and text color and added tertiary option [David Ichim - [`58c2d28`](https://github.com/eea/volto-eea-website-policy/commit/58c2d2864fe94c9e7808064b61d3b6c4e6fccbb1)]
27
+ - change(item): commented sizes too small for item icons and enabled tertiary theme [David Ichim - [`0f02d7d`](https://github.com/eea/volto-eea-website-policy/commit/0f02d7d6204b068b78c3f977a561782a19b6f79e)]
26
28
 
27
- #### [0.2.6](https://github.com/eea/volto-eea-website-policy/compare/0.2.5...0.2.6)
29
+ ### [0.2.6](https://github.com/eea/volto-eea-website-policy/compare/0.2.5...0.2.6) - 1 July 2022
28
30
 
29
- > 1 July 2022
31
+ #### :hammer_and_wrench: Others
30
32
 
31
- - Fix Cannot read properties of undefined (reading 'translations') [`8e7b8b8`](https://github.com/eea/volto-eea-website-policy/commit/8e7b8b8533b14f173d77783fe2d0b517c29c5937)
32
- - Customize Toolbar.jsx - copied unchanged from @plone/volto 16.0.0.alpha.11 [`b7add4f`](https://github.com/eea/volto-eea-website-policy/commit/b7add4faa8ef2dde7d77489fc8bc431cbb023314)
33
+ - Fix Cannot read properties of undefined (reading 'translations') [Alin Voinea - [`8e7b8b8`](https://github.com/eea/volto-eea-website-policy/commit/8e7b8b8533b14f173d77783fe2d0b517c29c5937)]
34
+ - Customize Toolbar.jsx - copied unchanged from @plone/volto 16.0.0.alpha.11 [Alin Voinea - [`b7add4f`](https://github.com/eea/volto-eea-website-policy/commit/b7add4faa8ef2dde7d77489fc8bc431cbb023314)]
35
+ ### [0.2.5](https://github.com/eea/volto-eea-website-policy/compare/0.2.4...0.2.5) - 23 June 2022
33
36
 
34
- #### [0.2.5](https://github.com/eea/volto-eea-website-policy/compare/0.2.4...0.2.5)
37
+ #### :hammer_and_wrench: Others
35
38
 
36
- > 23 June 2022
39
+ - Rounded card via style wrapper [Alin Voinea - [`6728684`](https://github.com/eea/volto-eea-website-policy/commit/67286844b00902aa4c6b316b50be35db95c531f0)]
40
+ - Revert "Rounded Card variation - refs #148723" [Alin Voinea - [`0168a86`](https://github.com/eea/volto-eea-website-policy/commit/0168a86fa644a9b848e37c7f5054eb4308c36784)]
41
+ - Disable Image Cards block [Alin Voinea - [`3ed8dc3`](https://github.com/eea/volto-eea-website-policy/commit/3ed8dc311cad8e30a8c918ecec7b21cc99260c50)]
42
+ - Rounded Card variation - refs #148723 [Alin Voinea - [`4b46731`](https://github.com/eea/volto-eea-website-policy/commit/4b46731e25962bbb6e7159d0db8a9a642a95eb53)]
43
+ ### [0.2.4](https://github.com/eea/volto-eea-website-policy/compare/0.2.3...0.2.4) - 13 June 2022
37
44
 
38
- - Rounded Card variation and disable ImageCards block [`#11`](https://github.com/eea/volto-eea-website-policy/pull/11)
39
- - Rounded card via style wrapper [`6728684`](https://github.com/eea/volto-eea-website-policy/commit/67286844b00902aa4c6b316b50be35db95c531f0)
40
- - Revert "Rounded Card variation - refs #148723" [`0168a86`](https://github.com/eea/volto-eea-website-policy/commit/0168a86fa644a9b848e37c7f5054eb4308c36784)
41
- - Disable Image Cards block [`3ed8dc3`](https://github.com/eea/volto-eea-website-policy/commit/3ed8dc311cad8e30a8c918ecec7b21cc99260c50)
42
- - Rounded Card variation - refs #148723 [`4b46731`](https://github.com/eea/volto-eea-website-policy/commit/4b46731e25962bbb6e7159d0db8a9a642a95eb53)
45
+ #### :hammer_and_wrench: Others
43
46
 
44
- #### [0.2.4](https://github.com/eea/volto-eea-website-policy/compare/0.2.3...0.2.4)
47
+ - Fix listing block title: Listing (Content) [Alin Voinea - [`cec2760`](https://github.com/eea/volto-eea-website-policy/commit/cec276082c3fc1b5486c996c3746a6958fb3a1a9)]
48
+ - Add theme to teaser stylewrapper [Alin Voinea - [`60eeb28`](https://github.com/eea/volto-eea-website-policy/commit/60eeb28b7793708c59d0af73ffb09895e8f2c87d)]
49
+ - Fix className vs class warning [Alin Voinea - [`fea1603`](https://github.com/eea/volto-eea-website-policy/commit/fea1603eefd628d57640a6b94ddbbb7edfb0d841)]
50
+ - Custom card view for teaser [Alin Voinea - [`c8eded0`](https://github.com/eea/volto-eea-website-policy/commit/c8eded011b8317cce9f842526f5d86771f54797b)]
51
+ ### [0.2.3](https://github.com/eea/volto-eea-website-policy/compare/0.2.2...0.2.3) - 10 June 2022
45
52
 
46
- > 13 June 2022
53
+ #### :hammer_and_wrench: Others
47
54
 
48
- - Release [`#10`](https://github.com/eea/volto-eea-website-policy/pull/10)
49
- - Fix listing block title: Listing (Content) [`cec2760`](https://github.com/eea/volto-eea-website-policy/commit/cec276082c3fc1b5486c996c3746a6958fb3a1a9)
50
- - Add theme to teaser stylewrapper [`60eeb28`](https://github.com/eea/volto-eea-website-policy/commit/60eeb28b7793708c59d0af73ffb09895e8f2c87d)
51
- - Fix className vs class warning [`fea1603`](https://github.com/eea/volto-eea-website-policy/commit/fea1603eefd628d57640a6b94ddbbb7edfb0d841)
52
- - Custom card view for teaser [`c8eded0`](https://github.com/eea/volto-eea-website-policy/commit/c8eded011b8317cce9f842526f5d86771f54797b)
55
+ - prettier fix [David Ichim - [`c2a6d2d`](https://github.com/eea/volto-eea-website-policy/commit/c2a6d2d3b12ce771b9b4413c5a6db157ccd9d1fc)]
56
+ - Update index.js [ichim-david - [`fb73895`](https://github.com/eea/volto-eea-website-policy/commit/fb7389509bc7e207942762c5e02a93d0168a6fba)]
57
+ - removed change from commit 719e3778 [ichim-david - [`29e636b`](https://github.com/eea/volto-eea-website-policy/commit/29e636b34ab02992c67cc5960f4dc6b21b1b4e71)]
58
+ - added navDepth to level 4 in order to fill mega menu [ichim-david - [`719e377`](https://github.com/eea/volto-eea-website-policy/commit/719e37785cfa2ed37568c82a34dc470b52483d04)]
59
+ - Rearrange Block Chooser [Alin Voinea - [`9a5c118`](https://github.com/eea/volto-eea-website-policy/commit/9a5c1187ba21fa1898394a4b6cf6dd68bd68f258)]
60
+ - Move Item block un components folder [Miu Razvan - [`9fb6ab2`](https://github.com/eea/volto-eea-website-policy/commit/9fb6ab2fb02cc5c1a7e25367de5ebe7109bd3dc4)]
61
+ - Set default sizes for image & icon in Item block [Miu Razvan - [`af22ec7`](https://github.com/eea/volto-eea-website-policy/commit/af22ec78b2c6fd1d033dc1acfec5e64f8926cd77)]
62
+ - Add helpers functions [Miu Razvan - [`353581c`](https://github.com/eea/volto-eea-website-policy/commit/353581cc6602b5e573eee93c74a67656203c0968)]
63
+ - Add Teaser block folder's structure [Alin Voinea - [`9457dd4`](https://github.com/eea/volto-eea-website-policy/commit/9457dd4ffaa2631eceb46bfd1ec2d201e8b3d7a8)]
64
+ ### [0.2.2](https://github.com/eea/volto-eea-website-policy/compare/0.2.1...0.2.2) - 24 May 2022
53
65
 
54
- #### [0.2.3](https://github.com/eea/volto-eea-website-policy/compare/0.2.2...0.2.3)
66
+ ### [0.2.1](https://github.com/eea/volto-eea-website-policy/compare/0.2.0...0.2.1) - 25 March 2022
55
67
 
56
- > 10 June 2022
68
+ ### [0.2.0](https://github.com/eea/volto-eea-website-policy/compare/0.1.1...0.2.0) - 18 March 2022
57
69
 
58
- - Add Item block [`#9`](https://github.com/eea/volto-eea-website-policy/pull/9)
59
- - prettier fix [`c2a6d2d`](https://github.com/eea/volto-eea-website-policy/commit/c2a6d2d3b12ce771b9b4413c5a6db157ccd9d1fc)
60
- - Update index.js [`fb73895`](https://github.com/eea/volto-eea-website-policy/commit/fb7389509bc7e207942762c5e02a93d0168a6fba)
61
- - removed change from commit 719e3778 [`29e636b`](https://github.com/eea/volto-eea-website-policy/commit/29e636b34ab02992c67cc5960f4dc6b21b1b4e71)
62
- - added navDepth to level 4 in order to fill mega menu [`719e377`](https://github.com/eea/volto-eea-website-policy/commit/719e37785cfa2ed37568c82a34dc470b52483d04)
63
- - Rearrange Block Chooser [`9a5c118`](https://github.com/eea/volto-eea-website-policy/commit/9a5c1187ba21fa1898394a4b6cf6dd68bd68f258)
64
- - Move Item block un components folder [`9fb6ab2`](https://github.com/eea/volto-eea-website-policy/commit/9fb6ab2fb02cc5c1a7e25367de5ebe7109bd3dc4)
65
- - Set default sizes for image & icon in Item block [`af22ec7`](https://github.com/eea/volto-eea-website-policy/commit/af22ec78b2c6fd1d033dc1acfec5e64f8926cd77)
66
- - Add helpers functions [`353581c`](https://github.com/eea/volto-eea-website-policy/commit/353581cc6602b5e573eee93c74a67656203c0968)
67
- - Add Teaser block folder's structure [`9457dd4`](https://github.com/eea/volto-eea-website-policy/commit/9457dd4ffaa2631eceb46bfd1ec2d201e8b3d7a8)
70
+ #### :hammer_and_wrench: Others
68
71
 
69
- #### [0.2.2](https://github.com/eea/volto-eea-website-policy/compare/0.2.1...0.2.2)
72
+ - Release 0.2.0 [Alin Voinea - [`4b72206`](https://github.com/eea/volto-eea-website-policy/commit/4b72206675ab13ed81567df590849613581d7f10)]
73
+ - Update index.js [Alexandru Ghica - [`0f5be15`](https://github.com/eea/volto-eea-website-policy/commit/0f5be1553b608f49c9a61bbc69a0f90219260a83)]
74
+ - Update index.js [Alexandru Ghica - [`03dd3b1`](https://github.com/eea/volto-eea-website-policy/commit/03dd3b162d3175df00048339bed4f9a7d097a896)]
75
+ - format index.js [Andrei Grigore - [`db4481a`](https://github.com/eea/volto-eea-website-policy/commit/db4481aeeba59a769272659f33278c902fc69bec)]
76
+ - Update index.js [Alexandru Ghica - [`dc09886`](https://github.com/eea/volto-eea-website-policy/commit/dc0988640a76a9914381b120f58bb61a9ab1eb39)]
77
+ - Added externalRoutes [Alexandru Ghica - [`b68135b`](https://github.com/eea/volto-eea-website-policy/commit/b68135b013fafa93a41ea602ea2fad30879abe0f)]
78
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`575cca6`](https://github.com/eea/volto-eea-website-policy/commit/575cca674602ca2e1c2a41300c47ba594ff49aa0)]
79
+ ### [0.1.1](https://github.com/eea/volto-eea-website-policy/compare/0.1.0...0.1.1) - 4 March 2022
70
80
 
71
- > 24 May 2022
81
+ #### :hammer_and_wrench: Others
72
82
 
73
- - Install callout and remove blockquote - refs #148688 [`#8`](https://github.com/eea/volto-eea-website-policy/pull/8)
83
+ - Enable description block by default [Alin Voinea - [`b3d6534`](https://github.com/eea/volto-eea-website-policy/commit/b3d6534a57f7288899c4f59b5cec553370363d8b)]
84
+ - Prepare for first release [Alin Voinea - [`69e36b1`](https://github.com/eea/volto-eea-website-policy/commit/69e36b1c82b75b0917ef3d433581c50cdcf6c341)]
85
+ - Enable working copy support [Alin Voinea - [`7c6269d`](https://github.com/eea/volto-eea-website-policy/commit/7c6269d75df915f39c15e8ed0893cc062601e7a7)]
86
+ - Enable multilingual [Alin Voinea - [`73210b9`](https://github.com/eea/volto-eea-website-policy/commit/73210b90ad968909da0c15583992f8f58e99e632)]
87
+ ### 0.1.0 - 4 March 2022
74
88
 
75
- #### [0.2.1](https://github.com/eea/volto-eea-website-policy/compare/0.2.0...0.2.1)
89
+ #### :hammer_and_wrench: Others
76
90
 
77
- > 25 March 2022
78
-
79
- - 137187 keycloak integration for plone6 (#3) [`#6`](https://github.com/eea/volto-eea-website-policy/pull/6)
80
- - 137187 keycloak integration for plone6 [`#3`](https://github.com/eea/volto-eea-website-policy/pull/3)
81
-
82
- #### [0.2.0](https://github.com/eea/volto-eea-website-policy/compare/0.1.1...0.2.0)
83
-
84
- > 18 March 2022
85
-
86
- - Release [`#5`](https://github.com/eea/volto-eea-website-policy/pull/5)
87
- - Enable multilingual - refs #146771 [`#4`](https://github.com/eea/volto-eea-website-policy/pull/4)
88
- - Release 0.2.0 [`4b72206`](https://github.com/eea/volto-eea-website-policy/commit/4b72206675ab13ed81567df590849613581d7f10)
89
- - Update index.js [`0f5be15`](https://github.com/eea/volto-eea-website-policy/commit/0f5be1553b608f49c9a61bbc69a0f90219260a83)
90
- - Update index.js [`03dd3b1`](https://github.com/eea/volto-eea-website-policy/commit/03dd3b162d3175df00048339bed4f9a7d097a896)
91
- - format index.js [`db4481a`](https://github.com/eea/volto-eea-website-policy/commit/db4481aeeba59a769272659f33278c902fc69bec)
92
- - Update index.js [`dc09886`](https://github.com/eea/volto-eea-website-policy/commit/dc0988640a76a9914381b120f58bb61a9ab1eb39)
93
- - Added externalRoutes [`b68135b`](https://github.com/eea/volto-eea-website-policy/commit/b68135b013fafa93a41ea602ea2fad30879abe0f)
94
-
95
- #### [0.1.1](https://github.com/eea/volto-eea-website-policy/compare/0.1.0...0.1.1)
96
-
97
- > 4 March 2022
98
-
99
- - Release [`#1`](https://github.com/eea/volto-eea-website-policy/pull/1)
100
- - Enable description block by default [`b3d6534`](https://github.com/eea/volto-eea-website-policy/commit/b3d6534a57f7288899c4f59b5cec553370363d8b)
101
- - Prepare for first release [`69e36b1`](https://github.com/eea/volto-eea-website-policy/commit/69e36b1c82b75b0917ef3d433581c50cdcf6c341)
102
- - Enable working copy support [`7c6269d`](https://github.com/eea/volto-eea-website-policy/commit/7c6269d75df915f39c15e8ed0893cc062601e7a7)
103
- - Enable multilingual [`73210b9`](https://github.com/eea/volto-eea-website-policy/commit/73210b90ad968909da0c15583992f8f58e99e632)
104
-
105
- #### 0.1.0
106
-
107
- > 4 March 2022
108
-
109
- - Initial commit [`3800692`](https://github.com/eea/volto-eea-website-policy/commit/3800692f7a4de6460815bd6061facacb986cbef0)
91
+ - yarn bootstrap [Alin Voinea - [`9b4d197`](https://github.com/eea/volto-eea-website-policy/commit/9b4d197cbc7992566cb36524d190078d5ad21a44)]
92
+ - Initial commit [Alin Voinea - [`3800692`](https://github.com/eea/volto-eea-website-policy/commit/3800692f7a4de6460815bd6061facacb986cbef0)]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-website-policy",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "@eeacms/volto-eea-website-policy: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -0,0 +1,520 @@
1
+ /**
2
+ * Content Type component.
3
+ * @module components/manage/Controlpanels/ContentTypeLayout
4
+ */
5
+
6
+ import React, { Component } from 'react';
7
+ import PropTypes from 'prop-types';
8
+ import { connect } from 'react-redux';
9
+ import { compose } from 'redux';
10
+ import { Link } from 'react-router-dom';
11
+ import {
12
+ getParentUrl,
13
+ hasBlocksData,
14
+ getBlocksFieldname,
15
+ getBlocksLayoutFieldname,
16
+ } from '@plone/volto/helpers';
17
+ import { Portal } from 'react-portal';
18
+ import { Button, Segment } from 'semantic-ui-react';
19
+ import { toast } from 'react-toastify';
20
+ import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
21
+ import { nth, join } from 'lodash';
22
+ import {
23
+ Error,
24
+ Form,
25
+ Icon,
26
+ Toolbar,
27
+ Sidebar,
28
+ Toast,
29
+ } from '@plone/volto/components';
30
+ import {
31
+ getSchema,
32
+ updateSchema,
33
+ getControlpanel,
34
+ updateControlpanel,
35
+ } from '@plone/volto/actions';
36
+
37
+ import saveSVG from '@plone/volto/icons/save.svg';
38
+ import clearSVG from '@plone/volto/icons/clear.svg';
39
+ import backSVG from '@plone/volto/icons/back.svg';
40
+
41
+ const messages = defineMessages({
42
+ changesSaved: {
43
+ id: 'Changes saved.',
44
+ defaultMessage: 'Changes saved.',
45
+ },
46
+ back: {
47
+ id: 'Back',
48
+ defaultMessage: 'Back',
49
+ },
50
+ save: {
51
+ id: 'Save',
52
+ defaultMessage: 'Save',
53
+ },
54
+ cancel: {
55
+ id: 'Cancel',
56
+ defaultMessage: 'Cancel',
57
+ },
58
+ info: {
59
+ id: 'Info',
60
+ defaultMessage: 'Info',
61
+ },
62
+ enable: {
63
+ id: 'Enable editable Blocks',
64
+ defaultMessage: 'Enable editable Blocks',
65
+ },
66
+ });
67
+
68
+ /**
69
+ * ContentTypeLayout class.
70
+ * @class ContentTypeLayout
71
+ * @extends Component
72
+ */
73
+ class ContentTypeLayout extends Component {
74
+ /**
75
+ * Property types.
76
+ * @property {Object} propTypes Property types.
77
+ * @static
78
+ */
79
+ static propTypes = {
80
+ updateControlpanel: PropTypes.func.isRequired,
81
+ getControlpanel: PropTypes.func.isRequired,
82
+ getSchema: PropTypes.func.isRequired,
83
+ updateSchema: PropTypes.func.isRequired,
84
+ id: PropTypes.string.isRequired,
85
+ parent: PropTypes.string.isRequired,
86
+ pathname: PropTypes.string.isRequired,
87
+ schemaRequest: PropTypes.objectOf(PropTypes.any).isRequired,
88
+ cpanelRequest: PropTypes.objectOf(PropTypes.any).isRequired,
89
+ schema: PropTypes.objectOf(PropTypes.any),
90
+ controlpanel: PropTypes.shape({
91
+ '@id': PropTypes.string,
92
+ data: PropTypes.object,
93
+ schema: PropTypes.object,
94
+ title: PropTypes.string,
95
+ }),
96
+ };
97
+
98
+ /**
99
+ * Default properties.
100
+ * @property {Object} defaultProps Default properties.
101
+ * @static
102
+ */
103
+ static defaultProps = {
104
+ schema: {},
105
+ controlpanel: null,
106
+ };
107
+
108
+ /**
109
+ * Constructor
110
+ * @method constructor
111
+ * @param {Object} props Component properties
112
+ * @constructs ContentTypeLayout
113
+ */
114
+ constructor(props) {
115
+ super(props);
116
+
117
+ this.state = {
118
+ visual: false,
119
+ content: null,
120
+ readOnlyBehavior: null,
121
+ error: null,
122
+ isClient: false,
123
+ };
124
+
125
+ this.onCancel = this.onCancel.bind(this);
126
+ this.onSubmit = this.onSubmit.bind(this);
127
+ this.onEnableBlocks = this.onEnableBlocks.bind(this);
128
+ this.onEnableBlocksBehavior = this.onEnableBlocksBehavior.bind(this);
129
+ this.onDisableBlocksBehavior = this.onDisableBlocksBehavior.bind(this);
130
+ this.form = React.createRef();
131
+ }
132
+
133
+ /**
134
+ * Component did mount
135
+ * @method componentDidMount
136
+ * @returns {undefined}
137
+ */
138
+ componentDidMount() {
139
+ this.props.getControlpanel(join([this.props.parent, this.props.id], '/'));
140
+ this.props.getSchema(this.props.id);
141
+ this.setState({ isClient: true });
142
+ }
143
+
144
+ /**
145
+ * Component will receive props
146
+ * @method componentWillReceiveProps
147
+ * @param {Object} nextProps Next properties
148
+ * @returns {undefined}
149
+ */
150
+ UNSAFE_componentWillReceiveProps(nextProps) {
151
+ // Control Panel GET
152
+ if (
153
+ this.props.cpanelRequest.get.loading &&
154
+ nextProps.cpanelRequest.get.error
155
+ ) {
156
+ this.setState({
157
+ error: nextProps.cpanelRequest.get.error,
158
+ });
159
+ }
160
+
161
+ // Schema GET
162
+ if (this.props.schemaRequest.loading && nextProps.schemaRequest.loaded) {
163
+ const properties = nextProps.schema?.properties || {};
164
+ const content = {};
165
+ for (const key in properties) {
166
+ const value = properties[key].default;
167
+ if (value) {
168
+ content[key] = value;
169
+ }
170
+ }
171
+
172
+ if (hasBlocksData(properties)) {
173
+ this.setState({
174
+ visual: true,
175
+ });
176
+
177
+ const blocksFieldName = getBlocksFieldname(properties);
178
+ const blocksLayoutFieldname = getBlocksLayoutFieldname(properties);
179
+ content[blocksFieldName] = properties[blocksFieldName]?.default || {};
180
+ content[blocksLayoutFieldname] = properties[blocksLayoutFieldname]
181
+ ?.default || { items: [] };
182
+
183
+ const blocksBehavior = properties[blocksFieldName]?.behavior || '';
184
+ this.setState({
185
+ readOnlyBehavior: !blocksBehavior.includes('generated')
186
+ ? blocksBehavior
187
+ : '',
188
+ });
189
+ } else {
190
+ this.setState({
191
+ visual: false,
192
+ readOnlyBehavior: '',
193
+ });
194
+ }
195
+
196
+ this.setState({
197
+ content: content,
198
+ });
199
+ }
200
+
201
+ // Schema updated
202
+ if (
203
+ this.props.schemaRequest.update.loading &&
204
+ nextProps.schemaRequest.update.loaded
205
+ ) {
206
+ this.props.getSchema(this.props.id);
207
+ toast.info(
208
+ <Toast
209
+ info
210
+ title={this.props.intl.formatMessage(messages.info)}
211
+ content={this.props.intl.formatMessage(messages.changesSaved)}
212
+ />,
213
+ );
214
+ }
215
+
216
+ // Blocks behavior disabled
217
+ if (
218
+ this.props.cpanelRequest.update.loading &&
219
+ nextProps.cpanelRequest.update.loaded
220
+ ) {
221
+ this.onEnableBlocks();
222
+ }
223
+ }
224
+
225
+ /**
226
+ * Submit handler
227
+ * @method onSubmit
228
+ * @param {object} data Form data.
229
+ * @returns {undefined}
230
+ */
231
+ onSubmit(data) {
232
+ const schema = { properties: {} };
233
+ Object.keys(data)
234
+ .filter((k) => data[k])
235
+ .forEach((k) => (schema.properties[k] = { default: data[k] }));
236
+ this.props.updateSchema(this.props.id, schema);
237
+ }
238
+
239
+ /**
240
+ * Cancel handler
241
+ * @method onCancel
242
+ * @returns {undefined}
243
+ */
244
+ onCancel() {
245
+ const url = getParentUrl(this.props.pathname);
246
+ this.props.history.push(getParentUrl(url));
247
+ }
248
+
249
+ /**
250
+ * Enable blocks handler
251
+ * @method onEnableBlocks
252
+ * @returns {undefined}
253
+ */
254
+ onEnableBlocks() {
255
+ const { properties = {} } = this.props.schema;
256
+ const blocksFieldName = getBlocksFieldname(properties);
257
+ const blocksLayoutFieldname = getBlocksLayoutFieldname(properties);
258
+ const schema = {
259
+ fieldsets: [
260
+ {
261
+ id: 'layout',
262
+ title: 'Layout',
263
+ fields: ['blocks', 'blocks_layout'],
264
+ },
265
+ ],
266
+ properties: {
267
+ blocks: {
268
+ title: 'Blocks',
269
+ type: 'dict',
270
+ widget: 'json',
271
+ factory: 'JSONField',
272
+ default: properties[blocksFieldName]?.default || {},
273
+ },
274
+ blocks_layout: {
275
+ title: 'Blocks Layout',
276
+ type: 'dict',
277
+ widget: 'json',
278
+ factory: 'JSONField',
279
+ default: properties[blocksLayoutFieldname]?.default || { items: [] },
280
+ },
281
+ },
282
+ };
283
+ this.props.updateSchema(this.props.id, schema);
284
+ }
285
+
286
+ /**
287
+ * Disable Blocks behavior handler
288
+ * @method onDisableBlocksBehavior
289
+ * @returns {undefined}
290
+ */
291
+ onDisableBlocksBehavior() {
292
+ this.props.updateControlpanel(this.props.controlpanel['@id'], {
293
+ [this.state.readOnlyBehavior]: false,
294
+ 'volto.blocks.editable.layout': true,
295
+ });
296
+ }
297
+
298
+ /**
299
+ * Enable Blocks behavior handler
300
+ * @method onEnableBlocksBehavior
301
+ * @returns {undefined}
302
+ */
303
+ onEnableBlocksBehavior() {
304
+ this.props.updateControlpanel(this.props.controlpanel['@id'], {
305
+ 'volto.blocks.editable.layout': true,
306
+ });
307
+ }
308
+
309
+ /**
310
+ * Render method.
311
+ * @method render
312
+ * @returns {string} Markup for the component.
313
+ */
314
+ render() {
315
+ // Error
316
+ if (this.state.error) {
317
+ return <Error error={this.state.error} />;
318
+ }
319
+
320
+ if (!this.state.visual) {
321
+ // Still loading
322
+ if (!this.state.content) {
323
+ return <div />;
324
+ }
325
+
326
+ // Blocks are not enabled
327
+ return (
328
+ <>
329
+ <Segment
330
+ placeholder
331
+ id="page-controlpanel-layout"
332
+ className="ui container center aligned"
333
+ >
334
+ <div>
335
+ <FormattedMessage
336
+ id="Can not edit Layout for <strong>{type}</strong> content-type as it doesn't have support for <strong>Volto Blocks</strong> enabled"
337
+ defaultMessage="Can not edit Layout for <strong>{type}</strong> content-type as it doesn't have support for <strong>Volto Blocks</strong> enabled"
338
+ values={{
339
+ strong: (...chunks) => <strong>{chunks}</strong>,
340
+ type: this.props?.controlpanel?.title || this.props.id,
341
+ }}
342
+ />
343
+ </div>
344
+ <div className="ui divider"></div>
345
+ <Button
346
+ primary
347
+ onClick={this.onEnableBlocksBehavior}
348
+ content={this.props.intl.formatMessage(messages.enable)}
349
+ />
350
+ </Segment>
351
+ <Portal
352
+ node={this.state.isClient && document.getElementById('toolbar')}
353
+ >
354
+ <Toolbar
355
+ pathname={this.props.pathname}
356
+ hideDefaultViewButtons
357
+ inner={
358
+ <>
359
+ <Link className="item" to="#" onClick={() => this.onCancel()}>
360
+ <Icon
361
+ name={backSVG}
362
+ size="30px"
363
+ className="contents circled"
364
+ title={this.props.intl.formatMessage(messages.back)}
365
+ />
366
+ </Link>
367
+ </>
368
+ }
369
+ />
370
+ </Portal>
371
+ </>
372
+ );
373
+ }
374
+
375
+ if (this.state.readOnlyBehavior) {
376
+ return (
377
+ <>
378
+ <Segment
379
+ placeholder
380
+ id="page-controlpanel-layout"
381
+ className="ui container center aligned"
382
+ >
383
+ <div>
384
+ <FormattedMessage
385
+ id="Can not edit Layout for <strong>{type}</strong> content-type as the <strong>Blocks behavior</strong> is enabled and <strong>read-only</strong>"
386
+ defaultMessage="Can not edit Layout for <strong>{type}</strong> content-type as the <strong>Blocks behavior</strong> is enabled and <strong>read-only</strong>"
387
+ values={{
388
+ strong: (...chunks) => <strong>{chunks}</strong>,
389
+ type: this.props?.controlpanel?.title || this.props.id,
390
+ }}
391
+ />
392
+ </div>
393
+ <div className="ui divider"></div>
394
+ <Button
395
+ primary
396
+ onClick={this.onDisableBlocksBehavior}
397
+ content={this.props.intl.formatMessage(messages.enable)}
398
+ />
399
+ </Segment>
400
+ <Portal
401
+ node={this.state.isClient && document.getElementById('toolbar')}
402
+ >
403
+ <Toolbar
404
+ pathname={this.props.pathname}
405
+ hideDefaultViewButtons
406
+ inner={
407
+ <>
408
+ <Link className="item" to="#" onClick={() => this.onCancel()}>
409
+ <Icon
410
+ name={backSVG}
411
+ size="30px"
412
+ className="contents circled"
413
+ title={this.props.intl.formatMessage(messages.back)}
414
+ />
415
+ </Link>
416
+ </>
417
+ }
418
+ />
419
+ </Portal>
420
+ </>
421
+ );
422
+ }
423
+
424
+ // Render layout editor
425
+ const blocksFieldName = getBlocksFieldname(
426
+ this.props.schema?.properties || {},
427
+ );
428
+ const blocksLayoutFieldname = getBlocksLayoutFieldname(
429
+ this.props.schema?.properties || {},
430
+ );
431
+ return (
432
+ <div id="page-controlpanel-layout">
433
+ <Form
434
+ isAdminForm
435
+ ref={this.form}
436
+ schema={{
437
+ fieldsets: [
438
+ {
439
+ id: 'layout',
440
+ title: 'Layout',
441
+ fields: [blocksFieldName, blocksLayoutFieldname],
442
+ },
443
+ ],
444
+ properties: {
445
+ ...this.props.schema.properties[blocksFieldName],
446
+ ...this.props.schema.properties[blocksLayoutFieldname],
447
+ },
448
+ required: [],
449
+ }}
450
+ formData={this.state.content}
451
+ onSubmit={this.onSubmit}
452
+ onCancel={this.onCancel}
453
+ pathname={this.props.pathname}
454
+ visual={this.state.visual}
455
+ hideActions
456
+ />
457
+ <Portal
458
+ node={this.state.isClient && document.getElementById('sidebar')}
459
+ >
460
+ <Sidebar settingsTab={true} documentTab={false} />
461
+ </Portal>
462
+ <Portal
463
+ node={this.state.isClient && document.getElementById('toolbar')}
464
+ >
465
+ <Toolbar
466
+ pathname={this.props.pathname}
467
+ hideDefaultViewButtons
468
+ inner={
469
+ <>
470
+ <Button
471
+ id="toolbar-save"
472
+ className="save"
473
+ aria-label={this.props.intl.formatMessage(messages.save)}
474
+ onClick={() => this.form.current.onSubmit()}
475
+ disabled={this.props.schemaRequest.update.loading}
476
+ loading={this.props.schemaRequest.update.loading}
477
+ >
478
+ <Icon
479
+ name={saveSVG}
480
+ className="circled"
481
+ size="30px"
482
+ title={this.props.intl.formatMessage(messages.save)}
483
+ />
484
+ </Button>
485
+ <Button
486
+ className="cancel"
487
+ aria-label={this.props.intl.formatMessage(messages.cancel)}
488
+ onClick={() => this.onCancel()}
489
+ >
490
+ <Icon
491
+ name={clearSVG}
492
+ className="circled"
493
+ size="30px"
494
+ title={this.props.intl.formatMessage(messages.cancel)}
495
+ />
496
+ </Button>
497
+ </>
498
+ }
499
+ />
500
+ </Portal>
501
+ </div>
502
+ );
503
+ }
504
+ }
505
+
506
+ export default compose(
507
+ injectIntl,
508
+ connect(
509
+ (state, props) => ({
510
+ schema: state.schema.schema,
511
+ schemaRequest: state.schema,
512
+ cpanelRequest: state.controlpanels,
513
+ controlpanel: state.controlpanels.controlpanel,
514
+ pathname: props.location.pathname,
515
+ id: nth(props.location.pathname.split('/'), -2),
516
+ parent: nth(props.location.pathname.split('/'), -3),
517
+ }),
518
+ { getSchema, updateSchema, getControlpanel, updateControlpanel },
519
+ ),
520
+ )(ContentTypeLayout);
package/src/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  import { runtimeConfig } from '@plone/volto/runtime_config';
2
2
  import installCallout from 'volto-slate/editor/plugins/Callout';
3
- import installItemBlock from '@eeacms/volto-eea-website-policy/components/Blocks/Item';
4
- import customizeTeaserBlock from '@eeacms/volto-eea-website-policy/components/Blocks/Teaser';
5
3
  import installContextNavigationBlock from '@eeacms/volto-eea-website-policy/components/Blocks/ContextNavigation';
6
4
 
7
5
  const applyConfig = (config) => {
@@ -100,12 +98,10 @@ const applyConfig = (config) => {
100
98
  }
101
99
 
102
100
  // Custom blocks
103
- config = [
104
- installItemBlock,
105
- installContextNavigationBlock,
106
- customizeTeaserBlock,
107
- ].reduce((acc, apply) => apply(acc), config);
108
- config.blocks.blocksConfig.item.mostUsed = true;
101
+ config = [installContextNavigationBlock].reduce(
102
+ (acc, apply) => apply(acc),
103
+ config,
104
+ );
109
105
 
110
106
  // Disable some blocks
111
107
  if (config.blocks.blocksConfig.imagecards) {
@@ -1,98 +0,0 @@
1
- import React from 'react';
2
- import { connect } from 'react-redux';
3
- import config from '@plone/volto/registry';
4
- import { BlockDataForm, SidebarPortal } from '@plone/volto/components';
5
- import SlateEditor from 'volto-slate/editor/SlateEditor';
6
- import { handleKey } from 'volto-slate/blocks/Text/keyboard';
7
- import { uploadContent, saveSlateBlockSelection } from 'volto-slate/actions';
8
-
9
- import { createSlateParagraph } from '@eeacms/volto-eea-website-policy/helpers';
10
-
11
- import Item from './Item';
12
- import getSchema from './schema';
13
-
14
- const Edit = (props) => {
15
- const { slate } = config.settings;
16
- const {
17
- data = {},
18
- block = null,
19
- selected = false,
20
- index,
21
- properties,
22
- onChangeBlock,
23
- onSelectBlock,
24
- } = props;
25
- const { description } = data;
26
- const schema = React.useMemo(() => getSchema(props), [props]);
27
-
28
- const withBlockProperties = React.useCallback(
29
- (editor) => {
30
- editor.getBlockProps = () => props;
31
- return editor;
32
- },
33
- [props],
34
- );
35
-
36
- const handleFocus = React.useCallback(() => {
37
- if (!selected) {
38
- onSelectBlock(block);
39
- }
40
- }, [onSelectBlock, selected, block]);
41
-
42
- return (
43
- <>
44
- <Item {...data} mode="edit">
45
- <SlateEditor
46
- index={index}
47
- properties={properties}
48
- extensions={slate.textblockExtensions}
49
- renderExtensions={[withBlockProperties]}
50
- value={createSlateParagraph(description)}
51
- onChange={(description) => {
52
- onChangeBlock(block, {
53
- ...data,
54
- description,
55
- });
56
- }}
57
- block={block}
58
- onFocus={handleFocus}
59
- onKeyDown={handleKey}
60
- selected={selected}
61
- placeholder="Add item description..."
62
- slateSettings={slate}
63
- />
64
- </Item>
65
- <SidebarPortal selected={selected}>
66
- <BlockDataForm
67
- block={block}
68
- schema={schema}
69
- title={schema.title}
70
- onChangeField={(id, value) => {
71
- onChangeBlock(block, {
72
- ...data,
73
- [id]: value,
74
- });
75
- }}
76
- formData={data}
77
- />
78
- </SidebarPortal>
79
- </>
80
- );
81
- };
82
-
83
- export default connect(
84
- (state, props) => {
85
- const blockId = props.block;
86
- return {
87
- defaultSelection: blockId
88
- ? state.slate_block_selections?.[blockId]
89
- : null,
90
- uploadRequest: state.upload_content?.[props.block]?.upload || {},
91
- uploadedContent: state.upload_content?.[props.block]?.data || {},
92
- };
93
- },
94
- {
95
- uploadContent,
96
- saveSlateBlockSelection, // needed as editor blockProps
97
- },
98
- )(Edit);
@@ -1,50 +0,0 @@
1
- import cx from 'classnames';
2
- import { Item as UiItem, Icon } from 'semantic-ui-react';
3
- import { serializeText } from '@eeacms/volto-eea-website-policy/helpers';
4
-
5
- function Item({
6
- assetType,
7
- children,
8
- description,
9
- extra,
10
- header,
11
- icon,
12
- iconSize = 'huge',
13
- iconTheme,
14
- image,
15
- imageSize = 'tile',
16
- meta,
17
- mode = 'view',
18
- styles = {},
19
- }) {
20
- const { verticalAlign } = styles;
21
- return (
22
- <UiItem.Group unstackable className="row">
23
- <UiItem className={cx(styles?.theme)}>
24
- {assetType === 'image' && image && (
25
- <UiItem.Image
26
- src={`${image}/@@images/image/preview`}
27
- className={cx('ui', imageSize)}
28
- alt={header || 'Item image'}
29
- />
30
- )}
31
- {assetType === 'icon' && icon && (
32
- <Icon className={cx(icon, iconTheme)} size={iconSize} />
33
- )}
34
- <UiItem.Content verticalAlign={verticalAlign}>
35
- {header && <UiItem.Header>{header}</UiItem.Header>}
36
- {meta && <UiItem.Meta>{meta}</UiItem.Meta>}
37
- {description && mode === 'view' && (
38
- <UiItem.Description>
39
- {serializeText(description)}
40
- </UiItem.Description>
41
- )}
42
- {mode === 'edit' && children}
43
- {extra && <UiItem.Extra>{extra}</UiItem.Extra>}
44
- </UiItem.Content>
45
- </UiItem>
46
- </UiItem.Group>
47
- );
48
- }
49
-
50
- export default Item;
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import Item from './Item';
3
-
4
- const View = (props) => {
5
- const { data = {} } = props;
6
- return <Item {...data} />;
7
- };
8
-
9
- export default View;
@@ -1,32 +0,0 @@
1
- import codeSVG from '@plone/volto/icons/code.svg';
2
- import ItemEdit from './Edit';
3
- import ItemView from './View';
4
- import { stylingSchema } from './schema';
5
-
6
- export default (config) => {
7
- config.blocks.blocksConfig.item = {
8
- id: 'item',
9
- title: 'Item',
10
- icon: codeSVG,
11
- group: 'common',
12
- edit: ItemEdit,
13
- view: ItemView,
14
- blockHasOwnFocusManagement: true,
15
- stylesSchema: stylingSchema,
16
- enableStyling: true,
17
- restricted: false,
18
- mostUsed: false,
19
- sidebarTab: 1,
20
- security: {
21
- addPermission: [],
22
- view: [],
23
- },
24
- };
25
-
26
- config.settings.blocksWithFootnotesSupport = {
27
- ...(config.settings.blocksWithFootnotesSupport || {}),
28
- item: ['description'],
29
- };
30
-
31
- return config;
32
- };
@@ -1,110 +0,0 @@
1
- export default ({ data }) => {
2
- const { assetType = 'image' } = data;
3
- return {
4
- title: 'Item',
5
- fieldsets: [
6
- {
7
- id: 'default',
8
- title: 'Default',
9
- fields: ['assetType'],
10
- },
11
- ...(assetType === 'image'
12
- ? [{ id: 'image', title: 'Image', fields: ['image', 'imageSize'] }]
13
- : []),
14
- ...(assetType === 'icon'
15
- ? [
16
- {
17
- id: 'icon',
18
- title: 'Icon',
19
- fields: ['icon', 'iconSize', 'iconTheme'],
20
- },
21
- ]
22
- : []),
23
- ],
24
- properties: {
25
- assetType: {
26
- title: 'Asset type',
27
- choices: [
28
- ['image', 'Image'],
29
- ['icon', 'Icon'],
30
- ],
31
- default: 'image',
32
- },
33
- image: {
34
- title: 'Image',
35
- widget: 'attachedimage',
36
- },
37
- imageSize: {
38
- title: 'Image size',
39
- choices: [
40
- // commented as they were too small to use as item icons
41
- // ['mini', 'Mini'],
42
- // ['tile', 'Tile'],
43
- // ['tiny', 'Tiny'],
44
- // ['small', 'Small'],
45
- ['large', 'Large'],
46
- ['big', 'Big'],
47
- ['huge', 'Huge'],
48
- ['massive', 'Massive'],
49
- ],
50
- default: 'tile',
51
- },
52
- icon: {
53
- title: 'Icon name',
54
- },
55
- iconSize: {
56
- title: 'Icon size',
57
- choices: [
58
- ['mini', 'Mini'],
59
- ['tiny', 'Tiny'],
60
- ['small', 'Small'],
61
- ['large', 'Large'],
62
- ['big', 'Big'],
63
- ['huge', 'Huge'],
64
- ['massive', 'Massive'],
65
- ],
66
- default: 'huge',
67
- },
68
- iconTheme: {
69
- title: 'Icon theme',
70
- choices: [
71
- ['primary', 'Primary'],
72
- ['secondary', 'Secondary'],
73
- ['tertiary', 'Tertiary'],
74
- ],
75
- },
76
- },
77
- required: [],
78
- };
79
- };
80
-
81
- export const stylingSchema = ({ intl }) => ({
82
- title: 'Item style',
83
- block: 'item',
84
- fieldsets: [
85
- {
86
- id: 'default',
87
- title: 'Default',
88
- fields: ['theme', 'verticalAlign'],
89
- },
90
- ],
91
- properties: {
92
- theme: {
93
- title: 'Theme',
94
- choices: [
95
- ['primary', 'Primary'],
96
- ['secondary', 'Secondary'],
97
- ['tertiary', 'Tertiary'],
98
- ],
99
- },
100
- verticalAlign: {
101
- title: 'Vertical align',
102
- choices: [
103
- ['top', 'Top'],
104
- ['middle', 'Middle'],
105
- ['bottom', 'Bottom'],
106
- ],
107
- },
108
- },
109
- required: [],
110
- });
@@ -1,79 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { Message } from 'semantic-ui-react';
4
- import { defineMessages, useIntl } from 'react-intl';
5
- import imageBlockSVG from '@plone/volto/components/manage/Blocks/Image/block-image.svg';
6
- import { flattenToAppURL } from '@plone/volto/helpers';
7
- import { getTeaserImageURL } from './utils';
8
- import { MaybeWrap } from '@plone/volto/components';
9
- import { UniversalLink } from '@plone/volto/components';
10
- import cx from 'classnames';
11
-
12
- const messages = defineMessages({
13
- PleaseChooseContent: {
14
- id: 'Please choose an existing content as source for this element',
15
- defaultMessage:
16
- 'Please choose an existing content as source for this element',
17
- },
18
- });
19
-
20
- const TeaserCardTemplate = (props) => {
21
- const { data, isEditMode } = props;
22
- const intl = useIntl();
23
- const href = data.href?.[0];
24
- const image = data.preview_image?.[0];
25
-
26
- return (
27
- <>
28
- {!href && isEditMode && (
29
- <Message>
30
- <div className="grid-teaser-item placeholder">
31
- <img src={imageBlockSVG} alt="" />
32
- <p>{intl.formatMessage(messages.PleaseChooseContent)}</p>
33
- </div>
34
- </Message>
35
- )}
36
- {href && (
37
- <MaybeWrap
38
- condition={!isEditMode}
39
- as={UniversalLink}
40
- href={href['@id']}
41
- target={data.openLinkInNewTab ? '_blank' : null}
42
- >
43
- <div
44
- className={cx(
45
- 'ui fluid card',
46
- data?.styles?.theme,
47
- data?.styles?.rounded ? 'rounded big' : '',
48
- )}
49
- >
50
- {(href.hasPreviewImage || href.image_field || image) && (
51
- <div className="image">
52
- <img
53
- src={flattenToAppURL(getTeaserImageURL(href, image))}
54
- alt="a"
55
- />
56
- </div>
57
- )}
58
- <div className="content">
59
- {data?.head_title && (
60
- <div className="meta">{data?.head_title}</div>
61
- )}
62
- <div className="header">{data?.title}</div>
63
- {!data.hide_description && (
64
- <p className="description">{data?.description}</p>
65
- )}
66
- </div>
67
- </div>
68
- </MaybeWrap>
69
- )}
70
- </>
71
- );
72
- };
73
-
74
- TeaserCardTemplate.propTypes = {
75
- data: PropTypes.objectOf(PropTypes.any).isRequired,
76
- isEditMode: PropTypes.bool,
77
- };
78
-
79
- export default TeaserCardTemplate;
@@ -1,70 +0,0 @@
1
- import { defineMessages } from 'react-intl';
2
-
3
- const messages = defineMessages({
4
- Type: {
5
- id: 'Teaser',
6
- defaultMessage: 'Teaser',
7
- },
8
- Theme: {
9
- id: 'Theme',
10
- defaultMessage: 'Theme',
11
- },
12
- ThemeHelp: {
13
- id: 'Theme',
14
- defaultMessage: 'Theme',
15
- },
16
- ThemeDefault: {
17
- id: 'Default',
18
- defaultMessage: 'Default',
19
- },
20
- ThemePrimary: {
21
- id: 'Primary',
22
- defaultMessage: 'Primary',
23
- },
24
- ThemeSecondary: {
25
- id: 'Secondary',
26
- defaultMessage: 'Secondary',
27
- },
28
- ThemeTertiary: {
29
- id: 'Tertiary',
30
- defaultMessage: 'Tertiary',
31
- },
32
- Rounded: {
33
- id: 'Rounded',
34
- defaultMessage: 'Rounded',
35
- },
36
- RoundedHelp: {
37
- id: 'Rounded Image',
38
- defaultMessage: 'Rounded Image',
39
- },
40
- });
41
-
42
- export const StylingSchema = ({ intl }) => ({
43
- title: intl.formatMessage(messages.Type),
44
- block: 'teaserGrid',
45
- fieldsets: [
46
- {
47
- id: 'default',
48
- title: 'Default',
49
- fields: ['theme', 'rounded'],
50
- },
51
- ],
52
- properties: {
53
- theme: {
54
- title: intl.formatMessage(messages.Theme),
55
- description: intl.formatMessage(messages.ThemeHelp),
56
- choices: [
57
- ['', intl.formatMessage(messages.ThemeDefault)],
58
- ['primary', intl.formatMessage(messages.ThemePrimary)],
59
- ['secondary', intl.formatMessage(messages.ThemeSecondary)],
60
- ['tertiary', intl.formatMessage(messages.ThemeTertiary)],
61
- ],
62
- },
63
- rounded: {
64
- title: intl.formatMessage(messages.Rounded),
65
- description: intl.formatMessage(messages.RoundedHelp),
66
- type: 'boolean',
67
- },
68
- },
69
- required: [],
70
- });
@@ -1,26 +0,0 @@
1
- import TeaserCardTemplate from './Card';
2
- import { StylingSchema } from './Schema';
3
-
4
- export default (config) => {
5
- // Teaser
6
- if (config.blocks.blocksConfig.teaser) {
7
- config.blocks.blocksConfig.teaser.variations = [
8
- ...(config.blocks.blocksConfig.teaser.variations || []),
9
- {
10
- id: 'card',
11
- isDefault: true,
12
- title: 'Card (top image)',
13
- template: TeaserCardTemplate,
14
- },
15
- ];
16
- config.blocks.blocksConfig.teaser.enableStyling = true;
17
- config.blocks.blocksConfig.teaser.stylesSchema = StylingSchema;
18
- }
19
-
20
- // Teaser Grid
21
- if (config.blocks.blocksConfig.teaserGrid) {
22
- config.blocks.blocksConfig.teaserGrid.title = 'Teaser (Cards)';
23
- }
24
-
25
- return config;
26
- };
@@ -1,18 +0,0 @@
1
- import { isInternalURL } from '@plone/volto/helpers';
2
- import config from '@plone/volto/registry';
3
-
4
- export function getTeaserImageURL(href, image) {
5
- const imageScale =
6
- config.blocks.blocksConfig['teaser'].imageScale || 'preview';
7
- if (image) {
8
- if (isInternalURL(image['@id'])) {
9
- return `${image['@id']}/@@images/image/${imageScale}`;
10
- } else {
11
- return image['@id'];
12
- }
13
- } else {
14
- return `${href['@id']}/@@images/${
15
- href.image_field || 'preview_image'
16
- }/${imageScale}`;
17
- }
18
- }