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 icons in survey advanced search status filter #1821

Merged
merged 2 commits into from
Jul 11, 2023
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
19 changes: 10 additions & 9 deletions met-api/src/met_api/models/survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,18 @@ def filter_by_search_options(cls, survey_search_options: SurveySearchOptions, qu
if survey_search_options.exclude_template:
query = query.filter(Survey.is_template.is_(False))

if survey_search_options.is_unlinked:
query = query.filter(Survey.engagement_id.is_(None))

# filter by status
status_filters = []
if survey_search_options.is_linked:
query = query.filter(Survey.engagement_id.isnot(None))

if survey_search_options.is_hidden:
query = query.filter(Survey.is_hidden.is_(True))

status_filters.append(Survey.engagement_id.isnot(None))
if survey_search_options.is_unlinked:
status_filters.append(Survey.engagement_id.is_(None))
if survey_search_options.is_template:
query = query.filter(Survey.is_template.is_(True))
status_filters.append(Survey.is_template.is_(True))
if survey_search_options.is_hidden:
status_filters.append(Survey.is_hidden.is_(True))
if status_filters:
query = query.filter(or_(*status_filters))

query = cls._filter_by_created_date(query, survey_search_options)

Expand Down
40 changes: 36 additions & 4 deletions met-web/src/components/survey/listing/AdvancedSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import {
} from '@mui/material';
import { MetLabel, PrimaryButton, SecondaryButton } from 'components/common';
import { AdvancedSearchFilters, SurveyListingContext } from './SurveyListingContext';
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
import CheckIcon from '@mui/icons-material/Check';
import LinkIcon from '@mui/icons-material/Link';
import DashboardIcon from '@mui/icons-material/Dashboard';
import { Palette } from 'styles/Theme';

export const AdvancedSearch = () => {
const isMediumScreen = useMediaQuery((theme: Theme) => theme.breakpoints.down('lg'));
Expand Down Expand Up @@ -58,21 +63,48 @@ export const AdvancedSearch = () => {
<FormGroup row={isMediumScreen}>
<FormControlLabel
control={<Checkbox checked={status.hidden} onChange={handleStatusChange} name="hidden" />}
label="Hidden"
label={
<Stack direction="row" alignItems="center" spacing={1}>
<VisibilityOffIcon fontSize="small" />
<span>Hidden</span>
</Stack>
}
/>
<FormControlLabel
control={
<Checkbox checked={status.template} onChange={handleStatusChange} name="template" />
}
label="Template"
label={
<Stack direction="row" alignItems="center" spacing={1}>
<DashboardIcon fontSize="small" />
<span>Template</span>
</Stack>
}
/>
<FormControlLabel
control={<Checkbox checked={status.ready} onChange={handleStatusChange} name="ready" />}
label="Ready"
label={
<>
<Stack direction="row" alignItems="center" spacing={1}>
<CheckIcon
fontSize="small"
sx={{ stroke: Palette.icons.surveyReady, strokeWidth: '2' }}
/>
<span>Ready</span>
</Stack>
</>
}
/>
<FormControlLabel
control={<Checkbox checked={status.linked} onChange={handleStatusChange} name="linked" />}
label="Linked"
label={
<>
<Stack direction="row" alignItems="center" spacing={1}>
<LinkIcon fontSize="small" />
<span>Linked</span>
</Stack>
</>
}
/>
</FormGroup>
</FormControl>
Expand Down
Loading