templates.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. AdminTools.grid.TemplResources = function (config) {
  2. config = config || {};
  3. if (!config.id) {
  4. config.id = 'admintools-templresources-grid';
  5. }
  6. Ext.applyIf(config, {
  7. url: adminToolsSettings.config.connector_url,
  8. fields: this.getFields(config),
  9. columns: this.getColumns(config),
  10. baseParams: {
  11. action: 'mgr/resources/getlist',
  12. tid: MODx.request.id
  13. },
  14. listeners: {
  15. rowDblClick: function (grid, rowIndex, e) {
  16. var row = grid.store.getAt(rowIndex);
  17. }
  18. },
  19. viewConfig: {
  20. forceFit: true,
  21. enableRowBody: true,
  22. autoFill: true,
  23. showPreview: true,
  24. scrollOffset: 0,
  25. getRowClass: function (rec, ri, p) {
  26. return rec.data.deleted
  27. ? 'admintools-grid-row-disabled'
  28. : '';
  29. }
  30. },
  31. paging: true,
  32. remoteSort: true,
  33. autoHeight: true
  34. });
  35. AdminTools.grid.TemplResources.superclass.constructor.call(this, config);
  36. };
  37. Ext.extend(AdminTools.grid.TemplResources, MODx.grid.Grid, {
  38. windows: {},
  39. getFields: function (config) {
  40. return ['id', 'pagetitle', 'description', 'deleted' , 'published', 'context_key', 'uri'];
  41. },
  42. getColumns: function (config) {
  43. return [{
  44. header: "ID",
  45. dataIndex: 'id',
  46. fixed: true,
  47. sortable: true,
  48. width: 100
  49. }, {
  50. header: _('admintools_title'),
  51. dataIndex: 'pagetitle',
  52. sortable: true,
  53. width: 200
  54. }, {
  55. header: _('admintools_description'),
  56. dataIndex: 'description',
  57. sortable: false,
  58. width: 200
  59. }, {
  60. header: 'URI',
  61. dataIndex: 'uri',
  62. sortable: false,
  63. width: 100
  64. }, {
  65. header: _('admintools_context'),
  66. dataIndex: 'context_key',
  67. sortable: false,
  68. width: 70
  69. }, {
  70. header: _('admintools_published'),
  71. dataIndex: 'published',
  72. renderer: AdminTools.utils.renderBoolean,
  73. sortable: false,
  74. width: 70
  75. }, {
  76. header: _('admintools_deleted'),
  77. dataIndex: 'deleted',
  78. renderer: AdminTools.utils.renderBoolean,
  79. sortable: false,
  80. width: 70
  81. }];
  82. },
  83. getTopBar: function (config) {
  84. return [{
  85. text: '<i class="icon icon-plus"></i>&nbsp;' + _('admintools_create'),
  86. handler: this.createResource(),
  87. scope: this
  88. }];
  89. }
  90. });
  91. Ext.reg('admintools-templresources-grid', AdminTools.grid.TemplResources);
  92. /** ******************************** **/
  93. Ext.onReady(function () {
  94. MODx.addTab("modx-template-tabs",{
  95. id: "admintools-resources-tab",
  96. title: _('admintools_resources'),
  97. items: [{
  98. xtype: "admintools-templresources-grid",
  99. //html: "test",
  100. width: "100%"
  101. }]
  102. });
  103. });