{{'DATASET-PROFILE-EDITOR.TITLE.NEW-PROFILE' | translate}}
@@ -22,10 +24,10 @@
-
+
= [];
+
+ tocentries.forEach(tocentry=>{
+
+ const sectionModel = new DatasetDescriptionSectionEditorModel();
+ sectionModel.id = tocentry.id;
+ sectionModel.ordinal = tocentry.form.get('ordinal').value;
+ sectionModel.description = tocentry.form.get('description').value;
+ // sectionModel.page = entry.form.get('ordinal').value;
+ sectionModel.title = tocentry.label;
+ sectionModel.numbering = tocentry.numbering;
+
+ if(tocentry.subEntriesType == ToCEntryType.Section){
+ sectionModel.sections = this._buildSectionsRecursively(tocentry.subEntries);
+
+ }else{
+ sectionModel.compositeFields = this._buildFormFields(tocentry.subEntries);
+ }
+
+ result.push(sectionModel);
+ })
+
+ return result;
+ }
+
+ private _buildFormFields(tocentries: ToCEntry[]):DatasetDescriptionCompositeFieldEditorModel[]{
+ if(!tocentries) return null;
+
+ const fieldsets:DatasetDescriptionCompositeFieldEditorModel[] = [];
+
+ tocentries.forEach(fs=>{
+
+ const fieldset = new DatasetDescriptionCompositeFieldEditorModel();
+
+ fieldset.description = fs.form.get('description').value;
+ fieldset.extendedDescription = fs.form.get('extendedDescription').value;
+ fieldset.id = fs.form.get('id').value;
+ fieldset.multiplicity = fs.form.get('multiplicity').value;
+ fieldset.additionalInformation = fs.form.get('additionalInformation').value;
+ fieldset.ordinal = fs.form.get('ordinal').value;
+ fieldset.hasCommentField = fs.form.get('hasCommentField').value;
+ fieldset.title = fs.label;
+ // fieldset.fields = (fs.form.get('fields') as FormArray).getRawValue();
+ fieldset.fields = (fs.form.get('fields') as FormArray).controls.map(field=>{
+
+ const fieldModel = new DatasetDescriptionFieldEditorModel();
+
+ fieldModel.data = (field.get('data') as FormGroup).getRawValue();
+ fieldModel.id = field.get('id').value;
+ fieldModel.viewStyle = (field.get('viewStyle') as FormGroup).getRawValue();
+ fieldModel.defaultValue = field.get('defaultValue').value;
+ fieldModel.page = field.get('page').value;
+ fieldModel.validations = field.get('validations').value;
+
+ return fieldModel;
+ });
+
+
+
+ fieldsets.push(fieldset);
+ });
+
+ return fieldsets;
+ }
+
+ onMatStepperSelectionChange(event: StepperSelectionEvent){
+
+ if(event.selectedIndex === 2){//preview selected
+ this.generatePreviewForm();//TODO LAZY LOADING IN THE TEMPLATE
+ }
+
+ }
+
+ previewForm:FormGroup;
}
\ No newline at end of file
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.html b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.html
index 0ac817cd6..2cd2d637b 100644
--- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.html
+++ b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.html
@@ -2,11 +2,14 @@
-
-
- {{link.numbering}} {{link.label? link.label : 'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.UNTITLED' | translate}}
-
-
+
+
+
+ {{link.numbering}} {{link.label? link.label : 'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.UNTITLED' | translate}}
+
+
+
+
@@ -33,14 +36,15 @@
(removeEntry)="deleteEntry($event)"
[parentLink]="link"
[itemSelected] = "itemSelected"
- (createFooEntry)="createNewEntry($event)">
+ (createFooEntry)="createNewEntry($event)"
+ [viewOnly]="viewOnly">
-
+
NoEntries
@@ -61,7 +65,7 @@
-
+
\ No newline at end of file
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 606f45bd4..6d0b67543 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
@@ -36,6 +36,7 @@ import { Guid } from '@common/types/guid';
import { FieldEditorModel } from '../admin/field-editor-model';
import { VisibilityRulesService } from '@app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service';
import { StepperSelectionEvent } from '@angular/cdk/stepper';
+import { DatasetDescriptionCompositeFieldEditorModel, DatasetDescriptionFieldEditorModel, DatasetDescriptionFormEditorModel, DatasetDescriptionPageEditorModel, DatasetDescriptionSectionEditorModel } from '@app/ui/misc/dataset-description-form/dataset-description-form.model';
const skipDisable: any[] = require('../../../../../assets/resources/skipDisable.json');
@@ -612,6 +613,31 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
return result;
}
+
+
+ private _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry{
+ if(!tocentries){
+ return null;
+ }
+
+ let tocEntryFound = tocentries.find(entry=>entry.id === id);
+
+ if(tocEntryFound){
+ return tocEntryFound;
+ }
+
+ for(let entry of tocentries){
+ const result = this._findTocEntryById(id, entry.subEntries);
+ if(result){
+ tocEntryFound = result;
+ break;
+ }
+ }
+
+ if(tocEntryFound) return tocEntryFound;
+
+ return null;
+ }
addNewEntry(tce: Foo) {
const parent = tce.parent;
@@ -633,15 +659,8 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
//make new entry selected
const pagesArray = (this.form.get('pages') as FormArray);
const addedEntry = pagesArray.at(pagesArray.length-1) as FormGroup;
- this.selectedTocEntry = {
- form: addedEntry,
- label: addedEntry.get('title').value,
- type: ToCEntryType.Page,
- id: addedEntry.get('id').value,
- numbering:pagesArray.value.length,
- subEntries:null,
- subEntriesType: ToCEntryType.Section
- }
+
+ this.selectedTocEntry = this._findTocEntryById(addedEntry.get('id').value, this.getTocEntries());
break;
case ToCEntryType.Section: //adding a section
@@ -676,15 +695,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
const sectionAdded = sectionsArray.at(sectionsArray.length -1) as FormGroup;
- this.selectedTocEntry = {
- id: sectionAdded.get('id').value,
- label: sectionAdded.get('title').value,
- form: sectionAdded,
- numbering:'',
- subEntries: null,
- subEntriesType: undefined, //ADDNEW VALUE TO TOCENTRY TYPE FOR UNDFINED
- type: ToCEntryType.Section
- }
+ this.selectedTocEntry = this._findTocEntryById(sectionAdded.get('id').value, this.getTocEntries());
break;
case ToCEntryType.FieldSet:
@@ -705,16 +716,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
const parentArray = parent.form.get('fieldSets') as FormArray;
const addedFieldSet = parentArray.at(parentArray.length - 1);
- this.selectedTocEntry = {
- id: addedFieldSet.get('id').value,
- label: addedFieldSet.get('title').value,
- form: addedFieldSet,
- numbering: '',
- subEntries: null, //TODO IT SHOULD HAVE CHILDS
- subEntriesType: ToCEntryType.Field,
- type: ToCEntryType.FieldSet
- }
-
+ this.selectedTocEntry = this._findTocEntryById(addedFieldSet.get('id').value, this.getTocEntries());
break;
@@ -722,6 +724,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
break;
}
+
}
@@ -969,6 +972,11 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
return (selectedIndex / this.stepper.steps.length) * 110- 110;
}
+
+ get progressStyle(){
+ return {'transform': 'translateX('+this.barPercentage+'%) skewX(-25deg)'}
+ }
+
get steps(){
if(!this.stepper){
return [];
@@ -976,4 +984,133 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
return this.stepper.steps;
}
+
+
+ generatePreviewForm(){
+
+
+ const model = new DatasetDescriptionFormEditorModel();
+
+ const toCentries = this.getTocEntries();
+
+
+ //first level is always pages
+ model.pages = toCentries.map(entry=>{
+ if( !(entry.type == ToCEntryType.Page)){
+ return null;
+ }
+ const pageModel = new DatasetDescriptionPageEditorModel();
+
+ pageModel.ordinal = entry.form.get('ordinal').value;
+ pageModel.title = entry.label;
+
+ if(entry.subEntries){
+ pageModel.sections = entry.subEntries.map(section=>{
+ const sectionModel = new DatasetDescriptionSectionEditorModel();
+
+ sectionModel.id = section.id;
+ sectionModel.ordinal = section.form.get('ordinal').value;
+ sectionModel.description = section.form.get('description').value;
+ sectionModel.page = entry.form.get('ordinal').value;
+ sectionModel.title = section.label;
+ sectionModel.numbering = section.numbering;
+
+
+ if(section.subEntriesType == ToCEntryType.Section){
+ sectionModel.sections = this._buildSectionsRecursively(section.subEntries);
+ }else{
+ sectionModel.compositeFields = this._buildFormFields(section.subEntries)
+ }
+
+ return sectionModel;
+ })
+ };
+ return pageModel;
+
+ });
+
+
+ this.previewForm = model.buildForm();
+ }
+
+ private _buildSectionsRecursively( tocentries: ToCEntry[]): DatasetDescriptionSectionEditorModel[]{
+
+
+ if(!tocentries) return null;
+
+
+ const result: Array
-
-
- {{link.numbering}} {{link.label? link.label : 'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.UNTITLED' | translate}}
-
-
-
+
+
@@ -33,14 +36,15 @@
(removeEntry)="deleteEntry($event)"
[parentLink]="link"
[itemSelected] = "itemSelected"
- (createFooEntry)="createNewEntry($event)">
+ (createFooEntry)="createNewEntry($event)"
+ [viewOnly]="viewOnly">
+
+ {{link.numbering}} {{link.label? link.label : 'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.UNTITLED' | translate}}
+
+
+
+
+
NoEntries
@@ -61,7 +65,7 @@
-
+