@@ -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"
>