mirror of
https://github.com/ceph/ceph
synced 2025-01-11 05:29:51 +00:00
Merge pull request #21529 from ricardoasmarques/wip-fix-rbd-form
mgr/dashboard: Display RBD form errors on submission Reviewed-by: Stephan Müller <smueller@suse.com> Reviewed-by: Volker Theile <vtheile@suse.com>
This commit is contained in:
commit
ed46117e3f
@ -301,7 +301,7 @@
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
<div class="button-group text-right">
|
||||
<cd-submit-button [form]="rbdForm"
|
||||
<cd-submit-button [form]="formDir"
|
||||
type="button"
|
||||
(submitAction)="submit()">
|
||||
<span i18n>{mode, select, editing {Update} cloning {Clone} copying {Copy} other {Create}}</span> RBD
|
||||
|
@ -1,7 +1,7 @@
|
||||
<button [type]="type"
|
||||
class="btn btn-sm btn-primary tc_submitButton"
|
||||
[disabled]="loading"
|
||||
(click)="submit()">
|
||||
(click)="submit($event)">
|
||||
<ng-content></ng-content>
|
||||
<span *ngIf="loading">
|
||||
<i class="fa fa-spinner fa-spin fa-fw"></i>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Component, ElementRef, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { AbstractControl, FormGroup, FormGroupDirective, NgForm } from '@angular/forms';
|
||||
|
||||
import * as _ from 'lodash';
|
||||
|
||||
@ -27,7 +27,7 @@ import * as _ from 'lodash';
|
||||
styleUrls: ['./submit-button.component.scss']
|
||||
})
|
||||
export class SubmitButtonComponent implements OnInit {
|
||||
@Input() form: FormGroup;
|
||||
@Input() form: FormGroup | NgForm;
|
||||
@Input() type = 'submit';
|
||||
@Output() submitAction = new EventEmitter();
|
||||
|
||||
@ -40,14 +40,22 @@ export class SubmitButtonComponent implements OnInit {
|
||||
if (_.has(this.form.errors, 'cdSubmitButton')) {
|
||||
this.loading = false;
|
||||
_.unset(this.form.errors, 'cdSubmitButton');
|
||||
this.form.updateValueAndValidity();
|
||||
// Handle Reactive forms.
|
||||
if (this.form instanceof AbstractControl) {
|
||||
(<AbstractControl>this.form).updateValueAndValidity();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
submit() {
|
||||
submit($event) {
|
||||
this.focusButton();
|
||||
|
||||
// Special handling for Template driven forms.
|
||||
if (this.form instanceof FormGroupDirective) {
|
||||
(<FormGroupDirective>this.form).onSubmit($event);
|
||||
}
|
||||
|
||||
if (this.form.invalid) {
|
||||
this.focusInvalid();
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user