Skip to content

Commit f1f9137

Browse files
committed
Add Partner.organization sorting & filtering
1 parent d489c7c commit f1f9137

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/components/partner/dto/list-partner.dto.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
SecuredList,
77
SortablePaginationInput,
88
} from '~/common';
9+
import { OrganizationFilters } from '../../organization/dto';
910
import { Partner } from './partner.dto';
1011

1112
@InputType()
@@ -18,6 +19,9 @@ export abstract class PartnerFilters {
1819
nullable: true,
1920
})
2021
readonly pinned?: boolean;
22+
23+
@FilterField(() => OrganizationFilters)
24+
readonly organization?: OrganizationFilters & {};
2125
}
2226

2327
@InputType()

src/components/partner/partner.repository.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
createNode,
1818
createRelationships,
1919
defineSorters,
20+
filter,
2021
filter as filters,
2122
matchProjectScopedRoles,
2223
matchProjectSens,
@@ -28,6 +29,10 @@ import {
2829
requestingUser,
2930
sortWith,
3031
} from '~/core/database/query';
32+
import {
33+
organizationFilters,
34+
organizationSorters,
35+
} from '../organization/organization.repository';
3136
import {
3237
CreatePartner,
3338
Partner,
@@ -305,6 +310,15 @@ export const partnerFilters = filters.define(() => PartnerFilters, {
305310
relation('in', '', 'organization', ACTIVE),
306311
node('', 'User', { id }),
307312
]),
313+
organization: filter.sub(() => organizationFilters)((sub) =>
314+
sub
315+
.with('node as partner')
316+
.match([
317+
node('partner'),
318+
relation('out', '', 'organization'),
319+
node('node', 'Organization'),
320+
]),
321+
),
308322
});
309323

310324
export const partnerSorters = defineSorters(Partner, {
@@ -318,4 +332,14 @@ export const partnerSorters = defineSorters(Partner, {
318332
node('prop', 'Property'),
319333
])
320334
.return<{ sortValue: string }>('prop.value as sortValue'),
335+
// eslint-disable-next-line @typescript-eslint/naming-convention
336+
'organization.*': (query, input) =>
337+
query
338+
.with('node as partner')
339+
.match([
340+
node('partner'),
341+
relation('out', '', 'organization'),
342+
node('node', 'Organization'),
343+
])
344+
.apply(sortWith(organizationSorters, input)),
321345
});

0 commit comments

Comments
 (0)