Merge branch 'Development' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into Development
This commit is contained in:
commit
c277ea3095
|
@ -18,7 +18,7 @@ export class RestBase {
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
protocol: string = "http";
|
protocol: string = "http";
|
||||||
hostname: string = "192.168.32.171";
|
hostname: string = "192.168.32.96";
|
||||||
port: number = 8080;
|
port: number = 8080;
|
||||||
webappname: string = "";
|
webappname: string = "";
|
||||||
restpath: string = "";
|
restpath: string = "";
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<ng-template matStepLabel>{{'DATASET-WIZARD.THIRD-STEP.TITLE' | translate}}</ng-template>
|
<ng-template matStepLabel>{{'DATASET-WIZARD.THIRD-STEP.TITLE' | translate}}</ng-template>
|
||||||
<dynamic-form *ngIf="datasetWizardModel && datasetWizardModel.id" [dataModel]="datasetWizardModel"></dynamic-form>
|
<dynamic-form *ngIf="datasetWizardModel && datasetWizardModel.id" [dataModel]="datasetWizardModel"></dynamic-form>
|
||||||
<div>
|
<div>
|
||||||
<button matStepperPrevious mat-raised-button color="primary">{{'DATASET-WIZARD.ACTIONS.BACK' | translate}}</button>
|
<button style="margin-top:10px;" matStepperPrevious mat-raised-button color="primary">{{'DATASET-WIZARD.ACTIONS.BACK' | translate}}</button>
|
||||||
</div>
|
</div>
|
||||||
</mat-step>
|
</mat-step>
|
||||||
</mat-horizontal-stepper>
|
</mat-horizontal-stepper>
|
||||||
|
|
|
@ -31,5 +31,5 @@ mat-row:hover {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
mat-row:nth-child(odd){
|
mat-row:nth-child(odd){
|
||||||
background-color: #f1f1f1;
|
background-color:#eef0fb;
|
||||||
}
|
}
|
|
@ -23,16 +23,6 @@ export class DynamicFormCompositeFieldComponent implements OnInit {
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
console.log(this.form);
|
console.log(this.form);
|
||||||
if (this.compositeField.hasCommentField == true) {
|
|
||||||
let newfield: Field = new Field();
|
|
||||||
newfield.id = 'comment_' + this.compositeField.id;
|
|
||||||
newfield.data = {label: "Comments"};
|
|
||||||
newfield.viewStyle = {renderStyle: 'freetext', cssClass: ''};
|
|
||||||
newfield.validations = ["None"]
|
|
||||||
|
|
||||||
this.compositeField.fields.push(newfield);
|
|
||||||
(<FormArray>this.form.get("fields")).push(newfield.buildForm());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addMultipleField(fieldIndex: number) {
|
addMultipleField(fieldIndex: number) {
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
<mat-expansion-panel expanded=true>
|
<mat-expansion-panel expanded=true>
|
||||||
<mat-expansion-panel-header>
|
<mat-expansion-panel-header>
|
||||||
<mat-panel-title>
|
<mat-panel-title>
|
||||||
{{path}} {{section.title}}
|
{{path}} {{section.title}}
|
||||||
</mat-panel-title>
|
</mat-panel-title>
|
||||||
<mat-panel-description>
|
<mat-panel-description>
|
||||||
<h3 *ngIf="section.description">{{section.description}}</h3>
|
<h3 *ngIf="section.description">{{section.description}}</h3>
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
</div> -->
|
</div> -->
|
||||||
|
|
||||||
<div *ngFor="let compositeField of section.compositeFields; let i = index;">
|
<div *ngFor="let compositeField of section.compositeFields; let i = index;">
|
||||||
<div *ngIf="isVisible(compositeField)">
|
<div *ngIf="isVisible(pathName+'.compositeFields.'+i, compositeField)">
|
||||||
<div *ngIf="(compositeField?.multiplicity?.max - 1) > (compositeField?.multiplicityItems?.length)">
|
<div *ngIf="(compositeField?.multiplicity?.max - 1) > (compositeField?.multiplicityItems?.length)">
|
||||||
<a (click)="addMultipleField(i)" style="cursor: pointer">
|
<a (click)="addMultipleField(i)" style="cursor: pointer">
|
||||||
Add one more fieldset +
|
Add one more fieldset +
|
||||||
|
@ -65,6 +65,12 @@
|
||||||
[pathName]="pathName+'.compositeFields.'+i+'.multiplicityItems.'+j"></df-composite-field>
|
[pathName]="pathName+'.compositeFields.'+i+'.multiplicityItems.'+j"></df-composite-field>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div *ngIf="compositeField.hasCommentField">
|
||||||
|
<mat-form-field>
|
||||||
|
<input matInput formControlName="commentFieldValue" placeholder="comment">
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngIf="section.sections">
|
<div *ngIf="section.sections">
|
||||||
|
|
|
@ -19,7 +19,7 @@ export class DynamicFormSectionComponent implements OnInit {
|
||||||
@Input() form: FormGroup;
|
@Input() form: FormGroup;
|
||||||
@Input() pathName: string;
|
@Input() pathName: string;
|
||||||
@Input() path: string;
|
@Input() path: string;
|
||||||
constructor(private visibilityRulesService:VisibilityRulesService) { }
|
constructor(private visibilityRulesService: VisibilityRulesService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
console.log(this.section);
|
console.log(this.section);
|
||||||
|
@ -31,11 +31,11 @@ export class DynamicFormSectionComponent implements OnInit {
|
||||||
(<FormArray>(this.form.get("compositeFields").get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm());
|
(<FormArray>(this.form.get("compositeFields").get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
isVisible(fieldSet:CompositeField):boolean{
|
isVisible(pathname: string, fieldSet: CompositeField): boolean {
|
||||||
if(!this.visibilityRulesService.isElementVisible(null,fieldSet.id)) return false;
|
if (!this.visibilityRulesService.isElementVisible(pathname, fieldSet.id)) return false;
|
||||||
for(var i=0; i<fieldSet.fields.length; i++){
|
for (var i = 0; i < fieldSet.fields.length; i++) {
|
||||||
if (!this.visibilityRulesService.isElementVisible(null,fieldSet.fields[i].id))
|
if (!this.visibilityRulesService.isElementVisible(pathname+'.fields.'+i, fieldSet.fields[i].id))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,14 +5,14 @@ import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { FormGroup, FormControl, FormArray } from '@angular/forms'
|
import { FormGroup, FormControl, FormArray } from '@angular/forms'
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'progress-bar',
|
selector: 'progress-bar',
|
||||||
templateUrl: './progress-bar.component.html',
|
templateUrl: './progress-bar.component.html',
|
||||||
styles: ['.alwaysVisible .ui-progressbar-label { display:block!important; }'],
|
styles: ['.alwaysVisible .ui-progressbar-label { display:block!important; }'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class ProgressBarComponent implements OnInit {
|
export class ProgressBarComponent implements OnInit {
|
||||||
@Input() formGroup: FormGroup
|
@Input() formGroup: FormGroup
|
||||||
@Input("progressValueAccuracy") public accuracy: number = 1;
|
@Input("progressValueAccuracy") public accuracy: number = 1;
|
||||||
determinateProgressValue:number;
|
determinateProgressValue: number;
|
||||||
|
|
||||||
constructor(private visibilityRulesService: VisibilityRulesService) { }
|
constructor(private visibilityRulesService: VisibilityRulesService) { }
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ export class ProgressBarComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateValueForProgressbar(){
|
calculateValueForProgressbar() {
|
||||||
var progressSoFar = this.countFormControlsWithValue(this.formGroup);
|
var progressSoFar = this.countFormControlsWithValue(this.formGroup);
|
||||||
var total = this.getFormControlDepthLength(this.formGroup);
|
var total = this.getFormControlDepthLength(this.formGroup);
|
||||||
var perc = (progressSoFar / total) * 100;
|
var perc = (progressSoFar / total) * 100;
|
||||||
|
@ -44,7 +44,7 @@ export class ProgressBarComponent implements OnInit {
|
||||||
value += this.countFormControlsWithValue(<FormGroup>formArray.get("" + i))
|
value += this.countFormControlsWithValue(<FormGroup>formArray.get("" + i))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (key === "value" && control.value != null) value++;
|
else if (key === "value" && control.value != null && control.value != "") value++;
|
||||||
});
|
});
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -52,16 +52,17 @@ export class ProgressBarComponent implements OnInit {
|
||||||
getFormControlDepthLength(form: FormGroup): number {
|
getFormControlDepthLength(form: FormGroup): number {
|
||||||
let value = 0;
|
let value = 0;
|
||||||
Object.keys(form.controls).forEach(key => {
|
Object.keys(form.controls).forEach(key => {
|
||||||
let control = form.controls[key]
|
let control = form.controls[key];
|
||||||
if (control instanceof FormGroup)
|
if (control instanceof FormGroup) { value += this.getFormControlDepthLength(control); }
|
||||||
{ value += this.getFormControlDepthLength(control);}
|
|
||||||
else if (control instanceof FormArray) {
|
else if (control instanceof FormArray) {
|
||||||
let formArray = (<FormArray>control);
|
let formArray = (<FormArray>control);
|
||||||
for (let i = 0; i < formArray.length; i++) {
|
for (let i = 0; i < formArray.length; i++) {
|
||||||
value += this.getFormControlDepthLength(<FormGroup>formArray.get("" + i))
|
if (<FormGroup>formArray.get("" + i).value && this.visibilityRulesService.isElementVisible(null, formArray.get("" + i).value.id))
|
||||||
|
value += this.getFormControlDepthLength(<FormGroup>formArray.get("" + i))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (key === "value" && this.visibilityRulesService.isElementVisible(null, form.controls["id"].value)) value++;
|
else if (key === "value" && this.visibilityRulesService.isElementVisible(null, form.controls["id"].value))
|
||||||
|
value++;
|
||||||
});
|
});
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ export class CompositeField extends BaseModel implements Serializable<CompositeF
|
||||||
public description: string
|
public description: string
|
||||||
public extendedDescription: string
|
public extendedDescription: string
|
||||||
public hasCommentField: boolean;
|
public hasCommentField: boolean;
|
||||||
|
public commentFieldValue: string;
|
||||||
|
|
||||||
fromJSONObject(item: any): CompositeField {
|
fromJSONObject(item: any): CompositeField {
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ export class CompositeField extends BaseModel implements Serializable<CompositeF
|
||||||
this.description = item.description;
|
this.description = item.description;
|
||||||
this.extendedDescription = item.extendedDescription;
|
this.extendedDescription = item.extendedDescription;
|
||||||
this.hasCommentField = item.hasCommentField;
|
this.hasCommentField = item.hasCommentField;
|
||||||
|
this.commentFieldValue = item.commentFieldValue;
|
||||||
this.multiplicity = JsonSerializer.fromJSONObject(item.multiplicity, Multiplicity);
|
this.multiplicity = JsonSerializer.fromJSONObject(item.multiplicity, Multiplicity);
|
||||||
//this.multiplicity = new Multiplicity();
|
//this.multiplicity = new Multiplicity();
|
||||||
//this.multiplicity.max = 2;
|
//this.multiplicity.max = 2;
|
||||||
|
@ -38,7 +40,8 @@ export class CompositeField extends BaseModel implements Serializable<CompositeF
|
||||||
title: this.title,
|
title: this.title,
|
||||||
description: this.description,
|
description: this.description,
|
||||||
extendedDescription: this.extendedDescription,
|
extendedDescription: this.extendedDescription,
|
||||||
hasCommentField: this.hasCommentField
|
hasCommentField: this.hasCommentField,
|
||||||
|
commentFieldValue: this.commentFieldValue
|
||||||
});
|
});
|
||||||
|
|
||||||
let fieldsFormArray = new Array<FormGroup>();
|
let fieldsFormArray = new Array<FormGroup>();
|
||||||
|
|
|
@ -17,7 +17,8 @@ export class VisibilityRulesService {
|
||||||
if (this.checkElementVisibility(visibilityRule)) {
|
if (this.checkElementVisibility(visibilityRule)) {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
if (pathKey && this.formGroup.get(pathKey + '.value')) this.formGroup.get(pathKey + '.value').patchValue(null)
|
this.clearValues(pathKey)
|
||||||
|
// if (pathKey && this.formGroup.get(pathKey + '.value')) this.formGroup.get(pathKey + '.value').patchValue(null)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,4 +41,13 @@ export class VisibilityRulesService {
|
||||||
private getParentPath(parentId: string): string {
|
private getParentPath(parentId: string): string {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private clearValues(pathKey) {
|
||||||
|
if (pathKey && this.formGroup.get(pathKey + '.value')) this.formGroup.get(pathKey + '.value').patchValue(null)
|
||||||
|
if (pathKey && this.formGroup.get(pathKey)["controls"].fields){
|
||||||
|
for (var i = 0; i < this.formGroup.get(pathKey)["controls"].fields.length; i++)
|
||||||
|
this.clearValues(pathKey+'.fields.'+i);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue