Skip to content

Instantly share code, notes, and snippets.

@dougsyer
Forked from cluther/component-add-menu.js
Created March 20, 2019 21:36
Show Gist options
  • Save dougsyer/3c664da1c1f1282b92188a88d808d3c1 to your computer and use it in GitHub Desktop.
Save dougsyer/3c664da1c1f1282b92188a88d808d3c1 to your computer and use it in GitHub Desktop.
Zenoss: Add item to component-add-menu
(function(){
var router = Zenoss.remote.CustomRouter;
Ext.define('Zenoss.component.add.CustomThing',{
extend: 'Zenoss.SmartFormDialog',
constructor: function(config) {
config = config || {};
Ext.applyIf(config, {
height: 150,
title: _t('Add Custom Thing'),
submitHandler: Ext.bind(this.createCustomThing, this),
items: [{
xtype: 'hidden',
name: 'userCreated',
value: true
}, {
xtype: 'textfield',
name: 'newId',
fieldLabel: _t('ID')
}]
});
this.callParent([config]);
},
createCustomThing: function(values) {
values.uid = this.uid;
router.addCustomThing(values, function(response){
if (response.success) {
Zenoss.message.info(_t("Added Custom Thing"));
}
});
}
});
function addComponentHandler(item) {
var win = Ext.create('Zenoss.component.add.' + item.dialogId, {
componentType: item.dialogId,
uid: Zenoss.env.device_uid
});
win.show();
win.on('destroy', function(){
refreshComponentTreeAndGrid(win.componentType);
});
}
Ext.onReady(function(){
var COMPONENT_ADD_MENU = 'component-add-menu';
Ext.ComponentMgr.onAvailable(COMPONENT_ADD_MENU, function() {
var menu = Ext.getCmp(COMPONENT_ADD_MENU);
menu.menuItems.push({
text: _t('Add Custom Thing'),
dialogId: 'CustomThing',
handler: addComponentHandler});
});
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment