forms-encryption.grid.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. FormIt.grid.FormsEncryption = function(config) {
  2. config = config || {};
  3. Ext.applyIf(config,{
  4. id: 'formit-grid-forms-encryption'
  5. ,url: FormIt.config.connectorUrl
  6. ,baseParams: {
  7. action: 'mgr/form/getlistsingle'
  8. }
  9. ,fields: ['form', 'encrypted', 'total']
  10. ,autoHeight: true
  11. ,paging: true
  12. ,remoteSort: true
  13. ,columns: [{
  14. header: _('formit.form')
  15. ,dataIndex: 'form'
  16. },{
  17. header: _('formit.encrypted')
  18. ,dataIndex: 'encrypted'
  19. ,width: 250
  20. },{
  21. header: _('formit.total')
  22. ,dataIndex: 'total'
  23. ,width: 250
  24. }]
  25. });
  26. FormIt.grid.FormsEncryption.superclass.constructor.call(this,config);
  27. };
  28. Ext.extend(FormIt.grid.FormsEncryption,MODx.grid.Grid,{
  29. windows: {}
  30. ,getMenu: function() {
  31. var m = [];
  32. if (FormIt.config.opensslAvailable &&
  33. this.menu.record.encrypted !== undefined &&
  34. this.menu.record.total !== undefined &&
  35. this.menu.record.encrypted < this.menu.record.total)
  36. {
  37. m.push({
  38. text: _('formit.form_encryptall')
  39. , handler: this.encryptAll
  40. });
  41. }
  42. if (this.menu.record.encrypted !== undefined &&
  43. this.menu.record.encrypted > 0) {
  44. m.push({
  45. text: _('formit.form_decryptall')
  46. , handler: this.decryptAll
  47. });
  48. }
  49. if (m.length > 0) {
  50. this.addContextMenuItem(m);
  51. }
  52. }
  53. ,encryptAll: function(btn,e) {
  54. if (!this.menu.record) return false;
  55. MODx.msg.confirm({
  56. title: _('formit.form_encrypt')
  57. ,text: _('formit.form_encrypt_confirm')
  58. ,url: FormIt.config.connectorUrl
  59. ,params: {
  60. action: 'mgr/form/encrypt'
  61. ,form: this.menu.record.form
  62. }
  63. ,listeners: {
  64. 'success': {fn:function(r) { this.refresh(); },scope:this}
  65. }
  66. });
  67. }
  68. ,decryptAll: function(btn,e) {
  69. if (!this.menu.record) return false;
  70. MODx.msg.confirm({
  71. title: _('formit.form_decrypt')
  72. ,text: _('formit.form_decrypt_confirm')
  73. ,url: FormIt.config.connectorUrl
  74. ,params: {
  75. action: 'mgr/form/decrypt'
  76. ,form: this.menu.record.form
  77. }
  78. ,listeners: {
  79. 'success': {fn:function(r) { this.refresh(); },scope:this}
  80. }
  81. });
  82. }
  83. });
  84. Ext.reg('formit-grid-forms-encryption',FormIt.grid.FormsEncryption);