detailpanel.v21.resources.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. VersionX.panel.ResourcesDetail.Main = function(config) {
  2. config = config || {};
  3. config.id = config.id || 'versionx-panel-resourcesdetail';
  4. Ext.apply(config,{
  5. border: false,
  6. layout: 'form',
  7. items: [{
  8. html: '<p>'+_('versionx.resources.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-resourceversions',
  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/resources/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.resources.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.resources.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.resources.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-resourcesdetail-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-resourcesdetail-resource-fields',
  88. xtype: 'versionx-panel-common-detailpanel',
  89. vxRecord: config.vxRecord,
  90. vxRecordCmp: config.vxRecordCmp ? config.vxRecordCmp : undefined,
  91. vxFieldMap: [
  92. { key: 'pagetitle', lexicon:'resource_pagetitle' },
  93. { key: 'longtitle', lexicon:'resource_longtitle' },
  94. { key: 'template', lexicon:'template' },
  95. { key: 'description', lexicon:'resource_description' },
  96. { key: 'alias', lexicon:'resource_alias' },
  97. { key: 'link_attributes', lexicon:'resource_link_attributes' },
  98. { key: 'introtext', lexicon:'resource_summary' },
  99. { key: 'parent', lexicon:'resource_parent' },
  100. { key: 'menutitle', lexicon:'resource_menutitle' },
  101. { key: 'menuindex', lexicon:'resource_menuindex' },
  102. { key: 'published', lexicon:'resource_published' },
  103. { key: 'hidemenu', lexicon:'resource_hide_from_menus' }
  104. ]
  105. }]
  106. },{
  107. title: _('versionx.common.content'),
  108. items: [{
  109. id: 'versionx-panel-resourcesdetail-content',
  110. xtype: 'versionx-panel-common-contentpanel',
  111. border: false,
  112. vxRecord: config.vxRecord,
  113. vxRecordCmp: config.vxRecordCmp ? config.vxRecordCmp : undefined,
  114. vxContentField: 'content'
  115. }]
  116. },{
  117. title: _('versionx.resources.detail.tabs.template-variables'),
  118. items: [{
  119. id: 'versionx-panel-resourcesdetail-tvs',
  120. xtype: 'versionx-panel-resourcesdetail-tvs',
  121. border: false,
  122. vxRecord: config.vxRecord,
  123. vxRecordCmp: config.vxRecordCmp ? config.vxRecordCmp : undefined
  124. }]
  125. },{
  126. title: _('versionx.resources.detail.tabs.page-settings'),
  127. items: [{
  128. id: 'versionx-panel-resourcesdetail-page-settings',
  129. xtype: 'versionx-panel-common-detailpanel',
  130. border: false,
  131. vxRecord: config.vxRecord,
  132. vxRecordCmp: config.vxRecordCmp ? config.vxRecordCmp : undefined,
  133. vxFieldMap: [
  134. { key: 'isfolder', lexicon:'resource_folder' },
  135. { key: 'richtext', lexicon:'resource_richtext' },
  136. { key: 'publishedon', lexicon:'resource_publishedon' },
  137. { key: 'pub_date', lexicon:'resource_publishdate' },
  138. { key: 'unpub_date', lexicon:'resource_unpublishdate' },
  139. { key: 'searchable', lexicon:'resource_searchable' },
  140. { key: 'cacheable', lexicon:'resource_cacheable' },
  141. { key: 'deleted', lexicon:'deleted' },
  142. { key: 'content_type', lexicon:'resource_content_type' },
  143. { key: 'content_dispo', lexicon:'resource_contentdispo' },
  144. { key: 'class_key', lexicon:'class_key' }
  145. ]
  146. }]
  147. }],
  148. stateful: true,
  149. stateId: config.id,
  150. stateEvents: ['tabchange'],
  151. getState: function() {
  152. return { activeTab:this.items.indexOf(this.getActiveTab()) };
  153. }
  154. }]
  155. }],
  156. listeners: {
  157. }
  158. });
  159. VersionX.panel.ResourcesDetail.Main.superclass.constructor.call(this,config);
  160. };
  161. Ext.extend(VersionX.panel.ResourcesDetail.Main,MODx.FormPanel,{
  162. compareVersion: function (tf) {
  163. var cmid = tf.getValue();
  164. var backTo = (MODx.request.backTo) ? '&backTo='+MODx.request.backTo : '';
  165. MODx.loadPage('?namespace=versionx&a=resource&vid='+MODx.request['vid']+'&cmid='+cmid+backTo)
  166. },
  167. revertVersion: function(version) {
  168. if (version < 1) { console.log('Version not properly defined: '+version); }
  169. MODx.msg.confirm({
  170. title: _('versionx.resources.revert.confirm'),
  171. text: _('versionx.resources.revert.confirm.text',{id: version}),
  172. url: VersionX.config.connector_url,
  173. params: {
  174. version_id: version,
  175. content_id: VersionX.record.content_id,
  176. action: 'mgr/resources/revert'
  177. },
  178. listeners: {
  179. success: {fn: function() {
  180. MODx.msg.status({
  181. message: _('versionx.resources.reverted'),
  182. delay: 4
  183. });
  184. }, scope: this }
  185. }
  186. });
  187. }
  188. });
  189. Ext.reg('versionx-panel-resourcesdetail',VersionX.panel.ResourcesDetail.Main);