checkbox with label

This commit is contained in:
annabakouli 2017-12-06 14:16:31 +02:00
parent 07a4433f34
commit 902116e039
6 changed files with 82 additions and 71 deletions

View File

@ -1,27 +1,42 @@
package models.components.commons.datafield; package models.components.commons.datafield;
import java.util.Map;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import utilities.XmlSerializable; import utilities.XmlSerializable;
public class CheckBoxData extends FieldData<CheckBoxData>{ public class CheckBoxData extends FieldData<CheckBoxData>{
private String label;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
@Override @Override
public Element toXml(Document doc) { public Element toXml(Document doc) {
// TODO Auto-generated method stub Element root = doc.createElement("data");
return doc.createElement("data"); root.setAttribute("label", this.label);
return root;
} }
@Override @Override
public CheckBoxData fromXml(Element item) { public CheckBoxData fromXml(Element item) {
// TODO Auto-generated method stub this.label = item.getAttribute("label");
return this; return this;
} }
@Override @Override
public CheckBoxData fromData(Object data) { public CheckBoxData fromData(Object data) {
// TODO Auto-generated method stub if(data!=null){
this.label= (String)((Map<String,Object>)data).get("label");
}
return this; return this;
} }

View File

@ -76,13 +76,13 @@ public class Admin {
datasetProfileViewstyleDao.update(oldviewStyle); datasetProfileViewstyleDao.update(oldviewStyle);
if(!datasetprofile.getDataset().isEmpty())throw new Exception ("Cannot edit a Profile that has Datasets assigned"); //if(!datasetprofile.getDataset().isEmpty())throw new Exception ("Cannot edit a Profile that has Datasets assigned");
datasetprofile.setViewstyle(oldviewStyle); datasetprofile.setViewstyle(oldviewStyle);
datasetprofile.setDefinition(modelDefinition.getDefinition()); datasetprofile.setDefinition(modelDefinition.getDefinition());
datasetProfileDao.update(datasetprofile); datasetProfileDao.update(datasetprofile);
return ResponseEntity.status(HttpStatus.OK).body(datasetprofile); return ResponseEntity.status(HttpStatus.OK).body(null);
}catch(Exception ex){ }catch(Exception ex){
ex.printStackTrace(); ex.printStackTrace();
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"reason\":\""+ex.getMessage()+"\"}"); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"reason\":\""+ex.getMessage()+"\"}");

View File

@ -5,6 +5,7 @@ import java.util.List;
import entities.xmlmodels.modeldefinition.DatabaseModelDefinition; import entities.xmlmodels.modeldefinition.DatabaseModelDefinition;
import entities.xmlmodels.viewstyledefinition.DatabaseViewStyleDefinition; import entities.xmlmodels.viewstyledefinition.DatabaseViewStyleDefinition;
import models.components.commons.datafield.CheckBoxData;
import models.components.commons.datafield.ComboBoxData; import models.components.commons.datafield.ComboBoxData;
import models.components.commons.datafield.FieldData; import models.components.commons.datafield.FieldData;
import models.components.commons.datafield.RadioBoxData; import models.components.commons.datafield.RadioBoxData;
@ -66,7 +67,7 @@ public class ModelBuilder {
if(type.equals("combobox")) return (U) new ComboBoxData().fromData(data); if(type.equals("combobox")) return (U) new ComboBoxData().fromData(data);
if(type.equals("booleanDecision"))return null; if(type.equals("booleanDecision"))return null;
if(type.equals("radiobox"))return (U) new RadioBoxData().fromData(data); if(type.equals("radiobox"))return (U) new RadioBoxData().fromData(data);
if(type.equals("checkBox"))return null; if(type.equals("checkBox"))return (U) new CheckBoxData().fromData(data);
if(type.equals("freetext"))return null; if(type.equals("freetext"))return null;
return null; return null;
} }

View File

@ -1,4 +1,4 @@
<div [formGroup]="form" class="form-group"> <div [formGroup]="form" class="form-group">
<input id="{{field.id + 'checkboc'}}" class="checkbox-icon" formControlName="value" type="checkbox"> <input id="{{field.id + 'checkboc'}}" class="checkbox-icon" formControlName="value" type="checkbox">
<label for="{{field.id + 'checkboc'}}" class="checkbox-label">Test</label> <label for="{{field.id + 'checkboc'}}" class="checkbox-label">{{field.data.label}}</label>
</div> </div>

View File

@ -61,8 +61,8 @@ export class DynamicFormComponent implements OnInit {
id: string; id: string;
datasetId: string; datasetId: string;
pathName: string; pathName: string;
pages: Set<number>;
stepperItems: MenuItem[]; stepperItems: MenuItem[] = new Array<MenuItem>();
activeStepperIndex: number = 1; activeStepperIndex: number = 1;
visibleSidebar: boolean = false; visibleSidebar: boolean = false;
@ -81,35 +81,11 @@ export class DynamicFormComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.stepperItems = [{
label: 'Personal',
command: (event: any) => {
this.activeStepperIndex = 0;
}
},
{
label: 'Seat',
command: (event: any) => {
this.activeStepperIndex = 1;
}
},
{
label: 'Payment',
command: (event: any) => {
this.activeStepperIndex = 2;
}
},
{
label: 'Confirmation',
command: (event: any) => {
this.activeStepperIndex = 3;
}
}
];
this.serverService.getDmp(this.datasetId).subscribe( this.serverService.getDmp(this.datasetId).subscribe(
response => { response => {
this.dataModel = new JsonSerializer<DatasetModel>().fromJSONObject(response, DatasetModel); this.dataModel = new JsonSerializer<DatasetModel>().fromJSONObject(response, DatasetModel);
this.pages = this.getPages(this.dataModel);
this.createPagination();
this.form = this.dataModel.buildForm(); this.form = this.dataModel.buildForm();
this.visibilityRulesService.formGroup = this.form; this.visibilityRulesService.formGroup = this.form;
let rules: Rule[] = new JsonSerializer<Rule>().fromJSONArray(response.rules, Rule); let rules: Rule[] = new JsonSerializer<Rule>().fromJSONArray(response.rules, Rule);
@ -139,6 +115,25 @@ export class DynamicFormComponent implements OnInit {
toggleSidebar() { toggleSidebar() {
this.visibleSidebar = !this.visibleSidebar; this.visibleSidebar = !this.visibleSidebar;
} }
getPages(model: DatasetModel): Set<number> {
let pageSet = new Set<number>();
model.sections.forEach(section => {
pageSet.add(section.page);
})
return pageSet;
}
createPagination() {
this.pages.forEach(item => {
this.stepperItems.push({
label: '',
command: (event: any) => {
this.activeStepperIndex = item;
}
})
})
}
/* scrollToElemID(elemID) { /* scrollToElemID(elemID) {
scroll("#" + elemID); scroll("#" + elemID);
} }