For modals, response error messages is shown in the footer. For modals, Accept button is always on the right.

This commit is contained in:
Tom
2025-03-20 13:14:09 +00:00
parent 1acda7978e
commit c8bfeed396
16 changed files with 120 additions and 41 deletions

View File

@@ -1,3 +1,4 @@
.error {
display: block;
color: #ba1a1a;
}

View File

@@ -9,7 +9,8 @@
[group]="data.group_id"
[groupDisabled]="data.groupDisabled"
[errorMessages]="groupErrorMessages" />
<policy-dropdown #policyDropdown [policy]="pathControl.value" />
<policy-dropdown #policyDropdown
[policy]="pathControl.value" />
<mat-form-field>
<mat-label>Usage</mat-label>
<input matInput
@@ -52,6 +53,10 @@
</mat-form-field>
</mat-card-content>
<mat-card-actions align="end">
<button mat-button
(click)="dialogRef.close()">
<mat-icon>cancel</mat-icon>Cancel
</button>
@if (isNew) {
<button mat-button
(click)="save()">
@@ -63,9 +68,11 @@
<mat-icon>save</mat-icon>Save
</button>
}
<button mat-button
(click)="dialogRef.close()">
<mat-icon>cancel</mat-icon>Cancel
</button>
</mat-card-actions>
@if (responseError) {
<mat-card-footer>
<small class="error below">{{responseError}}</small>
</mat-card-footer>
}
</mat-card>

View File

@@ -6,5 +6,14 @@
}
.error {
display: block;
color: #ba1a1a;
}
.below {
display: block;
justify-self: center;
align-items: center;
align-self: center;
text-align: center;
}

View File

@@ -49,6 +49,7 @@ export class PolicyItemEditComponent implements OnInit, AfterViewInit {
});
isNew: boolean = false;
responseError: string | undefined;
waitForResponse: boolean = false;
@ViewChild('policyDropdown') policyDropdown: PolicyDropdownComponent | undefined;
@@ -81,6 +82,7 @@ export class PolicyItemEditComponent implements OnInit, AfterViewInit {
return;
this.waitForResponse = true;
this.responseError = undefined;
const group_id = (this.groupControl.value as Group)!.id;
const path = this.pathControl.value!;
const usage = this.usageControl.value!;
@@ -91,12 +93,12 @@ export class PolicyItemEditComponent implements OnInit, AfterViewInit {
.subscribe({
next: (d) => {
if (d.d.error) {
// TODO: update & show response error message.
this.responseError = d.d.error;
} else {
this.dialogRef.close(d.d.data);
}
},
error: () => this.waitForResponse = false,
error: () => this.responseError = 'Something went wrong.',
complete: () => this.waitForResponse = false,
});
this.client.createPolicy(group_id, path, usage, span);
@@ -105,12 +107,12 @@ export class PolicyItemEditComponent implements OnInit, AfterViewInit {
.subscribe({
next: (d) => {
if (d.d.error) {
// TODO: update & show response error message.
this.responseError = d.d.error;
} else {
this.dialogRef.close(d.d.data);
}
},
error: () => this.waitForResponse = false,
error: () => this.responseError = 'Something went wrong.',
complete: () => this.waitForResponse = false,
});
this.client.updatePolicy(this.data.policy_id, group_id, path, usage, span);