Built files from Bizgaze WebServer
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ruleactions.widget.js 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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 RuleActions extends Platform.Core.BaseComponent {
  19. cssFiles() {
  20. return ["libs/querybuilder/query-builder.default.css"];
  21. }
  22. jsFiles() {
  23. return ["platform/automation/managers/rulemanager.js",
  24. "platform/automation/enums/executeactionstatus.js",
  25. "platform/automation/components/actions/actions.sms.js",
  26. "platform/automation/components/actions/actions.email.js",
  27. "platform/automation/components/actions/actions.notification.js",
  28. "platform/automation/components/actions/actions.task.js",
  29. "platform/automation/components/actions/actions.stagechange.js",
  30. "platform/automation/components/actions/actions.apiintegrator.js",
  31. "platform/automation/components/actions/actions.executequery.js",
  32. "platform/automation/enums/automationmode.js",
  33. "libs/querybuilder/query-builder.min.js",
  34. "libs/querybuilder/query-builder.standalone.js",
  35. "libs/querybuilder/sql-parser.min.js",
  36. "platform/datasources/components/datalistbuilder/querybuilder.js",
  37. "platform/forms/components/formviewer/formviewer.js",
  38. "libs/parsley/parsley.min.js"
  39. ];
  40. }
  41. html(id, containerid) {
  42. let html = ``;
  43. return html;
  44. }
  45. load(id, containerid, callback) {
  46. }
  47. init(containerid) {
  48. this.render(containerid);
  49. this.loadJsFiles();
  50. }
  51. render(containerid) {
  52. return __awaiter(this, void 0, void 0, function* () {
  53. $("." + containerid).empty();
  54. let html = `<form id="frmUnibase_RuleActions" data-validate="parsley" data-isdynamic="false">
  55. <div class="card bg-light m-0">
  56. <div class="b-b bg-white card-header">
  57. <strong class="biz-highlight-bg-color title" id="">Rule Actions</strong>
  58. <span class="badge badge-light badge-pill badge-outline span_ruleactions_count">0</span>
  59. </div>
  60. <div class="card-body scrollable p-0" style="height:100%;overflow-y:hidden scroll;">
  61. <table class="table m-0">
  62. <thead style="background: #EAECEE !important;">
  63. <tr>
  64. <th class="biz-list-header">Action Name</th>
  65. <th class="biz-list-header">Action Type</th>
  66. <th class="biz-list-header">Subject</th>
  67. <th></th>
  68. </tr>
  69. </thead>
  70. <tbody class="RuleActionslist_body bg-white text-dark font-14"></tbody>
  71. </table>
  72. </div>
  73. <div class="bg-white card-footer footer" id="RuleActionsFooter">
  74. </div>
  75. </div>
  76. </form>`;
  77. return yield $("." + containerid).append(html);
  78. });
  79. }
  80. loadJsFiles() {
  81. var jsfiles = Unibase.Platform.Automation.Components.RuleActions.Instance().jsFiles();
  82. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(jsfiles, function () {
  83. let RuleId = "";
  84. if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length > 0) {
  85. for (let obj of Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters) {
  86. if (obj.Key === "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_ruleid") {
  87. RuleId = obj.Value.toString();
  88. }
  89. }
  90. }
  91. if (Number(RuleId) != 0) {
  92. Unibase.Platform.Automation.Components.RuleActions.Instance().GetRuleActions(Number(RuleId));
  93. }
  94. });
  95. }
  96. GetRuleActions(RuleId) {
  97. Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleActions(RuleId).then(function (response) {
  98. if (response.length > 0) {
  99. $('.RuleActionslist_body').html('<tr class="RuleActionslist hidden"></tr>');
  100. var html = "";
  101. let RuleActions = response;
  102. for (var i = 0; i < RuleActions.length; i++) {
  103. let Status = RuleActions[i].ExecuteStatusId;
  104. let StatusName = "";
  105. let ChangeStatusName = "";
  106. let statusbadge = "";
  107. let ExecutedActionStatus;
  108. let Subject = RuleActions[i].BString1;
  109. if (Status == Number(Unibase.Platform.Automation.Enums.ExecuteActionStatus.Approved)) {
  110. StatusName = "Active";
  111. ChangeStatusName = "DeActivate";
  112. ExecutedActionStatus = Unibase.Platform.Automation.Enums.ExecuteActionStatus.Draft;
  113. statusbadge = "#fff";
  114. }
  115. else {
  116. StatusName = "InActive";
  117. ChangeStatusName = "Activate";
  118. ExecutedActionStatus = Unibase.Platform.Automation.Enums.ExecuteActionStatus.Approved;
  119. statusbadge = "#FFF1F1";
  120. }
  121. if (Subject == null) {
  122. Subject = "NA";
  123. }
  124. html = '<tr style="background:' + statusbadge + '"><td class="widget-list-item-main-title">' + RuleActions[i].RuleActionName + '</td><td>' + RuleActions[i].ActionName + '</td><td>' + Subject + '</td><td><div><a href="javascript:;" data-toggle="dropdown" class="no-caret dropdown-toggle pull-right biz-transparent-text-color" id="" aria-expanded="false"><i class="fa fa-ellipsis-h mr-20"></i></a><ul class="dropdown-menu pull-right clearfix"><li class="dropdown-menu-item hidden"></li><li id=""><a class="dropdown-item biz-transparent-text-color" href="javascript:;" id="" onclick="Unibase.Platform.Automation.Components.RuleActions.Instance().ChangeRuleActionStatus(' + RuleActions[i].RuleActionId + ',' + ExecutedActionStatus + ');">' + ChangeStatusName + '</a></li><li><a href="javascript:;" data-toggle="dropdown" class="dropdown-item biz-transparent-text-color" id="" onclick="Unibase.Platform.Automation.Components.RuleActions.Instance().EditRuleAction(' + RuleActions[i].RuleActionId + ',' + RuleActions[i].ActionId + ',' + RuleActions[i].RuleId + ',' + RuleActions[i].ParentActionId + ',`' + RuleActions[i].ActionName + '`);" aria-expanded="false">Edit</a></li></ul></div></td></tr>';
  125. $(".RuleActionslist:last").before(html);
  126. }
  127. $(".span_ruleactions_count").text(RuleActions.length);
  128. }
  129. else {
  130. $(".RuleActionslist_body").html('<div class="alert alert-primary text-center mb-0 border-0 rounded-0 w-100 ">No Records Found</div>');
  131. }
  132. });
  133. }
  134. ChangeRuleActionStatus(RuleActionId, Status) {
  135. Unibase.Platform.Automation.Managers.RuleManager.Instance().UpdateRuleActionStatus(RuleActionId, Status).then(function (response) {
  136. if (response.status == Unibase.Data.Status.Success) {
  137. MessageHelper.Instance().showSuccess(response.message, " ");
  138. Unibase.Platform.Automation.Components.RuleActions.Instance().GetRuleActions(response.result.RuleId);
  139. }
  140. });
  141. }
  142. EditRuleAction(RuleActionId, ActionId, RuleId, ParentActionId, ActionName) {
  143. Unibase.Platform.Automation.Managers.RuleManager.Instance().getRule(RuleId).then(function (ruleresponse) {
  144. if (ruleresponse != null) {
  145. Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleProvider(ruleresponse.RuleProviderId).then(function (ruleproviderresponse) {
  146. if (ruleproviderresponse != null) {
  147. let Action;
  148. if (ActionName == "Send Email") {
  149. Action = Unibase.Platform.Automation.Components.SendEmail.Instance();
  150. }
  151. else if (ActionName == "Send Sms") {
  152. Action = Unibase.Platform.Automation.Components.SendSms.Instance();
  153. }
  154. else if (ActionName == "Send Task") {
  155. Action = Unibase.Platform.Automation.Components.SendTask.Instance();
  156. }
  157. else if (ActionName == "Api Integration") {
  158. Action = Unibase.Platform.Automation.Components.ApiIntegrator.Instance();
  159. }
  160. else if (ActionName == "Execute Query") {
  161. Action = Unibase.Platform.Automation.Components.ExecuteQuery.Instance();
  162. }
  163. else if (ActionName == "Send Notification") {
  164. Action = Unibase.Platform.Automation.Components.SendNotification.Instance();
  165. }
  166. else if (ActionName == "Property Change") {
  167. Action = Unibase.Platform.Automation.Components.PropertyChange.Instance();
  168. }
  169. else if (ActionName == "Stage Change") {
  170. Action = Unibase.Platform.Automation.Components.StageChange.Instance();
  171. }
  172. Action.RuleProviderId = ruleproviderresponse.RuleProviderId;
  173. Action.ParentActionId = ParentActionId;
  174. Action.ActionId = ActionId;
  175. Action.RowIndex = 0;
  176. Action.RuleActionData = [];
  177. Action.IsAutomationMode = false;
  178. if (ruleresponse.AutomationModeId == Number(Unibase.Platform.Automation.Enums.AutomationMode.NormalMode)) {
  179. Action.AutomationMode = Unibase.Platform.Automation.Enums.AutomationMode.NormalMode;
  180. }
  181. else {
  182. Action.AutomationMode = Unibase.Platform.Automation.Enums.AutomationMode.AdvancedMode;
  183. }
  184. Unibase.Platform.Helpers.NavigationHelper.Instance().popup(RuleActionId, "", Action, null, Platform.Helpers.Size.DockLeft);
  185. }
  186. });
  187. }
  188. });
  189. }
  190. static Instance() {
  191. if (this.instance === undefined) {
  192. this.instance = new RuleActions();
  193. }
  194. return this.instance;
  195. }
  196. }
  197. Components.RuleActions = RuleActions;
  198. })(Components = Automation.Components || (Automation.Components = {}));
  199. })(Automation = Platform.Automation || (Platform.Automation = {}));
  200. })(Platform = Unibase.Platform || (Unibase.Platform = {}));
  201. })(Unibase || (Unibase = {}));