Skip to content

Commit 3b2effd

Browse files
authored
added visual feedback to filters (#6907)
1 parent d5d1bbb commit 3b2effd

File tree

3 files changed

+71
-12
lines changed

3 files changed

+71
-12
lines changed

app/react/App/styles/globals.css

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,6 +1833,10 @@ input[type="range"]::-ms-fill-lower {
18331833
margin-top: 1.5rem;
18341834
}
18351835

1836+
.ml-1 {
1837+
margin-left: 0.25rem;
1838+
}
1839+
18361840
.block {
18371841
display: block;
18381842
}
@@ -2924,6 +2928,11 @@ input[type="range"]::-ms-fill-lower {
29242928
background-color: rgb(67 56 202 / var(--tw-bg-opacity));
29252929
}
29262930

2931+
.bg-primary-900 {
2932+
--tw-bg-opacity: 1;
2933+
background-color: rgb(49 46 129 / var(--tw-bg-opacity));
2934+
}
2935+
29272936
.bg-red-100 {
29282937
--tw-bg-opacity: 1;
29292938
background-color: rgb(253 232 232 / var(--tw-bg-opacity));
@@ -3125,6 +3134,16 @@ input[type="range"]::-ms-fill-lower {
31253134
padding-bottom: 3px;
31263135
}
31273136

3137+
.py-\[2px\] {
3138+
padding-top: 2px;
3139+
padding-bottom: 2px;
3140+
}
3141+
3142+
.py-\[1px\] {
3143+
padding-top: 1px;
3144+
padding-bottom: 1px;
3145+
}
3146+
31283147
.pb-14 {
31293148
padding-bottom: 3.5rem;
31303149
}
@@ -3270,6 +3289,14 @@ input[type="range"]::-ms-fill-lower {
32703289
line-height: 1rem;
32713290
}
32723291

3292+
.text-\[8px\] {
3293+
font-size: 8px;
3294+
}
3295+
3296+
.text-\[10px\] {
3297+
font-size: 10px;
3298+
}
3299+
32733300
.font-black {
32743301
font-weight: 900;
32753302
}
@@ -3519,6 +3546,11 @@ input[type="range"]::-ms-fill-lower {
35193546
color: rgb(114 59 19 / var(--tw-text-opacity));
35203547
}
35213548

3549+
.text-primary-900 {
3550+
--tw-text-opacity: 1;
3551+
color: rgb(49 46 129 / var(--tw-text-opacity));
3552+
}
3553+
35223554
.underline {
35233555
text-decoration-line: underline;
35243556
}

app/react/V2/Routes/Settings/IX/IXSuggestions.tsx

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,24 @@ const ixmessages = {
6060
};
6161

6262
const IXSuggestions = () => {
63-
const { suggestions, extractor, templates, aggregation, currentStatus, totalPages } =
64-
useLoaderData() as {
65-
totalPages: number;
66-
suggestions: TableSuggestion[];
67-
extractor: IXExtractorInfo;
68-
templates: ClientTemplateSchema[];
69-
aggregation: any;
70-
currentStatus: ixStatus;
71-
_id: string;
72-
};
63+
const {
64+
suggestions,
65+
extractor,
66+
templates,
67+
aggregation,
68+
currentStatus,
69+
totalPages,
70+
activeFilters,
71+
} = useLoaderData() as {
72+
totalPages: number;
73+
suggestions: TableSuggestion[];
74+
extractor: IXExtractorInfo;
75+
templates: ClientTemplateSchema[];
76+
aggregation: any;
77+
currentStatus: ixStatus;
78+
_id: string;
79+
activeFilters: number;
80+
};
7381

7482
const [currentSuggestions, setCurrentSuggestions] = useState<TableSuggestion[]>(suggestions);
7583
const [property, setProperty] = useState<ClientPropertySchema>();
@@ -248,6 +256,7 @@ const IXSuggestions = () => {
248256
onFiltersButtonClicked={() => {
249257
setSidepanel('filters');
250258
}}
259+
activeFilters={activeFilters}
251260
/>
252261
}
253262
enableSelection
@@ -366,10 +375,14 @@ const IXSuggestionsLoader =
366375
if (!extractorId) throw new Error('extractorId is required');
367376
const searchParams = new URLSearchParams(request.url.split('?')[1]);
368377
const filter: any = { extractorId };
378+
let activeFilters = 0;
369379
if (searchParams.has('filter')) {
370380
filter.customFilter = JSON.parse(searchParams.get('filter')!);
381+
activeFilters = [
382+
...Object.values(filter.customFilter.labeled),
383+
...Object.values(filter.customFilter.nonLabeled),
384+
].filter(Boolean).length;
371385
}
372-
373386
const sortingOption = searchParams.has('sort') ? searchParams.get('sort') : undefined;
374387

375388
const suggestionsList: { suggestions: EntitySuggestionType[]; totalPages: number } =
@@ -396,6 +409,7 @@ const IXSuggestionsLoader =
396409
templates,
397410
aggregation,
398411
currentStatus: currentStatus.status,
412+
activeFilters,
399413
};
400414
};
401415

app/react/V2/Routes/Settings/IX/components/SuggestionsTitle.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@ import {
99
NumericPropertyIcon,
1010
TextPropertyIcon,
1111
SelectPropertyIcon,
12+
RelationshipPropertyIcon,
1213
} from 'app/V2/Components/CustomIcons';
1314

1415
const SuggestionsTitle = ({
1516
property,
1617
templates,
1718
onFiltersButtonClicked,
19+
activeFilters,
1820
}: {
1921
property: string;
2022
templates: ClientTemplateSchema[];
2123
onFiltersButtonClicked: () => void;
24+
activeFilters: number;
2225
}) => {
2326
const allProperties = [...(templates[0].commonProperties || []), ...templates[0].properties];
2427
const template = allProperties.find(prop => prop.name === property);
@@ -39,6 +42,9 @@ const SuggestionsTitle = ({
3942
case 'multiselect':
4043
propGraphics = <SelectPropertyIcon className="w-3" />;
4144
break;
45+
case 'relationship':
46+
propGraphics = <RelationshipPropertyIcon className="w-3" />;
47+
break;
4248
default:
4349
propGraphics = <TextPropertyIcon className="w-3" />;
4450
}
@@ -64,8 +70,15 @@ const SuggestionsTitle = ({
6470

6571
<div className="flex-none">
6672
<Button size="small" styling="light" onClick={onFiltersButtonClicked}>
67-
<FunnelIcon className="inline w-5 px-1 text-gray-800" />
73+
<FunnelIcon
74+
className={`inline w-4 mr-2 ${activeFilters > 0 ? 'text-primary-900' : 'text-gray-800'} `}
75+
/>
6876
<Translate>Stats & Filters</Translate>
77+
{activeFilters > 0 && (
78+
<span className="px-3 py-[2px] ml-2 text-xs text-white rounded-md bg-primary-900">
79+
{activeFilters}
80+
</span>
81+
)}
6982
</Button>
7083
</div>
7184
</div>

0 commit comments

Comments
 (0)