mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Merge branch 'dev' into fix/issue-3945
This commit is contained in:
commit
f6dadd8c82
@ -668,7 +668,7 @@ describe('DocumentDetailComponent', () => {
|
||||
const object = {
|
||||
id: 22,
|
||||
name: 'Correspondent22',
|
||||
last_correspondence: new Date(),
|
||||
last_correspondence: new Date().toISOString(),
|
||||
} as PaperlessCorrespondent
|
||||
const qfSpy = jest.spyOn(documentListViewService, 'quickFilter')
|
||||
component.filterDocuments([object])
|
||||
|
@ -31,8 +31,12 @@ describe('CorrespondentListComponent', () => {
|
||||
ReactiveFormsModule,
|
||||
],
|
||||
}).compileComponents()
|
||||
|
||||
correspondentsService = TestBed.inject(CorrespondentService)
|
||||
})
|
||||
|
||||
// Tests are included in management-list.compontent.spec.ts
|
||||
|
||||
it('should use correct delete message', () => {
|
||||
jest.spyOn(correspondentsService, 'listFiltered').mockReturnValue(
|
||||
of({
|
||||
count: 3,
|
||||
@ -56,15 +60,30 @@ describe('CorrespondentListComponent', () => {
|
||||
fixture = TestBed.createComponent(CorrespondentListComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
// Tests are included in management-list.compontent.spec.ts
|
||||
|
||||
it('should use correct delete message', () => {
|
||||
expect(
|
||||
component.getDeleteMessage({ id: 1, name: 'Correspondent1' })
|
||||
).toEqual(
|
||||
'Do you really want to delete the correspondent "Correspondent1"?'
|
||||
)
|
||||
})
|
||||
|
||||
it('should support very old date strings', () => {
|
||||
jest.spyOn(correspondentsService, 'listFiltered').mockReturnValue(
|
||||
of({
|
||||
count: 1,
|
||||
all: [1],
|
||||
results: [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Correspondent1',
|
||||
last_correspondence: '1832-12-31T15:32:54-07:52:58',
|
||||
},
|
||||
],
|
||||
})
|
||||
)
|
||||
fixture = TestBed.createComponent(CorrespondentListComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
})
|
||||
|
@ -44,7 +44,19 @@ export class CorrespondentListComponent extends ManagementListComponent<Paperles
|
||||
key: 'last_correspondence',
|
||||
name: $localize`Last used`,
|
||||
valueFn: (c: PaperlessCorrespondent) => {
|
||||
return this.datePipe.transform(c.last_correspondence)
|
||||
if (c.last_correspondence) {
|
||||
let date = new Date(c.last_correspondence)
|
||||
if (date.toString() == 'Invalid Date') {
|
||||
// very old date strings are unable to be parsed
|
||||
date = new Date(
|
||||
c.last_correspondence
|
||||
?.toString()
|
||||
.replace(/-(\d\d):\d\d:\d\d/gm, `-$1:00`)
|
||||
)
|
||||
}
|
||||
return this.datePipe.transform(date)
|
||||
}
|
||||
return ''
|
||||
},
|
||||
},
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { MatchingModel } from './matching-model'
|
||||
|
||||
export interface PaperlessCorrespondent extends MatchingModel {
|
||||
last_correspondence?: Date
|
||||
last_correspondence?: string // Date
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user