Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving remaining issues in the Search UI project #1594

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Progress #1141: workaround BE limitation on metadataKeys query (retur…
…ns empty [] after first call)
Ingvord committed Oct 4, 2024
commit 58350ce3d93c833a27fad11851244fab7e85ef1a
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ export class SearchParametersDialogComponent {
appConfig = this.appConfigService.getConfig();
unitsEnabled = this.appConfig.scienceSearchUnitsEnabled;

parameterKeys = this.data.parameterKeys;
parameterKeys = this.data.parameterTypes.map((type) => type.metadataKey);
parameterTypes = this.data.parameterTypes;
filteredOperators$: Observable<{ value: string; label: string }[]> = of([]); // TODO default set of operators
units: string[] = [];
@@ -72,8 +72,22 @@ export class SearchParametersDialogComponent {
public dialogRef: MatDialogRef<SearchParametersDialogComponent>,
private unitsService: UnitsService,
) {
function findMetadataTypeByKey(key) {
return (
this.parameterTypes.find((type) => type.metadataKey.includes(key)) ||
({ metadataType: "mixed" } as Record<string, string>)
);
}

if (this.data.condition?.lhs) {
this.getUnits(this.data.condition.lhs);
this.filteredOperators$ = of(
this.getOperatorsByType(
this.extractFieldType(
findMetadataTypeByKey.bind(this, this.data.condition.lhs),
),
),
);
}

// Dynamically update operators based on the field selected by the user
@@ -84,11 +98,7 @@ export class SearchParametersDialogComponent {
filter((selectedLhs: string) => selectedLhs && selectedLhs.length > 2),
distinctUntilChanged(),
mergeMap((selectedLhs: string) => {
return of(
this.parameterTypes.find((type) =>
type.metadataKey.includes(selectedLhs),
) || ({ metadataType: "mixed" } as Record<string, string>),
);
return of(findMetadataTypeByKey.bind(this, selectedLhs));
}),
// take(1),
map((field) => {