Skip to content

Commit

Permalink
Roll back to prior revision since backend support for protein name se…
Browse files Browse the repository at this point in the history
…arch is not ready
  • Loading branch information
jimmyzhen committed Aug 16, 2024
1 parent f45b8c3 commit bc699d2
Showing 1 changed file with 29 additions and 33 deletions.
62 changes: 29 additions & 33 deletions src/Search/searchPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import IconSet from '../lib/iconSet';
import { trackEvent } from '../GoogleAnalytics/googleAnalytics';
import { genes } from '../data/genes';
import { metabolites } from '../data/metabolites';
import { proteins } from '../data/proteins';
import searchStructuredData from '../lib/searchStructuredData/search';
import UserSurveyModal from '../UserSurvey/userSurveyModal';

Expand Down Expand Up @@ -111,20 +110,6 @@ export function SearchPage({
return null;
}

// get options based on selected search context
function getOptions() {
switch (searchParams.ktype) {
case 'gene':
return genes;
case 'metab':
return metabolites;
case 'protein':
return proteins;
default:
return [];
}
}

// render placeholder text in primary search input field
function renderPlaceholder() {
if (searchParams.ktype === 'protein') {
Expand All @@ -145,7 +130,7 @@ export function SearchPage({
multiSelections.forEach((item) => newArr.push(item.id));
return newArr.join(', ');
}
// Handle manually entered gene/metabolite/protein input
// Handle manually entered gene/metabolite input
if (inputEl.value && inputEl.value.length) {
const str = inputEl.value;
if (searchParams.ktype === 'gene') {
Expand All @@ -158,8 +143,14 @@ export function SearchPage({
}

// Clear manually entered gene/protein/metabolite input
function clearGeneInput() {
if (inputEl && inputEl.value && inputEl.value.length) {
function clearGeneInput(ktype) {
const inputElProtein = document.querySelector('.search-input-kype');

if (ktype && ktype === 'protein') {
if (inputElProtein && inputElProtein.value && inputElProtein.value.length) {
inputElProtein.value = '';
}
} else if (inputEl && inputEl.value && inputEl.value.length) {
inputRef.current.clear();
}
}
Expand Down Expand Up @@ -214,18 +205,22 @@ export function SearchPage({
pest_control_rodent
</span>
</div>
<Typeahead
id="dea-search-typeahead-multiple"
labelKey="id"
multiple
onChange={setMultiSelections}
options={getOptions()}
placeholder={renderPlaceholder()}
selected={multiSelections}
minLength={2}
ref={inputRef}
/>
{/*
{searchParams.ktype === 'gene' ||
searchParams.ktype === 'metab' ? (
<Typeahead
id="dea-search-typeahead-multiple"
labelKey="id"
multiple
onChange={setMultiSelections}
options={
searchParams.ktype === 'gene' ? genes : metabolites
}
placeholder={renderPlaceholder()}
selected={multiSelections}
minLength={2}
ref={inputRef}
/>
) : null}
{searchParams.ktype === 'protein' && (
<input
type="text"
Expand All @@ -237,7 +232,6 @@ export function SearchPage({
onChange={(e) => changeParam('keys', e.target.value)}
/>
)}
*/}
</div>
<PrimaryOmicsFilter
omics={searchParams.omics}
Expand Down Expand Up @@ -279,7 +273,9 @@ export function SearchPage({
type="button"
className="btn btn-secondary search-reset ml-2"
onClick={() => {
clearGeneInput();
clearGeneInput(
searchParams.ktype === 'protein' ? 'protein' : null
);
resetSearch('all');
setMultiSelections([]);
}}
Expand Down Expand Up @@ -481,7 +477,7 @@ function RadioButton({
{
keyType: 'protein',
id: 'inlineRadioProtein',
label: 'Protein Name',
label: 'Protein ID',
},
{
keyType: 'metab',
Expand Down

0 comments on commit bc699d2

Please sign in to comment.