@eeacms/volto-arcgis-block 0.1.72 → 0.1.73

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,7 +4,15 @@ 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.72](https://github.com/eea/volto-arcgis-block/compare/0.1.71...0.1.72) - 25 October 2022
7
+ ### [0.1.73](https://github.com/eea/volto-arcgis-block/compare/0.1.72...0.1.73) - 26 October 2022
8
+
9
+ #### :rocket: New Features
10
+
11
+ - feat: CLMS-1489 use cases viewer now saves dropdown expanded state and scroll position when navigating backwards from either a specific use case or a list of use cases (when clicking a cluster on the map) [joewdavies - [`6f821f4`](https://github.com/eea/volto-arcgis-block/commit/6f821f43fe9f31ccba4547cf01078eab8c2cead9)]
12
+ - feat: CLMS-1489 use cases viewer now saves dropdown expanded state and scroll position when navigating backwards from either a specific use case or a list of use cases (when clicking a cluster on the map) [joewdavies - [`0e4e940`](https://github.com/eea/volto-arcgis-block/commit/0e4e940a7d16674d625f62fe70abca74649d5f52)]
13
+ - feat: CLMS-1489 use cases viewer now saves dropdown expanded state and scroll position when navigating backwards from a specific use case to the product list [joewdavies - [`a7a7255`](https://github.com/eea/volto-arcgis-block/commit/a7a7255ccc9246e0eaf3b9cfa68b83920468d1ee)]
14
+
15
+ ### [0.1.72](https://github.com/eea/volto-arcgis-block/compare/0.1.71...0.1.72) - 26 October 2022
8
16
 
9
17
  ### [0.1.71](https://github.com/eea/volto-arcgis-block/compare/0.1.70...0.1.71) - 13 October 2022
10
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-arcgis-block",
3
- "version": "0.1.72",
3
+ "version": "0.1.73",
4
4
  "description": "volto-arcgis-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: CodeSyntax",
@@ -141,6 +141,22 @@ class InfoWidget extends React.Component {
141
141
  className="use-case-element"
142
142
  aria-hidden="true"
143
143
  onClick={() => {
144
+ //save scroll position CLMS-1489
145
+ let productsScrollPosition;
146
+ let pl = document.getElementById('use-cases-product-list');
147
+ if (pl) {
148
+ productsScrollPosition = pl.scrollTop;
149
+ } else {
150
+ productsScrollPosition = null;
151
+ }
152
+ let casesScrollPosition;
153
+ let ucl = document.getElementById('use-cases-list');
154
+ if (ucl) {
155
+ casesScrollPosition = ucl.scrollTop;
156
+ } else {
157
+ casesScrollPosition = null;
158
+ }
159
+
144
160
  view.popup.close();
145
161
  layerControl.getGeometry(val.Spatial_coverage, layerHighlight);
146
162
  layerControl.showLayer(layerHighlight.id);
@@ -148,6 +164,10 @@ class InfoWidget extends React.Component {
148
164
  useCaseLevel: 4,
149
165
  selectedUseCase: val,
150
166
  previousState: prevState.useCaseLevel,
167
+ productsScrollPosition: productsScrollPosition,
168
+ casesScrollPosition: casesScrollPosition
169
+ ? casesScrollPosition
170
+ : prevState,
151
171
  }));
152
172
  }}
153
173
  id={`use_case_${val.OBJECTID}`}
@@ -208,7 +228,7 @@ class InfoWidget extends React.Component {
208
228
  See all use cases
209
229
  </button>
210
230
  </div>
211
- <div className="use-cases-products-list">
231
+ <div className="use-cases-products-list" id="use-cases-list">
212
232
  <div key={selectedRegion} className="use-cases-dropdown">
213
233
  {this.getDataBrief(regionFeatures)}
214
234
  </div>
@@ -244,7 +264,7 @@ class InfoWidget extends React.Component {
244
264
  Back
245
265
  </button>
246
266
  </div>
247
- <div className="use-cases-products-list">
267
+ <div className="use-cases-products-list" id="specific-use-cases-list">
248
268
  <div key={selectedRegion} className="use-cases-dropdown">
249
269
  {this.getDataBrief(regionFeatures)}
250
270
  </div>
@@ -286,7 +306,8 @@ class InfoWidget extends React.Component {
286
306
  <div key={topic_name} className="use-cases-dropdown">
287
307
  <div
288
308
  className="ccl-expandable__button"
289
- aria-expanded="false"
309
+ aria-expanded={mapViewer.state.activeDropdowns.includes(topic_name)}
310
+ id={topic_name}
290
311
  onClick={this.toggleDropdownContent.bind(this)}
291
312
  onKeyDown={this.toggleDropdownContent.bind(this)}
292
313
  tabIndex="0"
@@ -306,13 +327,32 @@ class InfoWidget extends React.Component {
306
327
  toggleDropdownContent(e) {
307
328
  let aria = e.target.getAttribute('aria-expanded');
308
329
  e.target.setAttribute('aria-expanded', aria === 'true' ? 'false' : 'true');
330
+
331
+ // dropdown expanded
309
332
  if (aria === 'false') {
333
+ //save for reload
334
+ mapViewer.state.activeDropdowns.push(e.target.getAttribute('id'));
335
+
336
+ //scroll position
310
337
  document.querySelector('.use-cases-products-list').scrollTo({
311
338
  top:
312
339
  e.currentTarget.offsetTop -
313
340
  document.querySelector('.use-cases-products-list').offsetTop,
314
341
  behavior: 'smooth',
315
342
  });
343
+ } else {
344
+ if (
345
+ //remove for reload
346
+ mapViewer.state.activeDropdowns.includes(e.target.getAttribute('id'))
347
+ ) {
348
+ const index = mapViewer.state.activeDropdowns.indexOf(
349
+ e.target.getAttribute('id'),
350
+ );
351
+ if (index > -1) {
352
+ // only splice array when item is found
353
+ mapViewer.state.activeDropdowns.splice(index, 1);
354
+ }
355
+ }
316
356
  }
317
357
  }
318
358
 
@@ -414,7 +454,10 @@ class InfoWidget extends React.Component {
414
454
  </span>
415
455
  use cases
416
456
  </div>
417
- <div className="use-cases-products-list">
457
+ <div
458
+ className="use-cases-products-list"
459
+ id="use-cases-product-list"
460
+ >
418
461
  {this.setDOMSummary()}
419
462
  </div>
420
463
  </>
@@ -460,6 +503,27 @@ class InfoWidget extends React.Component {
460
503
  }
461
504
  }
462
505
 
506
+ componentDidUpdate() {
507
+ // code to run after initial render goes here
508
+ try {
509
+ // go to saved scroll position(s)
510
+ let pl = document.getElementById('use-cases-product-list');
511
+ if (pl) {
512
+ pl.scrollTo({
513
+ top: mapViewer.state.productsScrollPosition,
514
+ behavior: 'auto',
515
+ });
516
+ }
517
+ let ucl = document.getElementById('use-cases-list');
518
+ if (ucl) {
519
+ ucl.scrollTo({
520
+ top: mapViewer.state.casesScrollPosition,
521
+ behavior: 'auto',
522
+ });
523
+ }
524
+ } catch {}
525
+ }
526
+
463
527
  /**
464
528
  * This method renders the component
465
529
  * @returns jsx
@@ -83,7 +83,21 @@ class NavigationControl extends React.Component {
83
83
  */
84
84
  returnToPrevious() {
85
85
  // this.layerControl.hideLayer(layerHighlight.id);
86
-
86
+ // CLMS-1489
87
+ let productsScrollPosition;
88
+ let pl = document.getElementById('use-cases-product-list');
89
+ if (pl) {
90
+ productsScrollPosition = pl.scrollTop;
91
+ } else {
92
+ productsScrollPosition = null;
93
+ }
94
+ let casesScrollPosition;
95
+ let ucl = document.getElementById('use-cases-list');
96
+ if (ucl) {
97
+ casesScrollPosition = ucl.scrollTop;
98
+ } else {
99
+ casesScrollPosition = null;
100
+ }
87
101
  switch (
88
102
  mapViewer.state.previousState === mapViewer.state.useCaseLevel
89
103
  ? mapViewer.state.useCaseLevel - 1
@@ -101,14 +115,26 @@ class NavigationControl extends React.Component {
101
115
  mapViewer.state.selectedUseCase.Region,
102
116
  layerSpatial,
103
117
  );
104
- mapViewer.setState(() => ({
118
+ mapViewer.setState((prevState) => ({
105
119
  useCaseLevel: 2,
106
120
  region: mapViewer.state.selectedUseCase.Region,
121
+ productsScrollPosition: productsScrollPosition
122
+ ? productsScrollPosition
123
+ : prevState.productsScrollPosition,
124
+ casesScrollPosition: casesScrollPosition
125
+ ? casesScrollPosition
126
+ : prevState.casesScrollPosition,
107
127
  }));
108
128
  break;
109
129
  case 3:
110
- mapViewer.setState(() => ({
130
+ mapViewer.setState((prevState) => ({
111
131
  useCaseLevel: 3,
132
+ productsScrollPosition: productsScrollPosition
133
+ ? productsScrollPosition
134
+ : prevState.productsScrollPosition,
135
+ casesScrollPosition: casesScrollPosition
136
+ ? casesScrollPosition
137
+ : prevState.casesScrollPosition,
112
138
  }));
113
139
  break;
114
140
  default:
@@ -61,6 +61,9 @@ class UseCasesMapViewer extends React.Component {
61
61
  selectedUseCases: [],
62
62
  previousState: 1,
63
63
  showMapMenu: false,
64
+ activeDropdowns: [],
65
+ productsScrollPosition: 0,
66
+ casesScrollPosition: 0,
64
67
  };
65
68
  }
66
69
 
@@ -245,6 +248,21 @@ class UseCasesMapViewer extends React.Component {
245
248
  });
246
249
  view.on('click', (e) => {
247
250
  let screenPoint = { x: e.x, y: e.y };
251
+ // CLMS-1489
252
+ let productsScrollPosition;
253
+ let pl = document.getElementById('use-cases-product-list');
254
+ if (pl) {
255
+ productsScrollPosition = pl.scrollTop;
256
+ } else {
257
+ productsScrollPosition = null;
258
+ }
259
+ let casesScrollPosition;
260
+ let ucl = document.getElementById('use-cases-list');
261
+ if (ucl) {
262
+ casesScrollPosition = ucl.scrollTop;
263
+ } else {
264
+ casesScrollPosition = null;
265
+ }
248
266
 
249
267
  (async () => {
250
268
  let selectedPoint = await layerControl.getPointInfo(screenPoint);
@@ -259,12 +277,26 @@ class UseCasesMapViewer extends React.Component {
259
277
  selectedRegion,
260
278
  layerSpatial,
261
279
  );
280
+ // CLMS-1489
281
+ let productsScrollPosition;
282
+ let pl = document.getElementById('use-cases-product-list');
283
+ if (pl) {
284
+ productsScrollPosition = pl.scrollTop;
285
+ } else {
286
+ productsScrollPosition = 0;
287
+ }
262
288
  this.setState((prevState) => {
263
289
  return {
264
290
  useCaseLevel: 2,
265
291
  selectedUseCase: selectedPoint,
266
292
  region: selectedRegion,
267
293
  previousState: prevState.useCaseLevel,
294
+ productsScrollPosition: productsScrollPosition
295
+ ? productsScrollPosition
296
+ : prevState.productsScrollPosition,
297
+ casesScrollPosition: casesScrollPosition
298
+ ? casesScrollPosition
299
+ : prevState.casesScrollPosition,
268
300
  };
269
301
  });
270
302
  } else if (
@@ -288,6 +320,12 @@ class UseCasesMapViewer extends React.Component {
288
320
  selectedUseCase: data,
289
321
  region: data.Region,
290
322
  previousState: prevState.useCaseLevel,
323
+ productsScrollPosition: productsScrollPosition
324
+ ? productsScrollPosition
325
+ : prevState.productsScrollPosition,
326
+ casesScrollPosition: casesScrollPosition
327
+ ? casesScrollPosition
328
+ : prevState.casesScrollPosition,
291
329
  };
292
330
  });
293
331
  },
@@ -307,6 +345,12 @@ class UseCasesMapViewer extends React.Component {
307
345
  selectedUseCase: selectedPoint,
308
346
  selectedUseCases: data.features,
309
347
  previousState: prevState.useCaseLevel,
348
+ productsScrollPosition: productsScrollPosition
349
+ ? productsScrollPosition
350
+ : prevState.productsScrollPosition,
351
+ casesScrollPosition: casesScrollPosition
352
+ ? casesScrollPosition
353
+ : prevState.casesScrollPosition,
310
354
  };
311
355
  });
312
356
  } else {
@@ -322,6 +366,12 @@ class UseCasesMapViewer extends React.Component {
322
366
  useCaseLevel: 4,
323
367
  selectedUseCase: selectedPoint,
324
368
  previousState: prevState.useCaseLevel,
369
+ productsScrollPosition: productsScrollPosition
370
+ ? productsScrollPosition
371
+ : prevState.productsScrollPosition,
372
+ casesScrollPosition: casesScrollPosition
373
+ ? casesScrollPosition
374
+ : prevState.casesScrollPosition,
325
375
  };
326
376
  });
327
377
  }