agents.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /**
  2. * Copyright (c) UNA, Inc - https://una.io
  3. * MIT License - https://opensource.org/licenses/MIT
  4. *
  5. * @defgroup UnaStudio UNA Studio
  6. * @{
  7. */
  8. function BxDolStudioPageAgents(oOptions)
  9. {
  10. BxDolStudioPage.call(this, oOptions);
  11. this.sPageUrl = oOptions.sPageUrl;
  12. this.sObjName = oOptions.sObjName == undefined ? 'oBxDolStudioPageAgents' : oOptions.sObjName;
  13. this.sActionUrlCmts = oOptions.sActionUrlCmts == undefined ? this.sActionUrl : oOptions.sActionUrlCmts;
  14. this.sActionUrlGrid = oOptions.sActionUrlGrid == undefined ? this.sActionUrl : oOptions.sActionUrlGrid;
  15. /*
  16. * Note. Are needed for Grid and don't used for now.
  17. *
  18. this.sObjNameGrid = oOptions.sObjNameGrid;
  19. this.sParamsDivider = oOptions.sParamsDivider == undefined ? '#-#' : oOptions.sParamsDivider;
  20. this.sTextSearchInput = oOptions.sTextSearchInput == undefined ? '' : oOptions.sTextSearchInput;
  21. */
  22. }
  23. BxDolStudioPageAgents.prototype = Object.create(BxDolStudioPage.prototype);
  24. BxDolStudioPageAgents.prototype.constructor = BxDolStudioPageAgents;
  25. BxDolStudioPageAgents.prototype.onChangeAutomatorType = function(oSelect) {
  26. var aHide = [];
  27. var aShow = [];
  28. switch($(oSelect).val()) {
  29. case 'event':
  30. aHide = []; //['scheduler_time'];
  31. aShow = []; //['alert_unit', 'alert_action'];
  32. break;
  33. case 'scheduler':
  34. aHide = []; //['alert_unit', 'alert_action'];
  35. aShow = []; //['scheduler_time'];
  36. break;
  37. default:
  38. aHide = []; //['alert_unit', 'alert_action', 'scheduler_time'];
  39. aShow = [];
  40. }
  41. var sHide = '';
  42. aHide.forEach((sItem) => {
  43. sHide += ".bx-form-advanced #bx-form-element-" + sItem + ",";
  44. });
  45. var sShow = '';
  46. aShow.forEach((sItem) => {
  47. sShow += ".bx-form-advanced #bx-form-element-" + sItem + ",";
  48. });
  49. $(sHide.substring(0, sHide.length - 1)).bx_anim('hide', this.sAnimationEffect, 0);
  50. $(sShow.substring(0, sShow.length - 1)).bx_anim('show', this.sAnimationEffect, 0);
  51. };
  52. BxDolStudioPageAgents.prototype.approveCode = function(oSource, iCmtId) {
  53. var $this = this;
  54. var oData = this._getDefaultData();
  55. oData = jQuery.extend({}, oData, {action: 'approveCode', Cmt: iCmtId});
  56. oSource = $(oSource);
  57. bx_loading_btn(oSource, true);
  58. jQuery.post (
  59. this.sActionUrlCmts,
  60. oData,
  61. function(oData) {
  62. bx_loading_btn(oSource, false);
  63. processJsonData(oData);
  64. },
  65. 'json'
  66. );
  67. };
  68. BxDolStudioPageAgents.prototype.providerAdd = function(oButton, sName) {
  69. var oButton = $(oButton);
  70. var oSubentry = oButton.parents('#bx-form-element-' + sName).find('.bx-form-input-provider:first').clone();
  71. oSubentry.find("select").val('');
  72. oSubentry.find("input[type = 'hidden']").remove();
  73. oButton.parents('.bx-form-input-provider-add:first').before(oSubentry);
  74. };
  75. BxDolStudioPageAgents.prototype.providerDelete = function(oButton) {
  76. $(oButton).parents('.bx-form-input-provider:first').remove();
  77. };
  78. BxDolStudioPageAgents.prototype.helperAdd = function(oButton, sName) {
  79. var oButton = $(oButton);
  80. var oSubentry = oButton.parents('#bx-form-element-' + sName).find('.bx-form-input-helper:first').clone();
  81. oSubentry.find("select").val('');
  82. oSubentry.find("input[type = 'hidden']").remove();
  83. oButton.parents('.bx-form-input-helper-add:first').before(oSubentry);
  84. };
  85. BxDolStudioPageAgents.prototype.helperDelete = function(oButton) {
  86. $(oButton).parents('.bx-form-input-helper:first').remove();
  87. };
  88. BxDolStudioPageAgents.prototype._getDefaultData = function() {
  89. var oDate = new Date();
  90. return jQuery.extend({}, this._oRequestParams, {_t:oDate.getTime()});
  91. };
  92. /** @} */