diff --git a/dmp-frontend/src/app/app.component.ts b/dmp-frontend/src/app/app.component.ts index d6c0fb7d7..1655dc40a 100644 --- a/dmp-frontend/src/app/app.component.ts +++ b/dmp-frontend/src/app/app.component.ts @@ -64,12 +64,31 @@ export class AppComponent implements OnInit, AfterViewInit { ngAfterViewInit(): void { setTimeout(() => { this.sideNavSubscription = this.sidenavService.status().subscribe(isopen=>{ + const hamburger = document.getElementById('hamburger'); if(isopen){ //update value of hamburfer - document.getElementById('hamburger').classList.add('change'); + if(!hamburger){//try later + setTimeout(() => { + const hamburger = document.getElementById('hamburger'); + if(hamburger){ + hamburger.classList.add('change'); + } + }, 300); + }else{ + hamburger.classList.add('change'); + } this.sidenav.open() - }else{ - document.getElementById('hamburger').classList.remove('change'); + }else{//closed + if(!hamburger){//try later + setTimeout(() => { + const hamburger = document.getElementById('hamburger'); + if(hamburger){ + hamburger.classList.remove('change'); + } + }, 300); + }else{ + hamburger.classList.remove('change'); + } this.sidenav.close(); } diff --git a/dmp-frontend/src/app/library/guided-tour/guided-tour.component.ts b/dmp-frontend/src/app/library/guided-tour/guided-tour.component.ts index 913ab6d1b..e093b543b 100644 --- a/dmp-frontend/src/app/library/guided-tour/guided-tour.component.ts +++ b/dmp-frontend/src/app/library/guided-tour/guided-tour.component.ts @@ -388,7 +388,10 @@ export class GuidedTourComponent implements AfterViewInit, OnDestroy { } const scrollAdjustment = this.currentTourStep.scrollAdjustment ? this.currentTourStep.scrollAdjustment : 0; - const tourStepHeight = typeof this.tourStep.nativeElement.getBoundingClientRect === 'function' ? this.tourStep.nativeElement.getBoundingClientRect().height : 0; + let tourStepHeight = 0; + if (this.tourStep != null && this.tourStep.nativeElement != null && typeof this.tourStep.nativeElement.getBoundingClientRect === 'function') { + tourStepHeight = this.tourStep.nativeElement.getBoundingClientRect().height; + } const elementHeight = this.selectedElementRect.height + scrollAdjustment + tourStepHeight; if ((this.windowRef.nativeWindow.innerHeight - this.topOfPageAdjustment) < elementHeight) { 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 8cdbfaac0..c0a869bb5 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 @@ -67,12 +67,12 @@ --> - + - + + [formControl]="this.form.get('title')" required> @@ -145,6 +145,7 @@ [form]="form.get('fields').get(''+i)" [showOrdinal]="false" [indexPath]="indexPath + 'f' + i" [viewOnly]="viewOnly" [expandView]="hasFocus" + [canBeDeleted]="form.get('fields')['controls'].length !=1" (delete)="deleteField(i)"> 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 864770e50..69e75370c 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 @@ -32,6 +32,7 @@ import { CurrencyDataEditorModel } from '../../../admin/field-data/currency-data import { ValidationDataEditorModel } from '../../../admin/field-data/validation-data-editor-models'; import { DatasetProfileService } from '@app/core/services/dataset-profile/dataset-profile.service'; import { OrganizationsDataEditorModel } from '../../../admin/field-data/organizations-data-editor-models'; +import { EditorCustomValidators } from '../../custom-validators/editor-custom-validators'; @Component({ selector: 'app-dataset-profile-editor-composite-field-component', @@ -59,6 +60,7 @@ export class DatasetProfileEditorCompositeFieldComponent implements OnInit, OnCh viewStyleEnum = DatasetProfileFieldViewStyle; viewTypeEnum = ViewStyleType; + private myCustomValidators:EditorCustomValidators = new EditorCustomValidators(); constructor( private dialog: MatDialog, @@ -358,15 +360,15 @@ export class DatasetProfileEditorCompositeFieldComponent implements OnInit, OnCh fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.ComboBox) fieldForm.addControl('data', new WordListFieldDataEditorModel().buildForm()); - this.form.get('data').setValidators(this._atLeastOneElementListValidator('options')); - this.form.get('data').updateValueAndValidity(); + fieldForm.get('data').setValidators(this.myCustomValidators.atLeastOneElementListValidator('options')); + fieldForm.get('data').updateValueAndValidity(); break; case this.viewTypeEnum.Other: fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.ComboBox) fieldForm.addControl('data', new AutoCompleteFieldDataEditorModel().buildForm()); //TODO SEE - fieldForm.get('data').setValidators(this._atLeastOneElementListValidator('autoCompleteSingleDataList')); - + fieldForm.get('data').setValidators(this.myCustomValidators.atLeastOneElementListValidator('autoCompleteSingleDataList')); + fieldForm.get('data').updateValueAndValidity(); break; case this.viewTypeEnum.InternalDmpEntities: @@ -380,6 +382,9 @@ export class DatasetProfileEditorCompositeFieldComponent implements OnInit, OnCh case this.viewTypeEnum.RadioBox: fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.RadioBox) fieldForm.addControl('data', new RadioBoxFieldDataEditorModel().buildForm()); + fieldForm.get('data').setValidators(this.myCustomValidators.atLeastOneElementListValidator('options')); + fieldForm.get('data').updateValueAndValidity(); + break; case this.viewTypeEnum.TextArea: fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.TextArea) @@ -416,7 +421,7 @@ export class DatasetProfileEditorCompositeFieldComponent implements OnInit, OnCh break; case this.viewTypeEnum.Organizations: fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Organizations) - this.form.addControl('data', new OrganizationsDataEditorModel().buildForm()); + fieldForm.addControl('data', new OrganizationsDataEditorModel().buildForm()); // this.form.addControl('data', new OrganizationsDataEditorModel().buildForm()) // fieldForm.addControl('data', new DatasetsAutoCompleteFieldDataEditorModel().buildForm()); //TODO break; @@ -436,7 +441,9 @@ export class DatasetProfileEditorCompositeFieldComponent implements OnInit, OnCh (this.form.get('fields')).push(fieldForm); - // fieldForm.updateValueAndValidity(); + fieldForm.get('viewStyle').get('renderStyle').updateValueAndValidity(); + fieldForm.get('data').updateValueAndValidity(); + } @@ -488,17 +495,17 @@ export class DatasetProfileEditorCompositeFieldComponent implements OnInit, OnCh // } - private _atLeastOneElementListValidator(arrayToCheck): ValidatorFn{ - return (control: AbstractControl): ValidationErrors | null=>{ + // private _atLeastOneElementListValidator(arrayToCheck): ValidatorFn{ + // return (control: AbstractControl): ValidationErrors | null=>{ - const fa = control.get(arrayToCheck) as FormArray; + // const fa = control.get(arrayToCheck) as FormArray; - if(fa.length === 0){ - return {emptyArray: true}; - } - return null; - } - } + // if(fa.length === 0){ + // return {emptyArray: true}; + // } + // return null; + // } + // } calculateLabelWidth(numbering: string){ 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 b36e10663..d221f961b 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 @@ -12,7 +12,7 @@
  • visibility
  • -
  • +
  • delete
  • 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 111c98f42..4cef20a53 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 @@ -60,7 +60,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements @Input() expandView: boolean = true; - + @Input() canBeDeleted:boolean = true; @Output() delete = new EventEmitter(); @@ -425,7 +425,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.ComboBox) this.form.addControl('data', new WordListFieldDataEditorModel().buildForm()); - this.form.get('data').setValidators(this.myCustomValidators._atLeastOneElementListValidator('options')); + this.form.get('data').setValidators(this.myCustomValidators.atLeastOneElementListValidator('options')); this.form.get('data').updateValueAndValidity(); break; @@ -433,7 +433,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.ComboBox) this.form.addControl('data', new AutoCompleteFieldDataEditorModel().buildForm()); //TODO SEE - this.form.get('data').setValidators(this.myCustomValidators._atLeastOneElementListValidator('autoCompleteSingleDataList')); + this.form.get('data').setValidators(this.myCustomValidators.atLeastOneElementListValidator('autoCompleteSingleDataList')); this.form.get('data').updateValueAndValidity(); @@ -450,7 +450,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.RadioBox) this.form.addControl('data', new RadioBoxFieldDataEditorModel().buildForm()); - this.form.get('data').setValidators(this.myCustomValidators._atLeastOneElementListValidator('options')); + this.form.get('data').setValidators(this.myCustomValidators.atLeastOneElementListValidator('options')); this.form.get('data').updateValueAndValidity(); break; @@ -504,6 +504,10 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements this.form.addControl('data', new ValidationDataEditorModel().buildForm()); break; } + + this.form.get('data').updateValueAndValidity(); + this.form.get('viewStyle').get('renderStyle').updateValueAndValidity(); + this.form.updateValueAndValidity(); setTimeout(() => { //TODO this.showPreview = true; }); 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 d3a36d010..a7005e339 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 @@ -130,6 +130,8 @@ export class DatasetProfileEditorSectionFieldSetComponent extends BaseComponent if(el){ el.scrollIntoView({behavior: "smooth"}); } + }else{//scroll on top + window.scrollTo({top:0, behavior:'smooth'}); } } diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.html index 74f55f3f0..2ce1a73b2 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.html @@ -13,7 +13,8 @@
    {{'DATASET-PROFILE-EDITOR.STEPS.SECTION-INFO.SECTION-NAME-HINT' | translate}}
    + formControlName="title" required> + {{'GENERAL.VALIDATION.REQUIRED' | translate}} +
    @@ -127,7 +128,7 @@
    1.1 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-NAME'| translate}} *
    {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-NAME-HINT'| translate}}
    - {{'GENERAL.VALIDATION.REQUIRED' | translate}} @@ -139,7 +140,7 @@
    {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-DESCRIPTION-HINT'| translate}}
    - {{'GENERAL.VALIDATION.REQUIRED' @@ -153,7 +154,7 @@
    1.3 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-LANGUAGE'| translate}} *
    - + {{ lang.name }} @@ -181,7 +182,7 @@
    --> - +
    @@ -200,7 +201,8 @@ (removeEntry)="onRemoveEntry($event)" [itemSelected]="selectedTocEntry" [viewOnly]="viewOnly" - (dataNeedsRefresh)="onDataNeedsRefresh()"> + (dataNeedsRefresh)="onDataNeedsRefresh()" + [colorizeInvalid]="colorizeInvalid">
    @@ -224,6 +226,7 @@
    {{'DATASET-PROFILE-EDITOR.STEPS.PAGE-INFO.PAGE-NAME-HINT' | translate}}
    + {{'GENERAL.VALIDATION.REQUIRED' | translate}} @@ -402,7 +405,7 @@
    - + @@ -440,12 +443,20 @@
    - + - @@ -33,10 +33,14 @@
    - - {{parentLink.subEntries?.length}} - + + + priority_high + + {{parentLink.subEntries?.length}} + + + [parentRootId]="parentRootId" + [colorizeInvalid]="colorizeInvalid"> diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.ts index 60493a298..058989859 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.ts @@ -1,7 +1,7 @@ import { CdkDrag, CdkDragDrop, CdkDropList, moveItemInArray } from '@angular/cdk/drag-drop'; import { DOCUMENT } from '@angular/common'; import { Component, EventEmitter, Inject, Input, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core'; -import { FormArray } from '@angular/forms'; +import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms'; import { BaseComponent } from '@common/base/base.component'; import { Foo, ToCEntry, ToCEntryType } from '../table-of-contents-entry'; @@ -31,6 +31,8 @@ export class DatasetProfileTableOfContentsInternalSection extends BaseComponent @Input() draggingItemId: string; @Input() parentRootId: string; + @Input() colorizeInvalid:boolean = false; + @Input() viewOnly: boolean; // @Input() dropListGroup: Set = new Set(); @Input() dropListGroup: string[]; @@ -229,4 +231,78 @@ export class DatasetProfileTableOfContentsInternalSection extends BaseComponent return tocEntryFound? tocEntryFound: null; } + + + + colorError():boolean{ + + if(!this.colorizeInvalid) return false; + + const form = this.parentLink.form; + if(!form || form.valid || !form.touched) return false; + + const allFieldsAreTouched = this.allFieldsAreTouched(form); + + //fieldset may have errros that are inside its controls and not in the fieldsetFormGroup + if(this.parentLink.type === this.tocEntryType.FieldSet && allFieldsAreTouched) return true; + + if(form.errors && allFieldsAreTouched) return true; + + + + //checking form controls if have errors + let hasErrors = false; + + if(allFieldsAreTouched){ + if(form instanceof FormGroup){ + const formGroup = form as FormGroup; + + const controls = Object.keys(formGroup.controls); + + controls.forEach(control=>{ + if(formGroup.get(control).errors){ + hasErrors = true; + } + }) + + } + } + + return hasErrors; + } + + + allFieldsAreTouched(aControl:AbstractControl){//auto na testaroume + + if(!aControl|| aControl.untouched) return false; + + if(aControl instanceof FormControl){ + return aControl.touched; + }else if(aControl instanceof FormGroup){ + const controlKeys = Object.keys((aControl as FormGroup).controls); + let areAllTouched = true; + controlKeys.forEach(key=>{ + if(!this.allFieldsAreTouched(aControl.get(key))){ + areAllTouched = false; + } + }) + // const areAllTouched = controlKeys.reduce((acc, key)=>acc && this._allFieldsAreTouched(aControl.get(key)), true); + return areAllTouched; + + }else if(aControl instanceof FormArray){ + const controls = (aControl as FormArray).controls; + // const areAllTouched = controls.reduce((acc, control)=>acc && this._allFieldsAreTouched(control), true); + let areAllTouched = true; + // controls.reduce((acc, control)=>acc && this._allFieldsAreTouched(control), true); + controls.forEach(control=>{ + if(!this.allFieldsAreTouched(control)){ + areAllTouched = false; + } + }); + return areAllTouched; + } + + + return false; + } } \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.html b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.html index ae8b0f26d..00ff6e9ae 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.html @@ -22,6 +22,7 @@ [draggingItemId]="draggingItemId" [parentRootId]="ROOT_ID" style="padding-right: 1em;" + [colorizeInvalid]="colorizeInvalid" >