Skip to content

Commit 0c2de01

Browse files
KrupaRamiKrupa Rami
andauthored
GUUI 3669 resetting spatial piker should set spatial constraints of the collection (#29)
* Resetting spatial piker sets spatial constraints of the collection instead of null * Fixed reset all button to reset all selected parameters * adding alert for giovanni format * Adding optional close button on datepicker and spatialpicker dropdown * updating aria-label --------- Co-authored-by: Krupa Rami <krupa.m.rami@nasa.gov>
1 parent 970fe42 commit 0c2de01

3 files changed

Lines changed: 122 additions & 5 deletions

File tree

src/components/data-access/data-access.component.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ export default class TerraDataAccess extends TerraElement {
7777
@property({ reflect: true, attribute: 'version' })
7878
version?: string
7979

80+
@property({ type: Boolean }) showPanelClose = true
81+
8082
@state()
8183
private _gridInitialized = false
8284

@@ -124,6 +126,8 @@ export default class TerraDataAccess extends TerraElement {
124126
spatialPickerRef = createRef<TerraSpatialPicker>()
125127
cloudCoverSliderRef = createRef<TerraSlider>()
126128
gridRef = createRef<TerraDataGrid<CmrGranule>>()
129+
dateDropdownRef = createRef<TerraDropdown>()
130+
spatialDropdownRef = createRef<TerraDropdown>()
127131

128132
#controller = new DataAccessController(this)
129133
#boundHandleCloudCoverClickOutside: ((event: MouseEvent) => void) | null = null
@@ -629,7 +633,7 @@ export default class TerraDataAccess extends TerraElement {
629633
</div>
630634
631635
<div class="toggle-row">
632-
<terra-dropdown>
636+
<terra-dropdown ${ref(this.dateDropdownRef)}>
633637
<button
634638
slot="trigger"
635639
class="filter-btn ${this.startDate && this.endDate
@@ -659,6 +663,20 @@ export default class TerraDataAccess extends TerraElement {
659663
</button>
660664
661665
<div class="datepicker-container">
666+
${this.showPanelClose
667+
? html`
668+
<div class="dropdown-header">
669+
<button
670+
class="panel-close"
671+
@click=${() =>
672+
this.dateDropdownRef.value?.hide()}
673+
aria-label="Close"
674+
>
675+
×
676+
</button>
677+
</div>
678+
`
679+
: nothing}
662680
<terra-date-picker
663681
${ref(this.datePickerRef)}
664682
range
@@ -704,6 +722,7 @@ export default class TerraDataAccess extends TerraElement {
704722
distance="4"
705723
hoist
706724
@terra-show=${this.#handleSpatialDropdownShow}
725+
${ref(this.spatialDropdownRef)}
707726
>
708727
<div slot="trigger" class="filter">
709728
<button
@@ -733,6 +752,20 @@ export default class TerraDataAccess extends TerraElement {
733752
</div>
734753
735754
<div class="spatialpicker-container">
755+
${this.showPanelClose
756+
? html`
757+
<div class="dropdown-header">
758+
<button
759+
class="panel-close"
760+
@click=${() =>
761+
this.spatialDropdownRef.value?.hide()}
762+
aria-label="Close"
763+
>
764+
×
765+
</button>
766+
</div>
767+
`
768+
: nothing}
736769
<terra-spatial-picker
737770
${ref(this.spatialPickerRef)}
738771
hide-label

src/components/data-access/data-access.styles.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,4 +337,22 @@ export default css`
337337
left: 50%;
338338
margin-left: -100px;
339339
}
340+
341+
.dropdown-header {
342+
display: flex;
343+
justify-content: flex-end;
344+
padding: 4px 6px;
345+
}
346+
347+
.panel-close {
348+
border: none;
349+
background: transparent;
350+
font-size: 18px;
351+
cursor: pointer;
352+
line-height: 1;
353+
}
354+
355+
.panel-close:hover {
356+
opacity: 0.7;
357+
}
340358
`

src/components/data-subsetter/data-subsetter.component.ts

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ export default class TerraDataSubsetter extends TerraElement {
627627
// Get Data footer
628628
return html`
629629
<div slot="footer" class="footer">
630-
<button class="btn btn-secondary">Reset All</button>
630+
<button class="btn btn-secondary" @click=${this.#resetAllParameters}>Reset All</button>
631631
<div>
632632
<button class="btn btn-primary" @click=${this.#getData}>
633633
Get Data
@@ -780,7 +780,7 @@ export default class TerraDataSubsetter extends TerraElement {
780780
${this.dataAccessMode === 'subset' && !this.dialog
781781
? html`
782782
<div class="footer">
783-
<button class="btn btn-secondary">Reset All</button>
783+
<button class="btn btn-secondary" @click=${this.#resetAllParameters}>Reset All</button>
784784
<div>
785785
<button
786786
class="btn btn-primary"
@@ -809,6 +809,31 @@ export default class TerraDataSubsetter extends TerraElement {
809809
`
810810
}
811811

812+
#resetAllParameters = () => {
813+
// Reset variables
814+
this.selectedVariables = []
815+
816+
// Reset spatial to collection bounds (not null)
817+
if (this.#hasSpatialSubset()) {
818+
this.#resetSpatialSelection()
819+
}
820+
821+
// Reset date range
822+
this.selectedDateRange = {
823+
startDate: null,
824+
endDate: null,
825+
}
826+
827+
// Clear validation state
828+
this.touchedFields = new Set()
829+
this.validationError = undefined
830+
831+
// Collapse variable tree
832+
this.expandedVariableGroups = new Set()
833+
834+
this.requestUpdate()
835+
}
836+
812837
#renderSearchForCollection() {
813838
let placeholder =
814839
'Search all types of resources (e.g. rainfall, GPM, hurricanes, etc.)'
@@ -1355,8 +1380,37 @@ export default class TerraDataSubsetter extends TerraElement {
13551380
}
13561381
}
13571382

1358-
#resetSpatialSelection = () => {
1359-
this.spatialSelection = null
1383+
#resetSpatialSelection = () => {
1384+
const spatial_constraints =
1385+
this.collectionWithServices?.collection?.SpatialExtent
1386+
?.HorizontalSpatialDomain?.Geometry?.BoundingRectangles
1387+
1388+
if (!spatial_constraints) {
1389+
this.spatialSelection = null
1390+
return
1391+
}
1392+
1393+
type BoundingRect = {
1394+
WestBoundingCoordinate: number
1395+
SouthBoundingCoordinate: number
1396+
EastBoundingCoordinate: number
1397+
NorthBoundingCoordinate: number
1398+
}
1399+
1400+
const normalized: BoundingRect[] = Array.isArray(spatial_constraints)
1401+
? spatial_constraints
1402+
: [spatial_constraints]
1403+
1404+
const rect = normalized[0]
1405+
1406+
this.spatialSelection = {
1407+
w: Number(rect.WestBoundingCoordinate),
1408+
s: Number(rect.SouthBoundingCoordinate),
1409+
e: Number(rect.EastBoundingCoordinate),
1410+
n: Number(rect.NorthBoundingCoordinate),
1411+
}
1412+
1413+
this.#markFieldTouched('spatial')
13601414
}
13611415

13621416
#renderVariableSelection() {
@@ -1433,6 +1487,18 @@ export default class TerraDataSubsetter extends TerraElement {
14331487
Only certain variables are supported for the
14341488
selected output format. (Giovanni service)
14351489
</terra-alert>
1490+
<terra-alert
1491+
open
1492+
appearance="white"
1493+
style="margin: 10px 0"
1494+
>
1495+
<terra-icon
1496+
slot="icon"
1497+
name="outline-information-circle"
1498+
library="heroicons"
1499+
></terra-icon>
1500+
User's are allowed to select only one variable for the selected output format. (Giovanni service)
1501+
</terra-alert>
14361502
`
14371503
: nothing}
14381504
${variables.length === 0

0 commit comments

Comments
 (0)