123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var Unibase;
- (function (Unibase) {
- let Platform;
- (function (Platform) {
- let Automation;
- (function (Automation) {
- let Components;
- (function (Components) {
- class RuleActions extends Platform.Core.BaseComponent {
- cssFiles() {
- return ["libs/querybuilder/query-builder.default.css"];
- }
- jsFiles() {
- return ["platform/automation/managers/rulemanager.js",
- "platform/automation/enums/executeactionstatus.js",
- "platform/automation/components/actions/actions.sms.js",
- "platform/automation/components/actions/actions.email.js",
- "platform/automation/components/actions/actions.notification.js",
- "platform/automation/components/actions/actions.task.js",
- "platform/automation/components/actions/actions.stagechange.js",
- "platform/automation/components/actions/actions.apiintegrator.js",
- "platform/automation/components/actions/actions.executequery.js",
- "platform/automation/enums/automationmode.js",
- "libs/querybuilder/query-builder.min.js",
- "libs/querybuilder/query-builder.standalone.js",
- "libs/querybuilder/sql-parser.min.js",
- "platform/datasources/components/datalistbuilder/querybuilder.js",
- "platform/forms/components/formviewer/formviewer.js",
- "libs/parsley/parsley.min.js"
- ];
- }
- html(id, containerid) {
- let html = ``;
- return html;
- }
- load(id, containerid, callback) {
- }
- init(containerid) {
- this.render(containerid);
- this.loadJsFiles();
- }
- render(containerid) {
- return __awaiter(this, void 0, void 0, function* () {
- $("." + containerid).empty();
- let html = `<form id="frmUnibase_RuleActions" data-validate="parsley" data-isdynamic="false">
- <div class="card bg-light m-0">
- <div class="b-b bg-white card-header">
- <strong class="biz-highlight-bg-color title" id="">Rule Actions</strong>
- <span class="badge badge-light badge-pill badge-outline span_ruleactions_count">0</span>
- </div>
- <div class="card-body scrollable p-0" style="height:100%;overflow-y:hidden scroll;">
- <table class="table m-0">
- <thead style="background: #EAECEE !important;">
- <tr>
- <th class="biz-list-header">Action Name</th>
- <th class="biz-list-header">Action Type</th>
- <th class="biz-list-header">Subject</th>
- <th></th>
- </tr>
- </thead>
- <tbody class="RuleActionslist_body bg-white text-dark font-14"></tbody>
- </table>
- </div>
- <div class="bg-white card-footer footer" id="RuleActionsFooter">
-
- </div>
- </div>
- </form>`;
- return yield $("." + containerid).append(html);
- });
- }
- loadJsFiles() {
- var jsfiles = Unibase.Platform.Automation.Components.RuleActions.Instance().jsFiles();
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(jsfiles, function () {
- let RuleId = "";
- if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length > 0) {
- for (let obj of Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters) {
- if (obj.Key === "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_ruleid") {
- RuleId = obj.Value.toString();
- }
- }
- }
- if (Number(RuleId) != 0) {
- Unibase.Platform.Automation.Components.RuleActions.Instance().GetRuleActions(Number(RuleId));
- }
- });
- }
- GetRuleActions(RuleId) {
- Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleActions(RuleId).then(function (response) {
- if (response.length > 0) {
- $('.RuleActionslist_body').html('<tr class="RuleActionslist hidden"></tr>');
- var html = "";
- let RuleActions = response;
- for (var i = 0; i < RuleActions.length; i++) {
- let Status = RuleActions[i].ExecuteStatusId;
- let StatusName = "";
- let ChangeStatusName = "";
- let statusbadge = "";
- let ExecutedActionStatus;
- let Subject = RuleActions[i].BString1;
- if (Status == Number(Unibase.Platform.Automation.Enums.ExecuteActionStatus.Approved)) {
- StatusName = "Active";
- ChangeStatusName = "DeActivate";
- ExecutedActionStatus = Unibase.Platform.Automation.Enums.ExecuteActionStatus.Draft;
- statusbadge = "#fff";
- }
- else {
- StatusName = "InActive";
- ChangeStatusName = "Activate";
- ExecutedActionStatus = Unibase.Platform.Automation.Enums.ExecuteActionStatus.Approved;
- statusbadge = "#FFF1F1";
- }
- if (Subject == null) {
- Subject = "NA";
- }
- 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>';
- $(".RuleActionslist:last").before(html);
- }
- $(".span_ruleactions_count").text(RuleActions.length);
- }
- else {
- $(".RuleActionslist_body").html('<div class="alert alert-primary text-center mb-0 border-0 rounded-0 w-100 ">No Records Found</div>');
- }
- });
- }
- ChangeRuleActionStatus(RuleActionId, Status) {
- Unibase.Platform.Automation.Managers.RuleManager.Instance().UpdateRuleActionStatus(RuleActionId, Status).then(function (response) {
- if (response.status == Unibase.Data.Status.Success) {
- MessageHelper.Instance().showSuccess(response.message, " ");
- Unibase.Platform.Automation.Components.RuleActions.Instance().GetRuleActions(response.result.RuleId);
- }
- });
- }
- EditRuleAction(RuleActionId, ActionId, RuleId, ParentActionId, ActionName) {
- Unibase.Platform.Automation.Managers.RuleManager.Instance().getRule(RuleId).then(function (ruleresponse) {
- if (ruleresponse != null) {
- Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleProvider(ruleresponse.RuleProviderId).then(function (ruleproviderresponse) {
- if (ruleproviderresponse != null) {
- let Action;
- if (ActionName == "Send Email") {
- Action = Unibase.Platform.Automation.Components.SendEmail.Instance();
- }
- else if (ActionName == "Send Sms") {
- Action = Unibase.Platform.Automation.Components.SendSms.Instance();
- }
- else if (ActionName == "Send Task") {
- Action = Unibase.Platform.Automation.Components.SendTask.Instance();
- }
- else if (ActionName == "Api Integration") {
- Action = Unibase.Platform.Automation.Components.ApiIntegrator.Instance();
- }
- else if (ActionName == "Execute Query") {
- Action = Unibase.Platform.Automation.Components.ExecuteQuery.Instance();
- }
- else if (ActionName == "Send Notification") {
- Action = Unibase.Platform.Automation.Components.SendNotification.Instance();
- }
- else if (ActionName == "Property Change") {
- Action = Unibase.Platform.Automation.Components.PropertyChange.Instance();
- }
- else if (ActionName == "Stage Change") {
- Action = Unibase.Platform.Automation.Components.StageChange.Instance();
- }
- Action.RuleProviderId = ruleproviderresponse.RuleProviderId;
- Action.ParentActionId = ParentActionId;
- Action.ActionId = ActionId;
- Action.RowIndex = 0;
- Action.RuleActionData = [];
- Action.IsAutomationMode = false;
- if (ruleresponse.AutomationModeId == Number(Unibase.Platform.Automation.Enums.AutomationMode.NormalMode)) {
- Action.AutomationMode = Unibase.Platform.Automation.Enums.AutomationMode.NormalMode;
- }
- else {
- Action.AutomationMode = Unibase.Platform.Automation.Enums.AutomationMode.AdvancedMode;
- }
- Unibase.Platform.Helpers.NavigationHelper.Instance().popup(RuleActionId, "", Action, null, Platform.Helpers.Size.DockLeft);
- }
- });
- }
- });
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new RuleActions();
- }
- return this.instance;
- }
- }
- Components.RuleActions = RuleActions;
- })(Components = Automation.Components || (Automation.Components = {}));
- })(Automation = Platform.Automation || (Platform.Automation = {}));
- })(Platform = Unibase.Platform || (Unibase.Platform = {}));
- })(Unibase || (Unibase = {}));
|