update.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /**
  2. * Loads the TV update page
  3. *
  4. * @class MODx.page.UpdateTV
  5. * @extends MODx.Component
  6. * @param {Object} config An object of config properties
  7. * @xtype modx-page-tv-update
  8. */
  9. MODx.page.UpdateTV = function(config) {
  10. config = config || {};
  11. Ext.applyIf(config,{
  12. formpanel: 'modx-panel-tv'
  13. ,buttons: [{
  14. process: 'element/tv/update'
  15. ,text: _('save')
  16. ,id: 'modx-abtn-save'
  17. ,cls: 'primary-button'
  18. ,method: 'remote'
  19. // ,checkDirty: true
  20. ,keys: [{
  21. key: MODx.config.keymap_save || 's'
  22. ,ctrl: true
  23. }]
  24. },{
  25. text: _('delete')
  26. ,id: 'modx-abtn-delete'
  27. ,handler: this.delete
  28. ,scope: this
  29. },{
  30. text: _('duplicate')
  31. ,id: 'modx-abtn-duplicate'
  32. ,handler: this.duplicate
  33. ,scope: this
  34. },{
  35. text: _('cancel')
  36. ,id: 'modx-abtn-cancel'
  37. },{
  38. text: _('help_ex')
  39. ,id: 'modx-abtn-help'
  40. ,handler: MODx.loadHelpPane
  41. }]
  42. ,components: [{
  43. xtype: 'modx-panel-tv'
  44. ,renderTo: 'modx-panel-tv-div'
  45. ,tv: config.record.id || MODx.request.id
  46. ,record: config.record || {}
  47. }]
  48. });
  49. MODx.page.UpdateTV.superclass.constructor.call(this,config);
  50. };
  51. Ext.extend(MODx.page.UpdateTV,MODx.Component, {
  52. duplicate: function(btn, e) {
  53. var rec = {
  54. id: this.record.id
  55. ,type: 'tv'
  56. ,name: _('duplicate_of',{name: this.record.name})
  57. ,caption: _('duplicate_of',{name: this.record.caption})
  58. ,source: this.record.source
  59. ,static: this.record.static
  60. ,static_file: this.record.static_file
  61. ,category: this.record.category
  62. };
  63. var w = MODx.load({
  64. xtype: 'modx-window-element-duplicate'
  65. ,record: rec
  66. ,listeners: {
  67. success: {
  68. fn: function(r) {
  69. var response = Ext.decode(r.a.response.responseText);
  70. MODx.loadPage('element/'+ rec.type +'/update', 'id='+ response.object.id);
  71. },scope:this}
  72. ,hide:{fn:function() {this.destroy();}}
  73. }
  74. });
  75. w.show(e.target);
  76. }
  77. ,delete: function(btn, e) {
  78. MODx.msg.confirm({
  79. text: _('tv_delete_confirm')
  80. ,url: MODx.config.connector_url
  81. ,params: {
  82. action: 'element/tv/remove'
  83. ,id: this.record.id
  84. }
  85. ,listeners: {
  86. success: {
  87. fn: function(r) {
  88. MODx.loadPage('?');
  89. },scope:this}
  90. }
  91. });
  92. }
  93. });
  94. Ext.reg('modx-page-tv-update',MODx.page.UpdateTV);