I have a detail view screen that shows the details of a model and allows the user to conduct actions on that model. Problem is, the list of actions inherits every down stream module. And everyone of those modules provides an Update action (SCC.Update
, RPL.Update
, etc). I don't want 5 Updates, I only want the update specific to my module.
How do I filter out actions that I don't want to see?
One.model.ModelFormPanel
has a button, actionsButton
, which has an event on it called actionsloaded
. In the event handler, you can iterate across the items and remove the ones you don't want. It's a little bit trickier than normal because it's an array rather than an Ext.util.MixedCollection
.
Example:
Only want ONEI actions...
if (modelFormPanel.actionsButton) {
modelFormPanel.actionsButton.on('actionsloaded', function(aItems) {
for(var i = 0; i < aItems.length; i++){
alert(i + " " + aItems.length);
alert(aItems[i].actionName);
if(!aItems[i].actionName.match(/ONEI/)){
aItems.splice(i,1);
i--;
}
}
});
}
Sean gave me another example
//#Patch WMS/reports/CycleCountReportPlugin
define(['WMS/reports/CycleCountReportPlugin'], function() {
var origFn = WMS.reports.CycleCountReportPlugin.prototype.init;
Ext.override(WMS.reports.CycleCountReportPlugin, {
init: function(report) {
// Call the original function.
var returnVal = origFn.apply(this, arguments);
//Hide the WMS.Delete action. We don't want this soft delete and want DODC.Delete instead.
var origGetActionMenuItemsFn = report.getActionMenuItems;
report.getActionMenuItems = function() {
var menuItems = origGetActionMenuItemsFn.apply(this, arguments);
for(var i = 0; i < menuItems.length; i++){
if('WMS.Delete' === menuItems[i].actionName) {
menuItems.splice(i,1);
i--;
}
}
return menuItems;
};
return returnVal;
}
});
});