modx.grid.context.settings.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /**
  2. * Loads a grid of Context Settings
  3. *
  4. * @class MODx.grid.ContextSettings
  5. * @extends MODx.grid.Grid
  6. * @param {Object} config An object of options.
  7. * @xtype modx-grid-context-settings
  8. */
  9. MODx.grid.ContextSettings = function(config) {
  10. config = config || {};
  11. Ext.applyIf(config,{
  12. title: _('context_settings')
  13. ,id: 'modx-grid-context-settings'
  14. ,url: MODx.config.connector_url
  15. ,baseParams: {
  16. action: 'context/setting/getList'
  17. ,context_key: config.context_key
  18. }
  19. ,saveParams: {
  20. context_key: config.context_key
  21. }
  22. ,fk: config.context_key
  23. ,save_action: 'context/setting/updatefromgrid'
  24. ,tbar: [{
  25. text: _('create_new')
  26. ,scope: this
  27. ,cls:'primary-button'
  28. ,handler: {
  29. xtype: 'modx-window-setting-create'
  30. ,url: MODx.config.connector_url
  31. ,baseParams: {
  32. action: 'context/setting/create'
  33. }
  34. ,keyField: {
  35. xtype: 'modx-combo-setting-key'
  36. ,fieldLabel: _('key')
  37. ,name: 'key'
  38. ,id: 'modx-cs-key'
  39. ,maxLength: 100
  40. ,anchor: '100%'
  41. ,listeners: {
  42. 'render': {
  43. fn: function(key) {
  44. key.getStore().baseParams.namespace = Ext.getCmp('modx-cs-namespace').getValue();
  45. Ext.getCmp('modx-cs-namespace').on('select', function(combo, item) {
  46. key.getStore().baseParams.namespace = item.data.name;
  47. key.getStore().load();
  48. }, this);
  49. }
  50. ,scope: this
  51. }
  52. }
  53. }
  54. ,fk: config.context_key
  55. }
  56. }]
  57. });
  58. MODx.grid.ContextSettings.superclass.constructor.call(this,config);
  59. };
  60. Ext.extend(MODx.grid.ContextSettings,MODx.grid.SettingsGrid, {
  61. removeSetting: function() {
  62. return this.remove('setting_remove_confirm', 'context/setting/remove');
  63. }
  64. ,updateSetting: function(btn,e) {
  65. var r = this.menu.record;
  66. r.fk = Ext.isDefined(this.config.fk) ? this.config.fk : 0;
  67. var uss = MODx.load({
  68. xtype: 'modx-window-setting-update'
  69. ,action: 'context/setting/update'
  70. ,record: r
  71. ,grid: this
  72. ,listeners: {
  73. 'success': {fn:function(r) {
  74. this.refresh();
  75. },scope:this}
  76. }
  77. });
  78. uss.reset();
  79. uss.setValues(r);
  80. uss.show(e.target);
  81. }
  82. });
  83. Ext.reg('modx-grid-context-settings',MODx.grid.ContextSettings);
  84. /**
  85. * Update a Context Setting
  86. *
  87. * @class MODx.window.UpdateContextSetting
  88. * @extends MODx.window.UpdateSetting
  89. * @param {Object} config An object of config properties
  90. * @xtype modx-window-context-setting-update
  91. */
  92. MODx.window.UpdateContextSetting = function(config) {
  93. config = config || {};
  94. var r = config.record;
  95. Ext.applyIf(config,{
  96. title: _('setting_update')
  97. ,action: 'context/setting/update'
  98. ,fk: r.context_key
  99. });
  100. MODx.window.UpdateContextSetting.superclass.constructor.call(this,config);
  101. };
  102. Ext.extend(MODx.window.UpdateContextSetting,MODx.window.UpdateSetting);
  103. Ext.reg('modx-window-context-setting-update',MODx.window.UpdateContextSetting);