Built files from Bizgaze WebServer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rulebuilder.advrule.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  2. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3. return new (P || (P = Promise))(function (resolve, reject) {
  4. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  5. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  6. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  7. step((generator = generator.apply(thisArg, _arguments || [])).next());
  8. });
  9. };
  10. var Unibase;
  11. (function (Unibase) {
  12. let Platform;
  13. (function (Platform) {
  14. let Automation;
  15. (function (Automation) {
  16. let Components;
  17. (function (Components) {
  18. class AdvRule extends Platform.Core.BaseComponent {
  19. jsFiles() {
  20. var jsfiles = ["platform/automation/managers/rulemanager.js",
  21. "platform/datasources/managers/doctypemanager.js",
  22. "platform/analytics/managers/reportmanager.js",
  23. "platform/forms/managers/formmanager.js",
  24. "platform/automation/enums/eventtype.js",
  25. "platform/automation/enums/expop.js",
  26. "platform/automation/enums/automationmode.js",
  27. "platform/automation/enums/executeactionstatus.js",
  28. "platform/automation/components/conditions.js",
  29. "platform/automation/requests/rule.js",
  30. "platform/automation/requests/ruleevent.js",
  31. "platform/automation/requests/ruleaction.js",
  32. "platform/automation/requests/rulecondition.js",
  33. "platform/automation/components/rulebuilder/rulebuilder.condition.js",
  34. "platform/forms/components/formviewer/formviewer.js",
  35. "libs/parsley/parsley.min.js"
  36. ];
  37. return jsfiles;
  38. }
  39. cssFiles() {
  40. return [];
  41. }
  42. html(id, containerid) {
  43. let html = `<form id="frmUnibase_AdvRule" data-validate="parsley" data-isdynamic="false">
  44. <div class="card bg-light">
  45. <div class="b-b bg-white card-header header">
  46. <strong class="text-dark title" id="Form_AdvRule">Create Rule</strong>
  47. </div>
  48. <div class="card-body scrollable" style="overflow-y: scroll;">
  49. <div class="bg-white card" id="AdvRuleDetails">
  50. <div id="Validate_AdvRule" class="clear"></div>
  51. <div class="card-body">
  52. <div class="row">
  53. <div class="col-sm-12">
  54. <div class="floating-label-form-group">
  55. <label for="lbl_AdvRule" id="lbl_AdvRule">Rule Name<span class="text-danger">*</span></label>
  56. <input type="text" id="txt_AdvRule" class="form-control required value-control floating-label-control" data-isdynamic="false" placeholder="Rule Name*" data-placeholder="Enter Rule Name" data-label="Rule Name*" />
  57. <input type="hidden" id="hf_AdvRule" />
  58. <label for="Validation" id="lblValidation_AdvRule"></label>
  59. </div>
  60. </div>
  61. </div>
  62. <div class="row mt-10">
  63. <div class="col-sm-6">
  64. Installed App<span class="text-danger">*</span>
  65. <select id="Autocomplete_InstalledApp" class="required form-control value-control" data-isdynamic="true">
  66. </select>
  67. <input type="hidden" id="hf_Autocomplete_InstalledApp" value="" />
  68. </div>
  69. <div class="col-sm-6">
  70. Rule Provider<span class="text-danger">*</span>
  71. <select id="Autocomplete_RuleProvider" class="required form-control value-control" data-isdynamic="true">
  72. </select>
  73. <input type="hidden" id="hf_Autocomplete_RuleProvider" value="" />
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. <div class="bg-white card-footer footer" id="CreateAdvRuleFooter">
  80. <a href="javascript:;" id="btnCloseAdvRule" class="btn btn-light btn-sm mr-auto "> Close</a>
  81. <a href="javascript:;" id="btnSaveAdvRule" class="btn btn-primary btn-sm"> Save</a>
  82. </div>
  83. </div>
  84. </form>`;
  85. return html;
  86. }
  87. load(id, containerid, callback) {
  88. Unibase.Platform.Automation.Components.AdvRule.AutomationMode = Unibase.Platform.Automation.Enums.AutomationMode.AdvancedMode;
  89. $("#btnCloseAdvRule").click(function () {
  90. $('#' + containerid).modal('hide');
  91. $('#' + containerid).remove();
  92. });
  93. $("#btnSaveAdvRule").click(function () {
  94. let appcontrolid = "frmUnibase_AdvRule";
  95. let result = Unibase.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation(appcontrolid);
  96. if (result == false) {
  97. MessageHelper.Instance().showError("Mandatory fields are missing", "Validate_AdvRule");
  98. return false;
  99. }
  100. else {
  101. Unibase.Platform.Automation.Components.AdvRule.Instance().SaveRule(id, containerid);
  102. }
  103. });
  104. if (id != "") {
  105. Unibase.Platform.Automation.Components.AdvRule.Instance().EditRule(id);
  106. }
  107. var url = _appsettings.server_url() + '/apis/v4/unibase/platform/apps/installedappautocomplete';
  108. AutoCompleteHelper.getHelper().Create("#Autocomplete_InstalledApp", "#hf_Autocomplete_InstalledApp", url, function (response) {
  109. var data = response;
  110. });
  111. $("#Autocomplete_InstalledApp").change(function () {
  112. let InstalledappId = Number($("#Autocomplete_InstalledApp option:selected").val());
  113. var url = _appsettings.server_url() + '/apis/v4/unibase/notificationrule/platform/ruleprovidersautocomplete/InstalledAppId/' + InstalledappId;
  114. AutoCompleteHelper.getHelper().Create("#Autocomplete_RuleProvider", "hf_Autocomplete_RuleProvider", url, function (response) {
  115. var data = response;
  116. });
  117. });
  118. }
  119. SaveRule(id, containerid) {
  120. return __awaiter(this, void 0, void 0, function* () {
  121. let ruleid = Number(id);
  122. let model = new Unibase.Platform.Automation.Requests.Rule();
  123. model.RuleId = ruleid;
  124. model.RuleName = $("#txt_Rule").val().toString();
  125. model.RuleProviderId = Number($("#ddl_RuleProvider option:selected").val());
  126. model.AutomationModeId = Number(Unibase.Platform.Automation.Enums.AutomationMode.AdvancedMode);
  127. model.RuleType = Unibase.Platform.Automation.Enums.RuleType.Event;
  128. yield Automation.Managers.RuleManager.Instance().saveRule(model).then(function (response) {
  129. if (response.status == Unibase.Data.Status.Error) {
  130. MessageHelper.Instance().showError(response.message, "Validate_RuleEvent");
  131. }
  132. else {
  133. MessageHelper.Instance().showSuccess(response.message, "Validate_RuleEvent");
  134. eval("bizgaze_automation_flow_main.saveruleblock('" + response.result.RuleId + "','" + response.result.RuleName + "','" + response.result.RuleProviderId + "')");
  135. Components.RuleEvent.Instance().SaveRuleEvent(id, containerid);
  136. }
  137. });
  138. });
  139. }
  140. EditRule(id) {
  141. let ruleid = Number(id);
  142. $("#Form_AdvRule").text("Edit Rule");
  143. Unibase.Platform.Automation.Managers.RuleManager.Instance().getRule(ruleid).then(function (response) {
  144. let ruleid = response.RuleId;
  145. $("#hf_RuleProvider").val(response.RuleProviderId);
  146. $("#txt_AdvRule").val(response.RuleName);
  147. Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleProvider(response.RuleProviderId).then(function (response) {
  148. var installedappoption = new Option(response.AppTitle, response.InstalledAppId.toString(), true);
  149. $("#Autocomplete_InstalledApp").append(installedappoption);
  150. var ruleprovideroption = new Option(response.RuleProviderName, response.RuleProviderId.toString(), true);
  151. $("#Autocomplete_RuleProvider").append(ruleprovideroption);
  152. eval('_floatingLabelHelper.init();');
  153. });
  154. });
  155. }
  156. static Instance() {
  157. if (this.instance === undefined) {
  158. this.instance = new AdvRule();
  159. }
  160. return this.instance;
  161. }
  162. }
  163. AdvRule.AutomationMode = 0;
  164. Components.AdvRule = AdvRule;
  165. })(Components = Automation.Components || (Automation.Components = {}));
  166. })(Automation = Platform.Automation || (Platform.Automation = {}));
  167. })(Platform = Unibase.Platform || (Unibase.Platform = {}));
  168. })(Unibase || (Unibase = {}));