modx.grid.user.group.settings.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**
  2. * Loads a grid of Group Settings
  3. *
  4. * @class MODx.grid.GroupSettings
  5. * @extends MODx.grid.SettingsGrid
  6. * @param {Object} config An object of options.
  7. * @xtype modx-grid-group-settings
  8. */
  9. MODx.grid.GroupSettings = function(config) {
  10. config = config || {};
  11. Ext.applyIf(config,{
  12. title: _('user_group_settings')
  13. ,id: 'modx-grid-group-settings'
  14. ,url: MODx.config.connector_url
  15. ,baseParams: {
  16. action: 'security/group/setting/getList'
  17. ,group: config.group
  18. }
  19. ,saveParams: {
  20. group: config.group
  21. }
  22. ,save_action: 'security/group/setting/updatefromgrid'
  23. ,fk: config.group
  24. ,tbar: [{
  25. text: _('create_new')
  26. ,cls:'primary-button'
  27. ,scope: this
  28. ,handler: {
  29. xtype: 'modx-window-setting-create'
  30. ,url: MODx.config.connector_url
  31. ,baseParams: {
  32. action: 'security/group/setting/create'
  33. }
  34. ,fk: config.group
  35. }
  36. }]
  37. });
  38. MODx.grid.GroupSettings.superclass.constructor.call(this,config);
  39. };
  40. Ext.extend(MODx.grid.GroupSettings,MODx.grid.SettingsGrid, {
  41. _showMenu: function(g,ri,e) {
  42. e.stopEvent();
  43. e.preventDefault();
  44. this.menu.record = this.getStore().getAt(ri).data;
  45. if (!this.getSelectionModel().isSelected(ri)) {
  46. this.getSelectionModel().selectRow(ri);
  47. }
  48. this.menu.removeAll();
  49. var m = [];
  50. if (this.menu.record.menu) {
  51. m = this.menu.record.menu;
  52. } else {
  53. m.push({
  54. text: _('setting_update')
  55. ,handler: this.updateSetting
  56. },'-',{
  57. text: _('setting_remove')
  58. ,handler: this.remove.createDelegate(this,['setting_remove_confirm', 'security/group/setting/remove'])
  59. });
  60. }
  61. if (m.length > 0) {
  62. this.addContextMenuItem(m);
  63. this.menu.showAt(e.xy);
  64. }
  65. }
  66. ,updateSetting: function(btn,e) {
  67. var r = this.menu.record;
  68. r.fk = Ext.isDefined(this.config.fk) ? this.config.fk : 0;
  69. var uss = MODx.load({
  70. xtype: 'modx-window-setting-update'
  71. ,action: 'security/group/setting/update'
  72. ,record: r
  73. ,grid: this
  74. ,listeners: {
  75. 'success': {fn:function(r) {
  76. this.refresh();
  77. },scope:this}
  78. }
  79. });
  80. uss.reset();
  81. uss.setValues(r);
  82. uss.show(e.target);
  83. }
  84. });
  85. Ext.reg('modx-grid-group-settings',MODx.grid.GroupSettings);