mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-16 00:36:22 +00:00
Refactor frontend data models
This commit is contained in:
@@ -13,7 +13,7 @@ import {
|
||||
catchError,
|
||||
} from 'rxjs'
|
||||
import { FILTER_TITLE } from 'src/app/data/filter-rule-type'
|
||||
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 { AbstractInputComponent } from '../abstract-input'
|
||||
|
||||
@@ -34,9 +34,9 @@ export class DocumentLinkComponent
|
||||
implements OnInit, OnDestroy
|
||||
{
|
||||
documentsInput$ = new Subject<string>()
|
||||
foundDocuments$: Observable<PaperlessDocument[]>
|
||||
foundDocuments$: Observable<Document[]>
|
||||
loading = false
|
||||
selectedDocuments: PaperlessDocument[] = []
|
||||
selectedDocuments: Document[] = []
|
||||
|
||||
private unsubscribeNotifier: Subject<any> = new Subject()
|
||||
|
||||
@@ -104,21 +104,18 @@ export class DocumentLinkComponent
|
||||
)
|
||||
}
|
||||
|
||||
unselect(document: PaperlessDocument): void {
|
||||
unselect(document: Document): void {
|
||||
this.selectedDocuments = this.selectedDocuments.filter(
|
||||
(d) => d.id !== document.id
|
||||
)
|
||||
this.onChange(this.selectedDocuments.map((d) => d.id))
|
||||
}
|
||||
|
||||
compareDocuments(
|
||||
document: PaperlessDocument,
|
||||
selectedDocument: PaperlessDocument
|
||||
) {
|
||||
compareDocuments(document: Document, selectedDocument: Document) {
|
||||
return document.id === selectedDocument.id
|
||||
}
|
||||
|
||||
trackByFn(item: PaperlessDocument) {
|
||||
trackByFn(item: Document) {
|
||||
return item.id
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { Component, forwardRef, Input, OnInit } from '@angular/core'
|
||||
import { FormControl, FormGroup, NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||
import { PaperlessUser } from 'src/app/data/paperless-user'
|
||||
import { User } from 'src/app/data/user'
|
||||
import { AbstractInputComponent } from '../../abstract-input'
|
||||
|
||||
export interface PermissionsFormObject {
|
||||
@@ -34,7 +34,7 @@ export class PermissionsFormComponent
|
||||
implements OnInit
|
||||
{
|
||||
@Input()
|
||||
users: PaperlessUser[]
|
||||
users: User[]
|
||||
|
||||
@Input()
|
||||
accordion: boolean = false
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { Component, forwardRef, Input, OnInit } from '@angular/core'
|
||||
import { NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||
import { first } from 'rxjs/operators'
|
||||
import { PaperlessGroup } from 'src/app/data/paperless-group'
|
||||
import { Group } from 'src/app/data/group'
|
||||
import { GroupService } from 'src/app/services/rest/group.service'
|
||||
import { AbstractInputComponent } from '../../abstract-input'
|
||||
|
||||
@@ -17,8 +17,8 @@ import { AbstractInputComponent } from '../../abstract-input'
|
||||
templateUrl: './permissions-group.component.html',
|
||||
styleUrls: ['./permissions-group.component.scss'],
|
||||
})
|
||||
export class PermissionsGroupComponent extends AbstractInputComponent<PaperlessGroup> {
|
||||
groups: PaperlessGroup[]
|
||||
export class PermissionsGroupComponent extends AbstractInputComponent<Group> {
|
||||
groups: Group[]
|
||||
|
||||
constructor(groupService: GroupService) {
|
||||
super()
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { Component, forwardRef, Input, OnInit } from '@angular/core'
|
||||
import { NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||
import { first } from 'rxjs/operators'
|
||||
import { PaperlessUser } from 'src/app/data/paperless-user'
|
||||
import { User } from 'src/app/data/user'
|
||||
import { UserService } from 'src/app/services/rest/user.service'
|
||||
import { SettingsService } from 'src/app/services/settings.service'
|
||||
import { AbstractInputComponent } from '../../abstract-input'
|
||||
@@ -18,10 +18,8 @@ import { AbstractInputComponent } from '../../abstract-input'
|
||||
templateUrl: './permissions-user.component.html',
|
||||
styleUrls: ['./permissions-user.component.scss'],
|
||||
})
|
||||
export class PermissionsUserComponent extends AbstractInputComponent<
|
||||
PaperlessUser[]
|
||||
> {
|
||||
users: PaperlessUser[]
|
||||
export class PermissionsUserComponent extends AbstractInputComponent<User[]> {
|
||||
users: User[]
|
||||
|
||||
constructor(userService: UserService, settings: SettingsService) {
|
||||
super()
|
||||
|
@@ -10,7 +10,7 @@ import {
|
||||
NG_VALUE_ACCESSOR,
|
||||
} from '@angular/forms'
|
||||
import { SelectComponent } from './select.component'
|
||||
import { PaperlessTag } from 'src/app/data/paperless-tag'
|
||||
import { Tag } from 'src/app/data/tag'
|
||||
import {
|
||||
DEFAULT_MATCHING_ALGORITHM,
|
||||
MATCH_ALL,
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
import { NgSelectModule } from '@ng-select/ng-select'
|
||||
import { RouterTestingModule } from '@angular/router/testing'
|
||||
|
||||
const items: PaperlessTag[] = [
|
||||
const items: Tag[] = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Tag1',
|
||||
|
@@ -5,7 +5,7 @@ import {
|
||||
NG_VALUE_ACCESSOR,
|
||||
} from '@angular/forms'
|
||||
import { TagsComponent } from './tags.component'
|
||||
import { PaperlessTag } from 'src/app/data/paperless-tag'
|
||||
import { Tag } from 'src/app/data/tag'
|
||||
import {
|
||||
DEFAULT_MATCHING_ALGORITHM,
|
||||
MATCH_ALL,
|
||||
@@ -31,7 +31,7 @@ import { PermissionsFormComponent } from '../permissions/permissions-form/permis
|
||||
import { SelectComponent } from '../select/select.component'
|
||||
import { SettingsService } from 'src/app/services/settings.service'
|
||||
|
||||
const tags: PaperlessTag[] = [
|
||||
const tags: Tag[] = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Tag1',
|
||||
|
@@ -9,7 +9,7 @@ import {
|
||||
} from '@angular/core'
|
||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { PaperlessTag } from 'src/app/data/paperless-tag'
|
||||
import { Tag } from 'src/app/data/tag'
|
||||
import { TagEditDialogComponent } from '../../edit-dialog/tag-edit-dialog/tag-edit-dialog.component'
|
||||
import { TagService } from 'src/app/services/rest/tag.service'
|
||||
import { EditDialogMode } from '../../edit-dialog/edit-dialog.component'
|
||||
@@ -81,13 +81,13 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
|
||||
horizontal: boolean = false
|
||||
|
||||
@Output()
|
||||
filterDocuments = new EventEmitter<PaperlessTag[]>()
|
||||
filterDocuments = new EventEmitter<Tag[]>()
|
||||
|
||||
@ViewChild('tagSelect') select: NgSelectComponent
|
||||
|
||||
value: number[] = []
|
||||
|
||||
tags: PaperlessTag[] = []
|
||||
tags: Tag[] = []
|
||||
|
||||
public createTagRef: (name) => void
|
||||
|
||||
|
Reference in New Issue
Block a user