diff --git a/src-ui/src/app/app.module.ts b/src-ui/src/app/app.module.ts
index 3c1b37474..e10bdbd0c 100644
--- a/src-ui/src/app/app.module.ts
+++ b/src-ui/src/app/app.module.ts
@@ -39,6 +39,7 @@ import { CheckComponent } from './components/common/input/check/check.component'
import { SaveViewConfigDialogComponent } from './components/document-list/save-view-config-dialog/save-view-config-dialog.component';
import { InfiniteScrollModule } from 'ngx-infinite-scroll';
import { DateTimeComponent } from './components/common/input/date-time/date-time.component';
+import { TagsComponent } from './components/common/input/tags/tags.component';
@NgModule({
declarations: [
@@ -71,7 +72,8 @@ import { DateTimeComponent } from './components/common/input/date-time/date-time
SelectComponent,
CheckComponent,
SaveViewConfigDialogComponent,
- DateTimeComponent
+ DateTimeComponent,
+ TagsComponent
],
imports: [
BrowserModule,
diff --git a/src-ui/src/app/components/common/input/tags/tags.component.css b/src-ui/src/app/components/common/input/tags/tags.component.css
new file mode 100644
index 000000000..f2635b7f2
--- /dev/null
+++ b/src-ui/src/app/components/common/input/tags/tags.component.css
@@ -0,0 +1,10 @@
+.tags-form-control {
+ height: auto;
+}
+
+
+.scrollable-menu {
+ height: auto;
+ max-height: 300px;
+ overflow-x: hidden;
+}
\ No newline at end of file
diff --git a/src-ui/src/app/components/common/input/tags/tags.component.html b/src-ui/src/app/components/common/input/tags/tags.component.html
new file mode 100644
index 000000000..b2ad0944f
--- /dev/null
+++ b/src-ui/src/app/components/common/input/tags/tags.component.html
@@ -0,0 +1,30 @@
+
\ No newline at end of file
diff --git a/src-ui/src/app/components/common/input/tags/tags.component.spec.ts b/src-ui/src/app/components/common/input/tags/tags.component.spec.ts
new file mode 100644
index 000000000..582775da4
--- /dev/null
+++ b/src-ui/src/app/components/common/input/tags/tags.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { TagsComponent } from './tags.component';
+
+describe('TagsComponent', () => {
+ let component: TagsComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ TagsComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(TagsComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src-ui/src/app/components/common/input/tags/tags.component.ts b/src-ui/src/app/components/common/input/tags/tags.component.ts
new file mode 100644
index 000000000..7b5a36e90
--- /dev/null
+++ b/src-ui/src/app/components/common/input/tags/tags.component.ts
@@ -0,0 +1,96 @@
+import { ThrowStmt } from '@angular/compiler';
+import { Component, forwardRef, Input, OnInit } from '@angular/core';
+import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
+import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
+import { Observable } from 'rxjs';
+import { TagEditDialogComponent } from 'src/app/components/manage/tag-list/tag-edit-dialog/tag-edit-dialog.component';
+import { PaperlessTag } from 'src/app/data/paperless-tag';
+import { TagService } from 'src/app/services/rest/tag.service';
+
+@Component({
+ providers: [{
+ provide: NG_VALUE_ACCESSOR,
+ useExisting: forwardRef(() => TagsComponent),
+ multi: true
+ }],
+ selector: 'app-input-tags',
+ templateUrl: './tags.component.html',
+ styleUrls: ['./tags.component.css']
+})
+export class TagsComponent implements OnInit, ControlValueAccessor {
+
+ constructor(private tagService: TagService, private modalService: NgbModal) { }
+
+
+ onChange = (newValue: number[]) => {};
+
+ onTouched = () => {};
+
+ writeValue(newValue: number[]): void {
+ this.value = newValue
+ if (this.tags) {
+ this.displayValue = newValue
+ }
+ }
+ registerOnChange(fn: any): void {
+ this.onChange = fn;
+ }
+ registerOnTouched(fn: any): void {
+ this.onTouched = fn;
+ }
+ setDisabledState?(isDisabled: boolean): void {
+ this.disabled = isDisabled;
+ }
+
+ ngOnInit(): void {
+ this.tagService.listAll().subscribe(result => {
+ this.tags = result.results
+ this.displayValue = this.value
+ })
+ }
+
+ @Input()
+ disabled = false
+
+ @Input()
+ hint
+
+ value: number[]
+
+ displayValue: number[] = []
+
+ tags: PaperlessTag[]
+
+ getTag(id) {
+ return this.tags.find(tag => tag.id == id)
+ }
+
+ removeTag(id) {
+ let index = this.displayValue.indexOf(id)
+ if (index > -1) {
+ this.displayValue.splice(index, 1)
+ this.onChange(this.displayValue)
+ }
+ }
+
+ addTag(id) {
+ let index = this.displayValue.indexOf(id)
+ if (index == -1) {
+ this.displayValue.push(id)
+ this.onChange(this.displayValue)
+ }
+ }
+
+
+ createTag() {
+ var modal = this.modalService.open(TagEditDialogComponent, {backdrop: 'static'})
+ modal.componentInstance.dialogMode = 'create'
+ modal.componentInstance.success.subscribe(newTag => {
+ this.tagService.list().subscribe(tags => {
+ this.tags = tags.results
+ this.addTag(newTag.id)
+ })
+ })
+ }
+
+}
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 23981aa47..577b61a55 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
@@ -3,19 +3,19 @@
- Delete
+ Delete
- Download
+ Download
@@ -43,26 +43,9 @@
-
+
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 fb6be56aa..571192b04 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
@@ -33,7 +33,6 @@ export class DocumentDetailComponent implements OnInit {
correspondents: PaperlessCorrespondent[]
documentTypes: PaperlessDocumentType[]
- tags: PaperlessTag[]
documentForm: FormGroup = new FormGroup({
title: new FormControl(''),
@@ -50,7 +49,6 @@ export class DocumentDetailComponent implements OnInit {
private route: ActivatedRoute,
private correspondentService: CorrespondentService,
private documentTypeService: DocumentTypeService,
- private tagService: TagService,
private datePipe: DatePipe,
private router: Router,
private modalService: NgbModal,
@@ -64,7 +62,6 @@ export class DocumentDetailComponent implements OnInit {
this.correspondentService.list(1,100000).subscribe(result => this.correspondents = result.results)
this.documentTypeService.list(1,100000).subscribe(result => this.documentTypes = result.results)
- this.tagService.list(1,100000).subscribe(result => this.tags = result.results)
this.route.paramMap.subscribe(paramMap => {
this.documentId = +paramMap.get('id')
@@ -88,17 +85,6 @@ export class DocumentDetailComponent implements OnInit {
this.documentForm.patchValue(doc)
}
- createTag() {
- var modal = this.modalService.open(TagEditDialogComponent, {backdrop: 'static'})
- modal.componentInstance.dialogMode = 'create'
- modal.componentInstance.success.subscribe(newTag => {
- this.tagService.list().subscribe(tags => {
- this.tags = tags.results
- this.documentForm.get('tags_id').setValue(this.documentForm.get('tags_id').value.concat([newTag.id]))
- })
- })
- }
-
createDocumentType() {
var modal = this.modalService.open(DocumentTypeEditDialogComponent, {backdrop: 'static'})
modal.componentInstance.dialogMode = 'create'
@@ -121,28 +107,14 @@ export class DocumentDetailComponent implements OnInit {
})
}
- getTag(id: number): PaperlessTag {
- return this.tags.find(tag => tag.id == id)
+ discard() {
+ this.documentsService.get(this.documentId).subscribe(doc => {
+ Object.assign(this.document, doc)
+ this.title = doc.title
+ this.documentForm.patchValue(doc)
+ }, error => {this.router.navigate(['404'])})
}
- getColour(id: number) {
- return TAG_COLOURS.find(c => c.id == this.getTag(id).colour)
- }
-
- addTag(id: number) {
- if (this.documentForm.value.tags.indexOf(id) == -1) {
- this.documentForm.value.tags.push(id)
- }
- }
-
- removeTag(id: number) {
- let index = this.documentForm.value.tags.indexOf(id)
- if (index > -1) {
- this.documentForm.value.tags.splice(index, 1)
- }
- }
-
-
save() {
this.documentsService.update(this.document).subscribe(result => {
this.close()
diff --git a/src-ui/src/app/services/rest/abstract-paperless-service.ts b/src-ui/src/app/services/rest/abstract-paperless-service.ts
index c8459f080..cdf157aaa 100644
--- a/src-ui/src/app/services/rest/abstract-paperless-service.ts
+++ b/src-ui/src/app/services/rest/abstract-paperless-service.ts
@@ -40,6 +40,10 @@ export abstract class AbstractPaperlessService {
return this.http.get>(this.getResourceUrl(), {params: httpParams})
}
+ listAll(ordering?: string, extraParams?): Observable> {
+ return this.list(1, 100000, ordering, extraParams)
+ }
+
get(id: number): Observable {
return this.http.get(this.getResourceUrl(id))
}