| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394 |
- /**
- * Loads a grid of Plugin Events
- *
- * @class MODx.grid.PluginEvent
- * @extends MODx.grid.Grid
- * @param {Object} config An object of options.
- * @xtype modx-grid-plugin-event
- */
- MODx.grid.PluginEvent = function(config) {
- config = config || {};
- this.ident = config.ident || 'grid-pluge'+Ext.id();
- var ec = new Ext.ux.grid.CheckColumn({
- header: _('enabled')
- ,dataIndex: 'enabled'
- ,editable: true
- ,width: 80
- ,sortable: true
- });
- Ext.applyIf(config,{
- title: _('system_events')
- ,id: 'modx-grid-plugin-event'
- ,url: MODx.config.connector_url
- ,baseParams: {
- action: 'element/plugin/event/getList'
- ,plugin: config.plugin
- ,limit: 0
- }
- ,saveParams: {
- plugin: config.plugin
- }
- ,enableColumnResize: true
- ,enableColumnMove: true
- ,primaryKey: 'name'
- ,fields: ['name','service','groupname','enabled','priority','propertyset','menu']
- ,paging: false
- ,pageSize: 0
- ,remoteSort: false
- ,singleText: _('event')
- ,pluralText: _('events')
- ,plugins: ec
- ,columns: [{
- header: _('name')
- ,dataIndex: 'name'
- ,id: 'modx-'+this.ident+'-col-name'
- ,width: 250
- ,sortable: true
- },ec
- ,{
- header: _('group')
- ,dataIndex: 'groupname'
- ,id: 'modx-'+this.ident+'-col-groupname'
- ,width: 200
- ,editor: { xtype: 'textfield' }
- ,sortable: true
- },{
- header: _('propertyset')
- ,dataIndex: 'propertyset'
- ,id: 'modx-'+this.ident+'-col-propertyset'
- ,width: 180
- ,editor: {
- xtype: 'modx-combo-property-set'
- ,renderer: true
- ,baseParams: {
- action: 'element/propertyset/getList'
- ,showAssociated: true
- ,elementId: config.plugin
- ,elementType: 'modPlugin'
- }
- }
- ,sortable: true
- },{
- header: _('priority')
- ,dataIndex: 'priority'
- ,id: 'modx-'+this.ident+'-priority'
- ,width: 100
- ,editor: { xtype: 'textfield' ,allowBlank: false }
- ,sortable: true
- }]
- ,tbar: ['->',{
- xtype: 'modx-combo-eventgroup'
- ,name: 'group'
- ,id: 'modx-plugin-event-filter-group'
- ,itemId: 'group'
- ,emptyText: _('group')+'...'
- ,width: 200
- ,listeners: {
- 'select': {fn:this.filterGroup,scope:this}
- }
- },{
- xtype: 'textfield'
- ,name: 'search'
- ,id: 'modx-plugin-event-search'
- ,cls: 'x-form-filter'
- ,emptyText: _('search_ellipsis')
- ,listeners: {
- 'change': {fn: this.search, scope: this}
- ,'render': {fn: function(cmp) {
- new Ext.KeyMap(cmp.getEl(), {
- key: Ext.EventObject.ENTER
- ,fn: this.blur
- ,scope: cmp
- });
- },scope:this}
- }
- },{
- xtype: 'button'
- ,id: 'modx-filter-clear'
- ,cls: 'x-form-filter-clear'
- ,text: _('filter_clear')
- ,listeners: {
- 'click': {fn: this.clearFilter, scope: this},
- 'mouseout': {fn: function () {this.removeClass('x-btn-focus')}}
- }
- }]
- });
- MODx.grid.PluginEvent.superclass.constructor.call(this,config);
- this.store.sortInfo = {
- field: 'enabled',
- direction: 'DESC'
- };
- this.addEvents('updateEvent');
- };
- Ext.extend(MODx.grid.PluginEvent,MODx.grid.Grid,{
- search: function(tf,newValue) {
- var nv = newValue || tf;
- this.getStore().baseParams.query = Ext.isEmpty(nv) || Ext.isObject(nv) ? '' : nv;
- this.getStore().load();
- return true;
- }
- ,filterGroup: function (cb,nv,ov) {
- this.getStore().baseParams.group = Ext.isEmpty(nv) || Ext.isObject(nv) ? cb.getValue() : nv;
- this.getStore().load();
- return true;
- }
- ,clearFilter: function() {
- delete this.getStore().baseParams.query;
- delete this.getStore().baseParams.group;
- Ext.getCmp('modx-plugin-event-search').reset();
- Ext.getCmp('modx-plugin-event-filter-group').reset();
- this.getStore().load();
- }
- ,updateEvent: function(btn,e) {
- var r = this.menu.record;
- if (!this.windows.peu) {
- this.windows.peu = MODx.load({
- xtype: 'modx-window-plugin-event-update'
- ,record: r
- ,plugin: this.config.plugin
- ,listeners: {
- 'success': {fn:function(r) {
- this.refresh();
- this.fireEvent('updateEvent',r);
- },scope:this}
- }
- });
- }
- this.windows.peu.setValues(r);
- this.windows.peu.show(e.target);
- }
- });
- Ext.reg('modx-grid-plugin-event',MODx.grid.PluginEvent);
- MODx.window.UpdatePluginEvent = function(config) {
- config = config || {};
- this.ident = config.ident || 'upluge'+Ext.id();
- Ext.applyIf(config,{
- title: _('plugin_event_update')
- ,id: 'modx-window-plugin-event-update'
- ,url: MODx.config.connector_url
- ,action: 'element/plugin/event/associate'
- ,autoHeight: true // needed here or the window will always show a scrollbar
- ,width: 600
- ,fields: [{
- fieldLabel: _('name')
- ,name: 'name'
- ,id: 'modx-'+this.ident+'-name'
- ,xtype: 'statictextfield'
- ,anchor: '100%'
- ,submitValue: true
- },{
- xtype: 'modx-grid-plugin-event-assoc'
- ,id: 'modx-grid-'+this.ident+'-assoc'
- ,autoHeight: true
- ,plugin: config.plugin
- }]
- });
- MODx.window.UpdatePluginEvent.superclass.constructor.call(this,config);
- this.on('beforeSubmit',this.beforeSubmit,this);
- };
- Ext.extend(MODx.window.UpdatePluginEvent,MODx.Window,{
- onShow: function() {
- var evt = this.fp.getForm().findField('name').getValue();
- MODx.Ajax.request({
- url: MODx.config.connector_url
- ,params: {
- action: 'element/plugin/event/getAssoc'
- ,'event': evt
- }
- ,listeners: {
- 'success':{fn:function(r) {
- var data = r.results;
- var g = Ext.getCmp('modx-grid-'+this.ident+'-assoc');
- var s = g.getStore();
- s.removeAll();
- if (data.length > 0) {
- s.loadData(data);
- }
- },scope:this}
- }
- });
- }
- ,beforeSubmit: function(vs) {
- this.fp.getForm().baseParams = {
- action: 'element/plugin/event/associate'
- ,plugins: Ext.getCmp('modx-grid-'+this.ident+'-assoc').encode()
- };
- }
- });
- Ext.reg('modx-window-plugin-event-update',MODx.window.UpdatePluginEvent);
- MODx.grid.PluginEventAssoc = function(config) {
- config = config || {};
- this.ident = config.ident || 'grid-pluge-assoc'+Ext.id();
- Ext.applyIf(config,{
- title: _('plugins')
- ,id: this.ident
- ,url: MODx.config.connector_url
- ,baseParams: {
- action: 'element/plugin/event/getPlugins'
- ,plugin: config.plugin
- }
- ,saveParams: {
- plugin: config.plugin
- }
- ,fields: ['id','name','priority','propertyset']
- ,pluginRecord: [{name:'id'},{name:'name'},{name:'priority'},{name:'propertyset'}]
- ,paging: true
- ,remoteSort: true
- ,columns: [{
- header: _('id')
- ,dataIndex: 'id'
- ,width: 80
- ,sortable: true
- },{
- header: _('plugin')
- ,dataIndex: 'name'
- ,width: 150
- ,sortable: true
- },{
- header: _('propertyset')
- ,dataIndex: 'propertyset'
- ,width: 150
- ,editor: {
- xtype: 'modx-combo-property-set'
- ,renderer: true
- ,baseParams: {
- action: 'element/propertyset/getList'
- ,showAssociated: true
- ,elementId: config.plugin
- ,elementType: 'modPlugin'
- }
- }
- },{
- header: _('priority')
- ,dataIndex: 'priority'
- ,width: 100
- ,editor: { xtype: 'textfield' ,allowBlank: false }
- }]
- ,tbar: [{
- text: _('plugin_add')
- ,cls: 'primary-button'
- ,handler: this.addPlugin
- ,scope: this
- }]
- });
- MODx.grid.PluginEventAssoc.superclass.constructor.call(this,config);
- this.pluginRecord = Ext.data.Record.create(config.pluginRecord);
- };
- Ext.extend(MODx.grid.PluginEventAssoc,MODx.grid.LocalGrid,{
- addPlugin: function(btn,e) {
- this.loadWindow(btn,e,{
- xtype: 'modx-window-plugin-event-add-plugin'
- ,record: this.menu.record
- ,plugin: this.config.plugin
- ,listeners: {
- 'success': {fn:function(r) {
- var rec = new this.pluginRecord({
- id: r.id
- ,name: r.name
- ,priority: r.priority
- ,propertyset: r.propertyset
- });
- this.getStore().add(rec);
- },scope:this}
- }
- });
- }
- ,_showMenu: function(g,ri,e) {
- var sm = this.getSelectionModel();
- e.stopEvent();
- e.preventDefault();
- if (!sm.isSelected(ri)) {
- sm.selectRow(ri);
- }
- this.menu.removeAll();
- this.addContextMenuItem([{
- text: _('remove')
- ,handler: this.remove.createDelegate(this,[{
- title: _('warning')
- ,text: _('plugin_event_plugin_remove_confirm')
- }])
- ,scope: this
- }]);
- this.menu.show(e.target);
- }
- });
- Ext.reg('modx-grid-plugin-event-assoc',MODx.grid.PluginEventAssoc);
- MODx.window.AddPluginToEvent = function(config) {
- config = config || {};
- this.ident = config.ident || 'apluge'+Ext.id();
- Ext.applyIf(config,{
- title: _('plugin_add_to_event')
- ,id: this.ident
- ,url: MODx.config.connector_url
- ,action: 'element/plugin/event/addplugin'
- ,autoHeight: true
- // ,height: 250
- // ,width: 600
- ,fields: [{
- xtype: 'modx-combo-plugin'
- ,fieldLabel: _('plugin')
- ,name: 'plugin'
- ,id: 'modx-'+this.ident+'-plugin'
- ,anchor: '100%'
- ,allowBlank: false
- },{
- xtype: 'numberfield'
- ,name: 'priority'
- ,fieldLabel: _('priority')
- ,id: 'modx-'+this.ident+'-priority'
- ,value: 0
- ,allowBlank: false
- ,anchor: '100%'
- }]
- });
- MODx.window.AddPluginToEvent.superclass.constructor.call(this,config);
- };
- Ext.extend(MODx.window.AddPluginToEvent,MODx.Window,{
- submit: function() {
- var f = this.fp.getForm();
- var vs = f.getValues();
- var cb = f.findField('plugin');
- vs.id = cb.getValue();
- vs.name = cb.getRawValue();
- if (this.fp.getForm().isValid()) {
- if (this.fireEvent('success',vs)) {
- this.fp.getForm().reset();
- this.hide();
- return true;
- }
- }
- return false;
- }
- });
- Ext.reg('modx-window-plugin-event-add-plugin',MODx.window.AddPluginToEvent);
- MODx.combo.Plugin = function(config) {
- config = config || {};
- Ext.applyIf(config,{
- url: MODx.config.connector_url
- ,baseParams: {
- action: 'element/plugin/getlist'
- }
- ,fields: ['id','name','description']
- ,name: 'plugin'
- ,hiddenName: 'plugin'
- ,displayField: 'name'
- ,valueField: 'id'
- ,editable: false
- ,tpl: new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item"><span style="font-weight: bold">{name:htmlEncode}</span>'
- ,'<br />{description:htmlEncode}</div></tpl>')
- });
- MODx.combo.Plugin.superclass.constructor.call(this,config);
- };
- Ext.extend(MODx.combo.Plugin,MODx.combo.ComboBox);
- Ext.reg('modx-combo-plugin',MODx.combo.Plugin);
|