Skip to content

Commit

Permalink
fix(documents): Sort by publication v1 and v2 by default (#17157)
Browse files Browse the repository at this point in the history
* Sort by publication v1 and v2 by default

* Remove logg

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
thordurhhh and kodiakhq[bot] authored Dec 6, 2024
1 parent 202d2b1 commit c4685ef
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class GetDocumentListInput {
typeId?: string

@Field({ nullable: true })
sortBy?: 'Date' | 'Category' | 'Type' | 'Subject' | 'Sender'
sortBy?: 'Date' | 'Category' | 'Type' | 'Subject' | 'Sender' | 'Publication'

@Field({ nullable: true })
order?: 'Ascending' | 'Descending'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {
} from 'class-validator'

export enum DocumentPageSort {
Date = 'Date',
Date = 'Date', // Date is document date
Publication = 'Publication', // Publication is document publication date (default)
Category = 'Category',
Type = 'Type',
Sender = 'Sender',
Expand Down Expand Up @@ -79,7 +80,10 @@ export class DocumentsInput {
@IsBoolean()
readonly opened?: boolean

@Field(() => DocumentPageSort, { nullable: true, defaultValue: 'Date' })
@Field(() => DocumentPageSort, {
nullable: true,
defaultValue: 'Publication',
})
@IsOptional()
@IsEnum(DocumentPageSort)
readonly sortBy?: DocumentPageSort
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type ListDocumentsInputDto = {
typeId?: string
subjectContains?: string
archived?: boolean
sortBy?: 'Date' | 'Category' | 'Type' | 'Sender' | 'Subject'
sortBy?: 'Date' | 'Category' | 'Type' | 'Sender' | 'Subject' | 'Publication'
order?: 'Ascending' | 'Descending'
opened?: boolean
page?: number
Expand Down
2 changes: 1 addition & 1 deletion libs/clients/documents/src/lib/documentClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class DocumentClient {
type ExcludesFalse = <T>(x: T | null | undefined | false | '') => x is T

const inputs = [
sortBy ? `sortBy=${sortBy}` : 'sortBy=Date', // first in array to skip &
sortBy ? `sortBy=${sortBy}` : 'sortBy=Publication', // first in array to skip &
order ? `orderBy=${order}` : 'order=Descending',
page ? `page=${page}` : 'page=1',
pageSize ? `pageSize=${pageSize}` : 'pageSize=15',
Expand Down
2 changes: 1 addition & 1 deletion libs/clients/documents/src/lib/models/DocumentInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type GetDocumentListInput = {
categoryId?: string
subjectContains?: string
typeId?: string
sortBy?: 'Date' | 'Category' | 'Type' | 'Subject' | 'Sender'
sortBy?: 'Date' | 'Category' | 'Type' | 'Subject' | 'Sender' | 'Publication'
order?: 'Ascending' | 'Descending'
opened?: boolean
archived?: boolean
Expand Down

0 comments on commit c4685ef

Please sign in to comment.