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 d91aafd..816863e 100644 --- a/src/main/webapp/app/facet-composer/facet-composer.component.html +++ b/src/main/webapp/app/facet-composer/facet-composer.component.html @@ -19,11 +19,9 @@
- +

facet {{ind}}

- + occurr. min @@ -33,9 +31,6 @@ occurr. max - -
@@ -58,25 +53,43 @@ -
- -
- - -
+
+ + + +

Add new Facet:

+
+ + Available Facet Types + + + + {{item}} + + + + +
+
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 c519fb6..da98671 100644 --- a/src/main/webapp/app/facet-composer/facet-composer.component.ts +++ b/src/main/webapp/app/facet-composer/facet-composer.component.ts @@ -36,8 +36,10 @@ export class FacetComposerComponent implements OnInit { myForm: FormGroup; //form complessiva - facetData: IFacetComposer[]; + // facetData: IFacetComposer[]; typeSpec: ITypeSpecification; + fieldsMap: Map; + addableFacets: string[]; defaultProperty = { "type": "text", @@ -71,13 +73,14 @@ export class FacetComposerComponent implements OnInit { @Inject(MAT_DIALOG_DATA) data: {type: IResource ,context:IContextNode}){ this.titleType = data.type.name; this.titlePath = data.context.path; - this.facetData = []; + // this.facetData = []; this.typeSpec = {} as ITypeSpecification; + this.fieldsMap = new Map(); this.myForm = this.fb.group({ facets: new FormArray([ - ]) }); + this.addableFacets = []; /* this.propertyGroup = new FormGroup({ properties: new FormArray([]), @@ -90,36 +93,49 @@ export class FacetComposerComponent implements OnInit { const control = this.myForm.controls['times']; control.removeAt(i); } - /* - [INFO] An unhandled exception occurred: Script file node_modules/jsonpath-plus/dist/index-umd.js does not exist. -[INFO] See "/private/var/folders/sx/pzmn6csj17n2l3d_f1m5jmdr0000gn/T/ng-8XFcFL/angular-errors.log" for further details. -*/ + + ngOnInit(): void { this.guiService.getFormStructure(this.titlePath,this.titleType).subscribe(res => { this.typeSpec = res; - this.facetData = res.facetSpecs; - - //TODO: MAPPARE SUL NAME DELLA FACET TUTTO IN MODO DA USARE LA MAPPA INVECE DELL'ARRAY NELL'HTML - const mapRelazioni = new Map(res.facetSpecs.map((obj) => [obj.name, obj.relationOptions])); - - + //attenzione allo spazio prima della parentesi + this.fieldsMap = new Map(res.facetSpecs.map((obj) => [obj.name+' ('+obj.relation+')', obj])); + /* + this.fieldsMap.forEach(function(value,key){ + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + console.debug(`Map key is:${key} and value is:${value}`); + console.debug('************************'); + }); + */ + this.addableFacets = this.fillFacetSelect(this.fieldsMap); this.createForm(res); }); } - - - /* - relationOptions(relationName:string): string[]{ - let options: string[]=[]; - this.guiService.getRelationOptions(this.titlePath, relationName).subscribe(res => { - options = JSONPath({path: '$[*].name', json: res}); - }) - return options; - }*/ + fillFacetSelect(myMap:Map):string[]{ + const res:string[] = []; + myMap.forEach(function(value,key){ + const fComp : IFacetComposer = myMap.get(key)!; //'!' significa che assicuriamo che non si undefined (altrimenti segnala errore) + // eslint-disable-next-line @typescript-eslint/restrict-plus-operands + if(fComp.max==='many'){ + res.push(fComp.name+" ("+fComp.relation+")"); + } + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + //console.debug(`Map key is:${key} and value is:${value}`); + //console.debug('************************'); + }); + return res; + } + + selectedFacet = ''; + onSelectNewFacet(value:string): void { + this.selectedFacet = value; + alert('Cosa?...'+this.selectedFacet); + } + //TODO: NOTA BENE--> FormGroup->access by NAME, FormArray->access by INDEX!! createForm(fData:ITypeSpecification):void{ for(let i=0; ithis.fieldsMap.get(nameplus); const facetFg: FormGroup = this.fb.group({}); const nameFc = this.fb.control(icf.name); @@ -267,7 +283,7 @@ export class FacetComposerComponent implements OnInit { removeFacet(index: number): void { const controls: FormArray = this.myForm.controls['facets']; controls.removeAt(index); - + this.facetArray.removeAt(index) /* for(let j=0; j -->