]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Dont use document data from /documents API call for edit 2028/head
authorMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Tue, 22 Nov 2022 23:25:27 +0000 (15:25 -0800)
committerMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Mon, 28 Nov 2022 05:19:23 +0000 (21:19 -0800)
src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html
src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.scss
src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts
src-ui/src/app/components/document-detail/document-detail.component.ts
src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html
src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts
src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html
src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts
src-ui/src/app/components/document-list/document-list.component.html
src-ui/src/app/services/open-documents.service.ts

index 84ee1aabe12527555d7ec23501ff89b52e6bdcc1..32ca3859ef2a0901fbe31d189a84270098bfaf71 100644 (file)
@@ -11,9 +11,9 @@
       </tr>
     </thead>
     <tbody>
-      <tr *ngFor="let doc of documents" (click)="openDocumentsService.openDocument(doc)">
-        <td>{{doc.created_date | customDate}}</td>
-        <td>{{doc.title | documentTitle}}<app-tag [tag]="t" *ngFor="let t of doc.tags$ | async" class="ms-1" (click)="clickTag(t); $event.stopPropagation();"></app-tag></td>
+      <tr *ngFor="let doc of documents">
+        <td><a routerLink="/documents/{{doc.id}}" class="d-block text-dark text-decoration-none">{{doc.created_date | customDate}}</a></td>
+        <td><a routerLink="/documents/{{doc.id}}" class="d-block text-dark text-decoration-none">{{doc.title | documentTitle}}<app-tag [tag]="t" *ngFor="let t of doc.tags$ | async" class="ms-1" (click)="clickTag(t, $event)"></app-tag></a></td>
       </tr>
     </tbody>
   </table>
index 65ea4de0b26653f966a67701bf033e00aadf6494..5e30ff8cd458e1f7c9badb716eb62dabd380e969 100644 (file)
@@ -72,7 +72,9 @@ export class SavedViewWidgetComponent implements OnInit, OnDestroy {
     }
   }
 
-  clickTag(tag: PaperlessTag) {
+  clickTag(tag: PaperlessTag, event: MouseEvent) {
+    event.preventDefault()
+
     this.list.quickFilter([
       { rule_type: FILTER_HAS_TAGS_ALL, value: tag.id.toString() },
     ])
index 72f7b3613def3385b268c12f2c4a19c78d008b81..557a0929f278b4455e12881bdf55cf349276ed31 100644 (file)
@@ -184,7 +184,7 @@ export class DocumentDetailComponent
               this.openDocumentService.getOpenDocument(this.documentId)
             )
           } else {
-            this.openDocumentService.openDocument(doc, false)
+            this.openDocumentService.openDocument(doc)
             this.updateComponent(doc)
           }
 
index 1b859f39b2622b23b4a0649f663ed106d812a95c..80aedb7f2bdb7f6f80a3dcea4af346138cb12b15 100644 (file)
@@ -37,7 +37,7 @@
                 <use xlink:href="assets/bootstrap-icons.svg#diagram-3"/>
               </svg>&nbsp;<span class="d-none d-md-inline" i18n>More like this</span>
             </a>
-            <a (click)="openDocumentsService.openDocument(document)" class="btn btn-sm btn-outline-secondary">
+            <a routerLink="/documents/{{document.id}}" class="btn btn-sm btn-outline-secondary">
               <svg class="sidebaricon" fill="currentColor" class="sidebaricon">
                 <use xlink:href="assets/bootstrap-icons.svg#pencil"/>
               </svg>&nbsp;<span class="d-none d-md-inline" i18n>Edit</span>
