# Conflicts:
#	dmp-admin/src/app/dataset-profile-form/field-form/field-form.component.html
This commit is contained in:
annampak 2018-01-03 16:53:02 +02:00
commit 21ba057390
7 changed files with 46 additions and 31 deletions

View File

@ -2,14 +2,10 @@
<div [formGroup]="form">
<div class="row">
<div class="form-group col-md-6">
<label>Title</label>
<input data-toggle="tooltip" title="tooltip on second input!" type="text" class="form-control" formControlName="title">
</div>
<div class="form-group col-md-3">
<label>Id</label>
<input type="text" class="form-control" formControlName="id">
</div>
<div class="form-row col-md-3">
<div class="form-row col-md-6">
<div formGroupName="viewStyle">
<div class="form-group">
<label>View style</label>
@ -32,6 +28,18 @@
<div *ngSwitchCase="'radiobox'">
<radiobox-component [form]="form" [dataModel]="dataModel"></radiobox-component>
</div>
<div *ngSwitchCase="'freetext'">
<freetext-component [form]="form" [dataModel]="dataModel"></freetext-component>
</div>
<div *ngSwitchCase="'textarea'">
<textarea-component [form]="form" [dataModel]="dataModel"></textarea-component>
</div>
<div *ngSwitchCase="'booleanDecision'">
<booleanDecision-component [form]="form" [dataModel]="dataModel"></booleanDecision-component>
</div>
<div *ngSwitchCase="'checkBox'">
<checkbox-component [form]="form" [dataModel]="dataModel"></checkbox-component>
</div>
</div>
<!-- <div class="row">
<div class="form-group col-md-6">

View File

@ -1,16 +1,14 @@
import { DatasetProfileService } from 'app/services/dataset-profile.service';
import { Section } from '../../models/DataSetProfile/Section';
import { JsonSerializer } from '../../utilities/JsonSerializer';
import { DatasetProfileService } from '../../services/dataset-profile.service';
import { RestBase } from '../../services/rest-base';
import { DatasetProfileModel } from '../../models/DataSetProfile/DatasetProfileModel';
import { Page } from '../../models/DataSetProfile/Page';
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormControl } from '@angular/forms';
import { JsonSerializer } from 'app/utilities/JsonSerializer';
import { SectionFormComponent } from '../section-form/section-form.component';
import { Section } from 'app/models/DataSetProfile/Section';
import { FieldGroup } from 'app/models/DataSetProfile/FieldGroup';
import { DatasetProfileModel } from 'app/models/DataSetProfile/DatasetProfileModel';
import { TestModel } from 'app/testModel/testModel';
import { FormArray } from '@angular/forms/src/model';
import { RestBase } from 'app/services/rest-base';
import { Router, ActivatedRoute, ParamMap, Params } from '@angular/router';
import { Page } from 'app/models/DataSetProfile/Page'
import { PageFormComponent } from '../page-form/page-component'
@Component({

View File

@ -1,4 +1,8 @@
import { RadioBoxData } from '../DataField/RadioBoxData';
import { BooleanDecisionData } from '../DataField/BooleanDecisionData';
import { FreeTextData } from '../DataField/FreeTextData';
import { TextArea } from '../DataField/TextArea';
import { CheckBoxData } from '../DataField/CheckBoxData';
import { RadioBoxData } from '../DataField/RadioBoxData';
import { WordListData } from '../DataField/WordListData';
import { AutocompleteData } from '../DataField/AutocompleteData';
import { DataField } from '../DataField/DataField';
@ -43,6 +47,10 @@ export class Field extends BaseModel implements Serializable<Field>,FormGenerato
if(item.data.type === "wordlist")this.data = new JsonSerializer<WordListData>().fromJSONObject(item.data,WordListData);
}else{
if(this.viewStyle.renderStyle === "radiobox") this.data = new JsonSerializer<RadioBoxData>().fromJSONObject(item.data,RadioBoxData);
if(this.viewStyle.renderStyle === "checkBox") this.data = new JsonSerializer<CheckBoxData>().fromJSONObject(item.data,CheckBoxData);
if(this.viewStyle.renderStyle === "textarea") this.data = new JsonSerializer<TextArea>().fromJSONObject(item.data,TextArea);
if(this.viewStyle.renderStyle === "freetext") this.data = new JsonSerializer<FreeTextData>().fromJSONObject(item.data,FreeTextData);
if(this.viewStyle.renderStyle === "booleanDecision") this.data = new JsonSerializer<BooleanDecisionData>().fromJSONObject(item.data,BooleanDecisionData);
}
}
return this;

