From c42440f52fa560ea7971f6b8d3aff8289f624098 Mon Sep 17 00:00:00 2001 From: Yugay Vasiliy Date: Mon, 19 Feb 2024 10:41:18 +0000 Subject: [PATCH] Added provenance search tab for fragmentarium Added tests for proveance search tab ui --- .../application/FragmentService.test.ts | 1 + .../application/FragmentService.ts | 4 + .../infrastructure/FragmentRepository.ts | 3 + .../ui/ArchaeologySearchForm.sass | 3 + .../ui/ArchaeologySearchForm.tsx | 38 ++++++ src/fragmentarium/ui/SearchForm.test.tsx | 36 +++++ src/fragmentarium/ui/SearchForm.tsx | 21 +++ src/fragmentarium/ui/SearchHelp.tsx | 10 ++ .../ui/front-page/Fragmentarium.test.tsx | 1 + .../ui/search/FragmentariumSearch.test.tsx | 1 + .../FragmentariumSearch.test.tsx.snap | 126 +++++++++++++++--- src/query/FragmentQuery.ts | 1 + 12 files changed, 223 insertions(+), 22 deletions(-) create mode 100644 src/fragmentarium/ui/ArchaeologySearchForm.sass create mode 100644 src/fragmentarium/ui/ArchaeologySearchForm.tsx diff --git a/src/fragmentarium/application/FragmentService.test.ts b/src/fragmentarium/application/FragmentService.test.ts index 207c0023b..dbca368e0 100644 --- a/src/fragmentarium/application/FragmentService.test.ts +++ b/src/fragmentarium/application/FragmentService.test.ts @@ -59,6 +59,7 @@ const fragmentRepository = { updateNotes: jest.fn(), updateLemmatization: jest.fn(), fetchGenres: jest.fn(), + fetchArchaeologies: jest.fn(), updateGenres: jest.fn(), updateScript: jest.fn(), updateDate: jest.fn(), diff --git a/src/fragmentarium/application/FragmentService.ts b/src/fragmentarium/application/FragmentService.ts index 2c0c7defb..c09ce61a1 100644 --- a/src/fragmentarium/application/FragmentService.ts +++ b/src/fragmentarium/application/FragmentService.ts @@ -56,6 +56,7 @@ export interface FragmentRepository { ): Bluebird findInCorpus(number: string): Bluebird> fetchGenres(): Bluebird + fetchArchaeologies(): Bluebird fetchPeriods(): Bluebird updateGenres(number: string, genres: Genres): Bluebird updateScript(number: string, script: Script): Bluebird @@ -176,6 +177,9 @@ export class FragmentService { fetchGenres(): Bluebird { return this.fragmentRepository.fetchGenres() } + fetchArchaeologies(): Bluebird { + return this.fragmentRepository.fetchArchaeologies() + } fetchPeriods(): Bluebird { return this.fragmentRepository.fetchPeriods() diff --git a/src/fragmentarium/infrastructure/FragmentRepository.ts b/src/fragmentarium/infrastructure/FragmentRepository.ts index 6841a81da..0cae0c5c3 100644 --- a/src/fragmentarium/infrastructure/FragmentRepository.ts +++ b/src/fragmentarium/infrastructure/FragmentRepository.ts @@ -196,6 +196,9 @@ class ApiFragmentRepository fetchGenres(): Promise { return this.apiClient.fetchJson('/genres', false) } + fetchArchaeologies(): Promise { + return this.apiClient.fetchJson('/provenances', false) + } fetchPeriods(): Promise { return this.apiClient.fetchJson('/periods', false) diff --git a/src/fragmentarium/ui/ArchaeologySearchForm.sass b/src/fragmentarium/ui/ArchaeologySearchForm.sass new file mode 100644 index 000000000..9cc213404 --- /dev/null +++ b/src/fragmentarium/ui/ArchaeologySearchForm.sass @@ -0,0 +1,3 @@ +.archaeology-selector + &__menu + z-index: 99 !important \ No newline at end of file diff --git a/src/fragmentarium/ui/ArchaeologySearchForm.tsx b/src/fragmentarium/ui/ArchaeologySearchForm.tsx new file mode 100644 index 000000000..d3e63a616 --- /dev/null +++ b/src/fragmentarium/ui/ArchaeologySearchForm.tsx @@ -0,0 +1,38 @@ +import React from 'react' +import withData from 'http/withData' +import Select from 'react-select' +import FragmentService from 'fragmentarium/application/FragmentService' +import './ArchaeologySearchForm.sass' + +export default withData< + { + onChange: (value: string | null) => void + value?: string | null + }, + { fragmentService: FragmentService }, + ReadonlyArray> +>( + ({ data, value, onChange }) => { + const options = data.map((archaeology) => ({ + value: archaeology[0], + label: archaeology[0], + })) + const defaultOption = value ? { value: value, label: value } : null + + return ( + +
+
+ + +
+ + +
+ + + +
@@ -381,7 +463,7 @@ exports[`Searching fragments by transliteration Displays corpus results when cli autocapitalize="none" autocomplete="off" autocorrect="off" - id="react-select-36-input" + id="react-select-42-input" spellcheck="false" style="box-sizing: content-box; width: 2px; border: 0px; opacity: 1; outline: 0; padding: 0px;" tabindex="0" @@ -463,7 +545,7 @@ exports[`Searching fragments by transliteration Displays corpus results when cli autocapitalize="none" autocomplete="off" autocorrect="off" - id="react-select-37-input" + id="react-select-43-input" spellcheck="false" style="box-sizing: content-box; width: 2px; border: 0px; opacity: 1; outline: 0; padding: 0px;" tabindex="0" @@ -533,7 +615,7 @@ exports[`Searching fragments by transliteration Displays corpus results when cli autocapitalize="none" autocomplete="off" autocorrect="off" - id="react-select-34-input" + id="react-select-39-input" spellcheck="false" style="box-sizing: content-box; width: 2px; border: 0px; opacity: 1; outline: 0; padding: 0px;" tabindex="0" @@ -12441,7 +12523,7 @@ exports[`Searching fragments by transliteration Displays corpus results when cli class="chapter-display__toggle" >