debugging...

This commit is contained in:
Maria Teresa Paratore 2024-03-06 17:02:46 +01:00
parent e60020cc53
commit 39e8d5ded1
3 changed files with 89 additions and 24 deletions

View File

@ -23,7 +23,7 @@
<mat-expansion-panel-header>
<mat-panel-title>
<!--TODO: vedi quando si possono rendere editabili le relazioni-->
<input type="text" value="{{typeSpec.facetSpecs[ind].relation}}" disabled="true"/>
<input formControlName="relation" type="text" value="{{typeSpec.facetSpecs[ind].relation}}" [disabled]="true"/>
</mat-panel-title>
<mat-panel-description>
{{typeSpec.facetSpecs[ind].name}}
@ -31,10 +31,18 @@
</mat-expansion-panel-header>
<p>{{typeSpec.facetSpecs[ind].description}}</p>
<!-- OK SO FAR -->
<!-- OK SO FAR -->
<p>group {{ind}}</p>
<div formArrayName="facetGuis" style="border: 1px solid rgb(84, 193, 255); padding: 10px; margin: 5px;">
<div formArrayName="facetProps" style="border: 1px solid rgb(84, 193, 255); padding: 10px; margin: 5px;">
<div formGroupName="ind">
<!--
<div *ngFor="let student of studentsArray.controls; let i = index" [formGroupName]="i">
<input formControlName="firstName" placeholder="First Name">
<input formControlName="lastName" placeholder="Last Name">
<input formControlName="dob" placeholder="Date of Birth">
</div>
-->
<div *ngFor="let prop of typeSpec.facetSpecs[ind].guiProps; let i=index" >
<p> control {{i}} - <label>{{prop.label}}</label>
<input formControlName="i" type="{{prop.type}}"/>

View File

@ -6,7 +6,7 @@ import { FormArray, FormBuilder, FormControl, FormGroup, ReactiveFormsModule, Va
import { MAT_DIALOG_DATA, MatDialogActions, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import { IContextNode } from 'app/services/i-context-node';
import { IResource } from 'app/services/i-resource';
import { IFacetComposer, IFacetGui } from './i-facet-composer';
import { IFacetComposer, IFacetProps } from './i-facet-composer';
import { FacetComposerService, ITypeSpecification } from './facet-composer.service';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatButtonModule } from '@angular/material/button';
@ -32,13 +32,9 @@ export class FacetComposerComponent implements OnInit {
titlePath: string;
myForm: FormGroup ; //form complessiva
typeSpec: ITypeSpecification;
facetGuis: any;
// eslint-disable-next-line @typescript-eslint/member-ordering
constructor(private guiService: FacetComposerService, private fb: FormBuilder,
@ -48,22 +44,82 @@ export class FacetComposerComponent implements OnInit {
this.titlePath = data.context.path;
this.typeSpec = {} as ITypeSpecification;
/*
this.myForm = this.fb.group({
facets: this.fb.array([]),
facetGuis:this.fb.array([]),
'facets': this.fb.array([]),
'facetPropsArray':this.fb.array([]),
});
*/
this.myForm = this.fb.group({
'facets': this.fb.array([
this.fb.group({
'relation':'',
'facetPropsArray':this.fb.array([]),
})
]),
});
/*
segmentRows3: this.fb.array([
this.fb.group({
segmentId3: '',
segmentTime3: '',
personRows3: this.fb.array([
this.fb.group({
personR3: '',
personI3: ''
})
])
})
]),
*/
}
/*
Cannot find control with path
*/
get Facets(): FormArray {
return this.myForm.get('facets') as FormArray;
}
get FacetPropsArray(): FormArray {
return this.myForm.get('facetPropsArray') as FormArray;
}
addFacets() {
const fc = {} as IFacetComposer;
this.facets.push(this.fb.group(fc));
}
addFacetProps() {
const fp = {} as IFacetProps;
this.facetPropsArray.push(this.fb.group(fp));
}
ngOnInit(): void {
this.guiService.getFormStructure(this.titlePath,this.titleType).subscribe(res => {
this.typeSpec = res;
this.prepareEnvironment(res);
});
for (let ind = 0; ind < this.typeSpec.facetSpecs.length; ind++) {
}
prepareEnvironment(spec:ITypeSpecification){
for (let ind = 0; ind < spec.facetSpecs.length; ind++) {
//TODO: metti a posto validazione
//this.fb.group()
const itemExt = this.fb.control({
relation: [spec.facetSpecs[ind].relation,null]
});
const fGroup: FormGroup = new FormGroup({});
let ctrl: FormControl|undefined;
for(let j=0; j<this.typeSpec.facetSpecs[ind].guiProps.length; j++){
const item = this.typeSpec.facetSpecs[ind].guiProps[j];
for(let j=0; j<spec.facetSpecs[ind].guiProps.length; j++){
const item = spec.facetSpecs[ind].guiProps[j];
if(item.validations.length===0){
ctrl = this.fb.control({
name: ['',null]
@ -73,19 +129,20 @@ export class FacetComposerComponent implements OnInit {
name: ['',Validators.required]
});
}
//fGroup.addControl(''+String(j),ctrl);
fGroup.addControl('',ctrl); //AGGIUNGO FORMCONTROL AL FORMGROUP
}
//this.myForm.addControl('facetGui'+String(ind),fGroup); //AGGIUNGO FORMGROUP PER LA FACET
this.myForm.addControl('',fGroup); //AGGIUNGO FORMGROUP PER LA FACET
this.FacetPropsArray.push(fGroup); //AGGIUNGO FORMGROUP PER LA FACET
}
}
}
get facets() {
return this.myForm.get('facets') as FormArray;
}
// eslint-disable-next-line @typescript-eslint/adjacent-overload-signatures
get facetPropsArray(){
return this.myForm.get('facetPropsArray') as FormArray;
}
close():void {
this.dialogRef.close({event:'cancel'});

View File

@ -4,11 +4,11 @@ description:string //facet description (textarea)
relation:string
min:number
max:number
guiProps:IFacetGui[]
guiProps:IFacetProps[]
}
//for the facet's properties
export interface IFacetGui {
export interface IFacetProps {
type: string;
label: string;
name: string;