Quantcast
Channel: Experiencing Adobe Experience Manager (AEM, CQ)
Viewing all articles
Browse latest Browse all 525

AEM 61 - Classic UI Show Site Specific Workflows

$
0
0

Goal


Show Site specific Workflows in the Start Workflow Dialog of Classic UI SiteAdmin console

Demo | Package Install


Set Site Path on Workflow - eaemSitePath

              Set site root path - eaemSitePath for which the specific workflow should be available. Here Request for Activation workflow is shown for pages of Geometrixx Demo 
              Site /content/geometrixx only



Request for Activation available for pages of /content/geometrixx



Request for Activation NOT available for pages of  /content/geometrixx-media



Solution


1) Login to CRXDE Lite, create folder (nt:folder) /apps/classicui-site-specific-workflows

2) Create clientlib (type cq:ClientLibraryFolder/apps/classicui-site-specific-workflows/clientlib and set a property categories of String type to cq.widgets and dependencies value underscore

3) Create file ( type nt:file ) /apps/classicui-site-specific-workflows/clientlib/js.txt, add the following

                         site-workflows.js

4) Create file (type nt:file) /apps/classicui-site-specific-workflows/clientlib/site-workflows.js, add the following code

(function($){
if(window.location.pathname != "/siteadmin"){
return;
}

var SA_GRID = "cq-siteadmin-grid",
WORKFLOW_BUT_TEXT = "Workflow...",
START_WF_DIALOG_ID = "cq-workflowdialog",
QUERY = "SELECT * FROM [cq:Page] WHERE ISDESCENDANTNODE([/etc/workflow/models]) AND " +
"([jcr:content/eaemSitePath] = 'PLACEHOLDER' OR [jcr:content/eaemSitePath] IS NULL)";

var SA_INTERVAL = setInterval(function(){
var grid = CQ.Ext.getCmp(SA_GRID);

if(!grid || ( grid.rendered != true)){
return;
}

clearInterval(SA_INTERVAL);

var toolBar = grid.getTopToolbar();

try{
var wButton = toolBar.find("text", WORKFLOW_BUT_TEXT)[0];

wButton.on('click', filterWorkflows);
}catch(err){
console.log("Error adding workflow button listener");
}
}, 250);

function filterWorkflows(){
var wMgr = CQ.Ext.WindowMgr, winId;

var W_INTERVAL = setInterval(function () {
wMgr.each(function (win) {
winId = win.id;

if (winId && (winId.indexOf(START_WF_DIALOG_ID) < 0)) {
return;
}

var modelCombo = CQ.Ext.getCmp(winId + "-model");

if(modelCombo.eaemInit){
return;
}

clearInterval(W_INTERVAL);

modelCombo.eaemInit = true;

var contentPath = window.location.hash.split("#")[1],
//you may want to replace the following query with a servlet returning results
query = "/crx/de/query.jsp?type=JCR-SQL2&showResults=true&stmt=" + QUERY.replace('PLACEHOLDER', contentPath);

$.ajax( { url: query, context: modelCombo } ).done(filter);
});
}, 250);

function filter(data){
function handler(store, recs){
var paths = _.pluck(data.results, "path"), modelId;

_.each(recs, function (rec){
modelId = rec.data.wid;
modelId = modelId.substring(0, modelId.indexOf("/jcr:content/model"));

if(paths.indexOf(modelId) != -1){
return;
}

store.remove(rec);
})
}

this.store.on('load', handler);
}
}
}(jQuery));


Viewing all articles
Browse latest Browse all 525

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>