Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Fix broken card tags / correspondent links

Michael Shamoone7cb35853615
diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html
index bfc59b526..430a76a23 100644
--- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html
+++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html
@@ -7,7 +7,7 @@
<div class="card-body">
<div class="d-flex justify-content-between align-items-center">
- <h5 class="card-title">
+ <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$ | async)?.name}}</a>
<ng-template #nolink>{{(document.correspondent$ | async)?.name}}</ng-template>:
@@ -52,4 +52,4 @@
</div>
</div>
</div>
-</div>
\ No newline at end of file
+</div>
diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html
index 95cf2e191..b2e7b0218 100644
--- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html
+++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html
@@ -11,7 +11,7 @@
</div>
</div>
</div>
-
+
<div class="card-body p-2">
<p class="card-text">
<ng-container *ngIf="document.correspondent">
@@ -44,7 +44,7 @@
</div>
<small class="text-muted">{{document.created | date}}</small>
</div>
-
+
</div>
- </div>
-</div>
\ No newline at end of file
+ </div>
+</div>
diff --git a/src-ui/src/app/components/document-list/document-list.component.html b/src-ui/src/app/components/document-list/document-list.component.html
index f8c3445c5..a6ec1b741 100644
--- a/src-ui/src/app/components/document-list/document-list.component.html
+++ b/src-ui/src/app/components/document-list/document-list.component.html
@@ -64,7 +64,7 @@
<div class="card w-100 mb-3">
<div class="card-body">
- <app-filter-editor [(filterRules)]="filterRules" (apply)="applyFilterRules()" (clear)="clearFilterRules()"></app-filter-editor>
+ <app-filter-editor [(filterRules)]="filterRules" (apply)="applyFilterRules()" (clear)="clearFilterRules()" #filterEditor></app-filter-editor>
</div>
</div>
@@ -75,7 +75,7 @@
</div>
<div *ngIf="displayMode == 'largeCards'">
- <app-document-card-large *ngFor="let d of list.documents" [document]="d" [details]="d.content" (clickTag)="filterByTag($event)" (clickCorrespondent)="filterByCorrespondent($event)">
+ <app-document-card-large *ngFor="let d of list.documents" [document]="d" [details]="d.content" (clickTag)="clickTag($event)" (clickCorrespondent)="clickCorrespondent($event)">
</app-document-card-large>
</div>
@@ -95,16 +95,16 @@
</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$ | async)?.name}}</a>
+ <a [routerLink]="" (click)="clickCorrespondent(d.correspondent)" title="Filter by correspondent">{{(d.correspondent$ | async)?.name}}</a>
</ng-container>
</td>
<td>
<a routerLink="/documents/{{d.id}}" title="Edit document" style="overflow-wrap: anywhere;">{{d.title}}</a>
- <app-tag [tag]="t" *ngFor="let t of d.tags$ | async" class="ml-1" clickable="true" linkTitle="Filter by tag" (click)="filterByTag(t.id)"></app-tag>
+ <app-tag [tag]="t" *ngFor="let t of d.tags$ | async" class="ml-1" clickable="true" linkTitle="Filter by tag" (click)="clickTag(t)"></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$ | async)?.name}}</a>
+ <a [routerLink]="" (click)="clickDocumentType(d.document_type)" title="Filter by document type">{{(d.document_type$ | async)?.name}}</a>
</ng-container>
</td>
<td>
@@ -119,5 +119,5 @@
<div class=" m-n2 row" *ngIf="displayMode == 'smallCards'">
- <app-document-card-small [document]="d" *ngFor="let d of list.documents" (clickTag)="filterByTag($event)" (clickCorrespondent)="filterByCorrespondent($event)"></app-document-card-small>
+ <app-document-card-small [document]="d" *ngFor="let d of list.documents" (clickTag)="clickTag($event)" (clickCorrespondent)="clickCorrespondent($event)"></app-document-card-small>
</div>
diff --git a/src-ui/src/app/components/document-list/document-list.component.ts b/src-ui/src/app/components/document-list/document-list.component.ts
index 3ce00beab..5bbd5b49d 100644
--- a/src-ui/src/app/components/document-list/document-list.component.ts
+++ b/src-ui/src/app/components/document-list/document-list.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit } from '@angular/core';
+import { Component, OnInit, ViewChild } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { ActivatedRoute } from '@angular/router';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
@@ -11,6 +11,10 @@ import { SavedViewConfigService } from 'src/app/services/saved-view-config.servi
import { Toast, ToastService } from 'src/app/services/toast.service';
import { environment } from 'src/environments/environment';
import { SaveViewConfigDialogComponent } from './save-view-config-dialog/save-view-config-dialog.component';
+import { FilterEditorComponent } from './filter-editor/filter-editor.component';
+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';
@Component({
selector: 'app-document-list',
@@ -31,6 +35,8 @@ export class DocumentListComponent implements OnInit {
filterRules: FilterRule[] = []
+ @ViewChild('filterEditor') filterEditor: FilterEditorComponent
+
get isFiltered() {
return this.list.filterRules?.length > 0
}
@@ -99,4 +105,16 @@ export class DocumentListComponent implements OnInit {
})
}
+ clickTag(tagID: number) {
+ this.filterEditor.toggleFilterByItem(tagID, FILTER_HAS_TAG)
+ }
+
+ clickCorrespondent(correspondentID: number) {
+ this.filterEditor.toggleFilterByItem(correspondentID, FILTER_CORRESPONDENT)
+ }
+
+ clickDocumentType(documentTypeID: number) {
+ this.filterEditor.toggleFilterByItem(documentTypeID, FILTER_DOCUMENT_TYPE)
+ }
+
}
diff --git a/src-ui/src/app/components/filter-editor/filter-editor.component.ts b/src-ui/src/app/components/filter-editor/filter-editor.component.ts
index 93a91473f..b73b4387b 100644
--- a/src-ui/src/app/components/filter-editor/filter-editor.component.ts
+++ b/src-ui/src/app/components/filter-editor/filter-editor.component.ts
@@ -1,9 +1,9 @@
import { Component, EventEmitter, Input, OnInit, Output, ElementRef, AfterViewInit, QueryList, ViewChild, ViewChildren } from '@angular/core';
import { FilterRule } from 'src/app/data/filter-rule';
import { FilterRuleType, FILTER_RULE_TYPES, FILTER_CORRESPONDENT, FILTER_DOCUMENT_TYPE, FILTER_HAS_TAG, FILTER_TITLE, FILTER_ADDED_BEFORE, FILTER_ADDED_AFTER, FILTER_CREATED_BEFORE, FILTER_CREATED_AFTER, FILTER_CREATED_YEAR, FILTER_CREATED_MONTH, FILTER_CREATED_DAY } from 'src/app/data/filter-rule-type';
+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 { PaperlessTag } from 'src/app/data/paperless-tag';
import { AbstractPaperlessService } from 'src/app/services/rest/abstract-paperless-service';
import { ObjectWithId } from 'src/app/data/object-with-id';
import { CorrespondentService } from 'src/app/services/rest/correspondent.service';
@@ -120,7 +120,11 @@ export class FilterEditorComponent implements OnInit, AfterViewInit {
this.applySelected()
}
- toggleFilterByItem(item: ObjectWithId, filterRuleTypeID: number) {
+ toggleFilterByItem(item: any, filterRuleTypeID: number) {
+ let dropdown = this.getDropdownByFilterRuleTypeID(filterRuleTypeID)
+ if (typeof item == 'number') {
+ item = dropdown.items.find(i => i.id == item)
+ }
let filterRules = this.filterRules
let filterRuleType: FilterRuleType = FILTER_RULE_TYPES.find(t => t.id == filterRuleTypeID)
let existingRule = filterRules.find(rule => rule.type.id == filterRuleType.id)
@@ -137,7 +141,6 @@ export class FilterEditorComponent implements OnInit, AfterViewInit {
filterRules.push({type: FILTER_RULE_TYPES.find(t => t.id == filterRuleType.id), value: item.id})
}
- let dropdown = this.getDropdownByFilterRuleTypeID(filterRuleTypeID)
this.updateDropdownActiveItems(dropdown)
this.filterRules = filterRules