Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Disable Delete button on sites console

laughingb220006
Level 2
Level 2

AEM Author should be unable to delete content/page once it published.

delete.JPG

- Once author selects page from sites console, we have to disable the delete button if page was in published status.

- we need to enable the delete button if page is not in published status.

- Once author selects any page from sites console it shows action bar that means we are calling listeners (java script files) for showing action bar buttons on sites console.

Question is:

please let me know exact listeners java script files or paths that calls when we select the page on sites console.

8 Replies
Hemant_arora
Level 8
Level 8

Overlay this node in your project /libs/wcm/core/content/sites/jcr:content/actions/selection

copy the above sites page from libs and paste it under /apps/wcm/core/content

Remove the deletepage node under this node.

1391736_pastedImage_2.png

1391735_pastedImage_1.png

pankaj49319
Level 2
Level 2
I am wondering why this solution is flagged as accepted solution because it does not handle the scenario when delete button should be available for unpublished pages, removing delete action would make it unavailable irrespective of whether page is published or not.
laughingb220006
Level 2
Level 2

it should not show disable mode in every time.it has to show enable mode when page is not in published status.

Below is the status has to show when page is in activated or deactivated status:

if page is activated -disable delete button

if page is not activated - enable delete button

when author selects the page from console it shows action tool bar (these action bar items populates using listeners). so i want the listeners (java script files) that shows for action bar after selecting the page from console.if we know that, we can add our disable condition on listener.

Hemant_arora
Level 8
Level 8

Go to /libs/cq/gui/components/siteadmin/admin/clientlibs/collectionpage/js/viewpropertiesaction.js

Overlay the above js , copy to apps and edit the one in apps /apps/cq/gui/components/siteadmin/admin/clientlibs/collectionpage/js/viewpropertiesaction.js

go to line number line number 91 and add this line

if (isActivated(selections)) {       

         control.removeAttr("hidden");    

            $('.cq-siteadmin-admin-actions-delete-activator').attr('disabled','disabled');     

}

laughingb220006
Level 2
Level 2

Thank you for response.

-  But it is disabling every time. can't we enable for not activated/not published pages.

-  Can we do same for damadmin also ?

abhishekagg19
Employee
Employee

Have you tried custom render conditions? Refer:

1. GitHub - nateyolles/aem-granite-rendercondition-demo: AEM Granite Render Condition demo

Disable functionality can also be achieved using ACL's as well (button will not get disabled but delete operation will fail). You can set ACL on content node of page or asset (remove delete privilege) via custom Preprocessor when a page/asset is published. When a page is unpublished, you can remove these ACLs.

kautuk_sahni
Community Manager
Community Manager

There is no easy way to do so to solve problem efficiently.

On top of the solution suggested by Hemant, you can always check the status of page is activated or not and hide disable button accordingly.

Best way would be to create custom workflow and there you can put all the checks that you want to achieve.

~kautuk

sarveshkmr
Level 2
Level 2

I guess you are looking this js-  /libs/granite/ui/components/coral/foundation/clientlibs/foundation/js/collection/action/action.js