Hi,
I would like to show/hide the OOTB actions checkout/check-in which are available on Document Context Menu Actions. For the custom actions we will specify the file which does the hide/show functionality in the getActionModelClass() of action class. But for OOTB actions how do we do that? PFA the screenshot of the actions what I want to show/hide.
[1]: /answers/storage/temp/28262-checkoutcheck-in.jpg
Answer by jase_kross (196) | Jun 13 at 09:19 AM
You could replace the isVisible function in ecm.model.Action via ICN plugin. In doing so you would really want to augment the existing code with some additional logic that hides/shows the checkin/checkout actions. Your replacement function then would be a mix of your custom logic and the ootb function code. Keep in mind that when it comes time to upgrade ICN you'll want to revisit your replacement function for differences that the upgrade may introduce to the ootb function. If there are differences you should work to understand them and refactor your code to account for them.
The code below provides an example of a replacement function for ecm.model.Action.isVisible in ICN 3.0.5. As you'll notice I've commented the beginning and ending of the custom section. From your other thread on the role check you'd also need to incorporate logic into this section to evaluate whether the user is role or otherwise and return true/false.
// For ICN 3.0.5
ecm.model.Action.prototype.isVisible = function(repository, items, repositoryTypes, teamspace) {
// begin custom
var canPerform = true;
switch (this.id) {
case "CheckOut": canPerform = false;
case "CheckOutDownload": canPerform = false;
case "CheckOutLabelWithDownload": canPerform = false;
case "CheckOutNoDownload": canPerform = false;
case "CheckIn": canPerform = false;
case "Unlock": canPerform = false;
}
if (!canPerform){
return false;
}
// end custom
if (this.repositoryTypes == null || this.repositoryTypes == "") {
return this._isVisibleForItems(repository, items);
} else if (repositoryTypes && repositoryTypes.length > 0) {
return this._isVisibleToAnyOfRepositoryTypes(repositoryTypes);
} else if (repository) {
var serverTypes = this.repositoryTypes.split(',');
for (i in serverTypes) {
if (serverTypes[i] == repository.type) {
return this._isVisibleForItems(repository, items, teamspace);
}
}
return false;
} else {
return false;
}
};
Hi Jase,
Thanks for your time and reply. I have already implemented similar to this in global plugin. But I didn't use the OOTB function code in my overriden function isVisible. May I know why do we need OOTB function code here? This also avoids to write separate js file to show/hide for each custom action. Below is my code. Please check.
aspect.after(ecm.model.Action.prototype, "isVisible", function() {
var actionVisible = true;
if(ReturnedRestrictedActionsAndFeatures!=undefined){
if(ReturnedRestrictedActionsAndFeatures.length>0){
var SplitStringRestrictedActionsAndFeatures = ReturnedRestrictedActionsAndFeatures.split("!");
if(SplitStringRestrictedActionsAndFeatures[0]!=='NoValue'){
var SplitStringRestrictedActions = SplitStringRestrictedActionsAndFeatures[0].split(";");
for (var i in SplitStringRestrictedActions) {
if(SplitStringRestrictedActions[i]===this.id){
actionVisible=false;
}
}
}
}
}else{
actionVisible = true;
}
if(actionVisible===false){
return false;
}else{
return true;
}
});
Note: I see a minor risk here. That is, it will show the actions which are hidden by the system internally. I hope there are no such. But it will hide the actions what ever I configured :-).
What I suggested with replacing the function wasn't to actually modify the OOTB ecm.model.Action.js file. Instead it was to provide a replacement for the function through your plugin files, which can be done by including the replacement function in your main plugin js file. Replacement in this fashion is one approach that could be taken. Now knowing that you took the aspect.after approach that should be fine also.
As to your code, do you see errors in the browser console or debugging facilities when it executes? What is not working about it? Do the menu actions not show at all or do they all show? Are you receiving an undefined error because of ReturnedRestrictedActionsAndFeatures? Is ReturnedRestrictedActionsAndFeatures stored in a different container object and not the global namespace? Are you using the correct ids for the default checkin/checkout actions?
Ids for the checkin/checkout actions: CheckOut CheckOutDownload CheckOutLabelWithDownload CheckOutNoDownload CheckIn Unlock
These are a few things I would suggest to check out.
Hi Jase,
I didn't get any errors in the browser console or any where. The menu actions hide/show working as expected. The code I posted above is working perfectly.
Regards, Ravi
ICN Document Actions hide and show 2 Answers
download file showing up as .bin extension 1 Answer
ICN Add Document using Entry Template show/hide 1 Answer
Filenet and ICN JDBC validation 2 Answers
Keep Criteria Open when there is error 2 Answers