index 4ce1ef705fb2083c7893690e66287e2aca30431e..512cb51aeebc99fbdfa1aa495df3b254594461d7 100644 (file)
@@ -10,9 +10,6 @@ import { PaperlessDocument } from 'src/app/data/paperless-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 { OpenDocumentsService } from 'src/app/services/open-documents.service'
-import { DocumentListViewService } from 'src/app/services/document-list-view.service'
-import { FILTER_FULLTEXT_MORELIKE } from 'src/app/data/filter-rule-type'
 import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
 
 @Component({
@@ -26,8 +23,7 @@ import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
 export class DocumentCardLargeComponent implements OnInit {
   constructor(
     private documentService: DocumentService,
-    private settingsService: SettingsService,
-    public openDocumentsService: OpenDocumentsService
+    private settingsService: SettingsService
   ) {}
 
   @Input()
index aec8d76ae48f5ac3aa6505067ebda7bac5cd53b8..5e46ed7b4dd18f763d6f241f418638d3290ac990 100644 (file)
@@ -67,7 +67,7 @@
       </div>
       <div class="d-flex justify-content-between align-items-center">
         <div class="btn-group w-100">
-          <a (click)="openDocumentsService.openDocument(document)" class="btn btn-sm btn-outline-secondary" title="Edit" i18n-title>
+          <a routerLink="/documents/{{document.id}}" class="btn btn-sm btn-outline-secondary" title="Edit" i18n-title>
             <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-pencil" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
               <path fill-rule="evenodd" d="M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5L13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175l-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325z"/>
             </svg>
index 3f7fc79827eab918b7dea1b447311cdf8526f997..8e6ae33a66284afeee4b3425796be31a379685c4 100644 (file)
@@ -11,7 +11,6 @@ import { PaperlessDocument } from 'src/app/data/paperless-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 { OpenDocumentsService } from 'src/app/services/open-documents.service'
 import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
 
 @Component({
@@ -25,8 +24,7 @@ import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
 export class DocumentCardSmallComponent implements OnInit {
   constructor(
     private documentService: DocumentService,
-    private settingsService: SettingsService,
-    public openDocumentsService: OpenDocumentsService
+    private settingsService: SettingsService
   ) {}
 
   @Input()
index 9357813f603393fac717eb7cc3d8392cf8fcec97..892a0d3b24807202e2555e4bf1eff6eb15340942 100644 (file)
           </ng-container>
         </td>
         <td>
-          <a (click)="openDocumentsService.openDocument(d)" title="Edit document" i18n-title style="overflow-wrap: anywhere;">{{d.title | documentTitle}}</a>
+          <a routerLink="/documents/{{d.id}}" title="Edit document" i18n-title style="overflow-wrap: anywhere;">{{d.title | documentTitle}}</a>
           <app-tag [tag]="t" *ngFor="let t of d.tags$ | async" class="ms-1" clickable="true" linkTitle="Filter by tag" i18n-linkTitle (click)="clickTag(t.id);$event.stopPropagation()"></app-tag>
         </td>
         <td class="d-none d-xl-table-cell">
index 8533166c330a532aa1e979d3cbb827564aa049c9..a2152345825f8f6302136ef48cf44c4c29504a73 100644 (file)
@@ -6,7 +6,6 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
 import { ConfirmDialogComponent } from 'src/app/components/common/confirm-dialog/confirm-dialog.component'
 import { Observable, Subject, of } from 'rxjs'
 import { first } from 'rxjs/operators'
-import { Router } from '@angular/router'
 
 @Injectable({
   providedIn: 'root',
@@ -16,8 +15,7 @@ export class OpenDocumentsService {
 
   constructor(
     private documentService: DocumentService,
-    private modalService: NgbModal,
-    private router: Router
+    private modalService: NgbModal
   ) {
     if (sessionStorage.getItem(OPEN_DOCUMENT_SERVICE.DOCUMENTS)) {
       try {
@@ -57,39 +55,28 @@ export class OpenDocumentsService {
     return this.openDocuments.find((d) => d.id == id)
   }
 
-  openDocument(
-    doc: PaperlessDocument,
-    navigate: boolean = true
-  ): Observable<boolean> {
+  openDocument(doc: PaperlessDocument): Observable<boolean> {
     if (this.openDocuments.find((d) => d.id == doc.id) == null) {
       if (this.openDocuments.length == this.MAX_OPEN_DOCUMENTS) {
         // at max, ensure changes arent lost
         const docToRemove = this.openDocuments[this.MAX_OPEN_DOCUMENTS - 1]
         const closeObservable = this.closeDocument(docToRemove)
         closeObservable.pipe(first()).subscribe((closed) => {
-          if (closed) this.finishOpenDocument(doc, navigate)
+          if (closed) this.finishOpenDocument(doc)
         })
         return closeObservable
       } else {
         // not at max
-        this.finishOpenDocument(doc, navigate)
-      }
-    } else {
-      // doc is open, just maybe navigate
-      if (navigate) {
-        this.router.navigate(['documents', doc.id])
+        this.finishOpenDocument(doc)
       }
     }
     return of(true)
   }
 
-  private finishOpenDocument(doc: PaperlessDocument, navigate: boolean) {
+  private finishOpenDocument(doc: PaperlessDocument) {
     this.openDocuments.unshift(doc)
     this.dirtyDocuments.delete(doc.id)
     this.save()
-    if (navigate) {
-      this.router.navigate(['documents', doc.id])
-    }
   }
 
   setDirty(doc: PaperlessDocument, dirty: boolean) {