create.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * Loads the create resource page
  3. *
  4. * @class MODx.page.CreateResource
  5. * @extends MODx.Component
  6. * @param {Object} config An object of config properties
  7. * @xtype modx-page-resource-create
  8. */
  9. MODx.page.CreateResource = function(config) {
  10. config = config || {};
  11. Ext.applyIf(config,{
  12. url: MODx.config.connector_url
  13. ,formpanel: 'modx-panel-resource'
  14. ,id: 'modx-page-update-resource'
  15. ,which_editor: 'none'
  16. ,action: 'resource/create'
  17. ,buttons: this.getButtons(config)
  18. ,components: [{
  19. xtype: config.panelXType || 'modx-panel-resource'
  20. ,renderTo: config.panelRenderTo || 'modx-panel-resource-div'
  21. ,resource: 0
  22. ,record: config.record
  23. ,publish_document: config.publish_document
  24. ,show_tvs: config.show_tvs
  25. ,mode: config.mode
  26. ,url: config.url
  27. }]
  28. });
  29. MODx.page.CreateResource.superclass.constructor.call(this,config);
  30. };
  31. Ext.extend(MODx.page.CreateResource,MODx.Component,{
  32. getButtons: function(cfg) {
  33. var btns = [];
  34. if (cfg.canSave == 1) {
  35. btns.push({
  36. process: 'resource/create'
  37. ,reload: true
  38. ,text: _('save')
  39. ,id: 'modx-abtn-save'
  40. ,cls:'primary-button'
  41. ,method: 'remote'
  42. //,checkDirty: true
  43. ,keys: [{
  44. key: MODx.config.keymap_save || 's'
  45. ,ctrl: true
  46. }]
  47. });
  48. }
  49. btns.push({
  50. text: _('cancel')
  51. ,id: 'modx-abtn-cancel'
  52. });
  53. btns.push({
  54. text: _('help_ex')
  55. ,id: 'modx-abtn-help'
  56. ,handler: MODx.loadHelpPane
  57. });
  58. return btns;
  59. }
  60. });
  61. Ext.reg('modx-page-resource-create',MODx.page.CreateResource);