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 enduser filter #647

Merged
merged 1 commit into from
Jun 5, 2024
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
4 changes: 4 additions & 0 deletions ui/webapp/src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ export const COMMON_FILTERS: FilterSection[] = [
value: 'specification',
name: 'Specification',
},
{
value: 'enduser',
name: 'End user',
},
],
},
];
Expand Down
2 changes: 1 addition & 1 deletion ui/webapp/src/layout/explore/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ interface Props {
const TITLE_GAP = 40;
const CONTROLS_WIDTH = 102 + 49 + 160 + 101 + 24 + 32; // Filters + Group legend + View Mode + Zoom + Right margin + Loading
const CONTROLS_CARD_WIDTH = CONTROLS_WIDTH + 0 + 435 - 101; // + Classify/Sort - Zoom
const EXTRA_FILTERS = ['specification'];
const EXTRA_FILTERS = ['specification', 'enduser'];
const DELAY_ACTIONS = 40;

const Explore = (props: Props) => {
Expand Down
4 changes: 0 additions & 4 deletions ui/webapp/src/layout/logos/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ const Logos = () => {
list = itemsDataGetter.getItemsByEndUser() || [];
break;

case 'allenduser':
list = itemsDataGetter.getAllEndUserItems() || [];
break;

default:
break;
}
Expand Down
4 changes: 4 additions & 0 deletions ui/webapp/src/utils/filterData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const filterData = (items: Item[], activeFilters: ActiveFilters): Item[] => {
) {
return false;
}

if (activeFilters[FilterCategory.Extra].includes('enduser') && (isUndefined(item.enduser) || !item.enduser)) {
return false;
}
}

// Filter Category
Expand Down
14 changes: 0 additions & 14 deletions ui/webapp/src/utils/itemsDataGetter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,16 +584,6 @@ export class ItemsDataGetter {
}
}

// Get all end users
public getAllEndUserItems(): Item[] | undefined {
if (this.ready && this.landscapeData && this.landscapeData.items) {
return this.landscapeData.items.filter(
(i: Item) =>
(i.enduser && window.baseDS.members_category === i.category) || i.subcategory === 'End User Supporter'
);
}
}

// Get maturity options
public getMaturityOptions(): string[] {
const maturity = window.baseDS.items.map((i: Item) => i.maturity);
Expand Down Expand Up @@ -704,10 +694,6 @@ export class ItemsDataGetter {
value: 'enduser',
name: 'End user members',
},
{
value: 'allenduser',
name: 'All end users',
},
],
});
}
Expand Down
24 changes: 18 additions & 6 deletions ui/webapp/src/utils/prepareFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ const prepareFilters = (items: Item[], group: string): FilterSection[] => {
extraTypes.push('specification');
}

if (i.enduser) {
extraTypes.push('enduser');
}

if (i.category && checkIfCategoryInGroup(i.category, group)) {
categories.push(i.category);
}
Expand Down Expand Up @@ -193,15 +197,23 @@ const prepareFilters = (items: Item[], group: string): FilterSection[] => {
}

if (extraTypes.length > 0) {
const options = [];
if (extraTypes.includes('enduser')) {
options.push({
value: 'enduser',
name: 'End user',
});
}
if (extraTypes.includes('specification')) {
options.push({
value: 'specification',
name: 'Specification',
});
}
filters.push({
value: FilterCategory.Extra,
title: 'Extra',
options: [
{
value: 'specification',
name: 'Specification',
},
],
options: options,
});
}
}
Expand Down