From a5784ae14fa81a6aaf48a0be630bb86a42a1376a Mon Sep 17 00:00:00 2001 From: mariateresa Date: Sun, 10 Mar 2024 13:28:10 +0100 Subject: [PATCH] debugging... --- .../facet-composer.component.html | 8 +- .../facet-composer.component.ts | 86 ++++++++++--------- 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/src/main/webapp/app/facet-composer/facet-composer.component.html b/src/main/webapp/app/facet-composer/facet-composer.component.html index 53ac86d..fd34c74 100644 --- a/src/main/webapp/app/facet-composer/facet-composer.component.html +++ b/src/main/webapp/app/facet-composer/facet-composer.component.html @@ -17,8 +17,7 @@
- -
+
@@ -33,11 +32,10 @@

{{typeSpec.facetSpecs[ind].description}}

-
+
- - +
diff --git a/src/main/webapp/app/facet-composer/facet-composer.component.ts b/src/main/webapp/app/facet-composer/facet-composer.component.ts index 36dbe9f..69f254a 100644 --- a/src/main/webapp/app/facet-composer/facet-composer.component.ts +++ b/src/main/webapp/app/facet-composer/facet-composer.component.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/member-ordering */ /* eslint-disable @typescript-eslint/explicit-function-return-type */ /* eslint-disable no-console */ import { CommonModule } from '@angular/common'; @@ -32,6 +33,7 @@ export class FacetComposerComponent implements OnInit { titlePath: string; myForm: FormGroup ; //form complessiva + propertyGroup: FormGroup; //form complessiva typeSpec: ITypeSpecification; @@ -42,76 +44,80 @@ export class FacetComposerComponent implements OnInit { this.titleType = data.type.name; this.titlePath = data.context.path; this.typeSpec = {} as ITypeSpecification; - - this.myForm = this.fb.group({ - 'facetBlocks': this.fb.array([ - this.fb.group({ - 'relation':'', - 'facetPropsBlock':this.fb.array([]), - //TODO: PROVA-> 'facetPropsBlock':this.fb.array([this.fb.group({}]), - }) - ]), - - }); + this.myForm = this.fb.group({ + facetArray: this.fb.array([this.addFacetGroup()]) + }); + this.propertyGroup = this.fb.group({ + propertyGroup: [], + }); } - get facetBlocks() { - return this.myForm.get('facetBlocks') as FormArray; - } - - - get facetPropsBlock(): FormArray { - return this.myForm.get('facetPropsBlock') as FormArray; + private addFacetGroup(): FormGroup { + return this.fb.group({ + relation: [], + propertyArray: this.fb.array([]) + }); } - /* - addFacetBlocks() { - const fc = {} as IFacetComposer; - this.facetBlocks.push(this.fb.group(fc)); - } - addFacetProps() { - const fp = {} as IFacetProps; - this.facetPropsBlock.push(this.fb.control(fp)); - } - */ + addFacet(): void { + this.facetArray.push(this.addFacetGroup()); + } + + + removeFacet(index: number): void { + this.facetArray.removeAt(index); + } + get facetArray(): FormArray { + return this.myForm.get('facetArray'); + } + + + addProperty(index:number): void { + ((this.facetArray.controls[index]).controls.propertyArray).push(this.propertyGroup); + } + + + + ngOnInit(): void { - alert("facetPropsBlock"); - alert(this.facetPropsBlock); - this.guiService.getFormStructure(this.titlePath,this.titleType).subscribe(res => { this.typeSpec = res; this.prepareControls(res); }); } + + prepareControls(spec:ITypeSpecification){ for (let i=0; i