I had the following data model in backend:
AccordionComponentContainer extends CMSTabParagraphContainer
AccordionItemComponent extends SimpleCMSComponent
The container extending the CMSTabParagraphContainer because extending the AbstractCMSComponentContainer is pain in the ass (generated jalo classes has to be adapted but this isn't important for this case, only for understanding.
Now I have a component in Spartacus CmsAccordionComponent. I introduced a component mapping:
AccordionComponentContainer: {
component: CmsAccordionComponent,
},
In my component html file I have something like this:
<h2>{{headline$ | async}}</h2>
<ul>
<ng-container *ngFor="let component of components$ | async; let i = index">
<li>{{component.content}}</li>
</ng-container>
</ul>
I used the files in
projects/storefrontlib/src/cms-components/content/tab-paragraph-container
as
reference for my implementation (e.g. component implementation). Expect of ng-template (cxOutlet):
<ng-template [cxOutlet]="component.flexType" [cxOutletContext]="{}">
<ng-container [cxComponentWrapper]="component"></ng-container>
</ng-template>
Before, I tried the same solution as CMSTabParagraphContainer. For some reason this won't work in my project. I introduced an own component and a mapping for the children (AccordionItemComponent) but it didn't work. The child components aren't shown.
So I used my solution described above. With my solution the components are displayed (also the child components) but I cannot edit them in SmartEdit. Maybe it's related with this issue: https://github.com/SAP/spartacus/issues/1484.
For testing purpose I added the 'normal' CMSTabParagraphContainer with CMSParagraphComponent's to my content slot in the backoffice. And I can edit the first CMSParagraphComponent that is shown in SmartEdit. Unfortunately I cannot add new paragraphs to the CMSTabParagraphContainer. Therefore I think that the ng-template (cxOutlet) solution is the better one as mine.
Can you please explain how the TabParagraphContainerComponent and the snippet ng-template (cxOutlet) works? Also I think that this should considered in the github issue ticket (https://github.com/SAP/spartacus/issues/1484) so that CMSTabParagraphContainer (AbstractCMSComponentContainer) are better supported in Spartacus (SmartEdit).
Thanks for your help!