change on datamodel

This commit is contained in:
annampak 2018-01-02 18:29:27 +02:00
parent 391fd20baf
commit 9e25001f10
15 changed files with 140 additions and 89 deletions

View File

@ -2,12 +2,27 @@
<label> <label>
<input type="checkbox" [(ngModel)]="isComposite" (ngModelChange)="onIsCompositeChange(isComposite)" /> Composite Field</label> <input type="checkbox" [(ngModel)]="isComposite" (ngModelChange)="onIsCompositeChange(isComposite)" /> Composite Field</label>
<label> <label>
<input type="checkbox" [(ngModel)]="isMultiplicityEnabled" (ngModelChange)="onIsMultiplicityEnabledChange(isMultiplicityEnabled)" /> Multiplicity</label> <input type="checkbox" [(ngModel)]="isMultiplicityEnabled" (ngModelChange)="onIsMultiplicityEnabledChange(isMultiplicityEnabled)"
/> Multiplicity</label>
<div [formGroup]="form"> <div [formGroup]="form">
<div class="row"> <div class="row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<div class="row">
<div class="col-md-4">
<label>FieldSet Label</label>
<input data-toggle="tooltip" title="tooltip on second input!" type="text" class="form-control" formControlName="title">
</div>
<div class="form-group col-md-4">
<label>description</label>
<input type="text" class="form-control" formControlName="description">
</div>
<div class="form-group col-md-4">
<label>extendedDescription</label>
<input type="text" class="form-control" formControlName="extendedDescription">
</div>
</div>
<div *ngIf="isMultiplicityEnabled" formGroupName="multiplicity"> <div *ngIf="isMultiplicityEnabled" formGroupName="multiplicity">
<div class="form-group"> <div>
<h5 style="margin-left:15px; font-weight:bold;">Multiplicity</h5> <h5 style="margin-left:15px; font-weight:bold;">Multiplicity</h5>
<div class="col-md-2"> <div class="col-md-2">
<label>Min</label> <label>Min</label>
@ -20,11 +35,11 @@
</div> </div>
</div> </div>
</div> </div>
<div *ngIf="isComposite" class="form-group col-md-4"> <div *ngIf="isComposite" class="col-md-4">
<label>Ordinal</label> <label>Ordinal</label>
<input type="number" class="form-control" formControlName="ordinal"> <input type="number" class="form-control" formControlName="ordinal">
</div> </div>
<div *ngIf="isComposite" class="form-group col-md-4"> <div *ngIf="isComposite" class="col-md-4">
<label>Id</label> <label>Id</label>
<input type="string" class="form-control" formControlName="id"> <input type="string" class="form-control" formControlName="id">
</div> </div>
@ -33,7 +48,8 @@
</div> </div>
</div> </div>
<field-form *ngIf="!isComposite" [form]="form.get('fields').get(''+0)" [dataModel]="dataModel.fields[0]" [showMultiplicity]="false" [indexPath]="indexPath + 'f' + 0"></field-form> <field-form *ngIf="!isComposite" [form]="form.get('fields').get(''+0)" [dataModel]="dataModel.fields[0]" [showMultiplicity]="false"
[indexPath]="indexPath + 'f' + 0"></field-form>
<div *ngIf="isComposite" class="panel-group" style="margin-top:10px;"> <div *ngIf="isComposite" class="panel-group" style="margin-top:10px;">
<div *ngFor="let field of dataModel.fields let i=index;" class="panel panel-default"> <div *ngFor="let field of dataModel.fields let i=index;" class="panel panel-default">

View File

