mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	adjustments of the front end for API changes.
This commit is contained in:
		| @@ -13,7 +13,7 @@ | ||||
|     <tbody> | ||||
|       <tr *ngFor="let doc of documents" routerLink="/documents/{{doc.id}}"> | ||||
|         <td>{{doc.created | date}}</td> | ||||
|         <td>{{doc.title}}<app-tag [tag]="t" *ngFor="let t of doc.tags" class="ml-1"></app-tag> | ||||
|         <td>{{doc.title}}<app-tag [tag]="t" *ngFor="let t of doc.tags_objects" class="ml-1"></app-tag> | ||||
|       </tr> | ||||
|     </tbody> | ||||
|   </table> | ||||
|   | ||||
| @@ -53,11 +53,11 @@ | ||||
|                 <textarea class="form-control" id="content" rows="5" formControlName='content'></textarea> | ||||
|             </div> | ||||
|  | ||||
|             <app-input-select [items]="correspondents" title="Correspondent" formControlName="correspondent_id" allowNull="true" (createNew)="createCorrespondent()"></app-input-select> | ||||
|             <app-input-select [items]="correspondents" title="Correspondent" formControlName="correspondent" allowNull="true" (createNew)="createCorrespondent()"></app-input-select> | ||||
|  | ||||
|             <app-input-select [items]="documentTypes" title="Document type" formControlName="document_type_id" allowNull="true" (createNew)="createDocumentType()"></app-input-select> | ||||
|             <app-input-select [items]="documentTypes" title="Document type" formControlName="document_type" allowNull="true" (createNew)="createDocumentType()"></app-input-select> | ||||
|  | ||||
|             <app-input-tags formControlName="tags_id" title="Tags"></app-input-tags> | ||||
|             <app-input-tags formControlName="tags" title="Tags"></app-input-tags> | ||||
|  | ||||
|             <button type="button" class="btn btn-outline-secondary" (click)="discard()">Discard</button>  | ||||
|             <button type="button" class="btn btn-outline-primary" (click)="saveEditNext()" *ngIf="hasNext()">Save & edit next</button>  | ||||
|   | ||||
| @@ -37,10 +37,10 @@ export class DocumentDetailComponent implements OnInit { | ||||
|     title: new FormControl(''), | ||||
|     content: new FormControl(''), | ||||
|     created: new FormControl(), | ||||
|     correspondent_id: new FormControl(), | ||||
|     document_type_id: new FormControl(), | ||||
|     correspondent: new FormControl(), | ||||
|     document_type: new FormControl(), | ||||
|     archive_serial_number: new FormControl(), | ||||
|     tags_id: new FormControl([]) | ||||
|     tags: new FormControl([]) | ||||
|   }) | ||||
|  | ||||
|   constructor( | ||||
| @@ -93,7 +93,7 @@ export class DocumentDetailComponent implements OnInit { | ||||
|     modal.componentInstance.success.subscribe(newDocumentType => { | ||||
|       this.documentTypeService.listAll().subscribe(documentTypes => { | ||||
|         this.documentTypes = documentTypes.results | ||||
|         this.documentForm.get('document_type_id').setValue(newDocumentType.id) | ||||
|         this.documentForm.get('document_type').setValue(newDocumentType.id) | ||||
|       }) | ||||
|     }) | ||||
|   } | ||||
| @@ -104,7 +104,7 @@ export class DocumentDetailComponent implements OnInit { | ||||
|     modal.componentInstance.success.subscribe(newCorrespondent => { | ||||
|       this.correspondentService.listAll().subscribe(correspondents => { | ||||
|         this.correspondents = correspondents.results | ||||
|         this.documentForm.get('correspondent_id').setValue(newCorrespondent.id) | ||||
|         this.documentForm.get('correspondent').setValue(newCorrespondent.id) | ||||
|       }) | ||||
|     }) | ||||
|   } | ||||
|   | ||||
| @@ -8,12 +8,12 @@ | ||||
|  | ||||
|         <div class="d-flex justify-content-between align-items-center"> | ||||
|           <h5 class="card-title">     | ||||
|             <ng-container *ngIf="document.correspondent"> | ||||
|               <a *ngIf="clickCorrespondent.observers.length ; else nolink" [routerLink]="" title="Filter by correspondent" (click)="clickCorrespondent.emit(document.correspondent)" class="font-weight-bold">{{document.correspondent.name}}</a> | ||||
|               <ng-template #nolink>{{document.correspondent.name}}</ng-template>: | ||||
|             <ng-container *ngIf="document.correspondent_object"> | ||||
|               <a *ngIf="clickCorrespondent.observers.length ; else nolink" [routerLink]="" title="Filter by correspondent" (click)="clickCorrespondent.emit(document.correspondent)" class="font-weight-bold">{{document.correspondent_object.name}}</a> | ||||
|               <ng-template #nolink>{{document.correspondent_object.name}}</ng-template>: | ||||
|             </ng-container> | ||||
|             {{document.title}} | ||||
|             <app-tag [tag]="t" linkTitle="Filter by tag" *ngFor="let t of document.tags" class="ml-1" (click)="clickTag.emit(t)" [clickable]="clickTag.observers.length"></app-tag> | ||||
|             <app-tag [tag]="t" linkTitle="Filter by tag" *ngFor="let t of document.tags_objects" class="ml-1" (click)="clickTag.emit(t.id)" [clickable]="clickTag.observers.length"></app-tag> | ||||
|           </h5> | ||||
|           <h5 class="card-title" *ngIf="document.archive_serial_number">#{{document.archive_serial_number}}</h5> | ||||
|         </div> | ||||
|   | ||||
| @@ -20,10 +20,10 @@ export class DocumentCardLargeComponent implements OnInit { | ||||
|   details: any | ||||
|  | ||||
|   @Output() | ||||
|   clickTag = new EventEmitter<PaperlessTag>() | ||||
|   clickTag = new EventEmitter<number>() | ||||
|  | ||||
|   @Output() | ||||
|   clickCorrespondent = new EventEmitter<PaperlessDocument>() | ||||
|   clickCorrespondent = new EventEmitter<number>() | ||||
|  | ||||
|   ngOnInit(): void { | ||||
|   } | ||||
|   | ||||
| @@ -1,15 +1,15 @@ | ||||
| <div class="col p-2 h-100" style="width: 16rem;"> | ||||
|   <div class="card h-100 shadow-sm"> | ||||
|     <div class=" border-bottom doc-img pr-1" [ngStyle]="{'background-image': 'url(' + getThumbUrl() + ')'}"> | ||||
|       <div class="row" *ngFor="let t of document.tags"> | ||||
|         <app-tag style="font-size: large;" [tag]="t" class="col text-right" (click)="clickTag.emit(t)" [clickable]="true" linkTitle="Filter by tag"></app-tag> | ||||
|       <div class="row" *ngFor="let t of document.tags_objects"> | ||||
|         <app-tag style="font-size: large;" [tag]="t" class="col text-right" (click)="clickTag.emit(t.id)" [clickable]="true" linkTitle="Filter by tag"></app-tag> | ||||
|       </div> | ||||
|     </div> | ||||
|      | ||||
|     <div class="card-body p-2"> | ||||
|       <p class="card-text"> | ||||
|         <ng-container *ngIf="document.correspondent"> | ||||
|           <a [routerLink]="" title="Filter by correspondent" (click)="clickCorrespondent.emit(document.correspondent)" class="font-weight-bold">{{document.correspondent.name}}</a>: | ||||
|         <ng-container *ngIf="document.correspondent_object"> | ||||
|           <a [routerLink]="" title="Filter by correspondent" (click)="clickCorrespondent.emit(document.correspondent)" class="font-weight-bold">{{document.correspondent_object.name}}</a>: | ||||
|         </ng-container> | ||||
|         {{document.title}} | ||||
|       </p> | ||||
|   | ||||
| @@ -16,10 +16,10 @@ export class DocumentCardSmallComponent implements OnInit { | ||||
|   document: PaperlessDocument | ||||
|  | ||||
|   @Output() | ||||
|   clickTag = new EventEmitter<PaperlessTag>() | ||||
|   clickTag = new EventEmitter<number>() | ||||
|  | ||||
|   @Output() | ||||
|   clickCorrespondent = new EventEmitter<PaperlessDocument>() | ||||
|   clickCorrespondent = new EventEmitter<number>() | ||||
|  | ||||
|   ngOnInit(): void { | ||||
|   } | ||||
|   | ||||
| @@ -100,17 +100,17 @@ | ||||
|         {{d.archive_serial_number}} | ||||
|       </td> | ||||
|       <td class="d-none d-md-table-cell"> | ||||
|         <ng-container *ngIf="d.correspondent"> | ||||
|           <a [routerLink]="" (click)="filterByCorrespondent(d.correspondent)" title="Filter by correspondent">{{d.correspondent.name}}</a> | ||||
|         <ng-container *ngIf="d.correspondent_object"> | ||||
|           <a [routerLink]="" (click)="filterByCorrespondent(d.correspondent)" title="Filter by correspondent">{{d.correspondent_object.name}}</a> | ||||
|         </ng-container> | ||||
|       </td> | ||||
|       <td> | ||||
|         <a routerLink="/documents/{{d.id}}" title="Edit document">{{d.title}}</a> | ||||
|         <app-tag [tag]="t" *ngFor="let t of d.tags" class="ml-1" clickable="true" linkTitle="Filter by tag" (click)="filterByTag(t)"></app-tag> | ||||
|         <app-tag [tag]="t" *ngFor="let t of d.tags_objects" class="ml-1" clickable="true" linkTitle="Filter by tag" (click)="filterByTag(t.id)"></app-tag> | ||||
|       </td> | ||||
|       <td class="d-none d-xl-table-cell"> | ||||
|         <ng-container *ngIf="d.document_type"> | ||||
|           <a [routerLink]="" (click)="filterByDocumentType(d.document_type)" title="Filter by document type">{{d.document_type.name}}</a> | ||||
|         <ng-container *ngIf="d.document_type_object"> | ||||
|           <a [routerLink]="" (click)="filterByDocumentType(d.document_type)" title="Filter by document type">{{d.document_type_object.name}}</a> | ||||
|         </ng-container> | ||||
|       </td> | ||||
|       <td> | ||||
|   | ||||
| @@ -95,40 +95,40 @@ export class DocumentListComponent implements OnInit { | ||||
|     }) | ||||
|   } | ||||
|  | ||||
|   filterByTag(t: PaperlessTag) { | ||||
|   filterByTag(tag_id: number) { | ||||
|     let filterRules = this.list.filterRules | ||||
|     if (filterRules.find(rule => rule.type.id == FILTER_HAS_TAG && rule.value == t.id)) { | ||||
|     if (filterRules.find(rule => rule.type.id == FILTER_HAS_TAG && rule.value == tag_id)) { | ||||
|       return | ||||
|     } | ||||
|  | ||||
|     filterRules.push({type: FILTER_RULE_TYPES.find(t => t.id == FILTER_HAS_TAG), value: t.id}) | ||||
|     filterRules.push({type: FILTER_RULE_TYPES.find(t => t.id == FILTER_HAS_TAG), value: tag_id}) | ||||
|     this.filterRules = filterRules | ||||
|     this.applyFilterRules() | ||||
|   } | ||||
|  | ||||
|   filterByCorrespondent(c: PaperlessCorrespondent) { | ||||
|   filterByCorrespondent(correspondent_id: number) { | ||||
|     let filterRules = this.list.filterRules | ||||
|     let existing_rule = filterRules.find(rule => rule.type.id == FILTER_CORRESPONDENT) | ||||
|     if (existing_rule && existing_rule.value == c.id) { | ||||
|     if (existing_rule && existing_rule.value == correspondent_id) { | ||||
|       return | ||||
|     } else if (existing_rule) { | ||||
|       existing_rule.value = c.id | ||||
|       existing_rule.value = correspondent_id | ||||
|     } else { | ||||
|       filterRules.push({type: FILTER_RULE_TYPES.find(t => t.id == FILTER_CORRESPONDENT), value: c.id}) | ||||
|       filterRules.push({type: FILTER_RULE_TYPES.find(t => t.id == FILTER_CORRESPONDENT), value: correspondent_id}) | ||||
|     } | ||||
|     this.filterRules = filterRules | ||||
|     this.applyFilterRules() | ||||
|   } | ||||
|  | ||||
|   filterByDocumentType(dt: PaperlessDocumentType) { | ||||
|   filterByDocumentType(document_type_id: number) { | ||||
|     let filterRules = this.list.filterRules | ||||
|     let existing_rule = filterRules.find(rule => rule.type.id == FILTER_DOCUMENT_TYPE) | ||||
|     if (existing_rule && existing_rule.value == dt.id) { | ||||
|     if (existing_rule && existing_rule.value == document_type_id) { | ||||
|       return | ||||
|     } else if (existing_rule) { | ||||
|       existing_rule.value = dt.id | ||||
|       existing_rule.value = document_type_id | ||||
|     } else { | ||||
|       filterRules.push({type: FILTER_RULE_TYPES.find(t => t.id == FILTER_DOCUMENT_TYPE), value: dt.id}) | ||||
|       filterRules.push({type: FILTER_RULE_TYPES.find(t => t.id == FILTER_DOCUMENT_TYPE), value: document_type_id}) | ||||
|     } | ||||
|     this.filterRules = filterRules | ||||
|     this.applyFilterRules() | ||||
|   | ||||
| @@ -5,13 +5,13 @@ import { PaperlessDocumentType } from './paperless-document-type' | ||||
|  | ||||
| export interface PaperlessDocument extends ObjectWithId { | ||||
|  | ||||
|     correspondent?: PaperlessCorrespondent | ||||
|     correspondent_object?: PaperlessCorrespondent | ||||
|  | ||||
|     correspondent_id?: number | ||||
|     correspondent?: number | ||||
|  | ||||
|     document_type?: PaperlessDocumentType | ||||
|     document_type_object?: PaperlessDocumentType | ||||
|  | ||||
|     document_type_id?: number | ||||
|     document_type?: number | ||||
|  | ||||
|     title?: string | ||||
|  | ||||
| @@ -19,9 +19,9 @@ export interface PaperlessDocument extends ObjectWithId { | ||||
|  | ||||
|     file_type?: string | ||||
|  | ||||
|     tags?: PaperlessTag[] | ||||
|     tags_objects?: PaperlessTag[] | ||||
|  | ||||
|     tags_id?: number[] | ||||
|     tags?: number[] | ||||
|  | ||||
|     checksum?: string | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 jonaswinkler
					jonaswinkler