Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
Check for live changes on document detail title
Browse files Browse the repository at this point in the history
  • Loading branch information
shamoon committed Feb 16, 2022
1 parent 8c853e5 commit 9bc48fe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<a ngbNavLink i18n>Details</a>
<ng-template ngbNavContent>

<app-input-text #inputTitle i18n-title title="Title" formControlName="title" [error]="error?.title"></app-input-text>
<app-input-text #inputTitle i18n-title title="Title" formControlName="title" (keyup)="titleKeyUp($event)" [error]="error?.title"></app-input-text>
<app-input-number i18n-title title="Archive serial number" [error]="error?.archive_serial_number" formControlName='archive_serial_number'></app-input-number>
<app-input-date i18n-title title="Date created" formControlName="created" [error]="error?.created"></app-input-date>
<app-input-select [items]="correspondents" i18n-title title="Correspondent" formControlName="correspondent" [allowNull]="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { TextComponent } from '../common/input/text/text.component';
import { SettingsService, SETTINGS_KEYS } from 'src/app/services/settings.service';
import { dirtyCheck, DirtyComponent } from '@ngneat/dirty-check-forms';
import { Observable, Subject, BehaviorSubject } from 'rxjs';
import { first, takeUntil, switchMap, map } from 'rxjs/operators';
import { first, takeUntil, switchMap, map, debounceTime, distinctUntilChanged } from 'rxjs/operators';
import { PaperlessDocumentSuggestions } from 'src/app/data/paperless-document-suggestions';
import { FILTER_FULLTEXT_MORELIKE } from 'src/app/data/filter-rule-type';

Expand All @@ -48,6 +48,7 @@ export class DocumentDetailComponent implements OnInit, OnDestroy, DirtyComponen
suggestions: PaperlessDocumentSuggestions

title: string
titleSubject: Subject<string> = new Subject()
previewUrl: string
downloadUrl: string
downloadOriginalUrl: string
Expand Down Expand Up @@ -91,7 +92,19 @@ export class DocumentDetailComponent implements OnInit, OnDestroy, DirtyComponen
private documentListViewService: DocumentListViewService,
private documentTitlePipe: DocumentTitlePipe,
private toastService: ToastService,
private settings: SettingsService) { }
private settings: SettingsService) {
this.titleSubject.pipe(
debounceTime(200),
distinctUntilChanged(),
takeUntil(this.unsubscribeNotifier)
).subscribe(titleValue => {
this.documentForm.patchValue({'title': titleValue})
})
}

titleKeyUp(event) {
this.titleSubject.next(event.target?.value)
}

get useNativePdfViewer(): boolean {
return this.settings.get(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER)
Expand Down

0 comments on commit 9bc48fe

Please sign in to comment.