Skip to content

Commit

Permalink
fix: Order users by name (#806)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmguyot authored Jul 15, 2024
1 parent 6052f89 commit ea94fe8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
11 changes: 7 additions & 4 deletions client/src/models/Board.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import orderBy from 'lodash/orderBy';
import { attr, fk, many } from 'redux-orm';

import BaseModel from './BaseModel';
Expand Down Expand Up @@ -218,10 +219,6 @@ export default class extends BaseModel {
}
}

getOrderedMembershipsQuerySet() {
return this.memberships.orderBy('createdAt');
}

getOrderedLabelsQuerySet() {
return this.labels.orderBy('position');
}
Expand All @@ -230,6 +227,12 @@ export default class extends BaseModel {
return this.lists.orderBy('position');
}

getOrderedMembershipsModelArray() {
return orderBy(this.memberships.toModelArray(), (boardMembershipModel) =>
boardMembershipModel.user.name.toLocaleLowerCase(),
);
}

getMembershipModelForUser(userId) {
return this.memberships
.filter({
Expand Down
2 changes: 1 addition & 1 deletion client/src/models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export default class extends BaseModel {
static getOrderedUndeletedQuerySet() {
return this.filter({
deletedAt: null,
}).orderBy('createdAt');
}).orderBy((user) => user.name.toLocaleLowerCase());
}

getOrderedProjectManagersQuerySet() {
Expand Down
19 changes: 8 additions & 11 deletions client/src/selectors/boards.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,14 @@ export const selectMembershipsForCurrentBoard = createSelector(
return boardModel;
}

return boardModel
.getOrderedMembershipsQuerySet()
.toModelArray()
.map((boardMembershipModel) => ({
...boardMembershipModel.ref,
isPersisted: !isLocalId(boardMembershipModel.id),
user: {
...boardMembershipModel.user.ref,
isCurrent: boardMembershipModel.user.id === currentUserId,
},
}));
return boardModel.getOrderedMembershipsModelArray().map((boardMembershipModel) => ({
...boardMembershipModel.ref,
isPersisted: !isLocalId(boardMembershipModel.id),
user: {
...boardMembershipModel.user.ref,
isCurrent: boardMembershipModel.user.id === currentUserId,
},
}));
},
);

Expand Down

0 comments on commit ea94fe8

Please sign in to comment.