-
Notifications
You must be signed in to change notification settings - Fork 32
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
WIP : Advanced filters #702
Closed
Closed
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
912f2cb
feat: adds ThesaurusTranslationSearchField request to fields
f-necas 6302fe0
Add contact filter from OrgForResource
Angi-Kinas c7d0f9a
feat(DH) :Add translation for contact filter
Angi-Kinas b91f0fa
feat: retrieve values for orgs
f-necas ff26b82
chore: add semver dependency
fgravin d4ac088
refactor(platform): remove isApiCompatible
fgravin 5c5aae1
refactor(org): use semver for version comparison
fgravin d56f845
feat(platform): throw an error is the version is not compatible
fgravin f909efc
WIP: Add new ContactField that differs between gn version
Angi-Kinas ed85f75
feat: update dump, remove log and fix filter
f-necas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import { | |
} from '@geonetwork-ui/common/domain/model/search' | ||
import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' | ||
import { ElasticsearchService } from '@geonetwork-ui/api/repository/gn4' | ||
import { LangService } from '@geonetwork-ui/util/i18n' | ||
|
||
export type FieldValue = string | number | ||
export interface FieldAvailableValue { | ||
|
@@ -127,6 +128,57 @@ export class GnUiTranslationSearchField extends SimpleSearchField { | |
} | ||
} | ||
|
||
export class ThesaurusTranslationSearchField extends SimpleSearchField { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could have extended the |
||
private toolsApiService = this.injector.get(ToolsApiService) | ||
private langService = this.injector.get(LangService) | ||
allTranslations = this.toolsApiService | ||
.getTranslationsFromThesaurus(this.thesaurusName, this.langService.iso3) | ||
.pipe( | ||
map((thesaurus) => { | ||
const alltranslations = {} | ||
thesaurus.map((val) => { | ||
alltranslations[val.uri] = val.value | ||
}) | ||
return alltranslations | ||
}), | ||
catchError(() => { | ||
console.warn('Error while loading thesaurus language package') | ||
return of({}) | ||
}), | ||
shareReplay(1) | ||
) | ||
|
||
constructor( | ||
esFieldName: string, | ||
protected thesaurusName: string, | ||
order: 'asc' | 'desc' = 'asc', | ||
injector: Injector | ||
) { | ||
super(esFieldName, order, injector) | ||
} | ||
|
||
private async getTranslation(topicKey: string) { | ||
return firstValueFrom( | ||
this.allTranslations.pipe(map((translations) => translations[topicKey])) | ||
) | ||
} | ||
|
||
protected async getBucketLabel(bucket: TermBucket) { | ||
return (await this.getTranslation(bucket.term)) || bucket.term | ||
} | ||
|
||
getAvailableValues(): Observable<FieldAvailableValue[]> { | ||
// sort values by alphabetical order | ||
return super | ||
.getAvailableValues() | ||
.pipe( | ||
map((values) => | ||
values.sort((a, b) => new Intl.Collator().compare(a.label, b.label)) | ||
) | ||
) | ||
} | ||
} | ||
|
||
export class FullTextSearchField implements AbstractSearchField { | ||
getAvailableValues(): Observable<FieldAvailableValue[]> { | ||
return of([]) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never write open API client by hand.
BTW, the
registries
client already exists inRegistriesApiService