@ -1,6 +1,6 @@
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { FormGroup } from '@angular/forms'; import { FormGroup } from '@angular/forms';
import { CompositeField } from 'app/models/DataSetProfile/CompositeField'; import { FieldSet } from 'app/models/DataSetProfile/FieldSet';
import { Field } from 'app/models/DataSetProfile/Field'; import { Field } from 'app/models/DataSetProfile/Field';
import { FormArray, FormControl } from '@angular/forms/src/model'; import { FormArray, FormControl } from '@angular/forms/src/model';
@ -12,7 +12,7 @@ import { FormArray, FormControl } from '@angular/forms/src/model';
export class CompositeFieldFormComponent { export class CompositeFieldFormComponent {
@Input() form: FormGroup; @Input() form: FormGroup;
@Input() dataModel: CompositeField; @Input() dataModel: FieldSet;
@Input() indexPath: string; @Input() indexPath: string;
isComposite: boolean = false; isComposite: boolean = false;

View File

@ -33,7 +33,7 @@
<radiobox-component [form]="form" [dataModel]="dataModel"></radiobox-component> <radiobox-component [form]="form" [dataModel]="dataModel"></radiobox-component>
</div> </div>
</div> </div>
<div class="row"> <!-- <div class="row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label>description</label> <label>description</label>
<input type="text" class="form-control" formControlName="description"> <input type="text" class="form-control" formControlName="description">
@ -42,7 +42,7 @@
<label>extendedDescription</label> <label>extendedDescription</label>
<input type="text" class="form-control" formControlName="extendedDescription"> <input type="text" class="form-control" formControlName="extendedDescription">
</div> </div>
</div> </div> -->
<div class="row"> <div class="row">
<div *ngIf="isFieldMultiplicityEnabled" formGroupName="multiplicity"> <div *ngIf="isFieldMultiplicityEnabled" formGroupName="multiplicity">
<div class="form-group"> <div class="form-group">
@ -68,16 +68,6 @@
<input type="text" class="form-control" formControlName="value"> <input type="text" class="form-control" formControlName="value">
</div> </div>
</div> </div>
<div class="form-group col-md-2">
<label class="radio control-label">Default Visibility</label>
<label class="radio-inline">
<input type="radio" [value]="true" formControlName="defaultVisibility"> true
</label>
<label class="radio-inline">
<input type="radio" [value]="false" formControlName="defaultVisibility"> false
</label>
</div>
</div> </div>
</div> </div>
<label *ngIf="showMultiplicity"> <label *ngIf="showMultiplicity">

View File

@ -4,7 +4,12 @@
<div class="row"> <div class="row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label>Label</label> <label>Label</label>
<input type="text" class="form-control" formControlName="label"> <input type="text" class="form-control" formControlName="label" id="label" required >
<!-- <div *ngIf="form.get('label').invalid && (form.get('label').dirty || form.get('label').touched)" class="alert alert-danger"> -->
<!-- <div *ngIf="form.get('label').errors.required" class="alert alert-danger">
Name is required.
</div> -->
<!-- </div> -->
</div> </div>
</div> </div>
@ -62,7 +67,7 @@
</a> </a>
</div> </div>
<button class="btn btn-primary" style="margin-top:20px;" type="submit">Save</button> <button class="btn btn-primary" style="margin-top:20px;" type="submit" [disabled]="!form.valid">Save</button>
</form> </form>
</div> </div>
<p>Form value: {{ form.value | json }}</p> <p>Form value: {{ form.value | json }}</p>

View File

@ -1,7 +1,7 @@
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { FormGroup } from '@angular/forms'; import { FormGroup } from '@angular/forms';
import { FieldGroup } from 'app/models/DataSetProfile/FieldGroup'; import { FieldGroup } from 'app/models/DataSetProfile/FieldGroup';
import { CompositeField } from 'app/models/DataSetProfile/CompositeField'; import { FieldSet } from 'app/models/DataSetProfile/FieldSet';
import { FormArray } from '@angular/forms/src/model'; import { FormArray } from '@angular/forms/src/model';
import { Field } from 'app/models/DataSetProfile/Field'; import { Field } from 'app/models/DataSetProfile/Field';
@ -23,7 +23,7 @@ export class GroupFieldFormComponent {
} }
addNewFieldSet(){ addNewFieldSet(){
let compositeField: CompositeField = new CompositeField(); let compositeField: FieldSet = new FieldSet();
let field: Field = new Field(); //create field at the same time let field: Field = new Field(); //create field at the same time
compositeField.fields.push(field); compositeField.fields.push(field);

View File

@ -57,9 +57,34 @@
<div *ngFor="let fieldGroup of dataModel.fieldGroups let i=index;"> <!-- <div *ngFor="let fieldGroup of dataModel.fieldGroups let i=index;">
<groupfield-form [form]="form.get('fieldGroups').get(''+i)" [dataModel]="fieldGroup" [indexPath]="indexPath + 'g' + i"></groupfield-form> <groupfield-form [form]="form.get('fieldGroups').get(''+i)" [dataModel]="fieldGroup" [indexPath]="indexPath + 'g' + i"></groupfield-form>
</div> -->
<div class="panel-group" style="margin-top:10px;">
<div *ngFor="let field of dataModel.fieldSets let i=index;" class="panel panel-default">
<div class="panel-heading clearfix">
<!-- <a *ngIf="form.get('compositeFields').get(''+i).get('title').value" data-toggle="collapse" href="#{{'compositeFieldCollapse' + i}}"
class="panel-title pull-left" style="padding-top: 7.5px;">{{i + 1}}. {{form.get('compositeFields').get(''+i).get('title').value}}</a>
<a *ngIf="!form.get('compositeFields').get(''+i).get('title').value" data-toggle="collapse" href="#{{'compositeFieldCollapse' + i}}"
class="panel-title pull-left" style="padding-top: 7.5px;">{{i + 1}}. Field {{i + 1}}</a> -->
<a data-toggle="collapse" href="#{{indexPath + 'cf' + i}}"
class="panel-title pull-left" style="padding-top: 7.5px;">{{i + 1}}. Field {{i + 1}}</a>
<div class="btn-group pull-right">
<button type="button" class="btn btn-sm" style="margin-left:5px;" (click)="DeleteFieldSet(i);">
<span class="glyphicon glyphicon-erase"></span>
</button>
</div>
</div>
<div id="{{indexPath + 'cf' + i}}" class="panel-collapse collapse in">
<div class="panel-body">
<compositefield-form [form]="form.get('fieldSets').get(''+i)" [dataModel]="field" [indexPath]="indexPath + 'cf' + i"></compositefield-form>
</div>
</div>
</div>
</div> </div>
<!-- <!--
<div *ngIf="dataModel.fieldGroups" class="panel-group" style="margin-top:10px;"> <div *ngIf="dataModel.fieldGroups" class="panel-group" style="margin-top:10px;">
<div *ngFor="let fieldGroup of dataModel.fieldGroups let i=index;" class="panel panel-default"> <div *ngFor="let fieldGroup of dataModel.fieldGroups let i=index;" class="panel panel-default">

View File

@ -4,7 +4,7 @@ import { Section } from 'app/models/DataSetProfile/Section';
import { FieldGroup } from 'app/models/DataSetProfile/FieldGroup'; import { FieldGroup } from 'app/models/DataSetProfile/FieldGroup';
import { FormArray } from '@angular/forms/src/model'; import { FormArray } from '@angular/forms/src/model';
import { DatasetProfileModel } from 'app/models/DataSetProfile/DatasetProfileModel'; import { DatasetProfileModel } from 'app/models/DataSetProfile/DatasetProfileModel';
import { CompositeField } from 'app/models/DataSetProfile/CompositeField'; import { FieldSet } from 'app/models/DataSetProfile/FieldSet';
import { Field } from 'app/models/DataSetProfile/Field'; import { Field } from 'app/models/DataSetProfile/Field';
import { Page } from 'app/models/DataSetProfile/Page'; import { Page } from 'app/models/DataSetProfile/Page';
import { JsonSerializer } from 'app/utilities/JsonSerializer'; import { JsonSerializer } from 'app/utilities/JsonSerializer';
@ -31,28 +31,28 @@ export class SectionFormComponent {
}); });
} }
addGroupField() { // addGroupField() {
let fieldGroup: FieldGroup = new FieldGroup(); // let fieldGroup: FieldGroup = new FieldGroup();
if (this.dataModel.fieldGroups) // if (this.dataModel.fieldGroups)
this.dataModel.fieldGroups.push(fieldGroup); // this.dataModel.fieldGroups.push(fieldGroup);
(<FormArray>this.form.get("fieldGroups")).push(fieldGroup.buildForm()); // (<FormArray>this.form.get("fieldGroups")).push(fieldGroup.buildForm());
} // }
addField() { addField() {debugger;
let fieldSet: CompositeField = new CompositeField(); let fieldSet: FieldSet = new FieldSet();
let field: Field = new Field(); let field: Field = new Field();
let fieldGroup: FieldGroup = new FieldGroup(); //let fieldGroup: FieldGroup = new FieldGroup();
fieldSet.fields.push(field); fieldSet.fields.push(field);
fieldGroup.compositeFields.push(fieldSet); //fieldGroup.compositeFields.push(fieldSet);
if (this.dataModel.fieldGroups) if (this.dataModel.fieldSets)
this.dataModel.fieldGroups.push(fieldGroup); this.dataModel.fieldSets.push(fieldSet);
(<FormArray>this.form.get("fieldGroups")).push(fieldGroup.buildForm()); (<FormArray>this.form.get("fieldSets")).push(fieldSet.buildForm());
} }
DeleteFieldGroup(index) { // DeleteFieldGroup(index) {
this.dataModel.fieldGroups.splice(index, 1); // this.dataModel.fieldGroups.splice(index, 1);
(<FormArray>this.form.get("fieldGroups")).removeAt(index) // (<FormArray>this.form.get("fieldGroups")).removeAt(index)
} // }
addSectioninSection() { addSectioninSection() {
let section: Section = new Section(); let section: Section = new Section();
@ -65,6 +65,11 @@ export class SectionFormComponent {
(<FormArray>this.form.get("sections")).removeAt(index); (<FormArray>this.form.get("sections")).removeAt(index);
} }
DeleteFieldSet(index){
this.dataModel.fieldSets.splice(index, 1);
(<FormArray>this.form.get("compositeFields")).removeAt(index);
}
keepPageSelectionValid(pagesJson: Array<any>) { keepPageSelectionValid(pagesJson: Array<any>) {
let selectedPage = this.form.get("page").value as number; let selectedPage = this.form.get("page").value as number;
let pages: Array<Page> = new JsonSerializer<Page>().fromJSONArray(pagesJson, Page); let pages: Array<Page> = new JsonSerializer<Page>().fromJSONArray(pagesJson, Page);

View File

@ -19,22 +19,22 @@
</tr> </tr>
<tr> <tr>
<th [ngClass]="{true:'visible', false:'invisible'}[showIDs]"><mfDefaultSorter by="id">ID</mfDefaultSorter></th> <!-- <th [ngClass]="{true:'visible', false:'invisible'}[showIDs]"><mfDefaultSorter by="id">ID</mfDefaultSorter></th> -->
<th><mfDefaultSorter by="label">Label</mfDefaultSorter></th> <th><mfDefaultSorter by="label">Label</mfDefaultSorter></th>
<th><mfDefaultSorter by="ruleset">Ruleset</mfDefaultSorter></th> <th><mfDefaultSorter by="created">Created</mfDefaultSorter></th>
<th><mfDefaultSorter by="viewstyle">Viewstyle</mfDefaultSorter></th> <th><mfDefaultSorter by="description">Description</mfDefaultSorter></th>
<th><mfDefaultSorter by="definition">Definition</mfDefaultSorter></th> <th><mfDefaultSorter by="status">Status</mfDefaultSorter></th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr class="grayout-empty-table" *ngIf="!mf.data[0]" [contextMenu]="basicMenu" [contextMenuSubject]="datasetProfile"> <td colspan="5">No elements</td></tr> <tr class="grayout-empty-table" *ngIf="!mf.data[0]" [contextMenu]="basicMenu" [contextMenuSubject]="datasetProfile"> <td colspan="5">No elements</td></tr>
<tr *ngFor="let datasetProfile of mf.data" class="hover" [contextMenu]="basicMenu" [contextMenuSubject]="datasetProfile"> <tr *ngFor="let datasetProfile of mf.data" class="hover" [contextMenu]="basicMenu" [contextMenuSubject]="datasetProfile">
<td [ngClass]="{true:'visible', false:'invisible'}[showIDs]">{{datasetProfile.id}}</td> <!-- <td [ngClass]="{true:'visible', false:'invisible'}[showIDs]">{{datasetProfile.id}}</td> -->
<td>{{datasetProfile?.label}}</td> <td>{{datasetProfile?.label}}</td>
<td>{{datasetProfile?.ruleset?.label}}</td> <td>{{datasetProfile?.created}}</td>
<td>{{datasetProfile?.viewstyle?.label}}</td> <td>{{datasetProfile?.description}}</td>
<td>{{datasetProfile?.definition}}</td> <td>{{datasetProfile?.status}}</td>
<td><button type="button" class="btn btn-sm btn-primary btn-create" data-toggle="modal" data-target="#newdataset-modal-container" [routerLink]="['/form/'+datasetProfile.id]">Go</button></td> <td><button type="button" class="btn btn-sm btn-primary btn-create" data-toggle="modal" data-target="#newdataset-modal-container" [routerLink]="['/form/'+datasetProfile.id]">Go</button></td>
</tr> </tr>

View File

@ -69,7 +69,7 @@ export class DatasetprofileEditorComponent implements OnInit {
this.tableVisible = false; this.tableVisible = false;
this.editorVisible = true; this.editorVisible = true;
if(datasetProfileID == null){ if(datasetProfileID == null){
this.editingDatasetProfile = {id: null, label: "", ruleset: "", viewstyle: "", definition: "" }; this.editingDatasetProfile = {id: null, label: "", created: "", description: "", status: "" };
} }
else{ else{
this.editingDatasetProfile = this.tableData.filter((datasetProfile) => datasetProfile.id === datasetProfileID)[0]; this.editingDatasetProfile = this.tableData.filter((datasetProfile) => datasetProfile.id === datasetProfileID)[0];
@ -79,7 +79,7 @@ export class DatasetprofileEditorComponent implements OnInit {
getAllDatasetProfiles(showNotification : boolean){ getAllDatasetProfiles(showNotification : boolean){
this.datasetProfileService.fetchAllDatasetProfiles().subscribe( (data) => { this.datasetProfileService.fetchAllDatasetProfiles().subscribe( (data) => {
this.tableData = data; this.tableData = data.payload;
if(showNotification) if(showNotification)
simple_notifier("info",null,"Refreshed the table"); simple_notifier("info",null,"Refreshed the table");
}); });

View File

@ -1,5 +1,5 @@
import { BaseModel } from '../BaseModel'; import { BaseModel } from '../BaseModel';
import { FormBuilder, FormGroup, FormControl } from '@angular/forms'; import { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms';
import { FormGenerator } from '../interfaces/FormGenerator'; import { FormGenerator } from '../interfaces/FormGenerator';
import { JsonSerializer } from 'app/utilities/JsonSerializer'; import { JsonSerializer } from 'app/utilities/JsonSerializer';
import { Section } from './Section'; import { Section } from './Section';
@ -30,13 +30,13 @@ export class DatasetProfileModel extends BaseModel implements Serializable<Datas
formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray)); formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray));
let pagesFormArray = new Array<FormGroup>(); let pagesFormArray = new Array<FormGroup>();
this.pages.forEach(item => { // this.pages.forEach(item => {
let form: FormGroup = item.buildForm(); // let form: FormGroup = item.buildForm();
pagesFormArray.push(form) // pagesFormArray.push(form)
}) // })
formGroup.addControl('pages', this.formBuilder.array(pagesFormArray)); formGroup.addControl('pages', this.formBuilder.array(pagesFormArray));
formGroup.addControl('label', new FormControl(this.label)); formGroup.addControl('label', new FormControl(this.label, [Validators.required]));
return formGroup; return formGroup;
} }

View File

@ -18,12 +18,9 @@ export class Field extends BaseModel implements Serializable<Field>,FormGenerato
public id:string; public id:string;
public title:string; public title:string;
public defaultValue:DefaultValue = new DefaultValue; public defaultValue:DefaultValue = new DefaultValue;
public description:string;
public extendedDescription:string;
public viewStyle:ViewStyle = new ViewStyle(); public viewStyle:ViewStyle = new ViewStyle();
public defaultVisibility:boolean;
public page:number; public page:number;
public multiplicity: Multiplicity = new Multiplicity(); //public multiplicity: Multiplicity = new Multiplicity();
public ordinal: number; public ordinal: number;
public visible: Visibility = new Visibility(); public visible: Visibility = new Visibility();
public data:DataField<any>; public data:DataField<any>;
@ -32,11 +29,8 @@ export class Field extends BaseModel implements Serializable<Field>,FormGenerato
this.id = item.id; this.id = item.id;
this.title = item.title; this.title = item.title;
this.defaultValue = new JsonSerializer<DefaultValue>().fromJSONObject(item.defaultValue, DefaultValue); this.defaultValue = new JsonSerializer<DefaultValue>().fromJSONObject(item.defaultValue, DefaultValue);
this.description = item.description;
this.extendedDescription = item.extendedDescription;
this.defaultVisibility = item.defaultVisibility !==null ? item.defaultVisibility : true;
this.page = item.page; this.page = item.page;
this.multiplicity = new JsonSerializer<Multiplicity>().fromJSONObject(item.multiplicity, Multiplicity); // this.multiplicity = new JsonSerializer<Multiplicity>().fromJSONObject(item.multiplicity, Multiplicity);
this.ordinal = item.ordinal; this.ordinal = item.ordinal;
this.viewStyle = new JsonSerializer<ViewStyle>().fromJSONObject(item.viewStyle, ViewStyle); this.viewStyle = new JsonSerializer<ViewStyle>().fromJSONObject(item.viewStyle, ViewStyle);
this.visible = new JsonSerializer<Visibility>().fromJSONObject(item.visible, Visibility); this.visible = new JsonSerializer<Visibility>().fromJSONObject(item.visible, Visibility);
@ -55,23 +49,18 @@ export class Field extends BaseModel implements Serializable<Field>,FormGenerato
let formGroup = this.formBuilder.group({ let formGroup = this.formBuilder.group({
id: [this.id], id: [this.id],
title: [this.title], title: [this.title],
description: [this.description],
extendedDescription:[this.extendedDescription],
defaultVisibility:[this.defaultVisibility],
page:[this.page] , page:[this.page] ,
ordinal:[this.ordinal] ordinal:[this.ordinal]
}); });
formGroup.addControl("multiplicity", this.multiplicity.buildForm()); //formGroup.addControl("multiplicity", this.multiplicity.buildForm());
formGroup.addControl("defaultValue", this.defaultValue.buildForm()); formGroup.addControl("defaultValue", this.defaultValue.buildForm());
formGroup.addControl("viewStyle", this.viewStyle.buildForm()); formGroup.addControl("viewStyle", this.viewStyle.buildForm());
formGroup.addControl("visible", this.visible.buildForm()); formGroup.addControl("visible", this.visible.buildForm());
//formGroup.addControl("data",this.data? this.data.buildForm():this.formBuilder.group({})); //formGroup.addControl("data",this.data? this.data.buildForm():this.formBuilder.group({}));
if(this.data)formGroup.addControl("data",this.data.buildForm()); if(this.data)formGroup.addControl("data",this.data.buildForm());
if( formGroup.controls["defaultVisibility"].value == null) formGroup.controls["defaultVisibility"].setValue(true);
return formGroup; return formGroup;
} }
} }

