add clear link for sort

This commit is contained in:
Stephanie Yang 2021-07-28 11:38:13 -05:00
parent d8ac3251f6
commit 8dc2105b63
4 changed files with 16 additions and 7 deletions

View file

@ -3,7 +3,7 @@
margin-bottom: 16px;
}
.filtersHeader {
.header {
display: flex;
align-items: center;
justify-content: space-between;

View file

@ -98,7 +98,7 @@ export const GroupByBuilder: FC<GroupByBuilderProps> = ({
/>
<div className={css.filtersSection}>
<div className={css.filtersHeader}>
<div className={css.header}>
<Typography variant="caption" color="textSecondary">
Filter (optional)
{filters.length > 0 && (
@ -144,9 +144,17 @@ export const GroupByBuilder: FC<GroupByBuilderProps> = ({
</div>
<div className={css.sortSection}>
<Typography variant="caption" color="textSecondary">
Sort (optional)
</Typography>
<div className={css.header}>
<Typography variant="caption" color="textSecondary">
Sort (optional)
</Typography>
<span
className={css.textLink}
onClick={() => onChange({ ...query, sort: [] })}
>
Clear
</span>
</div>
<GroupBySort
sort={sort ? sort : []}
onUpdate={(value) => {

View file

@ -20,7 +20,7 @@ export const GroupBySort: FC<GroupBySortProps> = ({
showErrors,
onUpdate
}) => {
const hasPrimary = sort.length > 0;
const hasPrimary = sort.length > 0 && sort[0].sortValue;
const primary = hasPrimary ? sort[0].sortValue.split(' ')[0] : '';
const hasSecondary = sort.length > 1;
const secondary = hasSecondary ? sort[1].sortValue.split(' ')[0] : '';
@ -76,6 +76,7 @@ export const GroupBySort: FC<GroupBySortProps> = ({
value={hasPrimary ? sort[0].sortValue : ''}
options={sortOptions}
onChange={(value) => onPrimaryChange(value)}
allowEmpty={true}
/>
{primary.includes('sum') ? (
@ -99,6 +100,7 @@ export const GroupBySort: FC<GroupBySortProps> = ({
(option) => !option.value.includes(primary)
)}
onChange={(value) => onSecondaryChange(value)}
allowEmpty={true}
/>
{secondary.includes('sum') ? (

View file

@ -12,7 +12,6 @@ import {
} from 'App/QueryBuilder/rowTypes';
import { RowCall } from './RowCall';
import css from './RowCallBuilder.module.scss';
import { useEffect } from 'react';
type RowCallBuilderProps = {
rowCalls: RowGrouping[];