Skip to content
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

Add quick oql edit feature to results view page next to current gene list #2994

Merged
merged 1 commit into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 53 additions & 3 deletions src/pages/resultsView/ResultsViewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as _ from 'lodash';
import $ from 'jquery';
import URL from 'url';
import { inject, observer } from 'mobx-react';
import { computed, observable, reaction, runInAction } from 'mobx';
import {action, computed, observable, reaction, runInAction} from 'mobx';
import { ResultsViewPageStore } from './ResultsViewPageStore';
import CancerSummaryContainer from 'pages/resultsView/cancerSummary/CancerSummaryContainer';
import Mutations from './mutation/Mutations';
Expand Down Expand Up @@ -47,6 +47,7 @@ import LoadingIndicator from "shared/components/loadingIndicator/LoadingIndicato
import onMobxPromise from "shared/lib/onMobxPromise";
import {createQueryStore} from "shared/lib/createQueryStore";
import {handleLegacySubmission, handlePostedSubmission} from "shared/lib/redirectHelpers";
import OQLTextArea, {GeneBoxType} from "shared/components/GeneSelectionBox/OQLTextArea";

function initStore(appStore: AppStore, urlWrapper: ResultsViewURLWrapper) {
const resultsViewPageStore = new ResultsViewPageStore(
Expand Down Expand Up @@ -94,6 +95,8 @@ export default class ResultsViewPage extends React.Component<

private urlWrapper: ResultsViewURLWrapper;

@observable showOQLEditor = false;

@observable showTabs = true;

constructor(props: IResultsViewPageProps) {
Expand Down Expand Up @@ -476,6 +479,29 @@ export default class ResultsViewPage extends React.Component<
return isRoutedTo || (!isExcludedInList && !isExcluded);
}

@computed get quickOQLSubmitButtion(){
return ( <>
<button className={"btn btn-primary btn-sm"} style={{marginLeft:10}} onClick={this.handleQuickOQLSubmission}>Go</button>
&nbsp;
<button className={'btn btn-link btn-sm'} onClick={this.toggleOQLEditor}>Cancel</button>
</>)
}

@autobind
@action
handleQuickOQLSubmission(){
this.showOQLEditor = false;
this.urlWrapper.updateURL({
gene_list:this.oqlSubmission
});
}

@autobind
@action
toggleOQLEditor(){
this.showOQLEditor = !this.showOQLEditor;
}

@autobind
private getTabHref(tabId: string) {
return URL.format({
Expand All @@ -485,6 +511,8 @@ export default class ResultsViewPage extends React.Component<
});
}

@observable oqlSubmission = "";

@computed get pageContent() {
if (this.resultsViewPageStore.invalidStudyIds.result.length > 0) {
return (
Expand Down Expand Up @@ -543,10 +571,32 @@ export default class ResultsViewPage extends React.Component<
<QuerySummary
routingStore={this.props.routing}
store={this.resultsViewPageStore}
onToggleQueryFormVisiblity={visible => {
this.showTabs = visible;
onToggleQueryFormVisibility={visible => {
runInAction(()=>{
this.showTabs = visible;
this.showOQLEditor = false;
});
}}
onToggleOQLEditUIVisibility={this.toggleOQLEditor}
/>

{
(this.showOQLEditor) && (
<div className={'quick_oql_edit'}>
<OQLTextArea
inputGeneQuery={this.resultsViewPageStore.oqlText}
validateInputGeneQuery={true}
callback={(...args)=>{
this.oqlSubmission = args[2];
}}
location={GeneBoxType.DEFAULT}
submitButton={this.quickOQLSubmitButtion}
/>

</div>
)
}

</div>

{// we don't show the result tabs if we don't have valid query
Expand Down
17 changes: 15 additions & 2 deletions src/pages/resultsView/querySummary/QuerySummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,20 @@ import ResultsPageSettings from "../settings/ResultsPageSettings";
import {createQueryStore} from "shared/lib/createQueryStore";
import _ from "lodash";

interface QuerySummaryProps {
routingStore:ExtendedRouterStore;
store: ResultsViewPageStore;
onToggleQueryFormVisibility:(visible:boolean)=>void;
onToggleOQLEditUIVisibility:()=>void;
}

@observer
export default class QuerySummary extends React.Component<{ routingStore:ExtendedRouterStore, store: ResultsViewPageStore, onToggleQueryFormVisiblity:(visible:boolean)=>void }, {}> {
export default class QuerySummary extends React.Component<QuerySummaryProps, {}> {

@autobind
@action
private toggleQueryFormVisibility() {
this.props.onToggleQueryFormVisiblity(this.props.store.queryFormVisible);
this.props.onToggleQueryFormVisibility(this.props.store.queryFormVisible);
// if clicked the query button in the download tab and want to close the query form, clear the selected sample ids
if (this.props.store.modifyQueryParams && this.props.store.queryFormVisible === true) {
this.props.store.modifyQueryParams = undefined;
Expand Down Expand Up @@ -80,6 +87,12 @@ export default class QuerySummary extends React.Component<{ routingStore:Extende

&nbsp;-&nbsp;
{getGeneSummary(this.props.store.hugoGeneSymbols)}
&nbsp;
<DefaultTooltip overlay={'Edit genes or OQL'}>
<a onClick={this.props.onToggleOQLEditUIVisibility}>
<i className={'fa fa-pencil'}></i>
</a>
</DefaultTooltip>
</div>
);
}
Expand Down
11 changes: 11 additions & 0 deletions src/pages/resultsView/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,14 @@
width: 100%;
max-width: 555px;
}

.quick_oql_edit {
display:flex;
margin-top:10px;
align-items: flex-start;

.oqlValidationContainer {
min-height:27px;
}

}
9 changes: 7 additions & 2 deletions src/shared/components/GeneSelectionBox/OQLTextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface IGeneSelectionBoxProps {
validateInputGeneQuery?: boolean;
location?: GeneBoxType;
textBoxPrompt?: string;
submitButton?:JSX.Element;
callback?: (
oql: {
query: SingleGeneQuery[];
Expand Down Expand Up @@ -264,7 +265,7 @@ export default class OQLTextArea extends React.Component<
render() {
return (
<div className={styles.genesSelection}>

<div className={styles.topRow}>
<textarea
ref={this.textAreaRef as any}
onFocus={this.onFocus}
Expand All @@ -279,7 +280,11 @@ export default class OQLTextArea extends React.Component<
data-test="geneSet"
/>

<div className={classnames({ [styles.minWidthContainer]: (this.props.location === GeneBoxType.DEFAULT) })}>
{
(this.props.submitButton) && this.props.submitButton
}
</div>
<div className={'oqlValidationContainer'}>
<GeneSymbolValidator
focus={this.props.focus}
geneQuery={this.queryToBeValidated}
Expand Down
9 changes: 7 additions & 2 deletions src/shared/components/GeneSelectionBox/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
margin: 0px 5px 3px 0;
padding: 2px 5px;
border-radius: $border-radius-base;
font-size:.8rem;
}

.minWidthContainer {
min-height:25px;
.topRow {
display:flex;
align-items: flex-start;
margin-bottom:5px;
}


.genesSelection {

textarea.default {
width: 555px;
resize: vertical;
Expand Down
4 changes: 4 additions & 0 deletions src/shared/components/query/styles/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ div.SelectedStudiesWindow {
margin-bottom: 8px;
}

:global(.oqlValidationContainer) {
min-height:27px;
}

.buttonRow {
margin-bottom: 8px;
justify-content: space-between;
Expand Down