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

Fix autocomplete sorting #2669

Merged
merged 1 commit into from
Nov 4, 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
18 changes: 9 additions & 9 deletions backend/src/services/organizationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1013,19 +1013,19 @@ export default class OrganizationService extends LoggerBase {
}

async findAllAutocomplete(data) {
const segmentId = data.segments && data.segments.length > 0 ? data.segments[0] : undefined

const res = await OrganizationRepository.findAndCountAll(
const { filter, orderBy, limit, offset, segments } = data
return OrganizationRepository.findAndCountAll(
{
...data,
segmentId,
include: {
segments: true,
},
filter,
orderBy,
limit,
offset,
segmentId: segments.length > 0 ? segments[0] : undefined,
fields: ['id', 'segmentId', 'displayName', 'memberCount', 'activityCount', 'logo'],
include: { aggregates: true, identities: false, lfxMemberships: true },
},
this.options,
)
return res
}

async findAndCountAll(args) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/modules/member/member-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class MemberService {
},
} : {},
offset: 0,
orderBy: 'displayName_ASC',
orderBy: 'activityCount_DESC',
limit,
...(segments && {
segments,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ import LfAvatar from '@/ui-kit/avatar/Avatar.vue';
import LfIconOld from '@/ui-kit/icon/IconOld.vue';
import LfProjectGroupsTags from '@/shared/modules/project-groups/components/project-groups-tags.vue';
import AppAutocompleteOneInput from '@/shared/form/autocomplete-one-input.vue';
import { storeToRefs } from 'pinia';
import { useLfSegmentsStore } from '@/modules/lf/segments/store';

const props = defineProps<{
modelValue: Organization | null,
}>();

const emit = defineEmits<{(e: 'update:modelValue', value: Organization | null): any}>();

const { selectedProjectGroup } = storeToRefs(useLfSegmentsStore());

const form = computed<Organization | null>({
get() {
return props.modelValue;
Expand All @@ -81,8 +85,8 @@ const fetchOrganizations = async ({ query } : {
query,
limit: 40,
excludeSegments: true,
})
.then((options: Organization[]) => options.filter((m) => m.id !== form.value?.id));
segments: [selectedProjectGroup.value?.id],
});

const createOrganization = (value: string) => OrganizationService.create({
name: value,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/modules/organization/organization-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class OrganizationService {
],
},
offset: 0,
orderBy: 'displayName_ASC',
orderBy: 'activityCount_DESC',
limit,
...(segments && {
segments,
Expand Down
Loading