more fixes regarding empty titles

This commit is contained in:
jonaswinkler 2020-12-16 16:44:54 +01:00
parent dec17a3b9b
commit 8e339789fa
5 changed files with 9 additions and 6 deletions

View File

@ -119,7 +119,8 @@ import { MetadataCollapseComponent } from './components/document-detail/metadata
useClass: CsrfInterceptor, useClass: CsrfInterceptor,
multi: true multi: true
}, },
FilterPipe FilterPipe,
DocumentTitlePipe
], ],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })

View File

@ -65,7 +65,7 @@
<svg class="sidebaricon" fill="currentColor"> <svg class="sidebaricon" fill="currentColor">
<use xlink:href="assets/bootstrap-icons.svg#file-text"/> <use xlink:href="assets/bootstrap-icons.svg#file-text"/>
</svg> </svg>
{{d.title}} {{d.title | documentTitle}}
</a> </a>
</li> </li>
<li class="nav-item w-100" *ngIf="openDocuments.length > 1"> <li class="nav-item w-100" *ngIf="openDocuments.length > 1">

View File

@ -13,7 +13,7 @@
<tbody> <tbody>
<tr *ngFor="let doc of documents" routerLink="/documents/{{doc.id}}"> <tr *ngFor="let doc of documents" routerLink="/documents/{{doc.id}}">
<td>{{doc.created | date}}</td> <td>{{doc.created | date}}</td>
<td>{{doc.title}}<app-tag [tag]="t" *ngFor="let t of doc.tags$ | async" class="ml-1"></app-tag> <td>{{doc.title | documentTitle}}<app-tag [tag]="t" *ngFor="let t of doc.tags$ | async" class="ml-1"></app-tag>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

@ -6,6 +6,7 @@ import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent';
import { PaperlessDocument } from 'src/app/data/paperless-document'; import { PaperlessDocument } from 'src/app/data/paperless-document';
import { PaperlessDocumentMetadata } from 'src/app/data/paperless-document-metadata'; import { PaperlessDocumentMetadata } from 'src/app/data/paperless-document-metadata';
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type'; import { PaperlessDocumentType } from 'src/app/data/paperless-document-type';
import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe';
import { DocumentListViewService } from 'src/app/services/document-list-view.service'; import { DocumentListViewService } from 'src/app/services/document-list-view.service';
import { OpenDocumentsService } from 'src/app/services/open-documents.service'; import { OpenDocumentsService } from 'src/app/services/open-documents.service';
import { CorrespondentService } from 'src/app/services/rest/correspondent.service'; import { CorrespondentService } from 'src/app/services/rest/correspondent.service';
@ -54,7 +55,8 @@ export class DocumentDetailComponent implements OnInit {
private router: Router, private router: Router,
private modalService: NgbModal, private modalService: NgbModal,
private openDocumentService: OpenDocumentsService, private openDocumentService: OpenDocumentsService,
private documentListViewService: DocumentListViewService) { } private documentListViewService: DocumentListViewService,
private documentTitlePipe: DocumentTitlePipe) { }
getContentType() { getContentType() {
return this.metadata?.has_archive_version ? 'application/pdf' : this.metadata?.original_mime_type return this.metadata?.has_archive_version ? 'application/pdf' : this.metadata?.original_mime_type
@ -90,7 +92,7 @@ export class DocumentDetailComponent implements OnInit {
this.documentsService.getMetadata(doc.id).subscribe(result => { this.documentsService.getMetadata(doc.id).subscribe(result => {
this.metadata = result this.metadata = result
}) })
this.title = doc.title this.title = this.documentTitlePipe.transform(doc.title)
this.documentForm.patchValue(doc) this.documentForm.patchValue(doc)
} }

View File

@ -5,7 +5,7 @@ import { Pipe, PipeTransform } from '@angular/core';
}) })
export class DocumentTitlePipe implements PipeTransform { export class DocumentTitlePipe implements PipeTransform {
transform(value: string): unknown { transform(value: string): string {
if (value) { if (value) {
return value return value
} else { } else {