albums.grid.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. GAL.grid.Albums = function(config) {
  2. config = config || {};
  3. Ext.applyIf(config,{
  4. id: 'gal-grid-albums'
  5. ,url: GAL.config.connector_url
  6. ,baseParams: {
  7. action: 'mgr/album/getlist'
  8. }
  9. ,fields: ['id','name','description','items','menu']
  10. ,autoHeight: true
  11. ,paging: true
  12. ,remoteSort: true
  13. ,columns: [{
  14. header: _('id')
  15. ,dataIndex: 'id'
  16. ,width: 70
  17. },{
  18. header: _('name')
  19. ,dataIndex: 'name'
  20. ,width: 200
  21. },{
  22. header: _('description')
  23. ,dataIndex: 'description'
  24. ,width: 250
  25. },{
  26. header: _('gallery.items')
  27. ,dataIndex: 'items'
  28. ,width: 70
  29. }]
  30. ,tbar: [{
  31. text: _('gallery.album_create')
  32. ,cls: 'primary-button'
  33. ,handler: this.createAlbum
  34. ,scope: this
  35. }]
  36. });
  37. GAL.grid.Albums.superclass.constructor.call(this,config);
  38. };
  39. Ext.extend(GAL.grid.Albums,MODx.grid.Grid,{
  40. windows: {}
  41. ,createAlbum: function(btn,e) {
  42. if (!this.windows.createAlbum) {
  43. this.windows.createAlbum = MODx.load({
  44. xtype: 'gal-window-album-create'
  45. ,listeners: {
  46. 'success': {fn:function() { this.refresh(); },scope:this}
  47. }
  48. });
  49. }
  50. this.windows.createAlbum.fp.getForm().reset();
  51. this.windows.createAlbum.show(e.target);
  52. }
  53. ,updateAlbum: function(btn,e) {
  54. if (!this.menu.record || !this.menu.record.id) return false;
  55. location.href = '?a='+MODx.request.a+'&action=album/update'+'&album='+this.menu.record.id;
  56. }
  57. ,removeAlbum: function(btn,e) {
  58. if (!this.menu.record) return false;
  59. MODx.msg.confirm({
  60. title: _('gallery.album_remove')
  61. ,text: _('gallery.album_remove_confirm')
  62. ,url: this.config.url
  63. ,params: {
  64. action: 'mgr/album/remove'
  65. ,id: this.menu.record.id
  66. }
  67. ,listeners: {
  68. 'success': {fn:function(r) { this.refresh(); },scope:this}
  69. }
  70. });
  71. }
  72. });
  73. Ext.reg('gal-grid-albums',GAL.grid.Albums);
  74. GAL.window.CreateAlbum = function(config) {
  75. config = config || {};
  76. this.ident = config.ident || 'gcalb'+Ext.id();
  77. Ext.applyIf(config,{
  78. title: _('gallery.album_create')
  79. ,id: this.ident
  80. // ,height: 150
  81. // ,width: 475
  82. ,url: GAL.config.connector_url
  83. ,action: 'mgr/album/create'
  84. ,fields: [{
  85. xtype: 'textfield'
  86. ,fieldLabel: _('name')
  87. ,name: 'name'
  88. ,id: 'gal-'+this.ident+'-name'
  89. ,width: 300
  90. },{
  91. xtype: 'textarea'
  92. ,fieldLabel: _('description')
  93. ,name: 'description'
  94. ,id: 'gal-'+this.ident+'-description'
  95. ,width: 300
  96. },{
  97. xtype: 'textfield'
  98. ,fieldLabel: _('gallery.year')
  99. ,name: 'year'
  100. ,anchor: '100%'
  101. ,allowBlank: true
  102. },{
  103. xtype: 'checkbox'
  104. ,fieldLabel: _('gallery.active')
  105. ,name: 'active'
  106. ,id: 'gal-'+this.ident+'-active'
  107. ,checked: true
  108. ,inputValue: 1
  109. },{
  110. xtype: 'checkbox'
  111. ,fieldLabel: _('gallery.prominent')
  112. ,description: _('gallery.prominent_desc')
  113. ,name: 'prominent'
  114. ,id: 'gal-'+this.ident+'-prominent'
  115. ,checked: true
  116. ,inputValue: 1
  117. }]
  118. });
  119. GAL.window.CreateAlbum.superclass.constructor.call(this,config);
  120. };
  121. Ext.extend(GAL.window.CreateAlbum,MODx.Window);
  122. Ext.reg('gal-window-album-create',GAL.window.CreateAlbum);