View File

@ -1,4 +1,4 @@
import { CompositeField } from './CompositeField'; import { FieldSet } from './FieldSet';
import { BaseModel } from '../BaseModel'; import { BaseModel } from '../BaseModel';
import { FormGroup } from '@angular/forms'; import { FormGroup } from '@angular/forms';
import { FormGenerator } from '../interfaces/FormGenerator'; import { FormGenerator } from '../interfaces/FormGenerator';
@ -18,7 +18,7 @@ export class FieldGroup extends BaseModel implements Serializable<FieldGroup>, F
public defaultVisibility: boolean; public defaultVisibility: boolean;
public page: number; public page: number;
public ordinal: number; public ordinal: number;
public compositeFields: Array<CompositeField> = new Array<CompositeField>(); public compositeFields: Array<FieldSet> = new Array<FieldSet>();
fromJSONObject(item: any): FieldGroup { fromJSONObject(item: any): FieldGroup {
this.id = item.id; this.id = item.id;
@ -29,7 +29,7 @@ export class FieldGroup extends BaseModel implements Serializable<FieldGroup>, F
this.defaultVisibility = item.defaultVisibility; this.defaultVisibility = item.defaultVisibility;
this.page = item.page; this.page = item.page;
this.ordinal = item.ordinal; this.ordinal = item.ordinal;
this.compositeFields = new JsonSerializer<CompositeField>().fromJSONArray(item.compositeFields, CompositeField); this.compositeFields = new JsonSerializer<FieldSet>().fromJSONArray(item.compositeFields, FieldSet);
return this; return this;
} }