View File

@ -1,5 +1,5 @@
import { FormGroup } from '@angular/forms';
import { JsonSerializer } from 'app/utilities/JsonSerializer';
import { JsonSerializer } from '../../utilities/JsonSerializer';
import { FormGroup } from '@angular/forms';
import { Serializable } from '../interfaces/Serializable';
import { BaseModel } from '../BaseModel';
import {Field} from './Field'

View File

@ -1,10 +1,10 @@
import { BaseModel } from '../BaseModel';
import { JsonSerializer } from '../../utilities/JsonSerializer';
import { FieldSet } from './FieldSet';
import { BaseModel } from '../BaseModel';
import { FormGenerator } from '../interfaces/FormGenerator';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { JsonSerializer } from 'app/utilities/JsonSerializer';
import { Serializable } from '../interfaces/Serializable';
import { FieldGroup } from './FieldGroup';
import { FieldSet } from 'app/models/DataSetProfile/FieldSet';
export class Section extends BaseModel implements Serializable<Section>, FormGenerator<FormGroup>{
public sections: Array<Section> = new Array<Section>();

View File

@ -33,7 +33,7 @@ public class FreeTextData extends FieldData<FreeTextData> {
@Override
public FreeTextData fromXml(Element item) {
item.setAttribute("label",this.getLabel());
this.setLabel(item.getAttribute("label"));
return this;
}
}

View File

@ -63,24 +63,24 @@ public class ModelBuilder {
return list;
}
public <U extends FieldData<U>> U toFieldData(Object data,String type,Element dataElement){
public <U> FieldData<U> toFieldData(Object data,String type,Element dataElement){
if(type.equals("combobox")){
if(dataElement!=null){
if(dataElement.getAttribute("type").equals("autocomplete")){
return (U) new AutoCompleteData().fromData(data);
return (FieldData<U>) new AutoCompleteData().fromData(data);
}else if(dataElement.getAttribute("type").equals("wordlist"))
return (U) new WordListData().fromData(data);
return (FieldData<U>) new WordListData().fromData(data);
}
}
if(type.equals("booleanDecision"))return (U) new BooleanDecisionData().fromData(data);
if(type.equals("radiobox"))return (U) new RadioBoxData().fromData(data);
if(type.equals("checkBox"))return (U) new CheckBoxData().fromData(data);
if(type.equals("freetext"))return (U) new FreeTextData().fromData(data);
if(type.equals("textarea"))return (U) new TextAreaData().fromData(data);
if(type.equals("booleanDecision"))return (FieldData<U>) new BooleanDecisionData().fromData(data);
if(type.equals("radiobox"))return (FieldData<U>) new RadioBoxData().fromData(data);
if(type.equals("checkBox"))return (FieldData<U>) new CheckBoxData().fromData(data);
if(type.equals("freetext"))return (FieldData<U>) new FreeTextData().fromData(data);
if(type.equals("textarea"))return (FieldData<U>) new TextAreaData().fromData(data);
return null;
}
public <U > FieldData<U> toFieldData(Object data,String type){
public <U> FieldData<U> toFieldData(Object data,String type){
if(type.equals("combobox")){
String comboboxType = (String)((Map<String,Object>)data).get("type");
if(comboboxType.equals("autocomplete")){
@ -88,10 +88,11 @@ public class ModelBuilder {
}else if(comboboxType.equals("wordlist"))
return (FieldData<U>) new WordListData().fromData(data);
}
if(type.equals("booleanDecision"))return null;
if(type.equals("booleanDecision"))return (FieldData<U>) new BooleanDecisionData().fromData(data);
if(type.equals("radiobox"))return (FieldData<U>) new RadioBoxData().fromData(data);
if(type.equals("checkBox"))return (FieldData<U>) new CheckBoxData().fromData(data);
if(type.equals("freetext"))return null;
if(type.equals("freetext"))return (FieldData<U>) new FreeTextData().fromData(data);
if(type.equals("textarea"))return (FieldData<U>) new TextAreaData().fromData(data);
return null;
}