]> git.ipfire.org Git - thirdparty/paperless-ngx.git/blob
b7d9a47113cf7ee0cc3ecaff724053cc3f66ad86
[thirdparty/paperless-ngx.git] /
1 import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
2 import { FormControl, FormGroup } from '@angular/forms'
3 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
4
5 @Component({
6 selector: 'pngx-save-view-config-dialog',
7 templateUrl: './save-view-config-dialog.component.html',
8 styleUrls: ['./save-view-config-dialog.component.scss'],
9 })
10 export class SaveViewConfigDialogComponent implements OnInit {
11 constructor(private modal: NgbActiveModal) {}
12
13 @Output()
14 public saveClicked = new EventEmitter()
15
16 @Input()
17 error
18
19 @Input()
20 buttonsEnabled = true
21
22 closeEnabled = false
23
24 _defaultName = ''
25
26 get defaultName() {
27 return this._defaultName
28 }
29
30 @Input()
31 set defaultName(value: string) {
32 this._defaultName = value
33 this.saveViewConfigForm.patchValue({ name: value })
34 }
35
36 saveViewConfigForm = new FormGroup({
37 name: new FormControl(''),
38 showInSideBar: new FormControl(false),
39 showOnDashboard: new FormControl(false),
40 })
41
42 ngOnInit(): void {
43 // wait to enable close button so it doesn't steal focus from input since its the first clickable element in the DOM
44 setTimeout(() => {
45 this.closeEnabled = true
46 })
47 }
48
49 save() {
50 this.saveClicked.emit(this.saveViewConfigForm.value)
51 }
52
53 cancel() {
54 this.modal.close()
55 }
56 }