View File

@ -5,25 +5,34 @@ import { BaseModel } from '../BaseModel';
import {Field} from './Field' import {Field} from './Field'
import {Multiplicity} from './Multiplicity' import {Multiplicity} from './Multiplicity'
export class CompositeField extends BaseModel implements Serializable<CompositeField> { export class FieldSet extends BaseModel implements Serializable<FieldSet> {
public fields:Array<Field> = new Array<Field>(); public fields:Array<Field> = new Array<Field>();
public id:string; public id:string;
public ordinal:number; public ordinal:number;
public multiplicity: Multiplicity = new Multiplicity(); public multiplicity: Multiplicity = new Multiplicity();
public title:string;
public description:string;
public extendedDescription:string;
fromJSONObject(item:any):CompositeField{ fromJSONObject(item:any):FieldSet{
this.fields = new JsonSerializer<Field>().fromJSONArray(item.fields,Field); this.fields = new JsonSerializer<Field>().fromJSONArray(item.fields,Field);
this.multiplicity = new JsonSerializer<Multiplicity>().fromJSONObject(item.multiplicity, Multiplicity); this.multiplicity = new JsonSerializer<Multiplicity>().fromJSONObject(item.multiplicity, Multiplicity);
this.id = item.id; this.id = item.id;
this.ordinal = item.ordinal; this.ordinal = item.ordinal;
this.title = item.title;
this.description = item.description;
this.extendedDescription = item.extendedDescription;
return this; return this;
} }
buildForm():FormGroup{ buildForm():FormGroup{
let formGroup = this.formBuilder.group({ let formGroup = this.formBuilder.group({
id:[this.id], id:[this.id],
ordinal:[this.ordinal] ordinal:[this.ordinal],
title:[this.title],
description: [this.description],
extendedDescription:[this.extendedDescription]
}); });
let fieldsFormArray = new Array<FormGroup>(); let fieldsFormArray = new Array<FormGroup>();

View File

@ -4,26 +4,29 @@ import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'
import { JsonSerializer } from 'app/utilities/JsonSerializer'; import { JsonSerializer } from 'app/utilities/JsonSerializer';
import { Serializable } from '../interfaces/Serializable'; import { Serializable } from '../interfaces/Serializable';
import { FieldGroup } from './FieldGroup'; import { FieldGroup } from './FieldGroup';
import { FieldSet } from 'app/models/DataSetProfile/FieldSet';
export class Section extends BaseModel implements Serializable<Section>, FormGenerator<FormGroup>{ export class Section extends BaseModel implements Serializable<Section>, FormGenerator<FormGroup>{
public sections: Array<Section> = new Array<Section>(); public sections: Array<Section> = new Array<Section>();
public fieldGroups: Array<FieldGroup> = new Array<FieldGroup>(); //public fieldGroups: Array<FieldGroup> = new Array<FieldGroup>();
public defaultVisibility: boolean; public defaultVisibility: boolean;
public page: number; public page: number;
public id: string public id: string
public title: string public title: string
public description: string; public description: string;
public ordinal: number; public ordinal: number;
public fieldSets: Array<FieldSet> = new Array<FieldSet>();
fromJSONObject(item: any): Section { fromJSONObject(item: any): Section {
this.sections = new JsonSerializer<Section>().fromJSONArray(item.sections, Section); this.sections = new JsonSerializer<Section>().fromJSONArray(item.sections, Section);
this.fieldGroups = new JsonSerializer<FieldGroup>().fromJSONArray(item.fieldGroups, FieldGroup); //this.fieldGroups = new JsonSerializer<FieldGroup>().fromJSONArray(item.fieldGroups, FieldGroup);
this.page = item.page; this.page = item.page;
this.defaultVisibility = item.defaultVisibility; this.defaultVisibility = item.defaultVisibility;
this.id = item.id; this.id = item.id;
this.title = item.title; this.title = item.title;
this.description = item.description; this.description = item.description;
this.ordinal = item.ordinal; this.ordinal = item.ordinal;
this.fieldSets = new JsonSerializer<FieldSet>().fromJSONArray(item.fieldSets, FieldSet);
return this; return this;
} }
@ -36,15 +39,24 @@ export class Section extends BaseModel implements Serializable<Section>, FormGen
sectionsFormArray.push(form) sectionsFormArray.push(form)
}) })
} }
let fieldGroupsFormArray = new Array<FormGroup>(); // let fieldGroupsFormArray = new Array<FormGroup>();
if (this.fieldGroups) { // if (this.fieldGroups) {
this.fieldGroups.forEach(item => { // this.fieldGroups.forEach(item => {
// let form: FormGroup = item.buildForm();
// fieldGroupsFormArray.push(form)
// })
// }
let compositeFieldsFormArray = new Array<FormGroup>();
if (this.fieldSets) {
this.fieldSets.forEach(item => {
let form: FormGroup = item.buildForm(); let form: FormGroup = item.buildForm();
fieldGroupsFormArray.push(form) compositeFieldsFormArray.push(form)
}) })
} }
formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray)); formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray));
formGroup.addControl('fieldGroups', this.formBuilder.array(fieldGroupsFormArray)); // formGroup.addControl('fieldGroups', this.formBuilder.array(fieldGroupsFormArray));
formGroup.addControl('fieldSets', this.formBuilder.array(compositeFieldsFormArray));
formGroup.addControl('defaultVisibility', new FormControl(this.defaultVisibility)); formGroup.addControl('defaultVisibility', new FormControl(this.defaultVisibility));
formGroup.addControl('page', new FormControl(this.page, [Validators.required])); formGroup.addControl('page', new FormControl(this.page, [Validators.required]));
formGroup.addControl('id', new FormControl(this.id)); formGroup.addControl('id', new FormControl(this.id));

View File

@ -17,7 +17,7 @@ export class DatasetProfileService implements OnInit {
} }
fetchAllDatasetProfiles(){ fetchAllDatasetProfiles(){
return this.restBase.get("datasetprofile/getAll"); return this.restBase.get("datasetprofiles/getAll");
} }
getDatasetProfileById(datasetProfileID){ getDatasetProfileById(datasetProfileID){