Customizing the childreneditor for custom components

Avatar

Avatar

ramaem12

Avatar

ramaem12

ramaem12

15-08-2020

Hi Everyone, can you provide me the steps to customize the childreneditor for custom components?

 

I followed the approach from accordion and carousel to do repeat in my component, but I am facing following issue -

 

org.apache.sling.api.resource.PersistenceException: Unable to commit changes to session.

 

Steps i followed -

  1. Made my component as cq:isContainer
  2. copied items tab from carousel to my custome component
    • core/wcm/components/commons/editor/dialog/childreneditor/v1/childreneditor
  3. copied cq:editConfig from Accordion with listeners
  4. included panelcontainer.js from accordion
  5. include below code for adding components

 

 

<sly data-sly-resource="${resource.path @ resourceType='wcm/foundation/components/parsys/newpar', appendPath='/*', decorationTagName='div', cssClassName='new section aem-Grid-newComponent'}"
     data-sly-test="${(wcmmode.edit || wcmmode.preview)}"></sly>​

 

 

FYI - I don't want to use the Accordion, Carousel or tab as my sling:resourceSuperType

6.4.8.0 customize

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

1.0K

Correct Answer

831

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

1.0K

Correct Answer

831
Arun_Patidar
MVP

16-08-2020

You can use child editor for custom components similar to the core components. 

I did it before for custom navigation component but unfortunately I don't have the complete package.

 

Editorhook.js

(function(channel) {
    "use strict";

    channel.on("cq-editor-loaded", function(event) {
        if (window.CQ && window.CQ.CoreComponents && window.CQ.CoreComponents.panelcontainer &&
            window.CQ.CoreComponents.panelcontainer.v1 && window.CQ.CoreComponents.panelcontainer.v1.registry) {
            window.CQ.CoreComponents.panelcontainer.v1.registry.register({
                name: "cmp-navigation",
                selector: ".cmp-navigation",
                itemSelector: "[data-cmp-hook-navigation='navpanel']",
                itemActiveSelector: ".cmp-navigation__navigation-item.is-active"
            });
        }
    });

})(jQuery(document));

 

extraclientlibs for navigation component dialog

(function($, $document) {
    "use strict";
    $(document).ready(function() {
        const NAV_SELECTOR = '.cmp-panelselector.is-open .cmp-panelselector__table tr';
        const NAVIGATIOIN_ITEM_TITLE = 'Navigation Item';
        const NOT_ACTIVE_NAVITEM_CLASS='navItemEditNotActiveItem';
        const NAV_Not_ACTIVE_ITEM_SELECTOR ='.'+ NOT_ACTIVE_NAVITEM_CLASS;
        const NOT_ACTIVE_ITEM_CLASS = 'notActiveItem';
        const ITEM_ACTIVE_CLASS = 'is-active';
        const CONTENT_IFRAME_SELECTOR ='#ContentFrame';


        $(document).on('click', NAV_SELECTOR, function() {
            var $this = $(this);
            var item = $this.data('id');
            var navItemSelector = '.cq-Overlay.cq-Overlay--component.cq-Overlay--container.cq-draggable.cq-droptarget.is-selected.is-active div.cq-droptarget[data-path="' + item + '"]';
            var $navItem = $(navItemSelector);
            if ($navItem.attr('title') == NAVIGATIOIN_ITEM_TITLE) {
                $(NAV_Not_ACTIVE_ITEM_SELECTOR).find('div').removeClass(NOT_ACTIVE_ITEM_CLASS);
                $($navItem).siblings().addClass(NOT_ACTIVE_NAVITEM_CLASS);
                $navItem.removeClass(NOT_ACTIVE_NAVITEM_CLASS);
                $(NAV_Not_ACTIVE_ITEM_SELECTOR).find('div').addClass(NOT_ACTIVE_ITEM_CLASS);
                var contentItem = $this.data('name');
                if (typeof contentItem !== 'undefined' || contentItem !== null) {
                    contentItem = contentItem.replace('_', '');
                    var contentItemSelector = '.cmp-navigation_author .cmp-navigation__navigation--item[data-nav-item="' + contentItem + '"]';
                    $(CONTENT_IFRAME_SELECTOR).contents().find('.cmp-navigation_author .cmp-navigation__navigation--item').removeClass(ITEM_ACTIVE_CLASS);
                    $(CONTENT_IFRAME_SELECTOR).contents().find(contentItemSelector).addClass(ITEM_ACTIVE_CLASS);
                }
            }
        })
    });
})($, $(document));

 

 

HTL

<div class="cmp-navigation__navigation--item" data-cmp-hook-navigation="navpanel" data-nav-item="item${linkList.index}">
            <sly data-sly-resource="${resourcePath @ resourceType='myapp/components/structure/header/navigation/navigation-item'}"/>
        </div>

Answers (1)

Answers (1)

Avatar

Avatar

ChitraMadan

MVP

Avatar

ChitraMadan

MVP

ChitraMadan
MVP

15-08-2020

Hi @ramaem12,

 

Please look at the below thread for your issue:

https://github.com/adobe/aem-core-wcm-components/issues/696

 

There is an open enhancement request for enabling children editor component to be made available to use on its own

The children editor which can be used with the core Carousel should be available by itself for use w...

 

Hope this helps!!