CST-12174 added resetForm and leave edit for edit-form and overview page

This commit is contained in:
Mattia Vianelli
2023-10-17 17:46:47 +02:00
parent 1c376b2964
commit ba0b110647
2 changed files with 44 additions and 0 deletions

View File

@@ -194,6 +194,11 @@
</div>
<button class="btn btn-primary" type="submit">{{ 'ldn-new-service.form.label.submit' | translate }}</button>
<div class="">
<button type="button" class="btn btn-danger" (click)="this.openResetFormModal(this.resetFormModal)">
<i class="fas fa-trash"></i> {{ 'submission.general.discard.submit' | translate }}
</button>
</div>
</form>
<ng-template #confirmModal>
@@ -224,3 +229,32 @@
</div>
</div>
</ng-template>
<ng-template #resetFormModal>
<div>
<div class="modal-header">
<div>
<h4>{{'service.overview.reset-form.modal' | translate }}</h4>
</div>
<button (click)="closeModal()" aria-label="Close"
class="close" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div>
{{ 'service.overview.reset-form.body' | translate }}
</div>
<div class="mt-4">
<button (click)="this.resetFormAndLeave()"
class="btn btn-primary mr-2 custom-btn" id="reset-confirm">{{ 'service.overview.reset-form.reset-confirm' | translate }}</button>
<button (click)="closeModal()" class="btn btn-danger"
id="reset-delete">{{ 'service.overview.reset-form.reset-return' | translate }}
</button>
</div>
</div>
</div>
</ng-template>

View File

@@ -29,6 +29,7 @@ import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
export class LdnServiceFormEditComponent implements OnInit {
formModel: FormGroup;
@ViewChild('confirmModal', {static: true}) confirmModal: TemplateRef<any>;
@ViewChild('resetFormModal', {static: true}) resetFormModal: TemplateRef<any>;
public inboundPatterns: object[] = notifyPatterns;
public outboundPatterns: object[] = notifyPatterns;
@@ -286,6 +287,10 @@ export class LdnServiceFormEditComponent implements OnInit {
this.modalRef = this.modalService.open(content);
}
openResetFormModal(content) {
this.modalRef = this.modalService.open(content);
}
patchService() {
const patchOperations = this.generatePatchOperations();
@@ -347,6 +352,11 @@ export class LdnServiceFormEditComponent implements OnInit {
this.router.navigateByUrl('admin/ldn/services');
}
resetFormAndLeave() {
this.sendBack();
this.closeModal();
}
private createOutboundPatternFormGroup(): FormGroup {
return this.formBuilder.group({
pattern: '',