Unverified Commit 388ede39 authored by Benjamin Parisel's avatar Benjamin Parisel Committed by GitHub
Browse files

feat(repeatedCollection): Container is now fully functional (#123)

* update component and container template
* $item, $count, $collection and $index is now usable in propertiesValues

Covers [UID-564](https://bonitasoft.atlassian.net/browse/UID-564)
parent 8c7d82c7
<ng-container *properties-values="'{{ reference }}'; let properties;">
<ng-container *properties-values="'{{ reference }}'; let properties; collection:$collection; index:$index; count:$count">
<div
*ngIf="!properties.hidden"
class="component {{ dimensionAsCssClasses }}"
......
<ng-container *properties-values="'{{ reference }}'; let properties;">
<ng-container *ngIf="!properties.hidden">
{{#repeated}}
{{#repeated}}
<ng-container *ngIf="properties.repeatedCollection as $collection">
{{/repeated}}
{{/repeated}}
<div class="{{ dimensionAsCssClasses }}"
[ngClass]="properties.cssClasses"
{{#repeated}}
*ngFor="let $item of $collection;index as $index; count as $count;"
*ngFor="let $item of $collection;index as $index; count as $count;"
{{/repeated}}>
{{{rowsHtml}}}
</div>
{{#repeated}}
{{#repeated}}
</ng-container>
{{/repeated}}
{{/repeated}}
</ng-container>
</ng-container>
......@@ -17,7 +17,7 @@
"@angular/platform-browser": "~12.0.3",
"@angular/platform-browser-dynamic": "~12.0.3",
"@angular/router": "~12.0.3",
"@bonitasoft/ui-designer-context-binding": "0.0.11",
"@bonitasoft/ui-designer-context-binding": "0.0.12",
"rxjs": "~6.6.0",
"tslib": "^2.1.0",
"zone.js": "~0.11.4"
......
import { Directive, Input, OnInit, ViewContainerRef, TemplateRef } from '@angular/core';
import propertiesValues from '../../assets/propertiesValues';
import { uidModel } from './uid-model-directive';
import { BindingFactory, EnumBinding, VariableContext } from '@bonitasoft/ui-designer-context-binding';
import { BindingContextFactory, BindingFactory, EnumBinding, VariableContext } from '@bonitasoft/ui-designer-context-binding';
/**
* Allow us to declare a directive to setup a structural directive like following
......@@ -12,24 +12,46 @@ import { BindingFactory, EnumBinding, VariableContext } from '@bonitasoft/ui-des
selector: '[properties-values]'
})
export class PropertiesValues implements OnInit {
private collection: Array<any> | undefined;
@Input('properties-values') reference: string = '';
// Properties input
@Input('properties') properties: any = {};
@Input('properties-valuesCollection') set setCollection(collection: Array<any>) {
this.scope.collection = collection;
}
@Input('properties-valuesIndex') set setIndex(index: number) {
this.scope.index = index;
}
@Input('properties-valuesItem') set setItem(item: any) {
this.scope.item = item;
}
@Input('properties-valuesCount') set setCount(count: number) {
this.scope.count = count;
}
private properties: any = {};
private context: VariableContext = {};
private model: uidModel;
private scope: any = {};
private bindingContextFactory: BindingContextFactory;
constructor(private templateRef: TemplateRef<any>,
private viewContainerRef: ViewContainerRef, private uidModel: uidModel) {
private viewContainerRef: ViewContainerRef, private uidModel: uidModel) {
this.model = uidModel;
this.bindingContextFactory = new BindingContextFactory();
}
ngOnInit(): void {
async ngOnInit(): Promise<void> {
const propertyValues = propertiesValues.get(this.reference);
let variablesAccessors = new Map(this.model.getVariableAccessors());
BindingFactory.createPropertiesBinding(
propertyValues,
this.model.getVariableAccessors(),
this.bindingContextFactory.addSpecificKeywordOnAccessors(variablesAccessors, this.scope),
this.properties);
this.properties.isBound = function (propertyName: string) {
......
......@@ -25,6 +25,6 @@
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
"strictTemplates": false
}
}
<ng-container *properties-values="'component-reference'; let properties;">
<ng-container *properties-values="'component-reference'; let properties; collection:$collection; index:$index; count:$count">
<div *ngIf="!properties.hidden" class="component col-xs-12" [ngClass]="properties.cssClasses">
<uid-input [label]="{{properties.label}}" [value]="properties.value"></uid-input>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment