update.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**
  2. * Loads the update plugin page
  3. *
  4. * @class MODx.page.UpdatePlugin
  5. * @extends MODx.Component
  6. * @param {Object} config An object of config properties
  7. * @xtype modx-page-plugin-update
  8. */
  9. MODx.page.UpdatePlugin = function(config) {
  10. config = config || {};
  11. Ext.applyIf(config,{
  12. formpanel: 'modx-panel-plugin'
  13. ,buttons: [{
  14. process: 'element/plugin/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-plugin'
  44. ,renderTo: 'modx-panel-plugin-div'
  45. ,plugin: config.record.id || MODx.request.id
  46. ,record: config.record || {}
  47. }]
  48. });
  49. MODx.page.UpdatePlugin.superclass.constructor.call(this,config);
  50. };
  51. Ext.extend(MODx.page.UpdatePlugin,MODx.Component, {
  52. duplicate: function(btn, e) {
  53. var rec = {
  54. id: this.record.id
  55. ,type: 'plugin'
  56. ,name: _('duplicate_of',{name: this.record.name})
  57. ,source: this.record.source
  58. ,static: this.record.static
  59. ,static_file: this.record.static_file
  60. ,category: this.record.category
  61. };
  62. var w = MODx.load({
  63. xtype: 'modx-window-element-duplicate'
  64. ,record: rec
  65. ,listeners: {
  66. success: {
  67. fn: function(r) {
  68. var response = Ext.decode(r.a.response.responseText);
  69. MODx.loadPage('element/'+ rec.type +'/update', 'id='+ response.object.id);
  70. },scope:this}
  71. ,hide:{fn:function() {this.destroy();}}
  72. }
  73. });
  74. w.show(e.target);
  75. }
  76. ,delete: function(btn, e) {
  77. MODx.msg.confirm({
  78. text: _('plugin_delete_confirm')
  79. ,url: MODx.config.connector_url
  80. ,params: {
  81. action: 'element/plugin/remove'
  82. ,id: this.record.id
  83. }
  84. ,listeners: {
  85. success: {
  86. fn: function(r) {
  87. MODx.loadPage('?');
  88. },scope:this}
  89. }
  90. });
  91. }
  92. });
  93. Ext.reg('modx-page-plugin-update',MODx.page.UpdatePlugin);