From a6ffa099242fe5d957c4a2d45027576e3394c7b6 Mon Sep 17 00:00:00 2001 From: jwnasambu Date: Tue, 18 Jan 2022 12:49:04 +0300 Subject: [PATCH] OCLOMRS-1044:Bug Fix: Pick Concepts from Source and Dictionaries --- .../components/ViewConceptsHeader.tsx | 2 +- src/apps/concepts/pages/ViewConceptsPage.tsx | 41 ++++++++++++------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/apps/concepts/components/ViewConceptsHeader.tsx b/src/apps/concepts/components/ViewConceptsHeader.tsx index 8e9bf461e..8558085b6 100644 --- a/src/apps/concepts/components/ViewConceptsHeader.tsx +++ b/src/apps/concepts/components/ViewConceptsHeader.tsx @@ -112,7 +112,7 @@ const ViewConceptsHeader: React.FC = ({ const [currentSources, setCurrentSources] = useState< { name: string; url: string }[] >(); - const [useSources] = useState(true); + const [useSources, setUseSources] = useState(true); const [currentPage, setCurrentPage] = useState(1); const [apiMethod, setApiMethod] = useState< | typeof sourceApi.sources.retrieve.private diff --git a/src/apps/concepts/pages/ViewConceptsPage.tsx b/src/apps/concepts/pages/ViewConceptsPage.tsx index bcf3b845d..c27db7345 100644 --- a/src/apps/concepts/pages/ViewConceptsPage.tsx +++ b/src/apps/concepts/pages/ViewConceptsPage.tsx @@ -61,8 +61,18 @@ export interface StateProps { loading: boolean; errors?: {}; meta?: { num_found?: number }; - dictionaryMeta?: { num_found?: number, page_number?:number,pages?:number, num_returned?:number }; - sourcesMeta?: { num_found?: number, page_number?:number,pages?:number, num_returned?:number }; + dictionaryMeta?: { + num_found?: number; + page_number?: number; + pages?: number; + num_returned?: number; + }; + sourcesMeta?: { + num_found?: number; + page_number?: number; + pages?: number; + num_returned?: number; + }; profile?: APIProfile; usersOrgs?: APIOrg[]; } @@ -178,8 +188,8 @@ const ViewConceptsPage: React.FC = ({ addToDictionary: dictionaryToAddTo } = queryParams; - const headerQueryParams: { q?: string } = useQueryParams(); - const { q: initialSearch = "" } = queryParams; + const headerQueryParams: { q?: string } = useQueryParams(); + const { q: initialSearch = "" } = queryParams; const sourceUrl = "/sources/"; const collectionsUrl = "/collections/"; @@ -240,14 +250,14 @@ const ViewConceptsPage: React.FC = ({ generalFilters: generalFilters, sourceFilters: sourceFilters, page: 1, - q, + q }, ...params }; return `${conceptsUrl}?${qs.stringify(newParams)}`; }; - const pathUrl = (params: { q?: string }) => { + const pathUrl = (params: { q?: string }) => { const newParams: { q?: string } = { ...headerQueryParams, ...params @@ -322,9 +332,9 @@ const ViewConceptsPage: React.FC = ({ gimmeAUrl={gimmeAUrl} addConceptToDictionary={dictionaryToAddTo} sources={sources} - dictionaries={dictionaries} - showOnlyVerified={showOnlyVerified} - toggleShowVerified={(e)=>setShowOnlyVerified(e.target.checked)} + dictionaries={dictionaries} + showOnlyVerified={showOnlyVerified} + toggleShowVerified={(e) => setShowOnlyVerified(e.target.checked)} goTo={goTo} initialSearch={initialSearch} pathUrl={pathUrl} @@ -413,7 +423,7 @@ const ViewConceptsPage: React.FC = ({ [ getContainerIdFromUrl(linkedSource), ...FILTER_SOURCE_IDS - ].filter(source => source !== undefined) as string[] + ].filter((source) => source !== undefined) as string[] } url={gimmeAUrl()} /> @@ -437,8 +447,8 @@ const ViewConceptsPage: React.FC = ({ const mapStateToProps = (state: AppState) => { const dictionary = dictionarySelector(state); const concepts = state.concepts.concepts.items || []; - const dictionaryConcepts = dictionary?.references?.map(r => r.expression); - const modifiedConcepts = concepts?.map(c => + const dictionaryConcepts = dictionary?.references?.map((r) => r.expression); + const modifiedConcepts = concepts?.map((c) => includes(dictionaryConcepts, c.version_url) ? { ...c, added: true } : { ...c } @@ -458,8 +468,11 @@ const mapStateToProps = (state: AppState) => { meta: state.concepts.concepts ? state.concepts.concepts.responseMeta : undefined, - dictionaryMeta: state.dictionaries.dictionaries[PUBLIC_DICTIONARIES_ACTION_INDEX] - ? state.dictionaries.dictionaries[PUBLIC_DICTIONARIES_ACTION_INDEX].responseMeta + dictionaryMeta: state.dictionaries.dictionaries[ + PUBLIC_DICTIONARIES_ACTION_INDEX + ] + ? state.dictionaries.dictionaries[PUBLIC_DICTIONARIES_ACTION_INDEX] + .responseMeta : undefined, sourcesMeta: state.sources.sources[PUBLIC_SOURCES_ACTION_INDEX] ? state.sources.sources[PUBLIC_SOURCES_ACTION_INDEX].responseMeta