Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions frontend/src/modules/activity/config/filters/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import date from './date/config';
import member from './member/config';
import platform from './platform/config';
import sentiment from './sentiment/config';
import organizations from './organizations/config';

export const activityFilters: Record<string, FilterConfig> = {
activityType,
channel,
date,
member,
organizations,
platform,
sentiment,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { FilterConfigType } from '@/shared/modules/filters/types/FilterConfig';
import { itemLabelRendererByType } from '@/shared/modules/filters/config/itemLabelRendererByType';
import {
MultiSelectAsyncFilterConfig,
MultiSelectAsyncFilterOptions, MultiSelectAsyncFilterValue,
} from '@/shared/modules/filters/types/filterTypes/MultiSelectAsyncFilterConfig';
import { OrganizationService } from '@/modules/organization/organization-service';
import { DEFAULT_ORGANIZATION_FILTERS } from '@/modules/organization/store/constants';

const organizations: MultiSelectAsyncFilterConfig = {
id: 'organizations',
label: 'Organizations',
iconClass: 'ri-community-line',
type: FilterConfigType.MULTISELECT_ASYNC,
options: {
remoteMethod: (query) => OrganizationService.listAutocomplete(query, 10)
.then((data: any[]) => data.map((organization) => ({
label: organization.label,
value: organization.id,
logo: organization.logo,
}))),
remotePopulateItems: (ids: string[]) => OrganizationService.listAutocomplete({
filter: {
and: [
...DEFAULT_ORGANIZATION_FILTERS,
{
id: { in: ids },
},
],
},
orderBy: null,
limit: ids.length,
offset: 0,
})
.then(({ rows }: any) => rows.map((organization: any) => ({
label: organization.displayName,
value: organization.id,
logo: organization.logo,
}))),
},
itemLabelRenderer(value: MultiSelectAsyncFilterValue, options: MultiSelectAsyncFilterOptions, data: any): string {
return itemLabelRendererByType[FilterConfigType.MULTISELECT_ASYNC]('Organizations', value, options, data);
},
apiFilterRenderer({ value, include }: MultiSelectAsyncFilterValue): any[] {
const filter = {
organizationId: value,
};
return [
(include ? filter : { not: filter }),
];
},
};

export default organizations;
2 changes: 2 additions & 0 deletions frontend/src/modules/member/config/filters/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import reach from './reach/config';
import tags from './tags/config';
import memberName from './memberName/config';
import jobTitle from './jobTitle/config';
import organizations from './organizations/config';

export const memberFilters: Record<string, FilterConfig> = {
memberName,
organizations,
noOfActivities,
noOfOSSContributions,
jobTitle,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { FilterConfigType } from '@/shared/modules/filters/types/FilterConfig';
import { itemLabelRendererByType } from '@/shared/modules/filters/config/itemLabelRendererByType';
import {
MultiSelectAsyncFilterConfig,
MultiSelectAsyncFilterOptions, MultiSelectAsyncFilterValue,
} from '@/shared/modules/filters/types/filterTypes/MultiSelectAsyncFilterConfig';
import { OrganizationService } from '@/modules/organization/organization-service';
import { DEFAULT_ORGANIZATION_FILTERS } from '@/modules/organization/store/constants';

const organizations: MultiSelectAsyncFilterConfig = {
id: 'organizations',
label: 'Organizations',
iconClass: 'ri-community-line',
type: FilterConfigType.MULTISELECT_ASYNC,
options: {
remoteMethod: (query) => OrganizationService.listAutocomplete(query, 10)
.then((data: any[]) => data.map((organization) => ({
label: organization.label,
value: organization.id,
logo: organization.logo,
}))),
remotePopulateItems: (ids: string[]) => OrganizationService.listAutocomplete({
filter: {
and: [
...DEFAULT_ORGANIZATION_FILTERS,
{
id: { in: ids },
},
],
},
orderBy: null,
limit: ids.length,
offset: 0,
})
.then(({ rows }: any) => rows.map((organization: any) => ({
label: organization.displayName,
value: organization.id,
logo: organization.logo,
}))),
},
itemLabelRenderer(value: MultiSelectAsyncFilterValue, options: MultiSelectAsyncFilterOptions, data: any): string {
return itemLabelRendererByType[FilterConfigType.MULTISELECT_ASYNC]('Organizations', value, options, data);
},
apiFilterRenderer({ value, include }: MultiSelectAsyncFilterValue): any[] {
const filter = {
or: value.map((id) => ({ organizations: { eq: id } })),
};
return [
(include ? filter : { not: filter }),
];
},
};

export default organizations;
2 changes: 2 additions & 0 deletions frontend/src/modules/organization/config/filters/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import joinedDate from './joinedDate/config';
import lastActivityDate from './lastActivityDate/config';
import location from './location/config';
import type from './type/config';
import organizations from './organizations/config';

export const organizationFilters: Record<string, FilterConfig> = {
organizations,
noOfActivities,
noOfMembers,
activeOn,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { FilterConfigType } from '@/shared/modules/filters/types/FilterConfig';
import { itemLabelRendererByType } from '@/shared/modules/filters/config/itemLabelRendererByType';
import {
MultiSelectAsyncFilterConfig,
MultiSelectAsyncFilterOptions, MultiSelectAsyncFilterValue,
} from '@/shared/modules/filters/types/filterTypes/MultiSelectAsyncFilterConfig';
import { OrganizationService } from '@/modules/organization/organization-service';
import { DEFAULT_ORGANIZATION_FILTERS } from '@/modules/organization/store/constants';

const organizations: MultiSelectAsyncFilterConfig = {
id: 'organizations',
label: 'Organizations',
iconClass: 'ri-community-line',
type: FilterConfigType.MULTISELECT_ASYNC,
options: {
remoteMethod: (query) => OrganizationService.listAutocomplete(query, 10)
.then((data: any[]) => data.map((organization) => ({
label: organization.label,
value: organization.id,
logo: organization.logo,
}))),
remotePopulateItems: (ids: string[]) => OrganizationService.listAutocomplete({
filter: {
and: [
...DEFAULT_ORGANIZATION_FILTERS,
{
id: { in: ids },
},
],
},
orderBy: null,
limit: ids.length,
offset: 0,
})
.then(({ rows }: any) => rows.map((organization: any) => ({
label: organization.displayName,
value: organization.id,
logo: organization.logo,
}))),
},
itemLabelRenderer(value: MultiSelectAsyncFilterValue, options: MultiSelectAsyncFilterOptions, data: any): string {
return itemLabelRendererByType[FilterConfigType.MULTISELECT_ASYNC]('Organizations', value, options, data);
},
apiFilterRenderer({ value, include }: MultiSelectAsyncFilterValue): any[] {
const filter = {
or: value.map((id) => ({ id: { eq: id } })),
};
return [
(include ? filter : { not: filter }),
];
},
};

export default organizations;
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
<span class="el-checkbox__inner" />
</span>
</div>
<template v-if="config.id === 'organizations'">
<span class="border rounded-md p-1 mr-2">
<img v-if="option.logo" :src="option.logo" class="h-5 w-5 flex items-center justify-center" :alt="option.label" />
<i v-else class="ri-community-line h-5 w-5 flex items-center justify-center" />
</span>
</template>
{{ option.label }}
</el-option>
</el-select>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { BaseFilterConfig, FilterConfigType } from '@/shared/modules/filters/typ
export interface MultiSelectAsyncFilterOption {
label: string;
value: string;
logo?: string;
}
export interface MultiSelectAsyncFilterOptions {
hideIncludeSwitch?: boolean;
Expand Down