diff --git a/src-ui/src/app/app.module.ts b/src-ui/src/app/app.module.ts index c78dc3cfe..8cd28b6fc 100644 --- a/src-ui/src/app/app.module.ts +++ b/src-ui/src/app/app.module.ts @@ -57,6 +57,7 @@ import { DocumentTitlePipe } from './pipes/document-title.pipe'; import { MetadataCollapseComponent } from './components/document-detail/metadata-collapse/metadata-collapse.component'; import { SelectDialogComponent } from './components/common/select-dialog/select-dialog.component'; import { NgSelectModule } from '@ng-select/ng-select'; +import { NumberComponent } from './components/common/input/number/number.component'; @NgModule({ declarations: [ @@ -104,7 +105,8 @@ import { NgSelectModule } from '@ng-select/ng-select'; FilterPipe, DocumentTitlePipe, MetadataCollapseComponent, - SelectDialogComponent + SelectDialogComponent, + NumberComponent ], imports: [ BrowserModule, diff --git a/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.ts b/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.ts index 8f7af1418..ff4660ca3 100644 --- a/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.ts +++ b/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.ts @@ -2,6 +2,7 @@ import { Directive, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { Observable } from 'rxjs'; +import { map } from 'rxjs/operators'; import { MATCHING_ALGORITHMS, MATCH_AUTO } from 'src/app/data/matching-model'; import { ObjectWithId } from 'src/app/data/object-with-id'; import { AbstractPaperlessService } from 'src/app/services/rest/abstract-paperless-service'; @@ -24,6 +25,10 @@ export abstract class EditDialogComponent implements OnI @Output() success = new EventEmitter() + networkActive = false + + error = null + abstract getForm(): FormGroup objectForm: FormGroup = this.getForm() @@ -77,11 +82,14 @@ export abstract class EditDialogComponent implements OnI default: break; } + this.networkActive = true serverResponse.subscribe(result => { this.activeModal.close() this.success.emit(result) + this.networkActive = false }, error => { - this.toastService.showError(this.getSaveErrorMessage(error.error.name)) + this.error = error.error + this.networkActive = false }) } diff --git a/src-ui/src/app/components/common/input/abstract-input.ts b/src-ui/src/app/components/common/input/abstract-input.ts index 78a4a1b69..f6039d2ec 100644 --- a/src-ui/src/app/components/common/input/abstract-input.ts +++ b/src-ui/src/app/components/common/input/abstract-input.ts @@ -30,6 +30,9 @@ export class AbstractInputComponent implements OnInit, ControlValueAccessor { @Input() disabled = false; + @Input() + error: string + value: T ngOnInit(): void { diff --git a/src-ui/src/app/components/common/input/number/number.component.html b/src-ui/src/app/components/common/input/number/number.component.html new file mode 100644 index 000000000..aa3a893d3 --- /dev/null +++ b/src-ui/src/app/components/common/input/number/number.component.html @@ -0,0 +1,8 @@ +
+ + + {{hint}} +
+ {{error}} +
+
\ No newline at end of file diff --git a/src-ui/src/app/components/common/input/number/number.component.scss b/src-ui/src/app/components/common/input/number/number.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src-ui/src/app/components/common/input/number/number.component.spec.ts b/src-ui/src/app/components/common/input/number/number.component.spec.ts new file mode 100644 index 000000000..3476cbc22 --- /dev/null +++ b/src-ui/src/app/components/common/input/number/number.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { NumberComponent } from './number.component'; + +describe('NumberComponent', () => { + let component: NumberComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ NumberComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(NumberComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src-ui/src/app/components/common/input/number/number.component.ts b/src-ui/src/app/components/common/input/number/number.component.ts new file mode 100644 index 000000000..987a4090b --- /dev/null +++ b/src-ui/src/app/components/common/input/number/number.component.ts @@ -0,0 +1,21 @@ +import { Component, forwardRef } from '@angular/core'; +import { NG_VALUE_ACCESSOR } from '@angular/forms'; +import { AbstractInputComponent } from '../abstract-input'; + +@Component({ + providers: [{ + provide: NG_VALUE_ACCESSOR, + useExisting: forwardRef(() => NumberComponent), + multi: true + }], + selector: 'app-input-number', + templateUrl: './number.component.html', + styleUrls: ['./number.component.scss'] +}) +export class NumberComponent extends AbstractInputComponent { + + constructor() { + super() + } + +} diff --git a/src-ui/src/app/components/common/input/text/text.component.html b/src-ui/src/app/components/common/input/text/text.component.html index 3a43b052f..78aa76577 100644 --- a/src-ui/src/app/components/common/input/text/text.component.html +++ b/src-ui/src/app/components/common/input/text/text.component.html @@ -1,5 +1,8 @@
- + {{hint}} +
+ {{error}} +
\ No newline at end of file diff --git a/src-ui/src/app/components/document-detail/document-detail.component.html b/src-ui/src/app/components/document-detail/document-detail.component.html index eae3367c1..4092b5a60 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.html +++ b/src-ui/src/app/components/document-detail/document-detail.component.html @@ -56,12 +56,8 @@ Details - -
- - -
+ + diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts index 053258f34..84a03446a 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.ts @@ -24,8 +24,12 @@ import { PDFDocumentProxy } from 'ng2-pdf-viewer'; }) export class DocumentDetailComponent implements OnInit { - public expandOriginalMetadata = false; - public expandArchivedMetadata = false; + expandOriginalMetadata = false + expandArchivedMetadata = false + + error: any + + networkActive = false documentId: number document: PaperlessDocument @@ -131,19 +135,33 @@ export class DocumentDetailComponent implements OnInit { } save() { + this.networkActive = true this.documentsService.update(this.document).subscribe(result => { this.close() + this.networkActive = false + this.error = null + }, error => { + this.networkActive = false + this.error = error.error }) } saveEditNext() { + this.networkActive = true this.documentsService.update(this.document).subscribe(result => { + this.error = null this.documentListViewService.getNext(this.document.id).subscribe(nextDocId => { + this.networkActive = false if (nextDocId) { this.openDocumentService.closeDocument(this.document) this.router.navigate(['documents', nextDocId]) } + }, error => { + this.networkActive = false }) + }, error => { + this.networkActive = false + this.error = error.error }) } diff --git a/src-ui/src/app/components/manage/correspondent-list/correspondent-edit-dialog/correspondent-edit-dialog.component.html b/src-ui/src/app/components/manage/correspondent-list/correspondent-edit-dialog/correspondent-edit-dialog.component.html index 48477b229..e2b7f13e0 100644 --- a/src-ui/src/app/components/manage/correspondent-list/correspondent-edit-dialog/correspondent-edit-dialog.component.html +++ b/src-ui/src/app/components/manage/correspondent-list/correspondent-edit-dialog/correspondent-edit-dialog.component.html @@ -1,4 +1,4 @@ -
+