panel.templates.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. VersionX.panel.Templates = function(config) {
  2. config = config || {};
  3. Ext.apply(config,{
  4. id: 'versionx-panel-templates',
  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-templates',
  17. fieldLabel: _('template'),
  18. name: 'fltr_template',
  19. width: '95%',
  20. id: 'tpl-f-template',
  21. value: (VersionX.inVersion) ? MODx.request.id : ''
  22. },{
  23. xtype: 'modx-combo-user',
  24. fieldLabel: _('user'),
  25. name: 'fltr_user',
  26. hiddenName: 'fltr_user',
  27. anchor: '1',
  28. id: 'tpl-f-user'
  29. },{
  30. xtype: 'datefield',
  31. fieldLabel: _('versionx.filter.datefrom'),
  32. name: 'fltr_from',
  33. anchor: '1',
  34. id: 'tpl-f-from'
  35. }]
  36. },{
  37. columnWidth:.5,
  38. layout: 'form',
  39. border: false,
  40. items: [{
  41. xtype: (VersionX.inVersion) ? 'hidden' : 'modx-combo-category',
  42. fieldLabel: _('category'),
  43. name: 'fltr_category',
  44. anchor: '1',
  45. id: 'tpl-f-category'
  46. },{
  47. xtype: 'datefield',
  48. fieldLabel: _('versionx.filter.dateuntil'),
  49. name: 'fltr_until',
  50. anchor: '1',
  51. id: 'tpl-f-until'
  52. }]
  53. }]
  54. },{
  55. layout: 'column',
  56. padding: '10px 0 0 0',
  57. border: false,
  58. defaults: {
  59. border: false
  60. },
  61. items: [{
  62. width: 90,
  63. items: [{
  64. border: false,
  65. html: ' '
  66. }]
  67. },{
  68. items: [{
  69. xtype: 'button',
  70. cls: 'primary-button',
  71. handler: this.doFilter,
  72. text: _('versionx.filter',{what: _('templates')})
  73. }]
  74. },{
  75. items: [{
  76. xtype: 'button',
  77. handler: this.resetFilter,
  78. text: _('versionx.filter.reset')
  79. }]
  80. },{
  81. columnWidth: 1,
  82. items: [{
  83. html: ' ',
  84. border: false
  85. }]
  86. }]
  87. }],
  88. listeners: {
  89. 'success': function () {}
  90. }
  91. });
  92. VersionX.panel.Templates.superclass.constructor.call(this,config);
  93. };
  94. Ext.extend(VersionX.panel.Templates,MODx.Panel,{
  95. doFilter: function() {
  96. var g = Ext.getCmp('versionx-grid-templates');
  97. if (g) {
  98. g.baseParams['template'] = Ext.getCmp('tpl-f-template').getValue();
  99. g.baseParams['category'] = Ext.getCmp('tpl-f-category').getValue();
  100. g.baseParams['user'] = Ext.getCmp('tpl-f-user').getValue();
  101. g.baseParams['from'] = Ext.getCmp('tpl-f-from').getValue();
  102. g.baseParams['until'] = Ext.getCmp('tpl-f-until').getValue();
  103. g.getBottomToolbar().changePage(1);
  104. g.refresh();
  105. }
  106. },
  107. resetFilter: function() {
  108. var g = Ext.getCmp('versionx-grid-templates');
  109. g.baseParams['template'] = (VersionX.inVersion) ? MODx.request.id : '';
  110. g.baseParams['category'] = '';
  111. g.baseParams['user'] = '';
  112. g.baseParams['from'] = '';
  113. g.baseParams['until'] = '';
  114. g.getBottomToolbar().changePage(1);
  115. g.refresh();
  116. Ext.getCmp('tpl-f-template').reset();
  117. Ext.getCmp('tpl-f-category').reset();
  118. Ext.getCmp('tpl-f-user').reset();
  119. Ext.getCmp('tpl-f-from').reset();
  120. Ext.getCmp('tpl-f-until').reset();
  121. }
  122. });
  123. Ext.reg('versionx-panel-templates',VersionX.panel.Templates);