Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 8
Add concept picker and Ontology filters to data region filter dialog#2205
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
d4acc6205105733344862a162d37f9c7adda7e123c2c0a6aab82ee99cee084b6d999a97520e3f01908011e1d463cb88b338b795d2631e086e97fc99750b3f472bb3d5213f82d474938266c01becd10f3b02191cefd2407876af308c6966732ed6ab1942d95aa9b5f894d5ee715494959e1e918e939893fFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| @import "@labkey/components-scss"; | ||
| .concept-filter-view { | ||
| margin: 0 0 10px; | ||
| padding: 5px 10px; | ||
| a.show-toggle { | ||
| cursor: pointer; | ||
| } | ||
| &.collapsed { | ||
| margin: unset; | ||
| padding: 2px 0 10px; | ||
| border: unset; | ||
| a.show-toggle { | ||
| margin-left: 105px; | ||
| } | ||
| } | ||
| .ontology-browser-container { | ||
| .concept-search-container { | ||
| padding-bottom: 10px; | ||
| .result-menu { | ||
| padding-right: 8px; //Allow room for scroll bar | ||
| min-width: 400px; | ||
| max-width: 458px; | ||
| max-height: 320px; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import React, { FC, memo, useCallback, useEffect, useState } from 'react'; | ||
| import { OntologyBrowserFilterPanel, } from '@labkey/components'; | ||
| import classNames from 'classnames'; | ||
| import './ConceptFilterView.scss'; | ||
| import { Filter, } from '@labkey/api'; | ||
| type ChangeListener = (newValue: string) => void; | ||
| type FilterChangeListener = (filter: Filter.IFilterType) => void; | ||
| type CollapseChangeListener = (collapse: boolean) => void; | ||
| export interface AppContext { | ||
| ontologyId: string; | ||
| initFilterValue?: string; | ||
| initFilter?: Filter.IFilterType; | ||
| subscribeFilterValue: (listener: ChangeListener) => void; | ||
| unsubscribeFilterValue: (listener:ChangeListener) => void; | ||
| onFilterChange: (filterValue: string) => void; | ||
| subscribeFilterTypeChanged: (listener: FilterChangeListener) => void; | ||
| unsubscribeFilterTypeChanged: (listener: FilterChangeListener) => void; | ||
| loadListener: () => void; | ||
| subscribeCollapse: (listener: CollapseChangeListener) => void; | ||
| unsubscribeCollapse: () => void; | ||
| onOpen: () => void; | ||
| } | ||
| interface Props { | ||
| context: AppContext; | ||
| } | ||
| export const ConceptFilterView: FC<Props> = memo(props => { | ||
| const { | ||
| initFilterValue, | ||
| initFilter, | ||
| onFilterChange, | ||
| ontologyId, | ||
| subscribeFilterValue, | ||
| unsubscribeFilterValue, | ||
| subscribeFilterTypeChanged, | ||
| unsubscribeFilterTypeChanged, | ||
| loadListener, | ||
| subscribeCollapse, | ||
| unsubscribeCollapse, | ||
| onOpen, | ||
| } = props.context; | ||
| const [filterValue, setFilterValue] = useState(initFilterValue); | ||
| const [filter, setFilter] = useState(initFilter); | ||
| const [collapsed, setCollapsed] = useState<boolean>(true); | ||
| const clickHandler = useCallback(() => { | ||
| setCollapsed(!collapsed); | ||
| onOpen(); | ||
| },[collapsed, setCollapsed]); | ||
| useEffect(() => { | ||
| const handleValueChange = (newValue: string) => { | ||
| setFilterValue(newValue); | ||
| }; | ||
| subscribeFilterValue(handleValueChange); | ||
| return () => unsubscribeFilterValue(handleValueChange); | ||
| },[setFilterValue, subscribeFilterValue, unsubscribeFilterValue]); | ||
| useEffect(() => { | ||
| const handleFilterChange = (newValue: Filter.IFilterType): void => { | ||
| setFilter(newValue); | ||
| }; | ||
| subscribeFilterTypeChanged(handleFilterChange); | ||
| return () => unsubscribeFilterTypeChanged(handleFilterChange); | ||
| },[setFilter, subscribeFilterTypeChanged, unsubscribeFilterTypeChanged]); | ||
| useEffect(() => { | ||
| const handleCollapse = (collapse: boolean): void => { | ||
| setCollapsed(true); | ||
| } | ||
| subscribeCollapse(handleCollapse); | ||
| return () => unsubscribeCollapse(); | ||
| }); | ||
| useEffect(() => { | ||
| loadListener(); | ||
| },[]); | ||
| //No need to show the filter tree if a value can't be set. | ||
| if (!filter?.isDataValueRequired()) | ||
| return null; | ||
| return ( | ||
| <div className={classNames('concept-filter-view', { collapsed, })}> | ||
| <a className='show-toggle' | ||
| onClick={clickHandler}>{collapsed ? 'Find Concepts By Tree' : 'Close Browser'}</a> | ||
| {!collapsed && | ||
| <OntologyBrowserFilterPanel ontologyId={ontologyId} filterValue={filterValue} filterType={filter} | ||
| onFilterChange={onFilterChange}/>} | ||
| </div> | ||
| ); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import React from 'react'; | ||
| import ReactDOM from 'react-dom'; | ||
| import { App } from '@labkey/api'; | ||
| import {AppContext, ConceptFilterView} from './ConceptFilterView'; | ||
| App.registerApp<AppContext>('conceptFilter', (target, ctx) => { | ||
| ReactDOM.render(<ConceptFilterView context={ctx} />, document.getElementById(target)); | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.