From 1d397d28cf2bab75904b12ae311f17bbf3eebf04 Mon Sep 17 00:00:00 2001 From: Kristan Ntavidi Date: Wed, 21 Jul 2021 16:41:38 +0300 Subject: [PATCH 1/8] Add ability to scroll on table of contents (dataset templates admin) --- .../dataset-profile-editor.component.html | 2 +- .../table-of-contents/table-of-contents.html | 15 ++++-- .../table-of-contents/table-of-contents.scss | 32 +++++++++++- .../table-of-contents/table-of-contents.ts | 51 +++++++++++++++++-- 4 files changed, 92 insertions(+), 8 deletions(-) diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html index 1e90e19a7..f3d90a719 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html @@ -247,7 +247,7 @@
-
+
-

{{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.TEMPLATE-OUTLINE' | translate}}

+
+

{{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.TEMPLATE-OUTLINE' | translate}}

- +
+
+ keyboard_arrow_up +
+
+
+
+ keyboard_arrow_down +
+
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.scss index ebd142270..dc1e64f35 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.scss +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.scss @@ -1,10 +1,12 @@ - +$scroller-height: 3em; .scroll-container { // overflow-y: auto; max-height: 60vh; overflow-y: scroll; padding-left: .2em; padding-right: 1em; + // padding-top: $scroller-height; + // padding-bottom: $scroller-height; } // #style-6::-webkit-scrollbar-track @@ -59,4 +61,32 @@ opacity: 0.6; font-size: 1.6em; margin-top: 0px; +} + +.table-container{ + position: relative; +} +.table-scroller{ + // background-color: #5cf7f221; + position: absolute; + width: 95%; + height: $scroller-height; + display: flex; + align-items: center; + justify-content: center; + // z-index: -9999; +} +.top-scroller{ + top: 1px; + background: rgb(255,255,255); + background: linear-gradient(0deg, rgba(255,255,255,0) 0%, rgba(92,247,242,0.4542191876750701) 100%); +} +.bottom-scroller{ + bottom: 1px; + background: rgb(255,255,255); + background: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(92,247,242,0.4542191876750701) 100%); +} + +.opacity-0{ + opacity: 0 !important; } \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.ts index 69717e782..685742eff 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.ts @@ -1,8 +1,8 @@ import { DOCUMENT } from '@angular/common'; -import { Component, EventEmitter, Inject, OnInit, Output, Input } from '@angular/core'; +import { Component, EventEmitter, Inject, OnInit, Output, Input, AfterViewInit } from '@angular/core'; import { BaseComponent } from '@common/base/base.component'; import { interval, Subject, Subscription } from 'rxjs'; -import { distinctUntilChanged } from 'rxjs/operators'; +import { distinctUntilChanged, filter, takeUntil } from 'rxjs/operators'; import { type } from 'os'; import { SimpleChanges } from '@angular/core'; import { NewEntryType, TableUpdateInfo, ToCEntry, ToCEntryType } from './table-of-contents-entry'; @@ -18,7 +18,7 @@ import { ContentObserver } from '@angular/cdk/observers'; styleUrls: ['./table-of-contents.scss'], templateUrl: './table-of-contents.html' }) -export class DatasetProfileTableOfContents extends BaseComponent implements OnInit { +export class DatasetProfileTableOfContents extends BaseComponent implements OnInit, AfterViewInit { @Input() links: ToCEntry[]; @Input() itemSelected: ToCEntry; @@ -42,6 +42,11 @@ export class DatasetProfileTableOfContents extends BaseComponent implements OnIn private VALID_DROP_TIME = 500;//ms overcontainer: string = null; + $clock = interval(10); + scrollTableTop = false; + scrollTableBottom = false; + pxToScroll = 15; + constructor( @Inject(DOCUMENT) private _document: Document, private dragulaService: DragulaService, @@ -449,6 +454,46 @@ export class DatasetProfileTableOfContents extends BaseComponent implements OnIn + } + ngAfterViewInit(): void { + + const top = document.querySelector('.top-scroller'); + const bottom = document.querySelector('.bottom-scroller'); + const tableDiv = document.querySelector('#tocentrytable'); + + try { + top.addEventListener('mouseover', (e) => {this.scrollTableTop = true; }); + bottom.addEventListener('mouseover', (e) => {this.scrollTableBottom = true; }); + + top.addEventListener('mouseout', (e) => {this.scrollTableTop = false}); + bottom.addEventListener('mouseout', (e) => {this.scrollTableBottom = false;}); + + + this.$clock + .pipe( + takeUntil(this._destroyed), + filter(() => this.scrollTableTop) + ) + .subscribe(()=>{ + try{ + tableDiv.scrollBy(0, -this.pxToScroll); + } catch {} + }); + this.$clock + .pipe( + takeUntil(this._destroyed), + filter(() => this.scrollTableBottom) + ) + .subscribe(()=>{ + try{ + tableDiv.scrollBy(0, this.pxToScroll); + } catch {} + }); + } catch { + console.log('could not find scrolling elements'); + } + + } private _scrollIntoDragginItem(id: string){ From 4c22799f913b5f2886b04b28b51d63e3dcb36753 Mon Sep 17 00:00:00 2001 From: Kristan Ntavidi Date: Fri, 23 Jul 2021 11:23:35 +0300 Subject: [PATCH 2/8] Bug fixes on dataset templates editor Admin (partial) * Make use of observables instead of setTimeouts * Remove not nessecary calculations --- ...file-editor-composite-field.component.html | 171 +++++++++--------- ...rofile-editor-composite-field.component.ts | 55 +++++- ...ataset-profile-editor-field.component.html | 11 +- .../dataset-profile-editor-field.component.ts | 3 + .../dataset-profile-editor-rule.component.ts | 19 +- ...ile-editor-section-fieldset.component.html | 5 +- ...ofile-editor-section-fieldset.component.ts | 114 +++++++----- .../dataset-profile-editor.component.html | 2 +- .../table-of-contents/table-of-contents.ts | 20 +- 9 files changed, 236 insertions(+), 164 deletions(-) diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html index 2f205b4ef..4c63edc38 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html @@ -76,46 +76,40 @@
-
- - - - -
- - - -
-
- - - -
-
- - - -
- -
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - -
-
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + +
@@ -123,59 +117,56 @@
-
+
-
- -
- - - - - - - - -
-
-
- + + + + + + + +
+
+ + - -
+ +
+ +
+ +
+
+ +
+
-->
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts index 4e3762bec..2e3480803 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts @@ -21,8 +21,9 @@ import { AutoCompleteFieldData, BooleanDecisionFieldData, CheckBoxFieldData, Cur import { CompositeField } from '@app/core/model/dataset-profile-definition/composite-field'; import {Field as FieldDefinition} from '@app/core/model/dataset-profile-definition/field'; import { Subject } from 'rxjs'; -import { debounceTime } from 'rxjs/operators'; +import { debounceTime, delay, map, takeUntil, tap } from 'rxjs/operators'; import { GENERAL_ANIMATIONS } from '../../animations/animations'; +import { BaseComponent } from '@common/base/base.component'; @Component({ selector: 'app-dataset-profile-editor-composite-field-component', @@ -30,7 +31,7 @@ import { GENERAL_ANIMATIONS } from '../../animations/animations'; styleUrls: ['./dataset-profile-editor-composite-field.component.scss'], animations:[GENERAL_ANIMATIONS] }) -export class DatasetProfileEditorCompositeFieldComponent implements OnInit, OnChanges { +export class DatasetProfileEditorCompositeFieldComponent extends BaseComponent implements OnInit, OnChanges { @Input() form: FormGroup; @Input() indexPath: string; @@ -61,7 +62,9 @@ export class DatasetProfileEditorCompositeFieldComponent implements OnInit, OnCh private language: TranslateService, public enumUtils: EnumUtils, public datasetProfileService: DatasetProfileService - ) { } + ) { + super(); + } ngOnChanges(){ // this.setTargetField(null); @@ -112,16 +115,52 @@ export class DatasetProfileEditorCompositeFieldComponent implements OnInit, OnCh this.showExtendedDescription = !!this.form.get('extendedDescription').value; this.showAdditionalInfo = !!this.form.get('additionalInformation').value; - this.form.valueChanges.subscribe(changes=>{ + this.form.valueChanges.pipe(takeUntil(this._destroyed)).subscribe(changes=>{ // this.previewForm = null; this.previewDirty = true; this.generatePreviewForm(); }); - this.previewSubject$.pipe(debounceTime(600)).subscribe(model=>{ - const updatedForm = model.buildForm(); - this.reloadPreview(updatedForm) - }) + this.previewSubject$ + .pipe(debounceTime(600)) + .pipe( + takeUntil(this._destroyed), + map(model => model.buildForm()), + map(updatedForm =>{ + const previewContainer = document.getElementById('preview_container'+ this.form.get('id').value); + // let clientHeight = -1; + if(previewContainer){ + // console.log(previewContainer); + const clientHeight = previewContainer.clientHeight; + // console.log(clientHeight); + + if(clientHeight){ + previewContainer.style.height = clientHeight.toString() + 'px'; + + // console.log('height:' ,previewContainer.style.height); + } + } + this.showPreview = false; + this.previewDirty = true; + this.previewForm = updatedForm; + return previewContainer; + }), + delay(100), + tap( previewContainer =>{ + this.showPreview = true; + this.previewDirty = false; + }), + delay(100) + ) + .subscribe(previewContainer=>{ + + if(previewContainer){ + previewContainer.style.height = 'auto'; + } + + // const updatedForm = model.buildForm(); + // this.reloadPreview(updatedForm) + }); this.generatePreviewForm(); diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.html index 0e73c87e1..610d39d31 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.html @@ -15,12 +15,10 @@
  • delete
  • -
    - - +
    - + -
    +
    - {{'DATASET-PROFILE-EDITOR.ACTIONS.FIELD.PREVIEW' | translate}} + {{'DATASET-PROFILE-EDITOR.ACTIONS.FIELD.PREVIEW' | translate}} {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.STATUS.PREVIEW-UPDATED' | translate}} @@ -184,7 +184,7 @@
    -
    +
    diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.scss index bae52298c..9b73377a3 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.scss +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.scss @@ -129,6 +129,11 @@ $blue-color-light: #5cf7f2; padding-bottom: 0px; } +.previewer-text{ + font-weight: bold; + font-style: italic; +} + // ::ng-deep .underline-line-field .mat-form-field-appearance-legacy .mat-form-field-wapper{ // padding-bottom: 1.25em !important; // } \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.html index 4f8382bc4..38426a3d6 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.html @@ -1,5 +1,5 @@ 
    -
    +
    diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.ts index 8fc445bec..0fd24684a 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.ts @@ -9,11 +9,13 @@ import { debounceTime, delay, tap } from 'rxjs/operators'; import { FieldEditorModel } from '../../../admin/field-editor-model'; import { FieldSetEditorModel } from '../../../admin/field-set-editor-model'; import { ToCEntry, ToCEntryType } from '../../../table-of-contents/table-of-contents-entry'; +import { GENERAL_ANIMATIONS } from '../../animations/animations'; @Component({ selector: 'app-dataset-profile-editor-section-fieldset-component', templateUrl: './dataset-profile-editor-section-fieldset.component.html', - styleUrls: ['./dataset-profile-editor-section-fieldset.component.scss'] + styleUrls: ['./dataset-profile-editor-section-fieldset.component.scss'], + animations:[GENERAL_ANIMATIONS] }) export class DatasetProfileEditorSectionFieldSetComponent implements OnInit, OnChanges, OnDestroy { @@ -144,7 +146,8 @@ export class DatasetProfileEditorSectionFieldSetComponent implements OnInit, OnC this.numbering = this.tocentry.numbering; this._selectedFieldSetId = null; - this.scroller.next(null); + // this.scroller.next(null); + this._scrollOnTop(true); }else if(this.tocentry.type === ToCEntryType.FieldSet){ this.form = this.tocentry.form.parent.parent; const numberingArray = this.tocentry.numbering.split('.'); @@ -170,10 +173,14 @@ export class DatasetProfileEditorSectionFieldSetComponent implements OnInit, OnC el.scrollIntoView({behavior: "smooth", block:'start'}); } } - private _scrollOnTop(){ + private _scrollOnTop(instant?: boolean){ const el = this.myElement.nativeElement.querySelector('#topofcontainer'); if(el){ - el.scrollIntoView({behavior:'smooth', block:'end'}); + if(instant){ + el.scrollIntoView({ block:'end'}); + }else{ + el.scrollIntoView({behavior:'smooth', block:'end'}); + } } } ngOnInit() { diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html index f752d8b63..efba00df8 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html @@ -276,7 +276,7 @@
    -
    +
    @@ -388,11 +388,10 @@ - +
    @@ -411,7 +410,6 @@ translate}}
    -
    @@ -424,7 +422,6 @@ translate}}
    -
    - + -->
    - -
    - - + +
    + +
    -
    +
    diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.scss index 176d82dd0..eb455bc3a 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.scss +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.scss @@ -346,7 +346,7 @@ $blue-color-light: #5cf7f2; background: #f4f4f4; position: sticky; top: 0.01em; - z-index: 99; + z-index: 9999; } #title-column{ @@ -354,3 +354,9 @@ $blue-color-light: #5cf7f2; align-items: baseline; padding-right: 15px; } +.side-actions{ + display: flex; + height: 40vh; + position: sticky; + top: 2em; +} \ No newline at end of file From 06961c0254872d80a83290cc9f81eec627a0ada3 Mon Sep 17 00:00:00 2001 From: Kristan Ntavidi Date: Fri, 23 Jul 2021 17:03:29 +0300 Subject: [PATCH 7/8] Deactivate Guard on dataset template editor --- .../app/library/deactivate/can-deactivate.guard.ts | 2 +- .../dataset-profile/dataset-profile.routing.ts | 13 +++++++++---- .../editor/animations/animations.ts | 2 +- ...set-profile-editor-composite-field.component.ts | 3 ++- .../dataset-profile-editor-field.component.ts | 2 +- .../rule/dataset-profile-editor-rule.component.ts | 1 + .../editor/dataset-profile-editor.component.ts | 14 ++++++++++++-- .../confirmation-dialog.component.html | 8 ++++---- .../confirmation-dialog.component.scss | 3 ++- 9 files changed, 33 insertions(+), 15 deletions(-) diff --git a/dmp-frontend/src/app/library/deactivate/can-deactivate.guard.ts b/dmp-frontend/src/app/library/deactivate/can-deactivate.guard.ts index 75d89ac2d..8e6df7ff9 100644 --- a/dmp-frontend/src/app/library/deactivate/can-deactivate.guard.ts +++ b/dmp-frontend/src/app/library/deactivate/can-deactivate.guard.ts @@ -30,7 +30,7 @@ export class CanDeactivateGuard extends BaseComponent implements CanDeactivate x ? true : false)); diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.routing.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.routing.ts index 4fb6f9404..1bf042f25 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.routing.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.routing.ts @@ -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', diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/animations/animations.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/animations/animations.ts index 4542d8b4a..5b4cd484a 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/animations/animations.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/animations/animations.ts @@ -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}))]), ]), diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts index 2e3480803..d6ac1fcfe 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts @@ -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) { diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts index 73746d533..5d3ae69d5 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts @@ -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(){ diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.ts index cd8f546b8..150d58c69 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.ts @@ -42,6 +42,7 @@ export class DatasetProfileEditorRuleComponent implements OnInit { deleteRule(index) { this.form.removeAt(index); + this.form.markAsDirty();//deactivate guard } ngOnInit(): void { diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts index 60b689d58..456e5fabd 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts @@ -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'; diff --git a/dmp-frontend/src/common/modules/confirmation-dialog/confirmation-dialog.component.html b/dmp-frontend/src/common/modules/confirmation-dialog/confirmation-dialog.component.html index 258eb7cda..199b9ed9b 100644 --- a/dmp-frontend/src/common/modules/confirmation-dialog/confirmation-dialog.component.html +++ b/dmp-frontend/src/common/modules/confirmation-dialog/confirmation-dialog.component.html @@ -1,14 +1,14 @@
    -
    -
    +
    +
    {{ data.icon }}
    -
    {{ data.warning }}
    +
    {{ data.warning }}
    close
    -
    +
    close
    diff --git a/dmp-frontend/src/common/modules/confirmation-dialog/confirmation-dialog.component.scss b/dmp-frontend/src/common/modules/confirmation-dialog/confirmation-dialog.component.scss index 5bd8b98b0..804e34258 100644 --- a/dmp-frontend/src/common/modules/confirmation-dialog/confirmation-dialog.component.scss +++ b/dmp-frontend/src/common/modules/confirmation-dialog/confirmation-dialog.component.scss @@ -14,7 +14,8 @@ } .warn-text { - color: #f44336; + // color: #f44336; + } .cancel { From a7abe6c2d89c827f44cdfce1ebfcc909091afbb0 Mon Sep 17 00:00:00 2001 From: Kristan Ntavidi Date: Fri, 23 Jul 2021 17:09:12 +0300 Subject: [PATCH 8/8] minor fix --- .../dataset-profile/editor/dataset-profile-editor.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts index 456e5fabd..951c168ad 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts @@ -2039,6 +2039,7 @@ export class DatasetProfileEditorComponent extends CheckDeactivateBaseComponent removeUser(user: any) { this.userChipList.splice(this.userChipList.indexOf(user), 1); this.form.patchValue({'users': this.userChipList}); + this.form.markAsDirty();//deactivate guard }