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 = `
Rule Actions 0
Action Name Action Type Subject
`; 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(''); 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 = '' + RuleActions[i].RuleActionName + '' + RuleActions[i].ActionName + '' + Subject + '
'; $(".RuleActionslist:last").before(html); } $(".span_ruleactions_count").text(RuleActions.length); } else { $(".RuleActionslist_body").html('
No Records Found
'); } }); } 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 = {}));