@eeacms/volto-clms-theme 1.0.75 → 1.0.76

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,17 @@ 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.76](https://github.com/eea/volto-clms-theme/compare/1.0.75...1.0.76)
8
+
9
+ - add modal when download requests are both standard downloads or prepackaged files [`#219`](https://github.com/eea/volto-clms-theme/pull/219)
10
+ - upgrade volto-accordion-block [`cf8a7a6`](https://github.com/eea/volto-clms-theme/commit/cf8a7a6909b1d38f855ef01f0642add7e882e804)
11
+ - add modal when downloading files are prepackaged and mapviewer [`c974d37`](https://github.com/eea/volto-clms-theme/commit/c974d37f42fd13d0de53416c36ed4b8f8a8ba2c0)
12
+
7
13
  #### [1.0.75](https://github.com/eea/volto-clms-theme/compare/1.0.74...1.0.75)
8
14
 
15
+ > 1 March 2022
16
+
17
+ - New release [`#218`](https://github.com/eea/volto-clms-theme/pull/218)
9
18
  - add elvis operator [`#217`](https://github.com/eea/volto-clms-theme/pull/217)
10
19
  - no need to tinker with dates, we configure the listing in Volto [`#215`](https://github.com/eea/volto-clms-theme/pull/215)
11
20
  - use new placeholder image [`#216`](https://github.com/eea/volto-clms-theme/pull/216)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-clms-theme",
3
- "version": "1.0.75",
3
+ "version": "1.0.76",
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",
@@ -30,7 +30,7 @@
30
30
  "@eeacms/volto-taxonomy"
31
31
  ],
32
32
  "dependencies": {
33
- "@eeacms/volto-accordion-block": "3.4.7",
33
+ "@eeacms/volto-accordion-block": "3.4.13",
34
34
  "@eeacms/volto-arcgis-block": "*",
35
35
  "@eeacms/volto-clms-utils": "0.1.6",
36
36
  "@eeacms/volto-columns-block": "4.4.3",
@@ -4,7 +4,7 @@
4
4
  * @module components/CLMSDownloadCartView/CLMSCartContent
5
5
  */
6
6
 
7
- import { Checkbox, Segment, Select } from 'semantic-ui-react';
7
+ import { Checkbox, Grid, Modal, Segment, Select } from 'semantic-ui-react';
8
8
  import React, { useEffect, useState } from 'react';
9
9
  import {
10
10
  getCartObjectFromMapviewer,
@@ -30,10 +30,16 @@ import useCartState from '@eeacms/volto-clms-utils/cart/useCartState';
30
30
  const CLMSCartContent = (props) => {
31
31
  const { localSessionCart } = props;
32
32
  const dispatch = useDispatch();
33
- const cart = useSelector((state) => state.cart_items.items);
34
33
  const { removeCartItem, removeCartItems } = useCartState();
34
+
35
+ // component states
36
+ const [openedModal, setOpenedModal] = useState(false);
35
37
  const [cartSelection, setCartSelection] = useState([]);
36
38
  const [loadingTable, setLoadingTable] = useState(false);
39
+ const [cartItems, setCartItems] = useState([]);
40
+
41
+ // state connections
42
+ const cart = useSelector((state) => state.cart_items.items);
37
43
  const post_download_in_progress = useSelector(
38
44
  (state) => state.downloadtool.post_download_in_progress,
39
45
  );
@@ -46,8 +52,6 @@ const CLMSCartContent = (props) => {
46
52
  );
47
53
  const nutsnames = useSelector((state) => state.nutsnames.nutsnames);
48
54
 
49
- const [cartItems, setCartItems] = useState([]);
50
-
51
55
  useEffect(() => {
52
56
  dispatch(getProjections());
53
57
  dispatch(getFormatConversionTable());
@@ -139,7 +143,7 @@ const CLMSCartContent = (props) => {
139
143
  dispatch(getDownloadtool());
140
144
  };
141
145
 
142
- function startDownloading() {
146
+ const startDownloading = () => {
143
147
  setLoadingTable(true);
144
148
  window.scrollTo(0, 0);
145
149
 
@@ -161,7 +165,21 @@ const CLMSCartContent = (props) => {
161
165
  setLoadingTable(false);
162
166
  toast.error(<Toast autoClose={5000} title={'Something went wrong.'} />);
163
167
  });
164
- }
168
+ };
169
+
170
+ const downloadModal = () => {
171
+ let selectedItems = getSelectedCartItems();
172
+ const hasPrepackaged =
173
+ selectedItems.filter((item) => item.file_id).length > 0;
174
+ const hasMapSelection =
175
+ selectedItems.filter((item) => item.area).length > 0;
176
+ if (!(hasMapSelection && hasPrepackaged)) {
177
+ startDownloading();
178
+ } else {
179
+ setOpenedModal(true);
180
+ }
181
+ };
182
+
165
183
  const setProjectionValue = (unique_id, value) => {
166
184
  const objIndex = cartItems.findIndex((obj) => obj.unique_id === unique_id);
167
185
  cartItems[objIndex].projection = value;
@@ -346,12 +364,70 @@ const CLMSCartContent = (props) => {
346
364
  )}
347
365
  {cartItems?.length !== 0 && (
348
366
  <CclButton
349
- onClick={() => startDownloading()}
367
+ onClick={() => downloadModal()}
350
368
  disabled={cartSelection.length === 0}
351
369
  >
352
370
  Start downloading
353
371
  </CclButton>
354
372
  )}
373
+ <Modal
374
+ // onClose={() => closeModal()}
375
+ // onOpen={() => openModal()}
376
+ open={openedModal}
377
+ // trigger={trigger}
378
+ className={'modal-clms'}
379
+ size={'fullscreen'}
380
+ >
381
+ <Modal.Header>Download processing</Modal.Header>
382
+ <Modal.Content>
383
+ <div className={'modal-clms-background'}>
384
+ <div className={'modal-clms-container'}>
385
+ {'The download is going to be processed in two different files.'}
386
+ <br />
387
+ <br />
388
+ <strong>Prepackaged files:</strong>
389
+ <ul>
390
+ {getSelectedCartItems()
391
+ .filter((item) => item.file_id)
392
+ .map((item, key) => (
393
+ <li key={key}>{item.name}</li>
394
+ ))}
395
+ </ul>
396
+ <br />
397
+ <strong>Map viewer selection:</strong>
398
+ <ul>
399
+ {getSelectedCartItems()
400
+ .filter((item) => item.area)
401
+ .map((item, key) => (
402
+ <li key={key}>{item.name}</li>
403
+ ))}
404
+ </ul>
405
+ </div>
406
+ </div>
407
+ </Modal.Content>
408
+ <Modal.Actions>
409
+ <Grid columns={2} stackable textAlign="center">
410
+ <Grid.Row verticalAlign="middle">
411
+ <Grid.Column>
412
+ <CclButton onClick={() => setOpenedModal(false)}>
413
+ Cancel
414
+ </CclButton>
415
+ </Grid.Column>
416
+ <Grid.Column>
417
+ <CclButton
418
+ mode={'filled'}
419
+ onClick={() => {
420
+ setOpenedModal(false);
421
+ startDownloading();
422
+ }}
423
+ >
424
+ Accept
425
+ </CclButton>
426
+ </Grid.Column>
427
+ </Grid.Row>
428
+ </Grid>
429
+ </Modal.Actions>
430
+ </Modal>
355
431
  </>
356
432
  );
357
433
  };