detailpanel.plugins.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. VersionX.panel.PluginsDetail = function(config) {
  2. config = config || {};
  3. config.id = config.id || 'versionx-panel-pluginsdetail';
  4. Ext.apply(config,{
  5. border: false,
  6. layout: 'form',
  7. items: [{
  8. html: '<p>'+_('versionx.plugins.detail.text')+'</p>',
  9. border: false,
  10. bodyCssClass: 'panel-desc'
  11. },{
  12. layout: 'form',
  13. cls: 'main-wrapper',
  14. items: [{
  15. layout: 'hbox',
  16. border: false,
  17. items: [{
  18. xtype: 'versionx-combo-pluginversions',
  19. emptyText: _('versionx.compare_to'),
  20. labelStyle: 'padding: 7px 0 0 5px;',
  21. width: 300,
  22. name: 'compare_to',
  23. baseParams: {
  24. content_id: (VersionX.record) ? VersionX.record['content_id'] : 0,
  25. current: (VersionX.record) ? VersionX.record['version_id'] : 0,
  26. action: 'mgr/plugins/get_versions'
  27. },
  28. listeners: {
  29. 'select': this.compareVersion
  30. }
  31. },{html: '&nbsp;', border: false, bodyStyle: 'margin-left: 10px;'},{
  32. xtype: 'button',
  33. cls: 'primary-button',
  34. text: _('versionx.plugins.revert.options'),
  35. handler: (VersionX.record && VersionX.cmrecord) ? Ext.emptyFn : function() {
  36. this.revertVersion((VersionX.record) ? VersionX.record['version_id'] : 0);
  37. },
  38. scope: this,
  39. menu: (VersionX.record && VersionX.cmrecord) ?
  40. [{
  41. text: _('versionx.plugins.revert',{id: VersionX.record['version_id']}),
  42. handler: function() {
  43. this.revertVersion((VersionX.record) ? VersionX.record['version_id'] : 0);
  44. },
  45. scope: this
  46. },{
  47. text: _('versionx.plugins.revert',{id: VersionX.cmrecord['version_id']}),
  48. handler: function() {
  49. this.revertVersion((VersionX.cmrecord) ? VersionX.cmrecord['version_id'] : 0);
  50. },
  51. scope: this
  52. }] : undefined
  53. }]
  54. },{
  55. xtype: 'panel',
  56. bodyStyle: 'height: 12px',
  57. border: false
  58. },{
  59. xtype: 'modx-tabs',
  60. bodyStyle: 'padding: 15px;',
  61. width: '98%',
  62. border: true,
  63. defaults: {
  64. border: false,
  65. autoHeight: true,
  66. defaults: {
  67. border: false
  68. }
  69. },
  70. items: [{
  71. title: _('versionx.common.version-details'),
  72. items: [{
  73. id: 'versionx-panel-pluginsdetail-versioninfo',
  74. xtype: 'versionx-panel-common-detailpanel',
  75. vxRecord: config.vxRecord,
  76. vxRecordCmp: config.vxRecordCmp ? config.vxRecordCmp : undefined,
  77. vxFieldMap: [
  78. { key: 'version_id', lexicon:'versionx.version_id' },
  79. { key: 'user', lexicon:'user' },
  80. { key: 'saved', lexicon:'versionx.saved' },
  81. { key: 'mode', lexicon:'versionx.mode' }
  82. ]
  83. }]
  84. },{
  85. title: _('versionx.common.fields'),
  86. items: [{
  87. id: 'versionx-panel-pluginsdetail-plugin-fields',
  88. xtype: 'versionx-panel-common-detailpanel',
  89. vxRecord: config.vxRecord,
  90. vxRecordCmp: config.vxRecordCmp ? config.vxRecordCmp : undefined,
  91. vxFieldMap: [
  92. { key: 'name', lexicon:'name' },
  93. { key: 'description', lexicon:'description' },
  94. { key: 'category', lexicon:'category' }
  95. ]
  96. }]
  97. },{
  98. title: _('versionx.common.content'),
  99. items: [{
  100. id: 'versionx-panel-pluginsdetail-content',
  101. xtype: 'versionx-panel-common-contentpanel',
  102. border: false,
  103. vxRecord: config.vxRecord,
  104. vxRecordCmp: config.vxRecordCmp ? config.vxRecordCmp : undefined,
  105. vxContentField: 'plugincode'
  106. }]
  107. }/*,{
  108. title: _('versionx.common.properties'),
  109. tabTip: _('versionx.common.properties.off'),
  110. items: [],
  111. disabled: true
  112. }*/],
  113. stateful: true,
  114. stateId: config.id,
  115. stateEvents: ['tabchange'],
  116. getState: function() {
  117. return { activeTab:this.items.indexOf(this.getActiveTab()) };
  118. }
  119. }]
  120. }],
  121. listeners: {
  122. }
  123. });
  124. VersionX.panel.PluginsDetail.superclass.constructor.call(this,config);
  125. };
  126. Ext.extend(VersionX.panel.PluginsDetail,MODx.FormPanel,{
  127. compareVersion: function (tf) {
  128. var cmid = tf.getValue();
  129. var backTo = (MODx.request.backTo) ? '&backTo='+MODx.request.backTo : '';
  130. MODx.loadPage('?namespace=versionx&a=plugin&vid='+MODx.request['vid']+'&cmid='+cmid+backTo)
  131. },
  132. revertVersion: function(version) {
  133. if (version < 1) { MODx.alert(_('error'),'Version not properly defined: '+version); }
  134. MODx.msg.confirm({
  135. title: _('versionx.plugins.revert.confirm'),
  136. text: _('versionx.plugins.revert.confirm.text',{id: version}),
  137. url: VersionX.config.connector_url,
  138. params: {
  139. version_id: version,
  140. content_id: VersionX.record.content_id,
  141. action: 'mgr/plugins/revert'
  142. },
  143. listeners: {
  144. success: {fn: function() {
  145. MODx.msg.status({
  146. message: _('versionx.plugins.reverted'),
  147. delay: 4
  148. });
  149. }, scope: this }
  150. }
  151. });
  152. }
  153. });
  154. Ext.reg('versionx-panel-pluginsdetail',VersionX.panel.PluginsDetail);