Skip to content

Commit

Permalink
Add option to search based on authorized and unauthorized studies
Browse files Browse the repository at this point in the history
  • Loading branch information
jagnathan committed Jan 10, 2024
1 parent 284baba commit 81484bd
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/shared/components/query/filteredSearch/Phrase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class ListPhrase implements Phrase {
for (const fieldName of this.fields) {
let anyPhraseMatch = false;
const fieldValue = study[fieldName];
if (fieldValue) {
if (typeof fieldValue !== 'undefined') {
for (const phrase of this._phraseList) {
anyPhraseMatch =
anyPhraseMatch ||
Expand Down
58 changes: 51 additions & 7 deletions src/shared/components/unknownStudies/UnknownStudiesWarning.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,70 @@
import * as React from 'react';
import { observer } from 'mobx-react';
import { Collapse } from 'react-collapse';
import classnames from 'classnames';

@observer
export default class UnknownStudiesWarning extends React.Component<
{ ids: String[] },
{ studiesCollapsed: boolean },
{}
> {
constructor(props: { ids: String[] }) {
super(props);
this.state = {
studiesCollapsed: true
};
}

toggleStudiesCollapse = () => {
this.setState(prevState => ({
studiesCollapsed: !prevState.studiesCollapsed
}));
}

render() {
const { studiesCollapsed } = this.state;
if (this.props.ids.length > 0) {
return (
<div
className="alert alert-danger"
data-test="unkown-study-warning"
style={{ marginBottom: 0 }}
>
<i className="fa fa-exclamation-triangle"></i> The following
studies do not exist or you do not have access to them:
<ul style={{ margin: '10px 0' }}>
{this.props.ids.map(id => (
<li>{id}</li>
))}
</ul>

<div
style={{
width: '100%',
display: 'flex',
alignItems: 'center',
}}
onClick={() => this.toggleStudiesCollapse()}
>
<i className="fa fa-exclamation-triangle"></i> The following
studies do not exist or you do not have access to them.
<span style={{ float: 'right' }}>
{studiesCollapsed ? (
<i
className={classnames(
'fa fa-chevron-down'
)}
/>
) : (
<i
className={classnames(
'fa fa-chevron-up'
)}
/>
)}
</span>
</div>
<Collapse isOpened={!studiesCollapsed}>
<ul style={{ margin: '10px 0' }}>
{this.props.ids.map(id => (
<li>{id}</li>
))}
</ul>
</Collapse>
Please resubmit your query below.
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/shared/lib/query/QueryParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class QueryParser {
form: {
input: FilterCheckbox,
options:
readPermissions.size >= 1
readPermissions.size > 1
? [
{ value: 'true', displayValue: 'Authorized' },
{
Expand Down

0 comments on commit 81484bd

Please sign in to comment.