view.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * @class MODx.page.ViewContext
  3. * @extends MODx.Component
  4. * @param {Object} config An object of configuration properties
  5. * @xtype page-context-view
  6. */
  7. MODx.page.ViewContext = function(config) {
  8. config = config || {};
  9. Ext.applyIf(config,{
  10. form: 'context_data'
  11. ,actions: {
  12. 'new': 'context/create'
  13. ,'edit': 'context/update'
  14. ,'delete': 'context/delete'
  15. ,'cancel': 'context/view'
  16. }
  17. ,buttons: this.getButtons()
  18. });
  19. MODx.page.ViewContext.superclass.constructor.call(this,config);
  20. };
  21. Ext.extend(MODx.page.ViewContext,MODx.Component,{
  22. getButtons: function(config) {
  23. var b = [];
  24. b.push({
  25. process: 'create'
  26. ,text: _('new')
  27. ,id: 'modx-abtn-new'
  28. ,params: {
  29. a: 'context/create'
  30. }
  31. },{
  32. process: 'edit'
  33. ,text: _('edit')
  34. ,id: 'modx-abtn-edit'
  35. ,params: {
  36. a: 'context/update'
  37. ,key: config.key
  38. }
  39. },{
  40. process: 'duplicate'
  41. ,text: _('duplicate')
  42. ,id: 'modx-abtn-duplicate'
  43. ,method: 'remote'
  44. ,confirm: _('context_duplicate_confirm')
  45. });
  46. if (config.key != 'web' && config.key != 'mgr') {
  47. b.push({
  48. process: 'delete'
  49. ,text: _('delete')
  50. ,id: 'modx-abtn-delete'
  51. ,method: 'remote'
  52. ,confirm: _('confirm_delete_context')
  53. });
  54. }
  55. b.push({
  56. process: 'cancel'
  57. ,text: _('cancel')
  58. ,id: 'modx-abtn-cancel'
  59. ,params: {
  60. a: 'context'
  61. }
  62. });
  63. b.push({
  64. text: _('help_ex')
  65. ,id: 'modx-abtn-help'
  66. ,handler: MODx.loadHelpPane
  67. });
  68. return b;
  69. }
  70. });
  71. Ext.reg('page-context-view',MODx.page.ViewContext);