modx.panel.resource.schedule.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. MODx.panel.ResourceSchedule = function(config) {
  2. config = config || {};
  3. Ext.applyIf(config,{
  4. id: 'modx-panel-resource-schedule'
  5. ,cls: 'container'
  6. ,bodyStyle: ''
  7. ,defaults: { collapsible: false ,autoHeight: true }
  8. ,items: [{
  9. html: _('site_schedule')
  10. ,id: 'modx-resource-schedule-header'
  11. ,xtype: 'modx-header'
  12. },{
  13. layout: 'form'
  14. ,items: [{
  15. html: '<p>'+_('site_schedule_desc')+'</p>'
  16. ,xtype: 'modx-description'
  17. },{
  18. xtype: 'modx-grid-resource-schedule'
  19. ,cls:'main-wrapper'
  20. ,preventRender: true
  21. }]
  22. }]
  23. });
  24. MODx.panel.ResourceSchedule.superclass.constructor.call(this,config);
  25. };
  26. Ext.extend(MODx.panel.ResourceSchedule,MODx.FormPanel);
  27. Ext.reg('modx-panel-resource-schedule',MODx.panel.ResourceSchedule);
  28. /**
  29. * Loads a grid of Publish/Unpublish events for a resource.
  30. *
  31. * @class MODx.grid.ResourceSchedule
  32. * @extends MODx.grid.Grid
  33. * @param {Object} config An object of options.
  34. * @xtype modx-grid-resource-schedule
  35. */
  36. MODx.grid.ResourceSchedule = function(config) {
  37. config = config || {};
  38. Ext.applyIf(config,{
  39. title: _('site_schedule')
  40. ,url: MODx.config.connector_url
  41. ,baseParams: {
  42. action: 'resource/event/getList'
  43. ,mode: 'pub_date'
  44. }
  45. ,fields: ['id','pagetitle','class_key'
  46. ,{name: 'pub_date', type: 'date'}
  47. ,{name: 'unpub_date', type:'date'}
  48. ,'menu']
  49. ,paging: true
  50. ,save_action: 'resource/event/updatefromgrid'
  51. ,autosave: true
  52. ,columns: [
  53. { header: _('id') ,dataIndex: 'id' ,width: 40 }
  54. ,{ header: _('pagetitle') ,dataIndex: 'pagetitle' ,width: 40 }
  55. ,{
  56. header: _('publish_date')
  57. ,dataIndex: 'pub_date'
  58. ,width: 150
  59. ,editor: {
  60. xtype: 'xdatetime'
  61. ,dateFormat: MODx.config.manager_date_format
  62. ,timeFormat: MODx.config.manager_time_format
  63. ,ctCls: 'x-datetime-inline-editor'
  64. }
  65. ,renderer: Ext.util.Format.dateRenderer(MODx.config.manager_date_format + ' ' + MODx.config.manager_time_format)
  66. },{
  67. header: _('unpublish_date')
  68. ,dataIndex: 'unpub_date'
  69. ,width: 150
  70. ,editor: {
  71. xtype: 'xdatetime'
  72. ,dateFormat: MODx.config.manager_date_format
  73. ,timeFormat: MODx.config.manager_time_format
  74. ,ctCls: 'x-datetime-inline-editor'
  75. }
  76. ,renderer: Ext.util.Format.dateRenderer(MODx.config.manager_date_format + ' ' + MODx.config.manager_time_format)
  77. }
  78. ]
  79. ,tbar: [{
  80. text: _('showing_pub')
  81. ,scope: this
  82. ,handler: this.toggle
  83. ,enableToggle: true
  84. ,tooltip: _('click_to_change')
  85. ,id: 'btn-toggle'
  86. ,cls:'primary-button'
  87. }]
  88. });
  89. MODx.grid.ResourceSchedule.superclass.constructor.call(this,config);
  90. };
  91. Ext.extend(MODx.grid.ResourceSchedule,MODx.grid.Grid,{
  92. toggle: function(btn,e) {
  93. var s = this.getStore();
  94. if (btn.pressed) {
  95. s.setBaseParam('mode','unpub_date');
  96. btn.setText(_('showing_unpub'));
  97. } else {
  98. s.setBaseParam('mode','pub_date');
  99. btn.setText(_('showing_pub'));
  100. }
  101. this.getBottomToolbar().changePage(1);
  102. s.removeAll();
  103. // this.refresh();
  104. }
  105. });
  106. Ext.reg('modx-grid-resource-schedule',MODx.grid.ResourceSchedule);