Skip to content

Commit 72dc9e5

Browse files
author
Abdi Abdulle
committed
improved UI of scientific condition
1 parent 359952a commit 72dc9e5

File tree

5 files changed

+159
-10
lines changed

5 files changed

+159
-10
lines changed

src/app/datasets/datasets-filter/datasets-filter.component.html

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,64 @@
6565
<mat-panel-title>
6666
<div class="condition-title-section">
6767
<div class="condition-field-name">
68-
{{ getHumanName(conditionConfig.condition.lhs) }}
68+
<mat-icon
69+
class="cell-icon"
70+
fontIcon="description"
71+
#hoverOriginSpan="cdkOverlayOrigin"
72+
cdkOverlayOrigin
73+
(mouseenter)="hoverKey = conditionConfig.condition.lhs"
74+
(mouseleave)="hoverKey = null"
75+
></mat-icon>
76+
<div class="field-name-wrapper">
77+
<div class="human-name">
78+
{{ getHumanName(conditionConfig.condition.lhs) }}
79+
</div>
80+
<div
81+
class="metadata-name"
82+
*ngIf="humanNameMap[conditionConfig.condition.lhs]"
83+
>
84+
{{ conditionConfig.condition.lhs }}
85+
</div>
86+
</div>
87+
88+
<!-- Hover overlay -->
89+
<ng-template
90+
cdkConnectedOverlay
91+
[cdkConnectedOverlayOrigin]="hoverOriginSpan"
92+
[cdkConnectedOverlayOpen]="
93+
hoverKey === conditionConfig.condition.lhs
94+
"
95+
[cdkConnectedOverlayPositions]="overlayPositions"
96+
>
97+
<mat-card class="hover-card">
98+
<mat-card-title class="hover-card-title">
99+
Name Details
100+
</mat-card-title>
101+
<div mat-card-content class="hover-card-content">
102+
<ng-container
103+
*ngIf="
104+
getHumanName(conditionConfig.condition.lhs);
105+
else rawNameOnly
106+
"
107+
>
108+
<strong>Human readable name: </strong>
109+
{{ getHumanName(conditionConfig.condition.lhs) }}
110+
<br />
111+
<strong>Metadata name:</strong>
112+
{{ conditionConfig.condition.lhs }}
113+
</ng-container>
114+
</div>
115+
<ng-template #rawNameOnly>
116+
<strong>Metadata name:</strong>
117+
{{ conditionConfig.condition.lhs }}
118+
</ng-template>
119+
</mat-card>
120+
</ng-template>
69121
</div>
70122
<div class="condition-description">
71-
{{ getConditionDisplayText(conditionConfig.condition) }}
123+
<span class="condition-chip">{{
124+
getConditionDisplayText(conditionConfig.condition)
125+
}}</span>
72126
</div>
73127
</div>
74128
</mat-panel-title>
@@ -229,7 +283,10 @@
229283
(input)="updateConditionUnit(i, $event)"
230284
[matAutocomplete]="rhsUnits"
231285
/>
232-
<mat-autocomplete #rhsUnits="matAutocomplete" (optionSelected)="updateConditionUnit(i, $event)">
286+
<mat-autocomplete
287+
#rhsUnits="matAutocomplete"
288+
(optionSelected)="updateConditionUnit(i, $event)"
289+
>
233290
<mat-option
234291
*ngFor="let unit of getUnits(conditionConfig.condition.lhs)"
235292
[value]="unit"

