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