Skip to content

Commit 2a5d2d3

Browse files
author
Sebastian Benjamin
committed
Add the ability to trigger a searchString=all search
1 parent 10b4a83 commit 2a5d2d3

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

jbrowse/src/client/JBrowse/VariantSearch/components/ArrowPagination.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const ArrowPagination: React.FC<ArrowPaginationProps> = ({ offset, onOffsetChang
2424
<IconButton onClick={handleLeftClick}>
2525
<ArrowBackIosIcon />
2626
</IconButton>
27-
<span style={{marginTop: "4px"}}><strong>Results {offset*100}-{(offset+1)*100}</strong></span>
27+
<span style={{marginTop: "4px"}}><strong>Page {offset+1}</strong></span>
2828
<IconButton onClick={handleRightClick}>
2929
<ArrowForwardIosIcon />
3030
</IconButton>

jbrowse/src/client/JBrowse/VariantSearch/components/FilterForm.tsx

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,17 @@ const FilterForm = (props: FilterFormProps ) => {
106106
};
107107

108108
const handleRemoveFilter = (index) => {
109+
// If it's the last filter, just reset its values to default empty values
110+
if (filters.length === 1) {
111+
localSetFilters([{ field: "", operator: "", value: "" }]);
112+
} else {
113+
// Otherwise, remove the filter normally
109114
localSetFilters(
110115
filters.filter((filter, i) => {
111116
return i !== index;
112117
})
113118
);
114-
};
119+
}};
115120

116121
const handleFilterChange = (index, key, value) => {
117122
const newFilters = filters.map((filter, i) => {
@@ -129,29 +134,30 @@ const handleSubmit = (event) => {
129134
const highlightedInputs = {};
130135

131136
filters.forEach((filter, index) => {
132-
highlightedInputs[index] = { field: false, operator: false, value: false };
137+
highlightedInputs[index] = { field: false, operator: false, value: false };
133138

134-
if (filter.field === '') {
135-
highlightedInputs[index].field = true;
136-
}
139+
if (filter.field === '') {
140+
highlightedInputs[index].field = true;
141+
}
137142

138-
if (filter.operator === '') {
139-
highlightedInputs[index].operator = true;
140-
}
143+
if (filter.operator === '') {
144+
highlightedInputs[index].operator = true;
145+
}
141146

142-
if (filter.value === '') {
143-
highlightedInputs[index].value = true;
144-
}
145-
});
147+
if (filter.value === '') {
148+
highlightedInputs[index].value = true;
149+
}
150+
});
146151

147-
setHighlightedInputs(highlightedInputs);
152+
const isSingleEmptyFilter = filters.length === 1 && !filters[0].field && !filters[0].operator && !filters[0].value;
148153

149-
if (!Object.values(highlightedInputs).some(v => (v as any).field || (v as any).operator || (v as any).value)) {
150-
handleQuery(filters);
151-
setFilters(filters);
152-
handleClose();
153-
}
154-
};
154+
setHighlightedInputs(highlightedInputs);
155+
if (isSingleEmptyFilter || !Object.values(highlightedInputs).some(v => (v as any).field || (v as any).operator || (v as any).value)) {
156+
handleQuery(filters);
157+
setFilters(filters);
158+
handleClose();
159+
}
160+
};
155161

156162
return (
157163
<Card className={classes.card} elevation={0}>
@@ -260,15 +266,13 @@ const handleSubmit = (event) => {
260266
/>
261267
)}
262268

263-
{filters.length > 1 && (
264269
<Button
265270
variant="contained"
266271
color="primary"
267272
onClick={() => handleRemoveFilter(index)}
268273
>
269274
Remove Filter
270275
</Button>
271-
)}
272276
</div>
273277
))}
274278
</div>

0 commit comments

Comments
 (0)