detailpanel.templatevars.js 8.1 KB

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