panel.resources.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. VersionX.panel.Resources = function(config) {
  2. config = config || {};
  3. Ext.apply(config,{
  4. id: 'versionx-panel-resources',
  5. border: false,
  6. forceLayout: true,
  7. width: '98%',
  8. items: [{
  9. layout: 'column',
  10. border: false,
  11. items: [{
  12. columnWidth:.5,
  13. layout: 'form',
  14. border: false,
  15. items: [{
  16. xtype: (VersionX.inVersion) ? 'hidden' : 'textfield', //'versionx-combo-resources',
  17. fieldLabel: _('resource'),
  18. name: 'fltr_resource',
  19. hiddenName: 'fltr_resource',
  20. allowBlank: true,
  21. width: '95%',
  22. id: 'res-f-resource',
  23. value: (VersionX.inVersion) ? MODx.request.id : ''
  24. },{
  25. xtype: VersionX.config.has_users_permission ? 'modx-combo-user' : 'hidden',
  26. fieldLabel: _('user'),
  27. name: 'fltr_user',
  28. hiddenName: 'fltr_user',
  29. allowBlank: true,
  30. anchor: '1',
  31. id: 'res-f-user'
  32. },{
  33. xtype: 'datefield',
  34. fieldLabel: _('versionx.filter.datefrom'),
  35. name: 'fltr_from',
  36. anchor: '1',
  37. id: 'res-f-from'
  38. }]
  39. },{
  40. columnWidth:.5,
  41. layout: 'form',
  42. border: false,
  43. items: [{
  44. xtype: (VersionX.inVersion) ? 'hidden' : 'modx-combo-context',
  45. fieldLabel: _('context'),
  46. name: 'fltr_context_key',
  47. hiddenName: 'fltr_context_key',
  48. anchor: '1',
  49. id: 'res-f-context'
  50. },{
  51. xtype: 'modx-combo-class-derivatives',
  52. fieldLabel: _('resource_type'),
  53. name: 'fltr_class',
  54. hiddenName: 'fltr_class',
  55. allowBlank: true,
  56. forceSelection: false,
  57. anchor: '1',
  58. id: 'res-f-class'
  59. },{
  60. xtype: 'datefield',
  61. fieldLabel: _('versionx.filter.dateuntil'),
  62. name: 'fltr_until',
  63. hiddenName: 'fltr_until',
  64. allowBlank: true,
  65. anchor: '1',
  66. id: 'res-f-until'
  67. }]
  68. }]
  69. },{
  70. layout: 'column',
  71. padding: '10px 0 0 0',
  72. border: false,
  73. defaults: {
  74. border: false
  75. },
  76. items: [{
  77. width: 90,
  78. items: [{
  79. border: false,
  80. html: ' '
  81. }]
  82. },{
  83. items: [{
  84. xtype: 'button',
  85. cls: 'primary-button',
  86. handler: this.doFilter,
  87. text: _('versionx.filter',{what: _('resources')})
  88. }]
  89. },{
  90. items: [{
  91. xtype: 'button',
  92. handler: this.resetFilter,
  93. text: _('versionx.filter.reset')
  94. }]
  95. },{
  96. columnWidth: 1,
  97. items: [{
  98. html: ' ',
  99. border: false
  100. }]
  101. }]
  102. }],
  103. listeners: {
  104. 'success': function () {}
  105. }
  106. });
  107. VersionX.panel.Resources.superclass.constructor.call(this,config);
  108. };
  109. Ext.extend(VersionX.panel.Resources,MODx.Panel,{
  110. doFilter: function() {
  111. var g = Ext.getCmp('versionx-grid-resources');
  112. if (g) {
  113. g.baseParams['resource'] = Ext.getCmp('res-f-resource').getValue();
  114. g.baseParams['context'] = Ext.getCmp('res-f-context').getValue();
  115. g.baseParams['class'] = Ext.getCmp('res-f-class').getValue();
  116. g.baseParams['user'] = Ext.getCmp('res-f-user').getValue();
  117. g.baseParams['from'] = Ext.getCmp('res-f-from').getValue();
  118. g.baseParams['until'] = Ext.getCmp('res-f-until').getValue();
  119. g.getBottomToolbar().changePage(1);
  120. g.refresh();
  121. }
  122. },
  123. resetFilter: function() {
  124. var g = Ext.getCmp('versionx-grid-resources');
  125. g.baseParams['resource'] = (VersionX.inVersion) ? MODx.request.id : '';
  126. g.baseParams['context'] = '';
  127. g.baseParams['class'] = '';
  128. g.baseParams['user'] = '';
  129. g.baseParams['from'] = '';
  130. g.baseParams['until'] = '';
  131. g.getBottomToolbar().changePage(1);
  132. g.refresh();
  133. // Reset Fields
  134. Ext.getCmp('res-f-resource').reset();
  135. Ext.getCmp('res-f-context').reset();
  136. Ext.getCmp('res-f-class').reset();
  137. Ext.getCmp('res-f-user').reset();
  138. Ext.getCmp('res-f-from').reset();
  139. Ext.getCmp('res-f-until').reset();
  140. }
  141. });
  142. Ext.reg('versionx-panel-resources',VersionX.panel.Resources);