src/app/datasets/datasets-filter/datasets-filter.component.scss

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use "@angular/material" as mat;
12
mat-card {
23
margin-top: 0.5rem;
34

@@ -96,16 +97,59 @@ mat-card {
9697
.condition-title-section {
9798
display: flex;
9899
flex-direction: column;
100+
width: 100%;
99101

100102
.condition-field-name {
101103
font-weight: 500;
104+
font-size: 1rem;
102105
margin-bottom: 0.25rem;
103106
word-break: break-word;
107+
display: flex;
108+
align-items: center;
109+
110+
.cell-icon {
111+
color: var(--theme-primary-default);
112+
flex-shrink: 0; /* prevent icon from being hidden */
113+
font-size: 19px;
114+
transform: translateY(4px);
115+
}
116+
.field-name-wrapper {
117+
display: flex;
118+
flex-direction: column;
119+
min-width: 0;
120+
flex: 1;
121+
122+
.human-name {
123+
font-size: 1rem;
124+
font-weight: 500;
125+
}
126+
127+
.metadata-name {
128+
font-size: 0.875rem;
129+
font-style: italic;
130+
color: rgba(0, 0, 0, 0.54);
131+
margin-top: 2px;
132+
}
133+
}
104134
}
105135

106136
.condition-description {
107137
font-size: 0.9em;
108138
color: rgba(0, 0, 0, 0.6);
139+
140+
.condition-chip {
141+
display: block;
142+
font-size: 0.85rem;
143+
font-weight: 500;
144+
padding: 2px 8px;
145+
background: transparent;
146+
border: 1px solid var(--theme-primary-default);
147+
color: var(--theme-primary-default);
148+
border-radius: 6px;
149+
overflow: hidden;
150+
text-overflow: ellipsis;
151+
white-space: nowrap;
152+
}
109153
}
110154
}
111155

@@ -122,28 +166,31 @@ mat-card {
122166
.mat-expansion-panel-header {
123167
height: auto !important;
124168
padding: 0.5rem !important;
169+
align-items: flex-start !important;
125170

126171
.mat-expansion-panel-header-title {
127172
white-space: normal !important;
128173
overflow: visible !important;
174+
flex: 1;
175+
min-width: 0;
129176
}
130177
.mat-expansion-panel-header-description {
131178
display: none !important;
132179
}
133180
}
134181

135182
.condition-details {
136-
padding: 0.5rem;
183+
padding: 0.25rem;
137184
display: flex;
138185
flex-direction: column;
139-
gap: 0.5rem;
186+
gap: 0.25rem;
140187

141188
.condition-actions-section {
142189
display: flex;
143190
align-items: center;
144191
justify-content: center;
145-
padding-top: 0.5rem;
146-
192+
margin-top: -0.5rem;
193+
margin-bottom: -0.5rem;
147194
.condition-toggle {
148195
margin: 0;
149196
}
@@ -170,6 +217,8 @@ mat-card {
170217
.condition-fields {
171218
margin-left: -20px;
172219
width: calc(100% + 40px);
220+
221+
@include mat.form-field-density(-5);
173222
}
174223

175224
.operator-symbol {
@@ -180,3 +229,25 @@ mat-card {
180229
}
181230
}
182231
}
232+
233+
.hover-card {
234+
min-width: 300px;
235+
max-width: 620px;
236+
}
237+
238+
.hover-card-title {
239+
padding: 0 16px;
240+
font-size: 14px;
241+
border-radius: 4px 4px 0 0;
242+
color: white;
243+
background: var(--theme-header-1-lighter);
244+
}
245+
246+
.hover-card-content {
247+
padding: 10px 16px;
248+
background: white;
249+
color: var(--theme-header-1-lighter-contrast);
250+
border-radius: 0 0 4px 4px;
251+
white-space: pre-line;
252+
word-wrap: break-word;
253+
}

src/app/datasets/datasets-filter/datasets-filter.component.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import { ActivatedRoute, Router } from "@angular/router";
5858
import { MultiSelectFilterValue } from "shared/modules/filters/multiselect-filter.component";
5959
import { INumericRange } from "shared/modules/numeric-range/form/model/numeric-range-field.model";
6060
import { UnitsOptionsService } from "shared/services/units-options.service";
61-
61+
import { ConnectedPosition } from "@angular/cdk/overlay";
6262
@Component({
6363
selector: "datasets-filter",
6464
templateUrl: "datasets-filter.component.html",
@@ -91,6 +91,25 @@ export class DatasetsFilterComponent implements OnInit, OnDestroy {
9191

9292
fieldTypeMap: { [key: string]: string } = {};
9393

94+
hoverKey: string | null = null;
95+
96+
overlayPositions: ConnectedPosition[] = [
97+
{
98+
originX: "end",
99+
originY: "center",
100+
overlayX: "start",
101+
overlayY: "center",
102+
offsetX: 8,
103+
},
104+
{
105+
originX: "center",
106+
originY: "center",
107+
overlayX: "end",
108+
overlayY: "top",
109+
offsetY: 8,
110+
},
111+
];
112+
94113
constructor(
95114
public appConfigService: AppConfigService,
96115
public dialog: MatDialog,
@@ -489,7 +508,7 @@ export class DatasetsFilterComponent implements OnInit, OnDestroy {
489508
.pipe(take(1))
490509
.subscribe((currentConditions) => {
491510
const existingConditionIndex = currentConditions.findIndex(
492-
(config) => isEqual(config.condition, data),
511+
(config) => isEqual(this.humanNameMap[config.condition.lhs], data.lhs),
493512
);
494513
if (existingConditionIndex !== -1) {
495514
this.snackBar.open("Condition already exists", "Close", {

src/app/datasets/datasets.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ import { ThumbnailPipe } from "shared/pipes/thumbnail.pipe";
8787
import { MatExpansionModule } from "@angular/material/expansion";
8888
import { MatBadgeModule } from "@angular/material/badge";
8989
import { TitleCasePipe } from "shared/pipes/title-case.pipe";
90+
import { OverlayModule } from "@angular/cdk/overlay";
9091

9192
@NgModule({
9293
imports: [
@@ -150,6 +151,7 @@ import { TitleCasePipe } from "shared/pipes/title-case.pipe";
150151
// FiltersModule,
151152
MatExpansionModule,
152153
MatBadgeModule,
154+
OverlayModule,
153155
],
154156
declarations: [
155157
BatchViewComponent,

src/app/shared/modules/search-parameters-dialog/search-parameters-dialog.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export class SearchParametersDialogComponent {
137137
const rhs =
138138
relation === "EQUAL_TO_STRING" ? String(rawRhs) : Number(rawRhs);
139139
this.parametersForm.patchValue({ rhs });
140-
this.dialogRef.close({ data: { lhs, relation, rhs, unit } });
140+
this.dialogRef.close({ data: { lhs: metadataKey, relation, rhs, unit } });
141141
};
142142

143143
cancel = (): void => this.dialogRef.close();

0 commit comments

Comments
 (0)