Monday, July 9, 2018

AEM 62 Touch UI Move Asset Wizard Set Default Path for Rename

AEM 62 Touch UI Move Asset Wizard Set Default Path for Rename


Goal


Handy extension for setting the default path in move asset wizard/mnt/overlay/dam/gui/content/assets/moveassetwizard.html, saving few clicks while renaming assets

Demo | Package Install | Git Hub



Solution


1) Login to CRXDE Lite, create folder (nt:folder) /apps/eaem-assets-move-set-default-path

2) Create clientlib (type cq:ClientLibraryFolder/apps/eaem-assets-move-set-default-path/clientlib and set a property categories of String type to cq.gui.damadmin.moveassetwizarddependencies of type String[] with value underscore

3) Create file ( type nt:file ) /apps/eaem-assets-move-set-default-path/clientlib/js.txt, add the following

                         set-default-path.js

4) Create file ( type nt:file ) /apps/eaem-assets-move-set-default-path/clientlib/set-default-path.js, add the following code

(function () {
var oneTime = false;

Granite.UI.MovePageWizard.prototype.getDestinationPath = function() {
if(oneTime){
return this.destinationPath;
}

oneTime = true;

this.destinationPath = getStringBeforeLastSlash(decodeURIComponent(queryParameters()["item"]));

return this.destinationPath;
};

function queryParameters() {
var result = {}, param,
params = document.location.search.split(/?|&/);

params.forEach( function(it) {
if (_.isEmpty(it)) {
return;
}

param = it.split("=");
result[param[0]] = param[1];
});

return result;
}

function getStringBeforeLastSlash(str){
if(!str){
return str;
}

return str.substring(0,str.lastIndexOf("/"));
}
}());



visit link download