Expand my Community achievements bar.

Restrict edit/delete options in author dialog for parsys child components AEM 6.2

Avatar

Level 2

Hi,

We have below use case in our project.

1) There will be multiple instances of a custom component (name:XZY)  created under parsys component in a page in author instance.

2) XYZ contains 3 properties (property-A , property-B,property-C) .

3) Multiple authors can access this page and should be able to see all the XYZ component instances created within this pasrsys

4) But those authors should be restricted with option to edit only few instances of XYZ component but not all.

5) The restriction is based on the one of the paramater of logged in author (Author has multiple attributes i.e Attribute-1,Attribute-2,Attribute-3). 

    i.e provide cq:editConfig (edit/delete) options for  XYZ component instance which matches below criteria 

        XYZ component property-A = Logged in author Attribute-1

if the above criteria doesn't met then we have to just display the XZY instance without edit options.

 

Thanks in Advance.

Regards,

Sagar

5 Replies

Avatar

Level 10

The best way to restrict what an author can edit and cannot edit is using permissions: 

https://docs.adobe.com/docs/en/aem/6-1/administer/security/security.html

However -- permissions do not apply at the component level. 

Avatar

Level 2

Our requirement is different. We dont want to restrict the components authoring capabilities using ACL permissions. We want this to happen on the fly by having below check.

If 

 XYZ component property-A = Logged in author Attribute-1                      (Show component with edit options)

 

Else 

 XYZ component property-A = Logged in author Attribute-1                      (Show component without edit options)

Avatar

Level 7

Hi Sagar,

This is not a suggested way of working with components and this behaviour is against the component behaviour how they are designed in aem. You cannot change the component editconfig behaviour of a page based on user.

For example you have create a page using a template and a component by admin user. Then it will get save on /content/<path> and it will have your editconfig listeners property like edit/delete. Now you cannot update these nodes based on user login. As this property is already saved on node.

Avatar

Level 2

Thank you all for your quick response.

Though its not recommended way to achieve this in AEM author instance ,we have requirement like this

As of now to solve this issue .i have added below code inside  XYZ component jsp.

If  XYZ component property-A = Logged in author Attribute-1  

componentContext.setDecorate(true) (show dialog editabr with edit & delete options)

Else 

componentContext.setDecorate(false) (hide dialog editabr with edit & delete options)

Please let me know in case if there is any better way to achieve this or if some problem occurs in future with the above approach.