@eeacms/volto-bise-policy 1.0.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/.coverage.babel.config.js +9 -0
- package/.i18n.babel.config.js +1 -0
- package/.project.eslintrc.js +47 -0
- package/.release-it.json +17 -0
- package/CHANGELOG.md +27 -0
- package/DEVELOP.md +53 -0
- package/LICENSE.md +9 -0
- package/README.md +84 -0
- package/RELEASE.md +74 -0
- package/babel.config.js +17 -0
- package/bootstrap +41 -0
- package/cypress.config.js +27 -0
- package/jest-addon.config.js +36 -0
- package/locales/bg/LC_MESSAGES/volto.po +14 -0
- package/locales/bg.json +1 -0
- package/locales/bs/LC_MESSAGES/volto.po +14 -0
- package/locales/bs.json +1 -0
- package/locales/cs/LC_MESSAGES/volto.po +14 -0
- package/locales/cs.json +1 -0
- package/locales/da/LC_MESSAGES/volto.po +14 -0
- package/locales/da.json +1 -0
- package/locales/de/LC_MESSAGES/volto.po +29 -0
- package/locales/de.json +1 -0
- package/locales/el/LC_MESSAGES/volto.po +14 -0
- package/locales/el.json +1 -0
- package/locales/en/LC_MESSAGES/volto.po +14 -0
- package/locales/en.json +1 -0
- package/locales/es/LC_MESSAGES/volto.po +24 -0
- package/locales/es.json +1 -0
- package/locales/et/LC_MESSAGES/volto.po +14 -0
- package/locales/et.json +1 -0
- package/locales/eu/LC_MESSAGES/volto.po +19 -0
- package/locales/eu.json +1 -0
- package/locales/fi/LC_MESSAGES/volto.po +14 -0
- package/locales/fi.json +1 -0
- package/locales/fr/LC_MESSAGES/volto.po +29 -0
- package/locales/fr.json +1 -0
- package/locales/ga/LC_MESSAGES/volto.po +14 -0
- package/locales/ga.json +1 -0
- package/locales/hr/LC_MESSAGES/volto.po +14 -0
- package/locales/hr.json +1 -0
- package/locales/hu/LC_MESSAGES/volto.po +14 -0
- package/locales/hu.json +1 -0
- package/locales/is/LC_MESSAGES/volto.po +14 -0
- package/locales/is.json +1 -0
- package/locales/it/LC_MESSAGES/volto.po +14 -0
- package/locales/it.json +1 -0
- package/locales/ja/LC_MESSAGES/volto.po +21 -0
- package/locales/ja.json +1 -0
- package/locales/lt/LC_MESSAGES/volto.po +14 -0
- package/locales/lt.json +1 -0
- package/locales/lv/LC_MESSAGES/volto.po +14 -0
- package/locales/lv.json +1 -0
- package/locales/mk/LC_MESSAGES/volto.po +14 -0
- package/locales/mk.json +1 -0
- package/locales/mt/LC_MESSAGES/volto.po +14 -0
- package/locales/mt.json +1 -0
- package/locales/nl/LC_MESSAGES/volto.po +33 -0
- package/locales/nl.json +1 -0
- package/locales/no/LC_MESSAGES/volto.po +14 -0
- package/locales/no.json +1 -0
- package/locales/pl/LC_MESSAGES/volto.po +14 -0
- package/locales/pl.json +1 -0
- package/locales/pt/LC_MESSAGES/volto.po +22 -0
- package/locales/pt.json +1 -0
- package/locales/pt_BR/LC_MESSAGES/volto.po +20 -0
- package/locales/pt_BR.json +1 -0
- package/locales/ro/LC_MESSAGES/volto.po +20 -0
- package/locales/ro.json +1 -0
- package/locales/sh/LC_MESSAGES/volto.po +14 -0
- package/locales/sh.json +1 -0
- package/locales/sk/LC_MESSAGES/volto.po +14 -0
- package/locales/sk.json +1 -0
- package/locales/sl/LC_MESSAGES/volto.po +14 -0
- package/locales/sl.json +1 -0
- package/locales/sq/LC_MESSAGES/volto.po +14 -0
- package/locales/sq.json +1 -0
- package/locales/sv/LC_MESSAGES/volto.po +14 -0
- package/locales/sv.json +1 -0
- package/locales/tr/LC_MESSAGES/volto.po +14 -0
- package/locales/tr.json +1 -0
- package/locales/volto.pot +16 -0
- package/package.json +57 -0
- package/razzle.extend.js +29 -0
- package/src/components/manage/Blocks/BodyClass/Edit.jsx +30 -0
- package/src/components/manage/Blocks/BodyClass/View.jsx +12 -0
- package/src/components/manage/Blocks/BodyClass/index.js +24 -0
- package/src/components/manage/Blocks/BodyClass/schema.js +20 -0
- package/src/components/manage/Blocks/FactsheetsListing/FactsheetsListingEdit.jsx +32 -0
- package/src/components/manage/Blocks/FactsheetsListing/FactsheetsListingView.jsx +81 -0
- package/src/components/manage/Blocks/FactsheetsListing/index.js +24 -0
- package/src/components/manage/Blocks/FactsheetsListing/schema.js +20 -0
- package/src/components/manage/Blocks/KeyFacts/KeyFactsEdit.jsx +34 -0
- package/src/components/manage/Blocks/KeyFacts/KeyFactsView.jsx +68 -0
- package/src/components/manage/Blocks/KeyFacts/index.js +22 -0
- package/src/components/manage/Blocks/KeyFacts/schema.jsx +74 -0
- package/src/components/manage/Blocks/MaesViewer/MaesViewerEdit.jsx +64 -0
- package/src/components/manage/Blocks/MaesViewer/MaesViewerView.jsx +136 -0
- package/src/components/manage/Blocks/MaesViewer/constants.js +1 -0
- package/src/components/manage/Blocks/MaesViewer/index.js +22 -0
- package/src/components/manage/Blocks/MaesViewer/schema.js +60 -0
- package/src/components/manage/Blocks/MaesViewer/style.css +64 -0
- package/src/components/manage/Blocks/MaesViewer/utils.js +473 -0
- package/src/components/manage/Blocks/Navigation/Edit.jsx +27 -0
- package/src/components/manage/Blocks/Navigation/View.jsx +43 -0
- package/src/components/manage/Blocks/Navigation/index.js +22 -0
- package/src/components/manage/Blocks/Navigation/schema.js +43 -0
- package/src/components/manage/Blocks/Navigation/styles.less +42 -0
- package/src/components/manage/Blocks/Redirect/Edit.jsx +29 -0
- package/src/components/manage/Blocks/Redirect/View.jsx +13 -0
- package/src/components/manage/Blocks/Redirect/index.js +24 -0
- package/src/components/manage/Blocks/Redirect/schema.js +20 -0
- package/src/components/manage/Blocks/index.js +17 -0
- package/src/components/manage/Styles/index.js +163 -0
- package/src/customizations/@eeacms/volto-block-style/StyleWrapper/schema.js +206 -0
- package/src/customizations/volto/components/manage/Toolbar/More.jsx +547 -0
- package/src/customizations/volto/components/theme/Footer/Footer.jsx +25 -0
- package/src/customizations/volto/components/theme/Header/Header.jsx +301 -0
- package/src/index.js +77 -0
- package/theme/assets/icons/plus.png +0 -0
- package/theme/assets/icons/plus.svg +6 -0
- package/theme/assets/icons/search.svg +3 -0
- package/theme/assets/images/Header/bise-logo-white.svg +47 -0
- package/theme/assets/images/Header/bise-logo.svg +132 -0
- package/theme/collections/table.variables +17 -0
- package/theme/extras/banner.variables +5 -0
- package/theme/extras/factsheets.less +76 -0
- package/theme/extras/footer.variables +6 -0
- package/theme/extras/header.overrides +30 -0
- package/theme/extras/header.variables +7 -0
- package/theme/extras/hero.overrides +4 -0
- package/theme/extras/inpageNavigation.variables +5 -0
- package/theme/extras/keyfacts.less +202 -0
- package/theme/extras/pluggables.less +191 -0
- package/theme/extras/stylemenu.less +48 -0
- package/theme/extras/tocnav.less +158 -0
- package/theme/globals/site.overrides +78 -0
- package/theme/globals/site.variables +22 -0
- package/theme/theme.config +135 -0
- package/theme/tokens/colors.less +15 -0
- package/theme/tokens/tokens.less +1 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import FactsheetsListingView from './FactsheetsListingView';
|
|
3
|
+
import schema from './schema';
|
|
4
|
+
import { SidebarPortal } from '@plone/volto/components';
|
|
5
|
+
import InlineForm from '@plone/volto/components/manage/Form/InlineForm';
|
|
6
|
+
|
|
7
|
+
class Edit extends Component {
|
|
8
|
+
render() {
|
|
9
|
+
const { selected, block, data, onChangeBlock } = this.props;
|
|
10
|
+
return (
|
|
11
|
+
<>
|
|
12
|
+
<FactsheetsListingView {...this.props} />
|
|
13
|
+
|
|
14
|
+
<SidebarPortal selected={selected}>
|
|
15
|
+
<InlineForm
|
|
16
|
+
schema={schema}
|
|
17
|
+
title={schema.title}
|
|
18
|
+
onChangeField={(id, value) => {
|
|
19
|
+
onChangeBlock(block, {
|
|
20
|
+
...data,
|
|
21
|
+
[id]: value,
|
|
22
|
+
});
|
|
23
|
+
}}
|
|
24
|
+
formData={data}
|
|
25
|
+
/>
|
|
26
|
+
</SidebarPortal>
|
|
27
|
+
</>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default Edit;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Container, Accordion } from 'semantic-ui-react';
|
|
3
|
+
import { Icon } from '@plone/volto/components';
|
|
4
|
+
|
|
5
|
+
import upSVG from '@plone/volto/icons/up-key.svg';
|
|
6
|
+
import downSVG from '@plone/volto/icons/down-key.svg';
|
|
7
|
+
import { Link } from 'react-router-dom';
|
|
8
|
+
import { flattenToAppURL } from '@plone/volto/helpers';
|
|
9
|
+
|
|
10
|
+
const FactsheetsListingView = (props) => {
|
|
11
|
+
const { data, properties, id } = props;
|
|
12
|
+
const sections = [
|
|
13
|
+
{
|
|
14
|
+
'@id': id,
|
|
15
|
+
id,
|
|
16
|
+
title: data.block_title,
|
|
17
|
+
items: properties?.items || [],
|
|
18
|
+
factsheet_group_title: data.block_title,
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
const [activeIndex, setActiveIndex] = React.useState(0);
|
|
22
|
+
|
|
23
|
+
function handleClick(e, titleProps) {
|
|
24
|
+
const { index } = titleProps;
|
|
25
|
+
const newIndex = activeIndex === index ? -1 : index;
|
|
26
|
+
|
|
27
|
+
setActiveIndex(newIndex);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div className="factsheet-view">
|
|
32
|
+
<Container>
|
|
33
|
+
<Accordion fluid styled exclusive={false}>
|
|
34
|
+
{sections.map((section, index) => {
|
|
35
|
+
return (
|
|
36
|
+
<React.Fragment key={section['@id']}>
|
|
37
|
+
<Accordion.Title
|
|
38
|
+
active={activeIndex === index}
|
|
39
|
+
index={index}
|
|
40
|
+
onClick={handleClick}
|
|
41
|
+
>
|
|
42
|
+
<span className="section-title">{section.title}</span>
|
|
43
|
+
<div className="accordion-tools">
|
|
44
|
+
{activeIndex === index ? (
|
|
45
|
+
<Icon name={upSVG} size="40px" color="#f3c715" />
|
|
46
|
+
) : (
|
|
47
|
+
<Icon name={downSVG} size="40px" color="#f3c715" />
|
|
48
|
+
)}
|
|
49
|
+
</div>
|
|
50
|
+
</Accordion.Title>
|
|
51
|
+
<Accordion.Content
|
|
52
|
+
className={section.id}
|
|
53
|
+
active={activeIndex === index}
|
|
54
|
+
>
|
|
55
|
+
<div
|
|
56
|
+
className="fdl-listing-section"
|
|
57
|
+
key={section['@id']}
|
|
58
|
+
style={{ columns: data.cols || 3 }}
|
|
59
|
+
>
|
|
60
|
+
{section.items?.map((item) => (
|
|
61
|
+
<div key={item['@id']}>
|
|
62
|
+
<Link to={flattenToAppURL(item['@id'])}>
|
|
63
|
+
{item.title}
|
|
64
|
+
</Link>
|
|
65
|
+
{section.factsheet_group_title && (
|
|
66
|
+
<div>{item.factsheet_group}</div>
|
|
67
|
+
)}
|
|
68
|
+
</div>
|
|
69
|
+
))}
|
|
70
|
+
</div>
|
|
71
|
+
</Accordion.Content>
|
|
72
|
+
</React.Fragment>
|
|
73
|
+
);
|
|
74
|
+
})}
|
|
75
|
+
</Accordion>
|
|
76
|
+
</Container>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export default FactsheetsListingView;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import codeSVG from '@plone/volto/icons/code.svg';
|
|
2
|
+
import FactsheetsListingView from './FactsheetsListingView';
|
|
3
|
+
import FactsheetsListingEdit from './FactsheetsListingEdit';
|
|
4
|
+
|
|
5
|
+
export default (config) => {
|
|
6
|
+
config.blocks.blocksConfig.biseFactsheetListing = {
|
|
7
|
+
id: 'biseFactsheetListing',
|
|
8
|
+
title: 'Factsheets Listing',
|
|
9
|
+
icon: codeSVG,
|
|
10
|
+
group: 'custom_addons',
|
|
11
|
+
view: FactsheetsListingView,
|
|
12
|
+
edit: FactsheetsListingEdit,
|
|
13
|
+
restricted: false,
|
|
14
|
+
mostUsed: false,
|
|
15
|
+
blockHasOwnFocusManagement: false,
|
|
16
|
+
sidebarTab: 1,
|
|
17
|
+
security: {
|
|
18
|
+
addPermission: [],
|
|
19
|
+
view: [],
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return config;
|
|
24
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const Schema = {
|
|
2
|
+
fieldsets: [
|
|
3
|
+
{
|
|
4
|
+
id: 'default',
|
|
5
|
+
title: 'Default',
|
|
6
|
+
fields: ['block_title', 'cols'],
|
|
7
|
+
},
|
|
8
|
+
],
|
|
9
|
+
properties: {
|
|
10
|
+
block_title: {
|
|
11
|
+
title: 'Title',
|
|
12
|
+
},
|
|
13
|
+
cols: {
|
|
14
|
+
title: 'Number of columns',
|
|
15
|
+
widget: 'number',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
required: [],
|
|
19
|
+
};
|
|
20
|
+
export default Schema;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { connect } from 'react-redux';
|
|
3
|
+
|
|
4
|
+
import { SidebarPortal } from '@plone/volto/components'; // EditBlock
|
|
5
|
+
import InlineForm from '@plone/volto/components/manage/Form/InlineForm';
|
|
6
|
+
|
|
7
|
+
import schema from './schema';
|
|
8
|
+
import KeyFactsView from './KeyFactsView';
|
|
9
|
+
|
|
10
|
+
class Edit extends Component {
|
|
11
|
+
render() {
|
|
12
|
+
return (
|
|
13
|
+
<>
|
|
14
|
+
<KeyFactsView data={this.props.data} />
|
|
15
|
+
|
|
16
|
+
<SidebarPortal selected={this.props.selected}>
|
|
17
|
+
<InlineForm
|
|
18
|
+
schema={schema}
|
|
19
|
+
title={schema.title}
|
|
20
|
+
onChangeField={(id, value) => {
|
|
21
|
+
this.props.onChangeBlock(this.props.block, {
|
|
22
|
+
...this.props.data,
|
|
23
|
+
[id]: value,
|
|
24
|
+
});
|
|
25
|
+
}}
|
|
26
|
+
formData={this.props.data}
|
|
27
|
+
/>
|
|
28
|
+
</SidebarPortal>
|
|
29
|
+
</>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default connect(null, {})(Edit);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import { serializeNodes } from '@plone/volto-slate/editor/render';
|
|
5
|
+
|
|
6
|
+
const View = ({ data }) => {
|
|
7
|
+
const { message, message_link, message_link_text, lines } = data;
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<div
|
|
11
|
+
className={cx(
|
|
12
|
+
'block align keyfacts-block',
|
|
13
|
+
{
|
|
14
|
+
center: !Boolean(data.align),
|
|
15
|
+
},
|
|
16
|
+
data.align,
|
|
17
|
+
)}
|
|
18
|
+
>
|
|
19
|
+
<div
|
|
20
|
+
className={cx({
|
|
21
|
+
'full-width': data.align === 'full',
|
|
22
|
+
})}
|
|
23
|
+
>
|
|
24
|
+
<div className="ui container block-wrapper">
|
|
25
|
+
<div className="title-wrapper">
|
|
26
|
+
<div className="title">
|
|
27
|
+
{message ? (
|
|
28
|
+
<>
|
|
29
|
+
<div className="headline">{message}</div>
|
|
30
|
+
{message_link && (
|
|
31
|
+
<Link className="ui primary button" to={message_link}>
|
|
32
|
+
{message_link_text}
|
|
33
|
+
</Link>
|
|
34
|
+
)}
|
|
35
|
+
</>
|
|
36
|
+
) : (
|
|
37
|
+
''
|
|
38
|
+
)}
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div className="facts-wrapper">
|
|
43
|
+
{(lines || []).map((line, i) => (
|
|
44
|
+
<div className="fact" key={i}>
|
|
45
|
+
{line.upper.data ? (
|
|
46
|
+
<>
|
|
47
|
+
<div
|
|
48
|
+
className="upper"
|
|
49
|
+
dangerouslySetInnerHTML={{ __html: line.upper.data }}
|
|
50
|
+
/>
|
|
51
|
+
<div className="lower">{line.lower}</div>
|
|
52
|
+
</>
|
|
53
|
+
) : (
|
|
54
|
+
<>
|
|
55
|
+
<div className="upper">{serializeNodes(line.upper)}</div>
|
|
56
|
+
<div className="lower">{serializeNodes(line.lower)}</div>
|
|
57
|
+
</>
|
|
58
|
+
)}
|
|
59
|
+
</div>
|
|
60
|
+
))}
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default View;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import codeSVG from '@plone/volto/icons/code.svg';
|
|
2
|
+
import KeyFactsView from './KeyFactsView';
|
|
3
|
+
import KeyFactsEdit from './KeyFactsEdit';
|
|
4
|
+
|
|
5
|
+
export default (config) => {
|
|
6
|
+
config.blocks.blocksConfig.keyfacts = {
|
|
7
|
+
id: 'keyfacts',
|
|
8
|
+
title: 'Key Facts',
|
|
9
|
+
icon: codeSVG,
|
|
10
|
+
group: 'custom_addons',
|
|
11
|
+
view: KeyFactsView,
|
|
12
|
+
edit: KeyFactsEdit,
|
|
13
|
+
restricted: false,
|
|
14
|
+
mostUsed: false,
|
|
15
|
+
sidebarTab: 1,
|
|
16
|
+
security: {
|
|
17
|
+
addPermission: [],
|
|
18
|
+
view: [],
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
return config;
|
|
22
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// import React from 'react';
|
|
2
|
+
|
|
3
|
+
const LineSchema = {
|
|
4
|
+
title: 'Line',
|
|
5
|
+
|
|
6
|
+
fieldsets: [
|
|
7
|
+
{
|
|
8
|
+
id: 'default',
|
|
9
|
+
title: 'Default',
|
|
10
|
+
fields: ['upper', 'lower'],
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
|
|
14
|
+
properties: {
|
|
15
|
+
upper: {
|
|
16
|
+
title: 'Upper text',
|
|
17
|
+
widget: 'slate_richtext',
|
|
18
|
+
},
|
|
19
|
+
lower: {
|
|
20
|
+
title: 'Lower',
|
|
21
|
+
widget: 'slate_richtext',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
required: ['upper', 'lower'],
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const KeyFactsSchema = {
|
|
29
|
+
title: 'KeyFacts',
|
|
30
|
+
|
|
31
|
+
fieldsets: [
|
|
32
|
+
{
|
|
33
|
+
id: 'default',
|
|
34
|
+
title: 'Default',
|
|
35
|
+
fields: [
|
|
36
|
+
'message',
|
|
37
|
+
'message_link_text',
|
|
38
|
+
'message_link',
|
|
39
|
+
'lines',
|
|
40
|
+
'align',
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
|
|
45
|
+
properties: {
|
|
46
|
+
lines: {
|
|
47
|
+
widget: 'object_list',
|
|
48
|
+
title: 'Lines',
|
|
49
|
+
// this is an invention, should confront with dexterity serializer
|
|
50
|
+
schema: LineSchema,
|
|
51
|
+
},
|
|
52
|
+
align: {
|
|
53
|
+
title: 'Alignment',
|
|
54
|
+
widget: 'align',
|
|
55
|
+
type: 'string',
|
|
56
|
+
},
|
|
57
|
+
message: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
title: 'Key message',
|
|
60
|
+
},
|
|
61
|
+
message_link_text: {
|
|
62
|
+
type: 'string',
|
|
63
|
+
title: 'Key message link text',
|
|
64
|
+
},
|
|
65
|
+
message_link: {
|
|
66
|
+
widget: 'object_by_path',
|
|
67
|
+
title: 'Key message link',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
required: ['lines'],
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default KeyFactsSchema;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { compose } from 'redux';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import { SidebarPortal } from '@plone/volto/components'; // EditBlock
|
|
5
|
+
import InlineForm from '@plone/volto/components/manage/Form/InlineForm';
|
|
6
|
+
|
|
7
|
+
import MaesViewerSchema from './schema';
|
|
8
|
+
import { connectToProviderData } from '@eeacms/volto-datablocks/hocs';
|
|
9
|
+
import MaesViewerView from './MaesViewerView';
|
|
10
|
+
import { defaultHoverTemplate } from './constants';
|
|
11
|
+
|
|
12
|
+
class Edit extends Component {
|
|
13
|
+
constructor(props) {
|
|
14
|
+
super(props);
|
|
15
|
+
this.schema = MaesViewerSchema();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getSchema = () => {
|
|
19
|
+
if (!this.props.provider_data) return this.schema;
|
|
20
|
+
const provider_data = this.props.provider_data || {};
|
|
21
|
+
|
|
22
|
+
const select_field = 'Ecosystem_level2';
|
|
23
|
+
const choices = Array.from(
|
|
24
|
+
new Set(provider_data?.[select_field] || []),
|
|
25
|
+
).map((n) => [n, n]);
|
|
26
|
+
|
|
27
|
+
const newSchema = this.schema;
|
|
28
|
+
newSchema.properties.ecosystem.choices = choices;
|
|
29
|
+
|
|
30
|
+
if (this.props.data && !this.props.data.hoverTemplate) {
|
|
31
|
+
this.props.onChangeBlock(this.props.block, {
|
|
32
|
+
...this.props.data,
|
|
33
|
+
hoverTemplate: defaultHoverTemplate,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return newSchema;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
render() {
|
|
41
|
+
const schema = this.getSchema();
|
|
42
|
+
return (
|
|
43
|
+
<div className={cx('block', { selected: this.props.selected })}>
|
|
44
|
+
<MaesViewerView data={this.props.data} />
|
|
45
|
+
|
|
46
|
+
<SidebarPortal selected={this.props.selected}>
|
|
47
|
+
<InlineForm
|
|
48
|
+
schema={schema}
|
|
49
|
+
title={schema.title}
|
|
50
|
+
onChangeField={(id, value) => {
|
|
51
|
+
this.props.onChangeBlock(this.props.block, {
|
|
52
|
+
...this.props.data,
|
|
53
|
+
[id]: value,
|
|
54
|
+
});
|
|
55
|
+
}}
|
|
56
|
+
formData={this.props.data}
|
|
57
|
+
/>
|
|
58
|
+
</SidebarPortal>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default compose(connectToProviderData)(Edit);
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { compose } from 'redux';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import loadable from '@loadable/component';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
customSelectStyles,
|
|
8
|
+
DropdownIndicator,
|
|
9
|
+
Option,
|
|
10
|
+
selectTheme,
|
|
11
|
+
} from '@plone/volto/components/manage/Widgets/SelectStyling';
|
|
12
|
+
|
|
13
|
+
import { serializeNodes } from '@plone/volto-slate/editor/render';
|
|
14
|
+
import { connectToProviderData } from '@eeacms/volto-datablocks/hocs';
|
|
15
|
+
import { makeChartTiles } from './utils';
|
|
16
|
+
|
|
17
|
+
import './style.css';
|
|
18
|
+
|
|
19
|
+
const Select = loadable(() => import('react-select'));
|
|
20
|
+
const LoadablePlot = loadable(() => import('react-plotly.js'));
|
|
21
|
+
|
|
22
|
+
const SelectCountry = (props) => {
|
|
23
|
+
const { id, onChange, data } = props;
|
|
24
|
+
const countries = Array.from(new Set(data['Country_name']));
|
|
25
|
+
const options = countries
|
|
26
|
+
.map((c) => ({ label: c, value: c }))
|
|
27
|
+
.concat({ label: 'EU', value: 'EU' });
|
|
28
|
+
return (
|
|
29
|
+
<Select
|
|
30
|
+
id={`field-${id}`}
|
|
31
|
+
name={id}
|
|
32
|
+
className="react-select-container"
|
|
33
|
+
classNamePrefix="react-select"
|
|
34
|
+
isMulti={id === 'roles' || id === 'groups'}
|
|
35
|
+
options={options}
|
|
36
|
+
styles={customSelectStyles}
|
|
37
|
+
theme={selectTheme}
|
|
38
|
+
components={{ DropdownIndicator, Option }}
|
|
39
|
+
defaultValue={null}
|
|
40
|
+
onChange={onChange}
|
|
41
|
+
placeholder="Select country..."
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const View = ({ data, provider_data, id, ...rest }) => {
|
|
47
|
+
const focusEcosystem = data.ecosystem;
|
|
48
|
+
const [focusOn, setFocusOn] = React.useState();
|
|
49
|
+
const [multiCharts, setMultiCharts] = React.useState([]);
|
|
50
|
+
const [firstRender, setFirstRender] = React.useState(true);
|
|
51
|
+
React.useEffect(() => {
|
|
52
|
+
if (provider_data) {
|
|
53
|
+
const { hoverTemplate } = data;
|
|
54
|
+
const ct = makeChartTiles(provider_data, focusOn, focusEcosystem, {
|
|
55
|
+
hoverTemplate,
|
|
56
|
+
});
|
|
57
|
+
setMultiCharts(ct);
|
|
58
|
+
|
|
59
|
+
// TODO: avoid this hack:
|
|
60
|
+
// hack to make the first-in-time selected country's label appear above
|
|
61
|
+
// the blue disc in the View of the MAES Viewer block
|
|
62
|
+
// (to make sure the hack is not needed anymore, remove this piece of code
|
|
63
|
+
// and if in the View of the page with the MAES Viewer's block the View of
|
|
64
|
+
// the MAES Viewer does not show the text above the black disc when first
|
|
65
|
+
// selecting a country in the CountrySelect, the hack is still needed
|
|
66
|
+
// because plotly.js or react-plotly.js puts the label of the black disc
|
|
67
|
+
// asynchronously and I think there is no Promise to depend on it)
|
|
68
|
+
if (firstRender) {
|
|
69
|
+
setTimeout(() => {
|
|
70
|
+
setFirstRender(false);
|
|
71
|
+
}, 2000);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}, [provider_data, focusOn, focusEcosystem, data, firstRender]);
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<div className={cx('block align', data.align)}>
|
|
78
|
+
<div
|
|
79
|
+
className={cx({
|
|
80
|
+
'full-width': data.align === 'full',
|
|
81
|
+
})}
|
|
82
|
+
>
|
|
83
|
+
<h3>{data.title}</h3>
|
|
84
|
+
{/* <div className="block-wrapper">{JSON.stringify(data)}</div> */}
|
|
85
|
+
|
|
86
|
+
<div className="maes-viewer-grid">
|
|
87
|
+
<div className="maes-viewer-select">
|
|
88
|
+
{provider_data && (
|
|
89
|
+
<>
|
|
90
|
+
<span className="maes-select-label">
|
|
91
|
+
Compare countries across Europe
|
|
92
|
+
</span>
|
|
93
|
+
<SelectCountry
|
|
94
|
+
data={provider_data}
|
|
95
|
+
id={`${id}-select-country`}
|
|
96
|
+
onChange={(data) => {
|
|
97
|
+
setFocusOn(data.value);
|
|
98
|
+
}}
|
|
99
|
+
defaultValue={
|
|
100
|
+
focusOn ? { value: focusOn, label: focusOn } : null
|
|
101
|
+
}
|
|
102
|
+
/>
|
|
103
|
+
</>
|
|
104
|
+
)}
|
|
105
|
+
<div>{serializeNodes(data.description)}</div>
|
|
106
|
+
</div>
|
|
107
|
+
<div className="maes-viewer-charts">
|
|
108
|
+
{provider_data
|
|
109
|
+
? multiCharts.map((chart, index) => {
|
|
110
|
+
return (
|
|
111
|
+
<>
|
|
112
|
+
<div>{chart.title}</div>
|
|
113
|
+
<LoadablePlot
|
|
114
|
+
key={index}
|
|
115
|
+
data={chart.data}
|
|
116
|
+
layout={chart.layout}
|
|
117
|
+
frames={[]}
|
|
118
|
+
config={{
|
|
119
|
+
displayModeBar: false,
|
|
120
|
+
editable: false,
|
|
121
|
+
responsive: true,
|
|
122
|
+
}}
|
|
123
|
+
useResizeHandler={true}
|
|
124
|
+
/>
|
|
125
|
+
</>
|
|
126
|
+
);
|
|
127
|
+
})
|
|
128
|
+
: ''}
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export default compose(connectToProviderData)(View);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const defaultHoverTemplate = '%{country}: %{x:,.02s}m²<extra></extra>';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import codeSVG from '@plone/volto/icons/code.svg';
|
|
2
|
+
import MaesViewerView from './MaesViewerView';
|
|
3
|
+
import MaesViewerEdit from './MaesViewerEdit';
|
|
4
|
+
|
|
5
|
+
export default (config) => {
|
|
6
|
+
config.blocks.blocksConfig.maesviewer = {
|
|
7
|
+
id: 'maesviewer',
|
|
8
|
+
title: 'MAES Viewer',
|
|
9
|
+
icon: codeSVG,
|
|
10
|
+
group: 'custom_addons',
|
|
11
|
+
view: MaesViewerView,
|
|
12
|
+
edit: MaesViewerEdit,
|
|
13
|
+
restricted: false,
|
|
14
|
+
mostUsed: false,
|
|
15
|
+
sidebarTab: 1,
|
|
16
|
+
security: {
|
|
17
|
+
addPermission: [],
|
|
18
|
+
view: [],
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
return config;
|
|
22
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { defaultHoverTemplate } from './constants';
|
|
3
|
+
|
|
4
|
+
const MaesViewerSchema = () => ({
|
|
5
|
+
title: 'Edit MAES Viewer',
|
|
6
|
+
|
|
7
|
+
fieldsets: [
|
|
8
|
+
{
|
|
9
|
+
id: 'default',
|
|
10
|
+
title: 'Default',
|
|
11
|
+
fields: ['title', 'description'],
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
id: 'source',
|
|
15
|
+
title: 'Data source',
|
|
16
|
+
fields: ['provider_url', 'ecosystem', 'hoverTemplate'],
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
|
|
20
|
+
properties: {
|
|
21
|
+
title: {
|
|
22
|
+
title: 'Title',
|
|
23
|
+
widget: 'string',
|
|
24
|
+
},
|
|
25
|
+
description: {
|
|
26
|
+
title: 'Description',
|
|
27
|
+
widget: 'slate_richtext',
|
|
28
|
+
},
|
|
29
|
+
provider_url: {
|
|
30
|
+
widget: 'pick_provider',
|
|
31
|
+
title: 'Data provider',
|
|
32
|
+
},
|
|
33
|
+
ecosystem: {
|
|
34
|
+
title: 'Ecosystem',
|
|
35
|
+
choices: [],
|
|
36
|
+
},
|
|
37
|
+
hoverTemplate: {
|
|
38
|
+
title: 'Hover template',
|
|
39
|
+
description: (
|
|
40
|
+
<div>
|
|
41
|
+
{'You can use %{country}, %{km2} and %{mm2}.'}
|
|
42
|
+
<br />
|
|
43
|
+
See{' '}
|
|
44
|
+
<a
|
|
45
|
+
target="_blank"
|
|
46
|
+
rel="noopener noreferrer"
|
|
47
|
+
href="https://github.com/d3/d3-3.x-api-reference/blob/master/Formatting.md#d3_format"
|
|
48
|
+
>
|
|
49
|
+
D3 format documentation
|
|
50
|
+
</a>
|
|
51
|
+
</div>
|
|
52
|
+
),
|
|
53
|
+
defaultValue: defaultHoverTemplate,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
required: ['provider_url'],
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export default MaesViewerSchema;
|