mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-30 18:27:45 -05:00
Refactor frontend data models
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Component, OnDestroy, OnInit } from '@angular/core'
|
||||
import { PaperlessTag } from 'src/app/data/paperless-tag'
|
||||
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent'
|
||||
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type'
|
||||
import { Tag } from 'src/app/data/tag'
|
||||
import { Correspondent } from 'src/app/data/correspondent'
|
||||
import { DocumentType } from 'src/app/data/document-type'
|
||||
import { TagService } from 'src/app/services/rest/tag.service'
|
||||
import { CorrespondentService } from 'src/app/services/rest/correspondent.service'
|
||||
import { DocumentTypeService } from 'src/app/services/rest/document-type.service'
|
||||
@@ -23,8 +23,8 @@ import { SettingsService } from 'src/app/services/settings.service'
|
||||
import { ToastService } from 'src/app/services/toast.service'
|
||||
import { saveAs } from 'file-saver'
|
||||
import { StoragePathService } from 'src/app/services/rest/storage-path.service'
|
||||
import { PaperlessStoragePath } from 'src/app/data/paperless-storage-path'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
|
||||
import { StoragePath } from 'src/app/data/storage-path'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
|
||||
import { ComponentWithPermissions } from '../../with-permissions/with-permissions.component'
|
||||
import { PermissionsDialogComponent } from '../../common/permissions-dialog/permissions-dialog.component'
|
||||
import {
|
||||
@@ -44,10 +44,10 @@ export class BulkEditorComponent
|
||||
extends ComponentWithPermissions
|
||||
implements OnInit, OnDestroy
|
||||
{
|
||||
tags: PaperlessTag[]
|
||||
correspondents: PaperlessCorrespondent[]
|
||||
documentTypes: PaperlessDocumentType[]
|
||||
storagePaths: PaperlessStoragePath[]
|
||||
tags: Tag[]
|
||||
correspondents: Correspondent[]
|
||||
documentTypes: DocumentType[]
|
||||
storagePaths: StoragePath[]
|
||||
|
||||
tagSelectionModel = new FilterableDropdownSelectionModel()
|
||||
correspondentSelectionModel = new FilterableDropdownSelectionModel()
|
||||
|
@@ -5,11 +5,11 @@ import {
|
||||
Output,
|
||||
ViewChild,
|
||||
} from '@angular/core'
|
||||
import { PaperlessDocument } from 'src/app/data/paperless-document'
|
||||
import { Document } from 'src/app/data/document'
|
||||
import { DocumentService } from 'src/app/services/rest/document.service'
|
||||
import { SettingsService } from 'src/app/services/settings.service'
|
||||
import { NgbPopover } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
|
||||
import { ComponentWithPermissions } from '../../with-permissions/with-permissions.component'
|
||||
|
||||
@Component({
|
||||
@@ -36,7 +36,7 @@ export class DocumentCardLargeComponent extends ComponentWithPermissions {
|
||||
}
|
||||
|
||||
@Input()
|
||||
document: PaperlessDocument
|
||||
document: Document
|
||||
|
||||
@Output()
|
||||
dblClickDocument = new EventEmitter()
|
||||
|
@@ -20,7 +20,7 @@ import { DocumentCardSmallComponent } from './document-card-small.component'
|
||||
import { of } from 'rxjs'
|
||||
import { By } from '@angular/platform-browser'
|
||||
import { TagComponent } from '../../common/tag/tag.component'
|
||||
import { PaperlessTag } from 'src/app/data/paperless-tag'
|
||||
import { Tag } from 'src/app/data/tag'
|
||||
import { IsNumberPipe } from 'src/app/pipes/is-number.pipe'
|
||||
import { PreviewPopupComponent } from '../../common/preview-popup/preview-popup.component'
|
||||
|
||||
@@ -89,10 +89,7 @@ describe('DocumentCardSmallComponent', () => {
|
||||
fixture.debugElement.queryAll(By.directive(TagComponent))
|
||||
).toHaveLength(5)
|
||||
component.document.tags = [1, 2]
|
||||
component.document.tags$ = of([
|
||||
{ id: 1 } as PaperlessTag,
|
||||
{ id: 2 } as PaperlessTag,
|
||||
])
|
||||
component.document.tags$ = of([{ id: 1 } as Tag, { id: 2 } as Tag])
|
||||
fixture.detectChanges()
|
||||
expect(
|
||||
fixture.debugElement.queryAll(By.directive(TagComponent))
|
||||
|
@@ -6,11 +6,11 @@ import {
|
||||
ViewChild,
|
||||
} from '@angular/core'
|
||||
import { map } from 'rxjs/operators'
|
||||
import { PaperlessDocument } from 'src/app/data/paperless-document'
|
||||
import { Document } from 'src/app/data/document'
|
||||
import { DocumentService } from 'src/app/services/rest/document.service'
|
||||
import { SettingsService } from 'src/app/services/settings.service'
|
||||
import { NgbPopover } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
|
||||
import { ComponentWithPermissions } from '../../with-permissions/with-permissions.component'
|
||||
|
||||
@Component({
|
||||
@@ -33,7 +33,7 @@ export class DocumentCardSmallComponent extends ComponentWithPermissions {
|
||||
toggleSelected = new EventEmitter()
|
||||
|
||||
@Input()
|
||||
document: PaperlessDocument
|
||||
document: Document
|
||||
|
||||
@Output()
|
||||
dblClickDocument = new EventEmitter()
|
||||
|
@@ -34,7 +34,7 @@ import {
|
||||
import { Subject, of, throwError } from 'rxjs'
|
||||
import { SavedViewService } from 'src/app/services/rest/saved-view.service'
|
||||
import { ActivatedRoute, Router, convertToParamMap } from '@angular/router'
|
||||
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view'
|
||||
import { SavedView } from 'src/app/data/saved-view'
|
||||
import {
|
||||
FILTER_FULLTEXT_MORELIKE,
|
||||
FILTER_FULLTEXT_QUERY,
|
||||
@@ -47,7 +47,7 @@ import { DocumentCardSmallComponent } from './document-card-small/document-card-
|
||||
import { DocumentCardLargeComponent } from './document-card-large/document-card-large.component'
|
||||
import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe'
|
||||
import { UsernamePipe } from 'src/app/pipes/username.pipe'
|
||||
import { PaperlessDocument } from 'src/app/data/paperless-document'
|
||||
import { Document } from 'src/app/data/document'
|
||||
import {
|
||||
DOCUMENT_SORT_FIELDS,
|
||||
DOCUMENT_SORT_FIELDS_FULLTEXT,
|
||||
@@ -61,10 +61,10 @@ import { CheckComponent } from '../common/input/check/check.component'
|
||||
import { HttpErrorResponse } from '@angular/common/http'
|
||||
import { PermissionsGuard } from 'src/app/guards/permissions.guard'
|
||||
import { SettingsService } from 'src/app/services/settings.service'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
|
||||
import { IsNumberPipe } from 'src/app/pipes/is-number.pipe'
|
||||
|
||||
const docs: PaperlessDocument[] = [
|
||||
const docs: Document[] = [
|
||||
{
|
||||
id: 1,
|
||||
title: 'Doc1',
|
||||
@@ -222,7 +222,7 @@ describe('DocumentListComponent', () => {
|
||||
})
|
||||
|
||||
it('should load saved view from URL', () => {
|
||||
const view: PaperlessSavedView = {
|
||||
const view: SavedView = {
|
||||
id: 10,
|
||||
sort_field: 'added',
|
||||
sort_reverse: true,
|
||||
@@ -264,7 +264,7 @@ describe('DocumentListComponent', () => {
|
||||
})
|
||||
|
||||
it('should load saved view from query params', () => {
|
||||
const view: PaperlessSavedView = {
|
||||
const view: SavedView = {
|
||||
id: 10,
|
||||
sort_field: 'added',
|
||||
sort_reverse: true,
|
||||
@@ -412,7 +412,7 @@ describe('DocumentListComponent', () => {
|
||||
})
|
||||
|
||||
it('should support saving an edited view', () => {
|
||||
const view: PaperlessSavedView = {
|
||||
const view: SavedView = {
|
||||
id: 10,
|
||||
name: 'Saved View 10',
|
||||
sort_field: 'added',
|
||||
@@ -448,7 +448,7 @@ describe('DocumentListComponent', () => {
|
||||
})
|
||||
|
||||
it('should support edited view saving as', () => {
|
||||
const view: PaperlessSavedView = {
|
||||
const view: SavedView = {
|
||||
id: 10,
|
||||
name: 'Saved View 10',
|
||||
sort_field: 'added',
|
||||
@@ -494,7 +494,7 @@ describe('DocumentListComponent', () => {
|
||||
})
|
||||
|
||||
it('should handle error on edited view saving as', () => {
|
||||
const view: PaperlessSavedView = {
|
||||
const view: SavedView = {
|
||||
id: 10,
|
||||
name: 'Saved View 10',
|
||||
sort_field: 'added',
|
||||
|
@@ -15,9 +15,9 @@ import {
|
||||
isFullTextFilterRule,
|
||||
} from 'src/app/utils/filter-rules'
|
||||
import { FILTER_FULLTEXT_MORELIKE } from 'src/app/data/filter-rule-type'
|
||||
import { PaperlessDocument } from 'src/app/data/paperless-document'
|
||||
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
|
||||
import { Document } from 'src/app/data/document'
|
||||
import { SavedView } from 'src/app/data/saved-view'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
|
||||
import {
|
||||
SortableDirective,
|
||||
SortEvent,
|
||||
@@ -67,7 +67,7 @@ export class DocumentListComponent
|
||||
displayMode = 'smallCards' // largeCards, smallCards, details
|
||||
|
||||
unmodifiedFilterRules: FilterRule[] = []
|
||||
private unmodifiedSavedView: PaperlessSavedView
|
||||
private unmodifiedSavedView: SavedView
|
||||
|
||||
private unsubscribeNotifier: Subject<any> = new Subject()
|
||||
|
||||
@@ -192,7 +192,7 @@ export class DocumentListComponent
|
||||
|
||||
saveViewConfig() {
|
||||
if (this.list.activeSavedViewId != null) {
|
||||
let savedView: PaperlessSavedView = {
|
||||
let savedView: SavedView = {
|
||||
id: this.list.activeSavedViewId,
|
||||
filter_rules: this.list.filterRules,
|
||||
sort_field: this.list.sortField,
|
||||
@@ -229,7 +229,7 @@ export class DocumentListComponent
|
||||
modal.componentInstance.defaultName = this.filterEditor.generateFilterName()
|
||||
modal.componentInstance.saveClicked.pipe(first()).subscribe((formValue) => {
|
||||
modal.componentInstance.buttonsEnabled = false
|
||||
let savedView: PaperlessSavedView = {
|
||||
let savedView: SavedView = {
|
||||
name: formValue.name,
|
||||
show_on_dashboard: formValue.showOnDashboard,
|
||||
show_in_sidebar: formValue.showInSideBar,
|
||||
@@ -260,11 +260,11 @@ export class DocumentListComponent
|
||||
})
|
||||
}
|
||||
|
||||
openDocumentDetail(document: PaperlessDocument) {
|
||||
openDocumentDetail(document: Document) {
|
||||
this.router.navigate(['documents', document.id])
|
||||
}
|
||||
|
||||
toggleSelected(document: PaperlessDocument, event: MouseEvent): void {
|
||||
toggleSelected(document: Document, event: MouseEvent): void {
|
||||
if (!event.shiftKey) this.list.toggleSelected(document)
|
||||
else this.list.selectRangeTo(document)
|
||||
}
|
||||
@@ -295,7 +295,7 @@ export class DocumentListComponent
|
||||
])
|
||||
}
|
||||
|
||||
trackByDocumentId(index, item: PaperlessDocument) {
|
||||
trackByDocumentId(index, item: Document) {
|
||||
return item.id
|
||||
}
|
||||
|
||||
|
@@ -49,11 +49,11 @@ import {
|
||||
FILTER_CUSTOM_FIELDS,
|
||||
FILTER_SHARED_BY_USER,
|
||||
} from 'src/app/data/filter-rule-type'
|
||||
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent'
|
||||
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type'
|
||||
import { PaperlessStoragePath } from 'src/app/data/paperless-storage-path'
|
||||
import { PaperlessTag } from 'src/app/data/paperless-tag'
|
||||
import { PaperlessUser } from 'src/app/data/paperless-user'
|
||||
import { Correspondent } from 'src/app/data/correspondent'
|
||||
import { DocumentType } from 'src/app/data/document-type'
|
||||
import { StoragePath } from 'src/app/data/storage-path'
|
||||
import { Tag } from 'src/app/data/tag'
|
||||
import { User } from 'src/app/data/user'
|
||||
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
|
||||
import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe'
|
||||
import { FilterPipe } from 'src/app/pipes/filter.pipe'
|
||||
@@ -78,7 +78,7 @@ import {
|
||||
} from '../../common/permissions-filter-dropdown/permissions-filter-dropdown.component'
|
||||
import { FilterEditorComponent } from './filter-editor.component'
|
||||
|
||||
const tags: PaperlessTag[] = [
|
||||
const tags: Tag[] = [
|
||||
{
|
||||
id: 2,
|
||||
name: 'Tag2',
|
||||
@@ -89,7 +89,7 @@ const tags: PaperlessTag[] = [
|
||||
},
|
||||
]
|
||||
|
||||
const correspondents: PaperlessCorrespondent[] = [
|
||||
const correspondents: Correspondent[] = [
|
||||
{
|
||||
id: 12,
|
||||
name: 'Corresp12',
|
||||
@@ -100,7 +100,7 @@ const correspondents: PaperlessCorrespondent[] = [
|
||||
},
|
||||
]
|
||||
|
||||
const document_types: PaperlessDocumentType[] = [
|
||||
const document_types: DocumentType[] = [
|
||||
{
|
||||
id: 22,
|
||||
name: 'DocType22',
|
||||
@@ -111,7 +111,7 @@ const document_types: PaperlessDocumentType[] = [
|
||||
},
|
||||
]
|
||||
|
||||
const storage_paths: PaperlessStoragePath[] = [
|
||||
const storage_paths: StoragePath[] = [
|
||||
{
|
||||
id: 32,
|
||||
name: 'StoragePath32',
|
||||
@@ -122,7 +122,7 @@ const storage_paths: PaperlessStoragePath[] = [
|
||||
},
|
||||
]
|
||||
|
||||
const users: PaperlessUser[] = [
|
||||
const users: User[] = [
|
||||
{
|
||||
id: 1,
|
||||
username: 'user1',
|
||||
|
@@ -8,9 +8,9 @@ import {
|
||||
ViewChild,
|
||||
ElementRef,
|
||||
} from '@angular/core'
|
||||
import { PaperlessTag } from 'src/app/data/paperless-tag'
|
||||
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent'
|
||||
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type'
|
||||
import { Tag } from 'src/app/data/tag'
|
||||
import { Correspondent } from 'src/app/data/correspondent'
|
||||
import { DocumentType } from 'src/app/data/document-type'
|
||||
import { Subject, Subscription } from 'rxjs'
|
||||
import { debounceTime, distinctUntilChanged, filter } from 'rxjs/operators'
|
||||
import { DocumentTypeService } from 'src/app/services/rest/document-type.service'
|
||||
@@ -62,8 +62,8 @@ import {
|
||||
SelectionData,
|
||||
SelectionDataItem,
|
||||
} from 'src/app/services/rest/document.service'
|
||||
import { PaperlessDocument } from 'src/app/data/paperless-document'
|
||||
import { PaperlessStoragePath } from 'src/app/data/paperless-storage-path'
|
||||
import { Document } from 'src/app/data/document'
|
||||
import { StoragePath } from 'src/app/data/storage-path'
|
||||
import { StoragePathService } from 'src/app/services/rest/storage-path.service'
|
||||
import { RelativeDate } from '../../common/date-dropdown/date-dropdown.component'
|
||||
import {
|
||||
@@ -230,10 +230,10 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
|
||||
@ViewChild('textFilterInput')
|
||||
textFilterInput: ElementRef
|
||||
|
||||
tags: PaperlessTag[] = []
|
||||
correspondents: PaperlessCorrespondent[] = []
|
||||
documentTypes: PaperlessDocumentType[] = []
|
||||
storagePaths: PaperlessStoragePath[] = []
|
||||
tags: Tag[] = []
|
||||
correspondents: Correspondent[] = []
|
||||
documentTypes: DocumentType[] = []
|
||||
storagePaths: StoragePath[] = []
|
||||
|
||||
tagDocumentCounts: SelectionDataItem[]
|
||||
correspondentDocumentCounts: SelectionDataItem[]
|
||||
@@ -242,7 +242,7 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
|
||||
|
||||
_textFilter = ''
|
||||
_moreLikeId: number
|
||||
_moreLikeDoc: PaperlessDocument
|
||||
_moreLikeDoc: Document
|
||||
|
||||
get textFilterTargets() {
|
||||
if (this.textFilterTarget == TEXT_FILTER_TARGET_FULLTEXT_MORELIKE) {
|
||||
|
Reference in New Issue
Block a user