blob: 0d48f63c05b65e4bc4bec4886b80dd9fee4a262e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
import { Location } from '@angular/common';
import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core';
import { FormGroup, NgForm } from '@angular/forms';
import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
import { ModalService } from '~/app/shared/services/modal.service';
import { SubmitButtonComponent } from '../submit-button/submit-button.component';
@Component({
selector: 'cd-form-button-panel',
templateUrl: './form-button-panel.component.html',
styleUrls: ['./form-button-panel.component.scss']
})
export class FormButtonPanelComponent {
@ViewChild(SubmitButtonComponent)
submitButton: SubmitButtonComponent;
@Output()
submitActionEvent = new EventEmitter();
@Output()
backActionEvent = new EventEmitter();
@Input()
form: FormGroup | NgForm;
@Input()
showSubmit = true;
@Input()
wrappingClass = '';
@Input()
btnClass = '';
@Input()
submitText: string = this.actionLabels.CREATE;
@Input()
cancelText: string = this.actionLabels.CANCEL;
@Input()
disabled = false;
constructor(
private location: Location,
private actionLabels: ActionLabelsI18n,
private modalService: ModalService
) {}
submitAction() {
this.submitActionEvent.emit();
}
backAction() {
if (this.backActionEvent.observers.length === 0) {
if (this.modalService.hasOpenModals()) {
this.modalService.dismissAll();
} else {
this.location.back();
}
} else {
this.backActionEvent.emit();
}
}
}
|