grid.groups.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. ClientConfig.grid.Groups = function(config) {
  2. config = config || {};
  3. Ext.applyIf(config,{
  4. url: ClientConfig.config.connectorUrl,
  5. id: 'clientconfig-grid-groups',
  6. baseParams: {
  7. action: 'mgr/groups/getlist'
  8. },
  9. save_action: 'mgr/groups/updatefromgrid',
  10. autosave: true,
  11. emptyText: _('clientconfig.error.noresults'),
  12. fields: [
  13. {name: 'id', type: 'int'},
  14. {name: 'label', type: 'string'},
  15. {name: 'description', type: 'string'},
  16. {name: 'sortorder', type: 'int'},
  17. {name: 'settings_count', type: 'int'}
  18. ],
  19. paging: true,
  20. remoteSort: true,
  21. columns: [{
  22. header: _('clientconfig.id'),
  23. dataIndex: 'id',
  24. sortable: true,
  25. width: .1
  26. },{
  27. header: _('clientconfig.label'),
  28. dataIndex: 'label',
  29. editor: { xtype: 'textfield' },
  30. sortable: true,
  31. width: .3
  32. },{
  33. header: _('clientconfig.description'),
  34. dataIndex: 'description',
  35. editor: { xtype: 'textfield' },
  36. sortable: true,
  37. width: .5
  38. },{
  39. header: _('clientconfig.settings_count'),
  40. dataIndex: 'settings_count',
  41. sortable: true,
  42. width: .1
  43. },{
  44. header: _('clientconfig.sortorder'),
  45. dataIndex: 'sortorder',
  46. editor: {
  47. xtype: 'numberfield',
  48. allowDecimal: false,
  49. allowNegative: false
  50. },
  51. sortable: true,
  52. width: .1
  53. }],
  54. tbar: [{
  55. text: _('clientconfig.add_group'),
  56. handler: this.addGroup,
  57. scope: this
  58. }, '->', {
  59. text: _('clientconfig.export_groups'),
  60. handler: this.exportGroups,
  61. scope: this
  62. }, '-', {
  63. text: _('clientconfig.import_groups'),
  64. handler: this.importGroups,
  65. scope: this
  66. }]
  67. });
  68. ClientConfig.grid.Groups.superclass.constructor.call(this,config);
  69. };
  70. Ext.extend(ClientConfig.grid.Groups,MODx.grid.Grid,{
  71. addGroup: function() {
  72. var win = MODx.load({
  73. xtype: 'clientconfig-window-group',
  74. listeners: {
  75. success: {fn: function(r) {
  76. this.refresh();
  77. },scope: this},
  78. scope: this
  79. }
  80. });
  81. win.show();
  82. },
  83. updateGroup: function() {
  84. var record = this.menu.record;
  85. var win = MODx.load({
  86. xtype: 'clientconfig-window-group',
  87. listeners: {
  88. success: {fn: function(r) {
  89. this.refresh();
  90. },scope: this},
  91. scope: this
  92. },
  93. isUpdate: true
  94. });
  95. win.setValues(record);
  96. win.show();
  97. },
  98. removeGroup: function() {
  99. var id = this.menu.record.id;
  100. MODx.msg.confirm({
  101. title: _('clientconfig.remove_group'),
  102. text: _('clientconfig.remove_group.confirm'),
  103. url: this.config.url,
  104. params: {
  105. action: 'mgr/groups/remove',
  106. id: id
  107. },
  108. listeners: {
  109. success: {fn: function(r) {
  110. this.refresh();
  111. },scope: this},
  112. scope: this
  113. }
  114. });
  115. },
  116. getMenu: function(node) {
  117. var m = [];
  118. m.push({
  119. text: _('clientconfig.update_group'),
  120. handler: this.updateGroup,
  121. scope: this
  122. },'-',{
  123. text: _('clientconfig.remove_group'),
  124. handler: this.removeGroup,
  125. scope: this
  126. });
  127. return m;
  128. },
  129. exportGroups: function() {
  130. Ext.Msg.confirm(_('clientconfig.export_groups'), _('clientconfig.export_groups.confirm'), function(e) {
  131. if (e == 'yes') {
  132. window.location = ClientConfig.config.connectorUrl + '?action=mgr/groups/export&HTTP_MODAUTH=' + MODx.siteId;
  133. }
  134. });
  135. },
  136. importGroups: function() {
  137. var win = MODx.load({
  138. xtype: 'clientconfig-window-import',
  139. title: _('clientconfig.import_groups'),
  140. introduction: _('clientconfig.import_groups.desc'),
  141. what: _('clientconfig.groups'),
  142. baseParams: {
  143. action: 'mgr/groups/import'
  144. },
  145. listeners: {
  146. success: {fn: function(r) {
  147. this.refresh();
  148. },scope: this},
  149. scope: this
  150. }
  151. });
  152. win.show();
  153. }
  154. });
  155. Ext.reg('clientconfig-grid-groups',ClientConfig.grid.Groups);