Skip to content

Commit

Permalink
OCLOMRS-1044:Bug Fix: Pick Concepts from Source and Dictionaries
Browse files Browse the repository at this point in the history
  • Loading branch information
jwamalwa committed Jan 18, 2022
1 parent 8093362 commit a6ffa09
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/apps/concepts/components/ViewConceptsHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const ViewConceptsHeader: React.FC<Props> = ({
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
Expand Down
41 changes: 27 additions & 14 deletions src/apps/concepts/pages/ViewConceptsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
}
Expand Down Expand Up @@ -178,8 +188,8 @@ const ViewConceptsPage: React.FC<Props> = ({
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/";
Expand Down Expand Up @@ -240,14 +250,14 @@ const ViewConceptsPage: React.FC<Props> = ({
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
Expand Down Expand Up @@ -322,9 +332,9 @@ const ViewConceptsPage: React.FC<Props> = ({
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}
Expand Down Expand Up @@ -413,7 +423,7 @@ const ViewConceptsPage: React.FC<Props> = ({
[
getContainerIdFromUrl(linkedSource),
...FILTER_SOURCE_IDS
].filter(source => source !== undefined) as string[]
].filter((source) => source !== undefined) as string[]
}
url={gimmeAUrl()}
/>
Expand All @@ -437,8 +447,8 @@ const ViewConceptsPage: React.FC<Props> = ({
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 }
Expand All @@ -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
Expand Down

0 comments on commit a6ffa09

Please sign in to comment.