Merge branch 'Development' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into Development
# Conflicts: # dmp-frontend/src/app/form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.html
This commit is contained in:
commit
e8d9190648
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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()+"\"}");
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,23 +56,23 @@ declare var PerfectScrollbar: any;
|
||||||
export class DynamicFormComponent implements OnInit {
|
export class DynamicFormComponent implements OnInit {
|
||||||
|
|
||||||
@Input() dataModel: DatasetModel = new DatasetModel();
|
@Input() dataModel: DatasetModel = new DatasetModel();
|
||||||
@Input() path:string;
|
@Input() path: string;
|
||||||
form: FormGroup;
|
form: FormGroup;
|
||||||
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;
|
||||||
|
|
||||||
private progressbar:boolean = false;
|
private progressbar: boolean = false;
|
||||||
|
|
||||||
private fragment:string;
|
private fragment: string;
|
||||||
constructor(private qcs: FieldControlService, private serverService: ServerService, private router: Router, private pdfService: PDFService,
|
constructor(private qcs: FieldControlService, private serverService: ServerService, private router: Router, private pdfService: PDFService,
|
||||||
private _location: Location, private route: ActivatedRoute, private pagerService: PaginationService, private tokenService: TokenService, private visibilityRulesService: VisibilityRulesService) {
|
private _location: Location, private route: ActivatedRoute, private pagerService: PaginationService, private tokenService: TokenService, private visibilityRulesService: VisibilityRulesService) {
|
||||||
this.datasetId = route.snapshot.params['id'];
|
this.datasetId = route.snapshot.params['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubForm(subformName) {
|
getSubForm(subformName) {
|
||||||
return this.form.controls[subformName];
|
return this.form.controls[subformName];
|
||||||
|
@ -81,64 +81,59 @@ export class DynamicFormComponent implements OnInit {
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
this.stepperItems = [{
|
this.serverService.getDmp(this.datasetId).subscribe(
|
||||||
label: 'Personal',
|
response => {
|
||||||
command: (event: any) => {
|
this.dataModel = new JsonSerializer<DatasetModel>().fromJSONObject(response, DatasetModel);
|
||||||
this.activeStepperIndex = 0;
|
this.pages = this.getPages(this.dataModel);
|
||||||
|
this.createPagination();
|
||||||
|
this.form = this.dataModel.buildForm();
|
||||||
|
this.visibilityRulesService.formGroup = this.form;
|
||||||
|
let rules: Rule[] = new JsonSerializer<Rule>().fromJSONArray(response.rules, Rule);
|
||||||
|
this.visibilityRulesService.buildVisibilityRules(rules)
|
||||||
|
this.progressbar = true;
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
console.log("Could not load dmp");
|
||||||
}
|
}
|
||||||
},
|
)
|
||||||
{
|
|
||||||
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(
|
/* else{
|
||||||
response => {
|
|
||||||
this.dataModel = new JsonSerializer<DatasetModel>().fromJSONObject(response, DatasetModel);
|
this.addSection();
|
||||||
this.form = this.dataModel.buildForm();
|
}
|
||||||
this.visibilityRulesService.formGroup = this.form;
|
this.dataModel = new JsonSerializer<DatasetModel>().fromJSONObject(TestModel,DatasetModel);
|
||||||
let rules:Rule[] = new JsonSerializer<Rule>().fromJSONArray(response.rules,Rule);
|
this.form = this.dataModel.buildForm();
|
||||||
this.visibilityRulesService.buildVisibilityRules(rules)
|
this.visibilityRulesService.formGroup = this.form;
|
||||||
this.progressbar = true;
|
let rules:Rule[] = new JsonSerializer<Rule>().fromJSONArray(TestModel.rules,Rule);
|
||||||
},
|
this.visibilityRulesService.buildVisibilityRules(rules) */
|
||||||
error => {
|
|
||||||
console.log("Could not load dmp");
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/* else{
|
|
||||||
|
|
||||||
this.addSection();
|
|
||||||
}
|
|
||||||
this.dataModel = new JsonSerializer<DatasetModel>().fromJSONObject(TestModel,DatasetModel);
|
|
||||||
this.form = this.dataModel.buildForm();
|
|
||||||
this.visibilityRulesService.formGroup = this.form;
|
|
||||||
let rules:Rule[] = new JsonSerializer<Rule>().fromJSONArray(TestModel.rules,Rule);
|
|
||||||
this.visibilityRulesService.buildVisibilityRules(rules) */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
submit(){
|
submit() {
|
||||||
this.serverService.updateDataset(this.datasetId,this.form.value).subscribe()
|
this.serverService.updateDataset(this.datasetId, this.form.value).subscribe()
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -212,9 +207,9 @@ export class DynamicFormComponent implements OnInit {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
createPDF(elementID : string, pdffilename : string){
|
createPDF(elementID: string, pdffilename: string) {
|
||||||
this.pdfService.toPDF(elementID, pdffilename);
|
this.pdfService.toPDF(elementID, pdffilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { VisibilityRulesService } from '../../../visibility-rules/visibility-rules.service';
|
||||||
import { BaseTableOfContent } from '../base-table-of-content.component';
|
import { BaseTableOfContent } from '../base-table-of-content.component';
|
||||||
import { CompositeField } from '../../../models/CompositeField';
|
import { CompositeField } from '../../../models/CompositeField';
|
||||||
import { Field } from '../../../models/Field';
|
import { Field } from '../../../models/Field';
|
||||||
|
@ -16,7 +17,7 @@ export class TableOfContentsFieldComponent extends BaseTableOfContent{
|
||||||
@Input() index:number;
|
@Input() index:number;
|
||||||
@Input() public path:string;
|
@Input() public path:string;
|
||||||
|
|
||||||
constructor(public router: Router, public route: ActivatedRoute) {
|
constructor(public router: Router, public route: ActivatedRoute,private visibilityRulesService: VisibilityRulesService) {
|
||||||
super(router, route)
|
super(router, route)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,10 @@
|
||||||
<!-- All contents in the first page -->
|
<!-- All contents in the first page -->
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li *ngFor="let field of model.fields let i = index">
|
<div *ngFor="let field of model.fields let i = index">
|
||||||
<table-of-contents-field [model]="field" [index]="i" [path]="path"> </table-of-contents-field>
|
<li *ngIf="visibilityRulesService.isElementVisible(null,field.id)">
|
||||||
</li>
|
<table-of-contents-field [model]="field" [index]="i" [path]="path">
|
||||||
|
</table-of-contents-field>
|
||||||
|
</li>
|
||||||
|
</div>
|
||||||
</ul>
|
</ul>
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { VisibilityRulesService } from '../../../visibility-rules/visibility-rules.service';
|
||||||
import { BaseTableOfContent } from '../base-table-of-content.component';
|
import { BaseTableOfContent } from '../base-table-of-content.component';
|
||||||
import { CompositeField } from '../../../models/CompositeField';
|
import { CompositeField } from '../../../models/CompositeField';
|
||||||
import { FieldGroup } from '../../../models/FieldGroup';
|
import { FieldGroup } from '../../../models/FieldGroup';
|
||||||
|
@ -19,7 +20,7 @@ export class TableOfContentsFieldSetComponent extends BaseTableOfContent {
|
||||||
@Input() index: number;
|
@Input() index: number;
|
||||||
@Input() public path: string;
|
@Input() public path: string;
|
||||||
|
|
||||||
constructor(public router: Router, public route: ActivatedRoute) {
|
constructor(public router: Router, public route: ActivatedRoute,private visibilityRulesService: VisibilityRulesService) {
|
||||||
super(router, route)
|
super(router, route)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { VisibilityRulesService } from '../../../visibility-rules/visibility-rules.service';
|
||||||
import { BaseTableOfContent } from '../base-table-of-content.component';
|
import { BaseTableOfContent } from '../base-table-of-content.component';
|
||||||
import { FieldGroup } from '../../../models/FieldGroup';
|
import { FieldGroup } from '../../../models/FieldGroup';
|
||||||
import { Section } from '../../../models/Section';
|
import { Section } from '../../../models/Section';
|
||||||
|
@ -21,7 +22,7 @@ export class TableOfContentsGroupComponent extends BaseTableOfContent {
|
||||||
setPage:EventEmitter<number> = new EventEmitter<number>();
|
setPage:EventEmitter<number> = new EventEmitter<number>();
|
||||||
|
|
||||||
*/
|
*/
|
||||||
constructor(public router: Router, public route: ActivatedRoute) {
|
constructor(public router: Router, public route: ActivatedRoute,private visibilityRulesService: VisibilityRulesService) {
|
||||||
super(router, route)
|
super(router, route)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
<!-- All contents in the first page -->
|
<!-- All contents in the first page -->
|
||||||
<ul>
|
<ul>
|
||||||
<li *ngFor="let sectionModel of model.sections let i = index">
|
<li *ngFor="let sectionModel of model.sections let i = index">
|
||||||
<table-of-contents-section [model]="sectionModel" [index]="i" [path]="path+'.'+(i+1)"> </table-of-contents-section>
|
<table-of-contents-section [model]="sectionModel" [index]="i" [path]="path+'.'+(i+1)"> </table-of-contents-section>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { VisibilityRulesService } from '../../../visibility-rules/visibility-rules.service';
|
||||||
import { BaseTableOfContent } from '../base-table-of-content.component';
|
import { BaseTableOfContent } from '../base-table-of-content.component';
|
||||||
import { Section } from '../../../models/Section';
|
import { Section } from '../../../models/Section';
|
||||||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||||||
|
@ -17,7 +18,7 @@ export class TableOfContentsSectionComponent extends BaseTableOfContent implemen
|
||||||
@Input() index: number;
|
@Input() index: number;
|
||||||
@Input() public path: string;
|
@Input() public path: string;
|
||||||
|
|
||||||
constructor(public router: Router,public route:ActivatedRoute){
|
constructor(public router: Router,public route:ActivatedRoute,private visibilityRulesService: VisibilityRulesService){
|
||||||
super(router,route)
|
super(router,route)
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
|
@ -9,9 +9,9 @@ export class VisibilityRulesService {
|
||||||
public formGroup: FormGroup;
|
public formGroup: FormGroup;
|
||||||
public visibilityRuleContext: VisibilityRulesContext;
|
public visibilityRuleContext: VisibilityRulesContext;
|
||||||
public fieldsPathMemory: any = {};
|
public fieldsPathMemory: any = {};
|
||||||
|
|
||||||
public isElementVisible(pathKey: string, id: string) {
|
public isElementVisible(pathKey: string, id: string) {
|
||||||
if (!this.fieldsPathMemory[id]) this.fieldsPathMemory[id] = pathKey;
|
if (!this.fieldsPathMemory[id] && pathKey) this.fieldsPathMemory[id] = pathKey;
|
||||||
let visibilityRule = this.visibilityRuleContext.getRulesFromKey(id);
|
let visibilityRule = this.visibilityRuleContext.getRulesFromKey(id);
|
||||||
if (!visibilityRule) return true;
|
if (!visibilityRule) return true;
|
||||||
return this.checkElementVisibility(visibilityRule);
|
return this.checkElementVisibility(visibilityRule);
|
||||||
|
@ -21,8 +21,8 @@ export class VisibilityRulesService {
|
||||||
let sourceVisibilityRules = visibilityRule.sourceVisibilityRules;
|
let sourceVisibilityRules = visibilityRule.sourceVisibilityRules;
|
||||||
for (let i = 0; i < sourceVisibilityRules.length; i++) {
|
for (let i = 0; i < sourceVisibilityRules.length; i++) {
|
||||||
let sourceVisibilityRule = sourceVisibilityRules[i];
|
let sourceVisibilityRule = sourceVisibilityRules[i];
|
||||||
if (!this.formGroup.get( this.fieldsPathMemory[sourceVisibilityRule.sourceControlId] + '.value'))return false; //TODO
|
if (!this.formGroup.get(this.fieldsPathMemory[sourceVisibilityRule.sourceControlId] + '.value')) return false; //TODO
|
||||||
if(sourceVisibilityRule.sourceControlValue != ''+this.formGroup.get( this.fieldsPathMemory[sourceVisibilityRule.sourceControlId] + '.value').value) return false;
|
if (sourceVisibilityRule.sourceControlValue != '' + this.formGroup.get(this.fieldsPathMemory[sourceVisibilityRule.sourceControlId] + '.value').value) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue