Skip to content

Commit

Permalink
Refactor UfeContext to dynamically render context
Browse files Browse the repository at this point in the history
elements with extra attributes.
  • Loading branch information
Milan Unger committed Oct 31, 2023
1 parent a66cbff commit 5da9ea1
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions web-ui/src/components/ufe-context/ufe-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,34 @@ export class UfeContext {
const contextElements = this.ufeRegistry.contextElements( this.context, this.selector );
this.ufeRegistry.preloadDependenciesAsync(contextElements);


return (

<Host>
<slot name="beforeALl"></slot>
{contextElements.map( el => {
const element = this.ufeRegistry.loadAndRenderElement(el, Object.assign({}, this.extraAttributes, this.data));
{contextElements.map( el => {
const attr = Object.assign(
{},
this.extraAttributes,
el.attributes.reduce(
(acc, a) => {
acc[a.name] = a.value;
return acc
}, {} as {
[name: string]: any
})
);

return (
<context-item>
<slot name="before-each"></slot>
{ element }
<el.element {...attr} ref={ (_ => {
if (_) {
for (let key in this.data) {
_[key] = this.data[key];
}
}
})}></el.element>
<slot name="after-each"></slot>
</context-item>
)
Expand Down

0 comments on commit 5da9ea1

Please sign in to comment.