OTRS API Reference JavaScript

Source: Core.Agent.Admin.MailAccount.js

  1. // --
  2. // Copyright (C) 2001-2018 OTRS AG, https://otrs.com/
  3. // --
  4. // This software comes with ABSOLUTELY NO WARRANTY. For details, see
  5. // the enclosed file COPYING for license information (GPL). If you
  6. // did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
  7. // --
  8. "use strict";
  9. var Core = Core || {};
  10. Core.Agent = Core.Agent || {};
  11. Core.Agent.Admin = Core.Agent.Admin || {};
  12. /**
  13. * @namespace Core.Agent.Admin.MailAccount
  14. * @memberof Core.Agent.Admin
  15. * @author OTRS AG
  16. * @description
  17. * This namespace contains the special module functions for MailAccount module.
  18. */
  19. Core.Agent.Admin.MailAccount = (function (TargetNS) {
  20. /**
  21. * @name MailAccountDelete
  22. * @memberof Core.Agent.Admin.MailAccount
  23. * @function
  24. * @description
  25. * Bind event on mail account delete button.
  26. */
  27. TargetNS.MailAccountDelete = function() {
  28. $('.MailAccountDelete').on('click', function () {
  29. var MailAccountDelete = $(this);
  30. Core.UI.Dialog.ShowContentDialog(
  31. $('#DeleteMailAccountDialogContainer'),
  32. Core.Language.Translate('Delete this Mail Account'),
  33. '240px',
  34. 'Center',
  35. true,
  36. [
  37. {
  38. Class: 'Primary',
  39. Label: Core.Language.Translate("Confirm"),
  40. Function: function() {
  41. $('.Dialog .InnerContent .Center').text(Core.Language.Translate("Deleting the mail account and its data. This may take a while..."));
  42. $('.Dialog .Content .ContentFooter').remove();
  43. Core.AJAX.FunctionCall(
  44. Core.Config.Get('Baselink'),
  45. MailAccountDelete.data('query-string'),
  46. function() {
  47. Core.App.InternalRedirect({
  48. Action: 'AdminMailAccount'
  49. });
  50. }
  51. );
  52. }
  53. },
  54. {
  55. Label: Core.Language.Translate("Cancel"),
  56. Function: function () {
  57. Core.UI.Dialog.CloseDialog($('#DeleteMailAccountDialog'));
  58. }
  59. }
  60. ]
  61. );
  62. return false;
  63. });
  64. };
  65. /*
  66. * @name Init
  67. * @memberof Core.Agent.Admin.MailAccount
  68. * @function
  69. * @description
  70. * This function registers onchange events for showing IMAP Folder and Queue field
  71. */
  72. TargetNS.Init = function () {
  73. // Show IMAP Folder selection only for IMAP backends
  74. $('select#TypeAdd, select#Type').on('change', function(){
  75. if (/IMAP/.test($(this).val())) {
  76. $('.Row_IMAPFolder').show();
  77. }
  78. else {
  79. $('.Row_IMAPFolder').hide();
  80. }
  81. }).trigger('change');
  82. // Show Queue field only if Dispatch By Queue is selected
  83. $('select#DispatchingBy').on('change', function(){
  84. if (/Queue/.test($(this).val())) {
  85. $('.Row_Queue').show();
  86. Core.UI.InputFields.Activate();
  87. }
  88. else {
  89. $('.Row_Queue').hide();
  90. }
  91. }).trigger('change');
  92. Core.UI.Table.InitTableFilter($("#FilterMailAccounts"), $("#MailAccounts"));
  93. TargetNS.MailAccountDelete();
  94. };
  95. Core.Init.RegisterNamespace(TargetNS, 'APP_MODULE');
  96. return TargetNS;
  97. }(Core.Agent.Admin.MailAccount || {}));

^ Use Elevator