/** * Panel to manage Product. * * @class JustKnit.panel.Product * @extends Ext.Panel * @param {Object} config An object of options. * @xtype Justknit-panel-product */ JustKnit.panel.Product = function(config) { config = config || {}; Ext.applyIf(config,{ id: 'justknit-panel-product' ,title: _('justknit.product') ,layout: 'anchor' ,defaults: { border: false } ,items:[{ html: '
'+_('justknit.product_management_desc')+'
' ,xtype: 'modx-description' },{ xtype: 'justknit-grid-product'//'modx-description'// }] }); JustKnit.panel.Product.superclass.constructor.call(this,config); }; Ext.extend(JustKnit.panel.Product,Ext.Panel); Ext.reg('justknit-panel-product', JustKnit.panel.Product); //justknit-grid-product //JustKnit.grid.Product JustKnit.grid.Product = function(config) { config = config || {}; Ext.applyIf(config,{ id: 'justknit-grid-product' ,url: MODx.config.connector_url ,cls: 'main-wrapper' ,baseParams: { action: 'JustKnit\\Processors\\Product\\GetList' } ,fields:['id', 'product_id', 'product_name', 'duration', 'modxusergroup' ] ,autoHeight: true ,paging: true ,emptyText: _('justknit.product_none') ,remoteSort: true ,save_action: 'JustKnit\\Processors\\Product\\UpdateFromGrid' ,autosave: true ,columns: [ { header: _('justknit.product_id') ,dataIndex: 'id' ,sortable: true ,editor: {xtype: 'textfield'} } ,{ header: _('justknit.product_DS24_id') ,dataIndex: 'product_id' ,sortable: true ,name: 'product_id' ,renderer: function(v) { return `${v}`; } // ,editor: {xtype: 'textfield'} } ,{ header: _('justknit.product_name') ,dataIndex: 'product_name' ,sortable: true ,editor: {xtype: 'textfield'} } ,{ header: _('justknit.product_duration') ,dataIndex: 'duration' ,editor: { xtype: 'justknit-combo-lapse', renderer: true } ,sortable: true } ,{ header: _('justknit.product_modxusergroup') ,dataIndex: 'modxusergroup' ,editor: { xtype: 'modx-combo-usergroup', renderer: true } ,sortable: true } ,{ header: _('justknit.product_modxusergroup') ,dataIndex: 'modxusergroup' ,sortable: true ,editor: {xtype: 'textfield'} } ] ,tbar:[{ text: _('justknit.product_create') ,handler: this.createProduct ,scope: this }] }); JustKnit.grid.Product.superclass.constructor.call(this, config); }; Ext.extend(JustKnit.grid.Product, MODx.grid.Grid, { search: function(tf,nv,ov) { var s = this.getStore(); s.baseParams.query = tf.getValue(); this.getBottomToolbar().changePage(1); this.refresh(); } ,createProduct: function(btn, e) { var win = MODx.load({ xtype: 'justknit-window-product-create-update' ,title: _('justknit.product_create') ,listeners: { 'success': {fn: function() {this.refresh();}, scope: this} } }); win.show(e.target); } ,updateProduct: function(btn, e) { if (!this.menu.record || !this.menu.record.id){ return false; } var win = MODx.load({ xtype: 'justknit-window-product-create-update' ,title: _('justknit.product_update') ,action: 'JustKnit\\Processors\\Product\\Update' ,listeners: { 'success': {fn: function() {this.refresh();}, scope: this} } }); win.fp.getForm().setValues(this.menu.record); win.show(e.target); } ,getMenu:function() { var m = []; m.push({ text: _('justknit.product_update') ,handler: this.updateProduct }); m.push({ text: _('justknit.product_remove') ,handler: this.removeProduct }); m.push('-'); this.addContextMenuItem(m); } ,removeProduct: function(btn, e) { if (!this.menu.record){ return false; } MODx.msg.confirm({ title: _('justknit.product_remove') ,text: _('justknit.product_remove_confirm') ,url: this.config.url ,params: { action: 'JustKnit\\Processors\\Product\\Remove' ,id: this.menu.record.id } ,listeners:{ 'success': { fn: function() {this.refresh();}, scope: this} } }); } }); Ext.reg('justknit-grid-product', JustKnit.grid.Product); // JustKnit.window.CreateUpdateProduct JustKnit.window.CreateUpdateProduct = function(config) { config = config || {}; Ext.applyIf(config, { width: 480 ,closeAction: 'close' ,url: MODx.config.connector_url ,preventRender: true ,action: 'JustKnit\\Processors\\Product\\Create' ,fields: [ { xtype: 'hidden' ,name: 'id' },{ xtype: 'textfield' ,fieldLabel: _('justknit.product_DS24_id') ,name: 'product_id' ,anchor: '100%' },{ xtype: 'textfield' ,fieldLabel: _('justknit.product_name') ,name: 'product_name' ,anchor: '100%' },{ xtype: 'justknit-combo-lapse' //,editor: { xtype: 'justknit-combo-lapse', renderer: true } ,fieldLabel: _('justknit.product_duration') ,name: 'duration' ,anchor: '100%' ,displayField: 'LapseDescription' ,valueField: 'Lapse' },{ xtype: 'modx-combo-usergroup' ,name: 'modxusergroup' ,hiddenName: 'modxusergroup' ,fieldLabel: _('justknit.product_modxusergroup') ,emptyText: _('justknit.product_modxusergroup') ,width: 250 ,listWidth: 250 ,displayField: 'name' } ] }); JustKnit.window.CreateUpdateProduct.superclass.constructor.call(this, config); }; Ext.extend(JustKnit.window.CreateUpdateProduct, MODx.Window); Ext.reg('justknit-window-product-create-update', JustKnit.window.CreateUpdateProduct);