column.window.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. collections.window.TemplateColumn = function(config) {
  2. config = config || {};
  3. Ext.applyIf(config,{
  4. title: _('collections.template.column.add')
  5. ,closeAction: 'close'
  6. ,isUpdate: false
  7. ,width: 600
  8. ,autoHeight: true
  9. ,url: collections.config.connectorUrl
  10. ,action: 'mgr/template/column/create'
  11. ,fields: this.getFields(config)
  12. });
  13. collections.window.TemplateColumn.superclass.constructor.call(this,config);
  14. };
  15. Ext.extend(collections.window.TemplateColumn,MODx.Window, {
  16. getLeftColumnFields: function (config) {
  17. return [{
  18. xtype: 'textfield'
  19. ,fieldLabel: _('collections.template.column.label')
  20. ,name: 'label'
  21. ,anchor: '100%'
  22. },{
  23. xtype: 'textfield'
  24. ,fieldLabel: _('collections.template.column.name')
  25. ,name: 'name'
  26. ,anchor: '100%'
  27. ,allowBlank: false
  28. ,readOnly: (config.record && config.record.name == 'id')
  29. ,cls: (config.record && config.record.name == 'id') ? 'x-item-disabled' : ''
  30. },{
  31. xtype: 'numberfield'
  32. ,allowNegative: false
  33. ,allowDecimals: false
  34. ,fieldLabel: _('collections.template.column.width')
  35. ,name: 'width'
  36. ,anchor: '100%'
  37. },{
  38. xtype: 'numberfield'
  39. ,allowNegative: false
  40. ,allowDecimals: false
  41. ,fieldLabel: _('collections.template.column.position')
  42. ,name: 'position'
  43. ,anchor: '100%'
  44. }];
  45. },
  46. getRightColumnFields: function (config) {
  47. return [{
  48. xtype: 'textfield'
  49. ,fieldLabel: _('collections.template.column.editor')
  50. ,name: 'editor'
  51. ,anchor: '100%'
  52. },{
  53. xtype: 'textfield'
  54. ,fieldLabel: _('collections.template.column.renderer')
  55. ,name: 'renderer'
  56. ,anchor: '100%'
  57. },{
  58. xtype: 'textfield'
  59. ,fieldLabel: _('collections.template.column.php_renderer')
  60. ,name: 'php_renderer'
  61. ,anchor: '100%'
  62. },{
  63. html: '<br />'
  64. },{
  65. layout: 'column'
  66. ,border: false
  67. ,anchor: '100%'
  68. ,defaults: {
  69. layout: 'form'
  70. ,labelAlign: 'top'
  71. ,labelSeparator: ''
  72. ,anchor: '100%'
  73. ,border: false
  74. }
  75. ,items: [{
  76. columnWidth:.5
  77. ,border: false
  78. ,defaults: {
  79. msgTarget: 'under'
  80. ,anchor: '100%'
  81. }
  82. ,items: [{
  83. xtype: 'xcheckbox'
  84. ,fieldLabel: _('collections.template.column.hidden')
  85. ,name: 'hidden'
  86. ,anchor: '100%'
  87. ,allowBlank: false
  88. }]
  89. },{
  90. columnWidth: .5
  91. ,border: false
  92. ,defaults: {
  93. msgTarget: 'under'
  94. ,anchor: '100%'
  95. }
  96. ,items: [{
  97. xtype: 'xcheckbox'
  98. ,fieldLabel: _('collections.template.column.sortable')
  99. ,name: 'sortable'
  100. ,anchor: '100%'
  101. ,allowBlank: false
  102. ,listeners: {
  103. check: function(t, checked) {
  104. var els = this.find('name', 'sort_type');
  105. if (els.length == 1) {
  106. if (checked) {
  107. els[0].show();
  108. } else {
  109. els[0].hide();
  110. }
  111. }
  112. }
  113. ,scope: this
  114. }
  115. }]
  116. }]
  117. },{
  118. xtype: 'collections-combo-sort-type'
  119. ,fieldLabel: _('collections.template.column.sort_type')
  120. ,name: 'sort_type'
  121. ,hiddenName: 'sort_type'
  122. ,hidden: config.record == undefined || !config.record.sortable
  123. ,anchor: '100%'
  124. ,hideMode:'offsets'
  125. }];
  126. },
  127. getFields: function(config) {
  128. return [{
  129. xtype: 'textfield'
  130. ,name: 'id'
  131. ,anchor: '100%'
  132. ,hidden: true
  133. },{
  134. xtype: 'textfield'
  135. ,name: 'template'
  136. ,hidden: true
  137. ,allowBlank: false
  138. },{
  139. layout: 'column'
  140. ,border: false
  141. ,anchor: '100%'
  142. ,defaults: {
  143. layout: 'form'
  144. ,labelAlign: 'top'
  145. ,labelSeparator: ''
  146. ,anchor: '100%'
  147. ,border: false
  148. }
  149. ,items: [{
  150. columnWidth:.5
  151. ,border: false
  152. ,defaults: {
  153. msgTarget: 'under'
  154. ,anchor: '100%'
  155. }
  156. ,items: this.getLeftColumnFields(config)
  157. },{
  158. columnWidth: .5
  159. ,border: false
  160. ,defaults: {
  161. msgTarget: 'under'
  162. ,anchor: '100%'
  163. }
  164. ,items: this.getRightColumnFields(config)
  165. }]
  166. }];
  167. }
  168. });
  169. Ext.reg('collections-window-template-column',collections.window.TemplateColumn);