Adjust doc detail filtering
This commit is contained in:
parent
46831c1d19
commit
948b93db89
@ -105,13 +105,13 @@
|
||||
<pngx-input-number i18n-title title="Archive serial number" [error]="error?.archive_serial_number" [horizontal]="true" formControlName='archive_serial_number'></pngx-input-number>
|
||||
<pngx-input-date i18n-title title="Date created" formControlName="created_date" [suggestions]="suggestions?.dates" [showFilter]="true" [horizontal]="true" (filterDocuments)="filterDocuments($event)"
|
||||
[error]="error?.created_date"></pngx-input-date>
|
||||
<pngx-input-select [items]="correspondents" i18n-title title="Correspondent" formControlName="correspondent" [allowNull]="true" [showFilter]="true" [horizontal]="true" (filterDocuments)="filterDocuments($event)"
|
||||
<pngx-input-select [items]="correspondents" i18n-title title="Correspondent" formControlName="correspondent" [allowNull]="true" [showFilter]="true" [horizontal]="true" (filterDocuments)="filterDocuments($event, DataType.Correspondent)"
|
||||
(createNew)="createCorrespondent($event)" [suggestions]="suggestions?.correspondents" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.Correspondent }"></pngx-input-select>
|
||||
<pngx-input-select [items]="documentTypes" i18n-title title="Document type" formControlName="document_type" [allowNull]="true" [showFilter]="true" [horizontal]="true" (filterDocuments)="filterDocuments($event)"
|
||||
<pngx-input-select [items]="documentTypes" i18n-title title="Document type" formControlName="document_type" [allowNull]="true" [showFilter]="true" [horizontal]="true" (filterDocuments)="filterDocuments($event, DataType.DocumentType)"
|
||||
(createNew)="createDocumentType($event)" [suggestions]="suggestions?.document_types" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.DocumentType }"></pngx-input-select>
|
||||
<pngx-input-select [items]="storagePaths" i18n-title title="Storage path" formControlName="storage_path" [allowNull]="true" [showFilter]="true" [horizontal]="true" (filterDocuments)="filterDocuments($event)"
|
||||
<pngx-input-select [items]="storagePaths" i18n-title title="Storage path" formControlName="storage_path" [allowNull]="true" [showFilter]="true" [horizontal]="true" (filterDocuments)="filterDocuments($event, DataType.StoragePath)"
|
||||
(createNew)="createStoragePath($event)" [suggestions]="suggestions?.storage_paths" i18n-placeholder placeholder="Default" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.StoragePath }"></pngx-input-select>
|
||||
<pngx-input-tags formControlName="tags" [suggestions]="suggestions?.tags" [showFilter]="true" [horizontal]="true" (filterDocuments)="filterDocuments($event)" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.Tag }"></pngx-input-tags>
|
||||
<pngx-input-tags formControlName="tags" [suggestions]="suggestions?.tags" [showFilter]="true" [horizontal]="true" (filterDocuments)="filterDocuments($event, DataType.Tag)" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.Tag }"></pngx-input-tags>
|
||||
@for (fieldInstance of document?.custom_fields; track fieldInstance.field; let i = $index) {
|
||||
<div [formGroup]="customFieldFormFields.controls[i]">
|
||||
@switch (getCustomFieldFromInstance(fieldInstance)?.data_type) {
|
||||
|
@ -81,6 +81,7 @@ import { environment } from 'src/environments/environment'
|
||||
import { RotateConfirmDialogComponent } from '../common/confirm-dialog/rotate-confirm-dialog/rotate-confirm-dialog.component'
|
||||
import { SplitConfirmDialogComponent } from '../common/confirm-dialog/split-confirm-dialog/split-confirm-dialog.component'
|
||||
import { PdfViewerModule } from 'ng2-pdf-viewer'
|
||||
import { DataType } from 'src/app/data/datatype'
|
||||
|
||||
const doc: Document = {
|
||||
id: 3,
|
||||
@ -781,10 +782,9 @@ describe('DocumentDetailComponent', () => {
|
||||
const object = {
|
||||
id: 22,
|
||||
name: 'Correspondent22',
|
||||
last_correspondence: new Date().toISOString(),
|
||||
} as Correspondent
|
||||
const qfSpy = jest.spyOn(documentListViewService, 'quickFilter')
|
||||
component.filterDocuments([object])
|
||||
component.filterDocuments([object], DataType.Correspondent)
|
||||
expect(qfSpy).toHaveBeenCalledWith([
|
||||
{
|
||||
rule_type: FILTER_CORRESPONDENT,
|
||||
@ -797,7 +797,7 @@ describe('DocumentDetailComponent', () => {
|
||||
initNormally()
|
||||
const object = { id: 22, name: 'DocumentType22' } as DocumentType
|
||||
const qfSpy = jest.spyOn(documentListViewService, 'quickFilter')
|
||||
component.filterDocuments([object])
|
||||
component.filterDocuments([object], DataType.DocumentType)
|
||||
expect(qfSpy).toHaveBeenCalledWith([
|
||||
{
|
||||
rule_type: FILTER_DOCUMENT_TYPE,
|
||||
@ -814,7 +814,7 @@ describe('DocumentDetailComponent', () => {
|
||||
path: '/foo/bar/',
|
||||
} as StoragePath
|
||||
const qfSpy = jest.spyOn(documentListViewService, 'quickFilter')
|
||||
component.filterDocuments([object])
|
||||
component.filterDocuments([object], DataType.StoragePath)
|
||||
expect(qfSpy).toHaveBeenCalledWith([
|
||||
{
|
||||
rule_type: FILTER_STORAGE_PATH,
|
||||
@ -840,7 +840,7 @@ describe('DocumentDetailComponent', () => {
|
||||
text_color: '#000000',
|
||||
} as Tag
|
||||
const qfSpy = jest.spyOn(documentListViewService, 'quickFilter')
|
||||
component.filterDocuments([object1, object2])
|
||||
component.filterDocuments([object1, object2], DataType.Tag)
|
||||
expect(qfSpy).toHaveBeenCalledWith([
|
||||
{
|
||||
rule_type: FILTER_HAS_TAGS_ALL,
|
||||
|
@ -70,6 +70,7 @@ import { SplitConfirmDialogComponent } from '../common/confirm-dialog/split-conf
|
||||
import { RotateConfirmDialogComponent } from '../common/confirm-dialog/rotate-confirm-dialog/rotate-confirm-dialog.component'
|
||||
import { HotKeyService } from 'src/app/services/hot-key.service'
|
||||
import { PDFDocumentProxy } from 'ng2-pdf-viewer'
|
||||
import { DataType } from 'src/app/data/datatype'
|
||||
|
||||
enum DocumentDetailNavIDs {
|
||||
Details = 1,
|
||||
@ -170,6 +171,8 @@ export class DocumentDetailComponent
|
||||
|
||||
public readonly ContentRenderType = ContentRenderType
|
||||
|
||||
public readonly DataType = DataType
|
||||
|
||||
@ViewChild('nav') nav: NgbNav
|
||||
@ViewChild('pdfPreview') set pdfPreview(element) {
|
||||
// this gets called when component added or removed from DOM
|
||||
@ -989,7 +992,7 @@ export class DocumentDetailComponent
|
||||
)
|
||||
}
|
||||
|
||||
filterDocuments(items: ObjectWithId[] | NgbDateStruct[]) {
|
||||
filterDocuments(items: ObjectWithId[] | NgbDateStruct[], type?: DataType) {
|
||||
const filterRules: FilterRule[] = items.flatMap((i) => {
|
||||
if (i.hasOwnProperty('year')) {
|
||||
const isoDateAdapter = new ISODateAdapter()
|
||||
@ -1008,30 +1011,28 @@ export class DocumentDetailComponent
|
||||
value: dateBefore.toISOString().substring(0, 10),
|
||||
},
|
||||
]
|
||||
} else if (i.hasOwnProperty('last_correspondence')) {
|
||||
// Correspondent
|
||||
}
|
||||
switch (type) {
|
||||
case DataType.Correspondent:
|
||||
return {
|
||||
rule_type: FILTER_CORRESPONDENT,
|
||||
value: (i as Correspondent).id.toString(),
|
||||
}
|
||||
} else if (i.hasOwnProperty('path')) {
|
||||
// Storage Path
|
||||
case DataType.DocumentType:
|
||||
return {
|
||||
rule_type: FILTER_DOCUMENT_TYPE,
|
||||
value: (i as DocumentType).id.toString(),
|
||||
}
|
||||
case DataType.StoragePath:
|
||||
return {
|
||||
rule_type: FILTER_STORAGE_PATH,
|
||||
value: (i as StoragePath).id.toString(),
|
||||
}
|
||||
} else if (i.hasOwnProperty('is_inbox_tag')) {
|
||||
// Tag
|
||||
case DataType.Tag:
|
||||
return {
|
||||
rule_type: FILTER_HAS_TAGS_ALL,
|
||||
value: (i as Tag).id.toString(),
|
||||
}
|
||||
} else {
|
||||
// Document Type, has no specific props
|
||||
return {
|
||||
rule_type: FILTER_DOCUMENT_TYPE,
|
||||
value: (i as DocumentType).id.toString(),
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user