Commit 06961c02 authored by Kristian Ntavidi's avatar Kristian Ntavidi
Browse files

Deactivate Guard on dataset template editor

parent 1be8e8e8
......@@ -30,7 +30,7 @@ export class CanDeactivateGuard extends BaseComponent implements CanDeactivate<C
warning: this.language.instant('GENERAL.CONFIRMATION-DIALOG.LEAVE-WARNING'),
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.LEAVE'),
icon: 'error_outline'
// icon: 'error_outline'
}
});
return dialogRef.afterClosed().pipe(map(x => x ? true : false));
......
......@@ -5,6 +5,7 @@ import { DatasetProfileListingComponent } from './listing/dataset-profile-listin
import { AdminAuthGuard } from '@app/core/admin-auth-guard.service';
import { AppRole } from '@app/core/common/enum/app-role';
import { SpecialAuthGuard } from '@app/core/special-auth-guard.service';
import { CanDeactivateGuard } from '@app/library/deactivate/can-deactivate.guard';
const routes: Routes = [
{
......@@ -16,7 +17,8 @@ const routes: Routes = [
permissions: [AppRole.Admin, AppRole.DatasetTemplateEditor]
}
},
canActivate: [SpecialAuthGuard]
canActivate: [SpecialAuthGuard],
canDeactivate:[CanDeactivateGuard]
},
{
path: ':id',
......@@ -27,7 +29,8 @@ const routes: Routes = [
permissions: [AppRole.Admin, AppRole.DatasetTemplateEditor]
}
},
canActivate: [SpecialAuthGuard]
canActivate: [SpecialAuthGuard],
canDeactivate:[CanDeactivateGuard]
},
{
path: 'clone/:cloneid',
......@@ -38,7 +41,8 @@ const routes: Routes = [
permissions: [AppRole.Admin, AppRole.DatasetTemplateEditor]
}
},
canActivate: [SpecialAuthGuard]
canActivate: [SpecialAuthGuard],
canDeactivate:[CanDeactivateGuard]
},
{
path: 'newversion/:newversionid',
......@@ -49,7 +53,8 @@ const routes: Routes = [
permissions: [AppRole.Admin, AppRole.DatasetTemplateEditor]
}
},
canActivate: [SpecialAuthGuard]
canActivate: [SpecialAuthGuard],
canDeactivate:[CanDeactivateGuard]
},
{
path: 'versions/:groupId',
......
......@@ -83,7 +83,7 @@ export const GENERAL_ANIMATIONS = [
transition(":enter", [style({opacity:0}), animate('1000ms 800ms ease', style({'opacity':1}))]),
]),
trigger('fade-in-fast',[
transition(":enter", [style({opacity:0}), animate('1000ms 200ms ease', style({'opacity':1}))]),
transition(":enter", [style({opacity:0}), animate('800ms 100ms ease', style({'opacity':1}))]),
]),
......
......@@ -364,7 +364,8 @@ export class DatasetProfileEditorCompositeFieldComponent extends BaseComponent i
fieldsForm.controls.forEach((field, idx)=>{
field.get('ordinal').setValue(idx);
field.updateValueAndValidity();
})
});
this.form.markAsDirty();//deactivate guard
}
getFieldTile(formGroup: FormGroup, index: number) {
......
......@@ -794,7 +794,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
validationsControl.setValue(validations.filter(validator=> validator != ValidationType.Required));
validationsControl.updateValueAndValidity();
}
this.form.markAsDirty();//deactivate guard
}
get isRequired(){
......
......@@ -42,6 +42,7 @@ export class DatasetProfileEditorRuleComponent implements OnInit {
deleteRule(index) {
this.form.removeAt(index);
this.form.markAsDirty();//deactivate guard
}
ngOnInit(): void {
......
......@@ -44,6 +44,7 @@ import { GENERAL_ANIMATIONS, STEPPER_ANIMATIONS } from './animations/animations'
import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type';
import { UserService } from '@app/core/services/user/user.service';
import { MatInput } from '@angular/material';
import { CheckDeactivateBaseComponent } from '@app/library/deactivate/deactivate.component';
const skipDisable: any[] = require('../../../../../assets/resources/skipDisable.json');
......@@ -55,7 +56,10 @@ const skipDisable: any[] = require('../../../../../assets/resources/skipDisable.
animations:[...STEPPER_ANIMATIONS, ...GENERAL_ANIMATIONS],
providers:[VisibilityRulesService]
})
export class DatasetProfileEditorComponent extends BaseComponent implements OnInit {
export class DatasetProfileEditorComponent extends CheckDeactivateBaseComponent implements OnInit {
canDeactivate(): boolean {
return !this.form.dirty;
}
isNew = true;
isNewVersion = false;
......@@ -425,6 +429,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
this.datasetProfileService.updateForm(this.datasetProfileId, data)
.pipe(takeUntil(this._destroyed))
.subscribe(() => {
this.form.markAsPristine();//deactivate guard
this.router.navigate(['/dataset-profiles']);
this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.FEEDBACK-MESSAGES.SAVE-SUCCESS'), SnackBarNotificationLevel.Success);
},error=> this.onCallbackError(error));
......@@ -434,6 +439,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
this.datasetProfileService.newVersion(this.newVersionId, data)
.pipe(takeUntil(this._destroyed))
.subscribe(() => {
this.form.markAsPristine();//deactivate guard
this.router.navigate(['/dataset-profiles']);
this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.FEEDBACK-MESSAGES.SAVE-SUCCESS'), SnackBarNotificationLevel.Success);
},
......@@ -447,6 +453,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
this.datasetProfileService.createForm(data)
.pipe(takeUntil(this._destroyed))
.subscribe(() => {
this.form.markAsPristine();//deactivate guard
this.router.navigate(['/dataset-profiles']);
this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.FEEDBACK-MESSAGES.SAVE-SUCCESS'), SnackBarNotificationLevel.Success);
}, error=> this.onCallbackError(error));
......@@ -1183,7 +1190,8 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
//in case selectedtocentrhy is child of the removed element
this.refreshToCEntries();
// this.refreshToCEntries();
this.onDataNeedsRefresh();
this.form.updateValueAndValidity();
}
......@@ -1572,6 +1580,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
this.displayItem(this._findTocEntryById(params.draggedItemId, tocentries));
}
}
this.form.markAsDirty();
}
cloneFieldSet(fieldset: FormGroup){
......@@ -1944,6 +1953,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
email.value = '';
this.userFormDisabled = false;
this.form.markAsDirty();
// email.focus();
// this.inputUserState = 'triggered';
......
<div class="confirmation-dialog">
<div *ngIf="data.icon" class="row d-flex flex-row">
<div class="col-auto close-btn justify-content-start">
<div class="row d-flex flex-row" *ngIf="data.icon || data.warning">
<div class="col-auto close-btn justify-content-start" *ngIf="data.icon">
<mat-icon color="warn">{{ data.icon }}</mat-icon>
</div>
<div *ngIf="data.warning" class="col justify-content-center warn-text">{{ data.warning }}</div>
<div *ngIf="data.warning" class="col justify-content-center warn-text"> <h5><strong>{{ data.warning }}</strong></h5></div>
<div class="col-auto close-btn justify-content-end" (click)="close()">
<mat-icon>close</mat-icon>
</div>
</div>
<div class="row justify-content-end mb-1" *ngIf="!data.icon">
<div class="row justify-content-end mb-1" *ngIf="!data.icon && !data.warning">
<div class="col-auto close-btn" (click)="close()">
<mat-icon>close</mat-icon>
</div>
......
......@@ -14,7 +14,8 @@
}
.warn-text {
color: #f44336;
// color: #f44336;
}
.cancel {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment