@eeacms/volto-cca-policy 0.1.50 → 0.1.51

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,6 +4,12 @@ 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.1.51](https://github.com/eea/volto-cca-policy/compare/0.1.50...0.1.51) - 12 December 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Refs #260715 - rast block open current path [Tripon Eugen - [`7125d5d`](https://github.com/eea/volto-cca-policy/commit/7125d5d79a31cba7c0f00929260e2c80e323896b)]
12
+ - Refs #260715 - rast block depend on path [Tripon Eugen - [`1c4950d`](https://github.com/eea/volto-cca-policy/commit/1c4950d3b1a5a9ae255ec59b33b96e6710a3258b)]
7
13
  ### [0.1.50](https://github.com/eea/volto-cca-policy/compare/0.1.49...0.1.50) - 8 December 2023
8
14
 
9
15
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.1.50",
3
+ "version": "0.1.51",
4
4
  "description": "@eeacms/volto-cca-policy: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -1,49 +1,44 @@
1
1
  import React from 'react';
2
2
  import { compose } from 'redux';
3
- import { withRouter } from 'react-router';
4
3
 
5
4
  import RASTMap from './RASTMap';
6
5
  import RASTAccordion from './RASTAccordion';
6
+ import { useLocation } from 'react-router-dom';
7
7
 
8
8
  import { withContentNavigation } from '@plone/volto/components/theme/Navigation/withContentNavigation';
9
9
 
10
- import { useLocation } from 'react-router-dom';
11
-
12
10
  /**
13
11
  * A navigation slot implementation, similar to the classic Plone navigation
14
12
  * portlet. It uses the same API, so the options are similar to
15
13
  * INavigationPortlet
16
14
  */
17
15
  export function ContextNavigationComponent(props) {
18
- const { navigation = {} } = props;
16
+ const { navigation = {}, location } = props;
19
17
  const { items = [] } = navigation;
20
18
  let activeMenu = null;
21
19
 
22
- const location = useLocation();
20
+ const curent_location = useLocation();
23
21
  for (let i = 0; i < items.length; i++) {
24
22
  let itemUrl = '/' + items[i].href.split('/').slice(3).join('/');
25
23
  items[i].is_active = false;
26
- if (location.pathname.includes(itemUrl)) {
24
+ if (curent_location.pathname.includes(itemUrl)) {
27
25
  activeMenu = i;
28
26
  items[i].is_active = true;
29
27
  }
30
28
  }
31
29
 
32
- return items.length ? (
30
+ return (
33
31
  <>
34
32
  <RASTMap
35
33
  items={items}
36
34
  pathname={location.pathname}
37
35
  activeMenu={activeMenu}
38
36
  />
39
- <RASTAccordion datasets={items} activeMenu={activeMenu} />
37
+ {items.length ? (
38
+ <RASTAccordion datasets={items} activeMenu={activeMenu} />
39
+ ) : null}
40
40
  </>
41
- ) : (
42
- ''
43
41
  );
44
42
  }
45
43
 
46
- export default compose(
47
- withRouter,
48
- withContentNavigation,
49
- )(ContextNavigationComponent);
44
+ export default compose(withContentNavigation)(ContextNavigationComponent);
@@ -4,18 +4,27 @@ import ContextNavigation from './ContextNavigation';
4
4
 
5
5
  export default function RASTView(props) {
6
6
  const { data } = props;
7
- const top_level = data?.top_level;
7
+ let root_path = data?.root_path;
8
+ let top_level = 1;
9
+ if (typeof root_path === 'undefined') {
10
+ root_path = '/';
11
+ }
12
+ top_level = (root_path.match(/\//g) || []).length - 1;
8
13
 
9
14
  return (
10
15
  <div className="block rast-block">
11
16
  <ContextNavigation
12
17
  params={{
13
18
  // name: 'CurrentTitle',
14
- includeTop: false,
15
- currentFolderOnly: false,
16
- topLevel: top_level ? top_level : 2,
19
+ // includeTop: false,
20
+ // currentFolderOnly: false,
21
+ topLevel: top_level,
22
+ // topLevel: 2,
17
23
  // rootPath: '/en/about/test-rast/',
18
24
  }}
25
+ location={{
26
+ pathname: root_path,
27
+ }}
19
28
  />
20
29
  </div>
21
30
  );
@@ -1,4 +1,4 @@
1
- const fields = ['top_level'];
1
+ const fields = ['root_path'];
2
2
 
3
3
  export default {
4
4
  title: 'RAST',
@@ -12,10 +12,11 @@ export default {
12
12
  ],
13
13
 
14
14
  properties: {
15
- top_level: {
16
- title: 'Top Level',
15
+ root_path: {
16
+ title: 'Rooth path',
17
17
  type: 'string',
18
- description: 'Ex 2 for /en/about/rast',
18
+ description:
19
+ 'Ex: /en/knowledge-and-data/regional-adaptation-support-tool',
19
20
  required: true,
20
21
  noValueOption: false,
21
22
  },