Skip to content

Commit

Permalink
Allow sorting by closed date (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
ushkarev authored Oct 30, 2023
1 parent 52394c8 commit ae327fc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions clients/node/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export type RestrictionType = typeof restrictionTypeOptions
export const sortByOptions = [
'WHEN_CREATED',
'WHEN_UPDATED',
'WHEN_CLOSED',
'LAST_NAME',
'FIRST_NAME',
'PRISONER_NUMBER',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ data class NonAssociationListOptions(
return when (sortBy) {
NonAssociationsSort.WHEN_CREATED -> compareBy(PrisonerNonAssociation::whenCreated)
NonAssociationsSort.WHEN_UPDATED -> compareBy(PrisonerNonAssociation::whenUpdated)
NonAssociationsSort.WHEN_CLOSED -> compareBy(PrisonerNonAssociation::closedAt)
NonAssociationsSort.LAST_NAME -> compareBy { nonna -> nonna.otherPrisonerDetails.lastName }
NonAssociationsSort.FIRST_NAME -> compareBy { nonna -> nonna.otherPrisonerDetails.firstName }
NonAssociationsSort.PRISONER_NUMBER -> compareBy { nonna -> nonna.otherPrisonerDetails.prisonerNumber }
Expand All @@ -61,6 +62,7 @@ data class NonAssociationListOptions(
enum class NonAssociationsSort(val defaultSortDirection: Sort.Direction) {
WHEN_CREATED(Sort.Direction.DESC),
WHEN_UPDATED(Sort.Direction.DESC),
WHEN_CLOSED(Sort.Direction.DESC),
LAST_NAME(Sort.Direction.ASC),
FIRST_NAME(Sort.Direction.ASC),
PRISONER_NUMBER(Sort.Direction.ASC),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class NonAssociationsResource(
allowableValues = [
"WHEN_CREATED",
"WHEN_UPDATED",
"WHEN_CLOSED",
"LAST_NAME",
"FIRST_NAME",
"PRISONER_NUMBER",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class NonAssociationsServiceTest {
val getter: (PrisonerNonAssociation) -> String = when (sortBy) {
NonAssociationsSort.WHEN_CREATED -> { n -> n.whenCreated.format(dtFormat) }
NonAssociationsSort.WHEN_UPDATED -> { n -> n.whenUpdated.format(dtFormat) }
NonAssociationsSort.WHEN_CLOSED -> { n -> n.closedAt?.format(dtFormat) ?: "" }
NonAssociationsSort.LAST_NAME -> { n -> n.otherPrisonerDetails.lastName }
NonAssociationsSort.FIRST_NAME -> { n -> n.otherPrisonerDetails.firstName }
NonAssociationsSort.PRISONER_NUMBER -> { n -> n.otherPrisonerDetails.prisonerNumber }
Expand Down

0 comments on commit ae327fc

Please sign in to comment.