window.settings.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. ClientConfig.window.Setting = function(config) {
  2. config = config || {};
  3. config.id = config.id || Ext.id(),
  4. Ext.applyIf(config,{
  5. title: (config.isUpdate) ?
  6. _('clientconfig.update_setting') :
  7. (config.isDuplicate) ? _('clientconfig.duplicate_setting') : _('clientconfig.add_setting'),
  8. autoHeight: true,
  9. url: ClientConfig.config.connectorUrl,
  10. baseParams: {
  11. action: (config.isUpdate) ?
  12. 'mgr/settings/update' :
  13. 'mgr/settings/create'
  14. },
  15. width: 750,
  16. fields: [{
  17. xtype: 'hidden',
  18. name: 'id'
  19. },{
  20. layout: 'column',
  21. items: [{
  22. columnWidth: 0.5,
  23. layout: 'form',
  24. items: [{
  25. xtype: 'textfield',
  26. name: 'key',
  27. fieldLabel: _('clientconfig.key') + '*',
  28. allowBlank: false,
  29. anchor: '100%'
  30. },{
  31. xtype: 'textfield',
  32. name: 'label',
  33. fieldLabel: _('clientconfig.label') + '*',
  34. allowBlank: false,
  35. anchor: '100%'
  36. },{
  37. xtype: 'textarea',
  38. name: 'description',
  39. fieldLabel: _('clientconfig.description'),
  40. anchor: '100%'
  41. },{
  42. xtype: 'clientconfig-combo-groups',
  43. name: 'group',
  44. fieldLabel: _('clientconfig.group'),
  45. anchor: '100%',
  46. autoLoad: true,
  47. storeLoadListener: function(store, data, request) {
  48. if (this.getValue() < 1) {
  49. this.setValue(store.getAt(0).get(this.valueField));
  50. }
  51. return true;
  52. }
  53. },{
  54. xtype: 'numberfield',
  55. name: 'sortorder',
  56. fieldLabel: _('clientconfig.sortorder'),
  57. allowBlank: false,
  58. minValue: 0,
  59. maxValue: 9999999999,
  60. anchor: '100%',
  61. value: 0
  62. }]
  63. },{
  64. columnWidth: 0.5,
  65. layout: 'form',
  66. items: [{
  67. xtype: 'clientconfig-combo-fieldtypes',
  68. name: 'xtype',
  69. fieldLabel: _('clientconfig.xtype') + '*',
  70. allowBlank: false,
  71. anchor: '100%',
  72. listeners: {
  73. select: {fn: function(field, record) {
  74. if (record.data.xtype == 'modx-combo') {
  75. Ext.getCmp(config.id + '-options').show();
  76. Ext.getCmp(config.id + '-process_options').show();
  77. } else {
  78. Ext.getCmp(config.id + '-options').hide();
  79. Ext.getCmp(config.id + '-process_options').hide();
  80. }
  81. if (['modx-panel-tv-image', 'modx-panel-tv-file'].indexOf(record.data.xtype) !== -1) {
  82. Ext.getCmp(config.id + '-source').show();
  83. } else {
  84. Ext.getCmp(config.id + '-source').hide();
  85. }
  86. }, scope: this}
  87. }
  88. },{
  89. xtype: (config.record && config.record.xtype && ['textarea', 'richtext'].indexOf(config.record.xtype) !== -1) ? 'textarea' : 'textfield',
  90. name: 'value',
  91. fieldLabel: _('clientconfig.value'),
  92. anchor: '100%'
  93. },{
  94. xtype: 'textarea',
  95. id: config.id + '-options',
  96. name: 'options',
  97. fieldLabel: _('clientconfig.options'),
  98. description: _('clientconfig.options.desc'),
  99. anchor: '100%',
  100. hidden: (config.record && (config.record.xtype === 'modx-combo')) ? false : true
  101. },{
  102. xtype: 'checkbox',
  103. id: config.id + '-process_options',
  104. name: 'process_options',
  105. boxLabel: _('clientconfig.process_options'),
  106. anchor: '100%'
  107. },{
  108. xtype: 'modx-combo-source',
  109. id: config.id + '-source',
  110. name: 'source',
  111. fieldLabel: _('clientconfig.source'),
  112. description: _('clientconfig.source.desc'),
  113. anchor: '100%',
  114. hidden: (config.record && (['modx-panel-tv-image', 'modx-panel-tv-file'].indexOf(config.record.xtype) !== -1)) ? false : true,
  115. hideMode: 'offsets',
  116. value: 0
  117. },{
  118. xtype: 'checkbox',
  119. name: 'is_required',
  120. boxLabel: _('clientconfig.is_required.long'),
  121. anchor: '100%'
  122. }]
  123. }]
  124. }],
  125. keys: [] //prevent enter in textarea from firing submit
  126. });
  127. ClientConfig.window.Setting.superclass.constructor.call(this,config);
  128. };
  129. Ext.extend(ClientConfig.window.Setting,MODx.Window);
  130. Ext.reg('clientconfig-window-setting',ClientConfig.window.Setting);