Commit 16f2acb6 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

The logic to add a wizard in the grid context menu.

parent f34114df
......@@ -54,6 +54,9 @@ gridModifier.append_filter(('id_categories', '==', T('is equal to')))
gridModifier.configure_filters(plugins=['pFormToolTip'], width=300)
gridModifier.configure_gridWithFilter(selectorTitle=T('Filter'))
gridModifier.configure(plugins=[{'ptype': 'pGridRowEditorAddWizard',
'wizard' :{'xtype': 'xwizardharvester'}}])
#-------------------------------------------------------------------------------
#
# STORE CONFIGURATiON
......
......@@ -22,7 +22,9 @@ Ext.require('Ext.direct.Manager');
Ext.require('Ext.direct.RemotingProvider');
Ext.require('Ext.EventManager');
Ext.require('Ext.tip.QuickTipManager');
Ext.require('Trp.wizard.Harvester');
Ext.require('Trp.grid.plugin.RowEditorAddWizard');
Ext.onReady(function(){
......
/**
* Add a wizard to the RowEditor context menu.
*
* @since 0.9.3
*
*/
Ext.define('Trp.grid.plugin.RowEditorAddWizard', {
extend: 'Ext.AbstractPlugin',
alias: 'plugin.pGridRowEditorAddWizard',
uses: ['Ext.menu.Menu'],
/**
* @cfg {String}
* The title of the window containing the wizard
*/
title: "Wizard...",
/**
* @cfg {String}
* The width of the window containing the wizard
*/
width: 350,
/**
* @cfg {Object}
* The wizard object
*/
wizard: null,
// private properties for internationalization
textExpert: 'mode expert',
textSimplify: 'mode simplified',
/**
* Initialize the plugin.
*
* @param {App.grid.Panel} grid
*/
init: function (grid) {
"use strict";
var me = this,
rowEditor = grid.getPlugin('rowEditor'),
contextMenu,
newAddItem,
oldAddItem;
me.setCmp(grid);
// protection
if (!rowEditor) {
throw new Error('no grid plugin RowEditor !!!');
}
contextMenu = grid.findPlugin('pGridRowEditorContextMenu');
if (!contextMenu) {
throw new Error('no grid plugin RowEditorContextMenu !!!');
}
contextMenu = contextMenu.menu;
oldAddItem = contextMenu.items.first();
// the new Add item
newAddItem = {
text: oldAddItem.text + '...',
menu: {
items: [{
text: me.textSimplify,
iconCls: 'xaction-wizard',
handler: me.onRunWizard,
scope: me
}, {
text: me.textExpert,
iconCls: 'xaction-create',
handler: rowEditor.onAddRow,
scope: rowEditor
}]
}
};
// replace the add item
contextMenu.remove(oldAddItem, true);
contextMenu.insert(0, newAddItem);
},
/**
* Hnadler creating and running the wizard
*
*/
onRunWizard: function () {
"use strict";
var me = this,
window;
window = Ext.create('Ext.window.Window', {
closable: true,
items: me.wizard,
layout: 'fit',
modal: true,
title: me.title,
width: me.width
});
window.show();
}
});
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment