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 PropertyChange extends Platform.Core.BaseComponent { constructor() { super(...arguments); this.RowIndex = 0; this.RuleProviderId = 0; this.AutomationMode = 0; } jsFiles() { var jsfiles = ["platform/automation/managers/rulemanager.js", "platform/automation/enums/automationmode.js", "platform/automation/components/conditions.js", "platform/automation/components/contactselection.js", "platform/automation/requests/ruleaction.js", "platform/automation/requests/rulecondition.js", "platform/forms/components/formviewer/formviewer.js", "libs/parsley/parsley.min.js", "libs/querybuilder/query-builder.min.js", "libs/querybuilder/query-builder.standalone.min.js", "libs/querybuilder/query-builder.standalone.js", "libs/querybuilder/sql-parser.min.js", "libs/notificationbuilder/notificationbuilder.js", "platform/automation/components/rulebuilder/notificationgroup.js", "platform/automation/managers/notificationgroupmanager.js" ]; return jsfiles; } cssFiles() { return []; } html(id, containerid) { let html = `
Create PropertyChange
 
`; return html; } load(id, containerid, callback) { return __awaiter(this, void 0, void 0, function* () { var instance = this; Unibase.Platform.Automation.Components.PropertyChange.Instance().ActionId = instance.ActionId; Unibase.Platform.Automation.Components.PropertyChange.Instance().RuleActionData = instance.RuleActionData; Unibase.Platform.Automation.Components.PropertyChange.Instance().RowIndex = instance.RowIndex; Unibase.Platform.Automation.Components.PropertyChange.Instance().AutomationMode = instance.AutomationMode; Unibase.Platform.Automation.Components.PropertyChange.Instance().RuleProviderId = instance.RuleProviderId; Unibase.Platform.Automation.Components.PropertyChange.Instance().ParentActionId = instance.ParentActionId; Unibase.Platform.Automation.Components.PropertyChange.Instance().IsAutomationMode = instance.IsAutomationMode; yield Unibase.Platform.Automation.Components.NotificationGroup.Instance().LoadNotificationGroups(); $("#btnClosePropertyChange").click(function () { $('#' + containerid).modal('hide'); $('#' + containerid).remove(); if (Unibase.Platform.Automation.Components.PropertyChange.Instance().AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.NormalMode) { if (Unibase.Platform.Automation.Components.PropertyChange.Instance().AutomationMode) { if (Unibase.Platform.Automation.Components.PropertyChange.Instance().IsAutomationMode) { Unibase.Platform.Automation.Components.Rule.Instance().ChangeAction(instance.RowIndex, id); } } } Unibase.Platform.Automation.Components.Conditions.conditionArray = []; }); $("#btnSavePropertyChange").click(function () { let appcontrolid = "frmUnibase_PropertyChange"; let result = Unibase.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation(appcontrolid); if (result == false) { MessageHelper.Instance().showError("Mandatory fields are missing", "Validate_PropertyChnageAction"); return false; } else { Unibase.Platform.Automation.Components.PropertyChange.Instance().SavePropertyChange(id, containerid); } }); $("#ddl_PropertyChangeParameters").change(function () { var textAreaTxt = $("#txtPropertyChange_Parameter").val(); var txtToAdd = '{{' + $("#ddl_PropertyChangeParameters option:selected").text() + '}}'; $("#txtPropertyChange_Parameter").val(textAreaTxt + txtToAdd); $("#ddl_PropertyChangeParameters").val(0); }); if (id != "") { Unibase.Platform.Automation.Components.PropertyChange.Instance().EditPropertyChange(id); } let rpid = instance.RuleProviderId; if (rpid != 0) { Unibase.Platform.Automation.Components.PropertyChange.Instance().LoadPropertyChangeParameters(rpid); Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(rpid, null); } if (instance.RuleActionData.length != 0) { Unibase.Platform.Automation.Components.PropertyChange.Instance().LoadPropertyChangeData(instance.RuleActionData); } $('#creategrp_btn').click(function () { Unibase.Platform.Automation.Components.NotificationGroup.Instance().init(0, null, true); }); if (instance.ParentActionId != 0) { Unibase.Platform.Automation.Components.ContactSelection.Instance().getResultActions(instance.ParentActionId); yield Unibase.Platform.Automation.Components.PropertyChange.Instance().GetRuleActionInfo(Number(instance.ParentActionId)); $('#ddl_NotificationGrp').prop("disabled", true); $('#creategrp_btn').addClass('d-none'); } var url = _appsettings.server_url() + '/apis/v4/unibase/platform/apps/installedappautocomplete'; AutoCompleteHelper.getHelper().Create("#txtAutoComplete_InstalledApps", "#hf_Autocomplete_InstalledApps", url, function (response) { var data = response; }); $("#txtAutoComplete_InstalledApps").change(function () { Unibase.Platform.Automation.Components.PropertyChange.Instance().OnChangeInstalledApp(); }); $("#txtAutoComplete_AppDoctypes").change(function () { Unibase.Platform.Automation.Components.PropertyChange.Instance().OnChangeDoctype(); }); }); } OnChangeInstalledApp() { return __awaiter(this, void 0, void 0, function* () { $("#txtAutoComplete_AppDoctypes").val(0); var url = _appsettings.server_url() + '/apis/v4/unibase/platform/doctypes/appdoctypesautocomplete/installedappid/' + Number($("#txtAutoComplete_InstalledApps option:selected").val()); return yield AutoCompleteHelper.getHelper().Create("#txtAutoComplete_AppDoctypes", "#hf_Autocomplete_AppDoctypes", url, function (response) { var data = response; }); }); } OnChangeDoctype() { return __awaiter(this, void 0, void 0, function* () { $("#txtAutoComplete_DocProperties").val(0); var url = _appsettings.server_url() + '/apis/v4/unibase/platform/doctypes/docpropertiesautocomplete/doctypeid/' + Number($("#txtAutoComplete_AppDoctypes option:selected").val()); return yield AutoCompleteHelper.getHelper().Create("#txtAutoComplete_DocProperties", "#hf_Autocomplete_DocProperties", url, function (response) { var data = response; }); }); } TogglePropertyChangeConditions() { $("#ActionConditionsDiv").toggle(function () { $("#btn_ActionConditions").addClass("hidden"); $("#ActionConditionsDiv").removeClass("hidden"); Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.PropertyChange.Instance().RuleProviderId, null); }); } LoadPropertyChangeData(Data) { for (var i = 0; i < Data.length; i++) { $("#txtPropertyChange_RuleActionName").val(Data[i].RuleActionName); $("#txt_Property").val(Data[i].BString1); $("#txtPropertyChange_Parameter").val(Data[i].BString2); $("#txtAutoComplete_InstalledApps").append(Data[i].String1); $("#txtAutoComplete_AppDoctypes").append(Data[i].String2); $("#txtAutoComplete_DocProperties").append(Data[i].String3); let id = Number(Data[i].String1); Unibase.Platform.Apps.Managers.AppManager.Instance().getInstallApp(id).then(function (res) { var selectedappoption = new Option(res.result.AppTitle, res.result.InstalledAppId.toString(), true); $("#txtAutoComplete_InstalledApps").append(selectedappoption); }); let docid = Number(Data[i].String2); Unibase.Platform.DataSources.Managers.DocTypeManager.Instance().getDoctype(docid).then(function (docres) { var selecteddoctypeoption = new Option(docres.result.DocTypeName, docres.result.DocTypeId.toString(), true); $("#txtAutoComplete_AppDoctypes").append(selecteddoctypeoption); }); let docpropid = Number(Data[i].String3); Unibase.Platform.DataSources.Managers.DocTypeManager.Instance().getDocProperty(docpropid).then(function (docpropres) { var selecteddocpropoption = new Option(docpropres.result.DocPropertyName, docpropres.result.DocPropertyId.toString(), true); $("#txtAutoComplete_DocProperties").append(selecteddocpropoption); }); if (Data[i].ExecuteStatusId != Number(Unibase.Platform.Automation.Enums.ExecuteActionStatus.Approved)) $("#chkAutoApprovedPropertyChange").prop("checked", false); else $("#chkAutoApprovedPropertyChange").prop("checked", true); if (Data[i].SqlWhere != "" && Data[i].SqlWhere != null) { Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.PropertyChange.Instance().RuleProviderId, Data[i].SqlWhere); $("#btn_ActionConditions").addClass("hidden"); $("#ActionConditionsDiv").removeClass("hidden"); } $("#div_Parameter").addClass('floating-label-form-group-with-value'); eval('_floatingLabelHelper.init();'); } } LoadPropertyChangeParameters(ruleproviderid) { Unibase.Platform.Automation.Managers.RuleManager.Instance().getTokens(ruleproviderid).then(function (response) { let ApiParameters = document.getElementById('ddl_PropertyChangeParameters'); $('#ddl_PropertyChangeParameters').empty(); var defaultOpt1 = document.createElement("option"); defaultOpt1.text = "Select Token"; defaultOpt1.value = "0"; ApiParameters.appendChild(defaultOpt1); for (let i = 0; i <= response.length - 1; i++) { var opt = document.createElement("option"); opt.text = response[i]; opt.value = (i + 1).toString(); ApiParameters.appendChild(opt); } }); } EditPropertyChange(id) { let actionid = Number(id); $("#Spn_PropertyChange").text("Edit PropertyChange"); Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleAction(actionid).then(function (response) { $("#txtPropertyChange_RuleActionName").val(response.RuleActionName); $("#txtPropertyChange_Parameter").val(response.BString2); $("#txt_Property").val(response.BString1); $('#ddl_NotificationGrp option[value=' + response.NotificationGroupId + ']').prop('selected', true); if (!Unibase.Platform.Automation.Components.PropertyChange.Instance().IsAutomationMode) { Unibase.Platform.Automation.Components.PropertyChange.Instance().RuleId = response.RuleId; Unibase.Platform.Automation.Components.PropertyChange.Instance().RuleEventId = response.RuleEventId; Unibase.Platform.Automation.Components.PropertyChange.Instance().EventGroupId = response.EventGroupId; Unibase.Platform.Automation.Components.PropertyChange.Instance().ActionId = response.ActionId; Unibase.Platform.Automation.Components.PropertyChange.Instance().ParentActionId = response.ParentActionId; } if (response.ExecuteStatusId != Number(Unibase.Platform.Automation.Enums.ExecuteActionStatus.Approved)) $("#chkAutoApprovedPropertyChange").prop("checked", false); else $("#chkAutoApprovedPropertyChange").prop("checked", true); let id = Number(response.String1); Unibase.Platform.Apps.Managers.AppManager.Instance().getInstallApp(id).then(function (res) { var selectedappoption = new Option(res.result.AppTitle, res.result.InstalledAppId.toString(), true); $("#txtAutoComplete_InstalledApps").append(selectedappoption); }); let docid = Number(response.String2); Unibase.Platform.DataSources.Managers.DocTypeManager.Instance().getDoctype(docid).then(function (docres) { var selecteddoctypeoption = new Option(docres.result.DocTypeName, docres.result.DocTypeId.toString(), true); $("#txtAutoComplete_AppDoctypes").append(selecteddoctypeoption); }); let docpropid = Number(response.String3); Unibase.Platform.DataSources.Managers.DocTypeManager.Instance().getDocProperty(docpropid).then(function (docpropres) { var selecteddocpropoption = new Option(docpropres.result.DocPropertyName, docpropres.result.DocPropertyId.toString(), true); $("#txtAutoComplete_DocProperties").append(selecteddocpropoption); }); Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(response.RuleProviderId, response.SqlWhere); $("#btn_ActionConditions").addClass("hidden"); $("#ActionConditionsDiv").removeClass("hidden"); $("#div_Parameter").addClass('floating-label-form-group-with-value'); eval('_floatingLabelHelper.init();'); }); } GetRuleActionInfo(parentactionid) { return __awaiter(this, void 0, void 0, function* () { yield Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleAction(parentactionid).then(function (response) { if (response != null) { var html = ''; $('#ddl_NotificationGrp').html('').html(html); } }); }); } SavePropertyChange(PropertyChangeid, containerid) { let ruleactionid = Number(PropertyChangeid); let queryelmnt = $("#builder"); let model = new Unibase.Platform.Automation.Requests.RuleAction(); model.RuleActionId = ruleactionid; model.RuleActionName = $("#txtPropertyChange_RuleActionName").val().toString(); model.String1 = $("#txtAutoComplete_InstalledApps option:selected").val().toString(); model.String2 = $("#txtAutoComplete_AppDoctypes option:selected").val().toString(); model.String3 = $("#txtAutoComplete_DocProperties option:selected").val().toString(); model.BString1 = $("#txt_Property").val().toString(); model.BString2 = $("#txtPropertyChange_Parameter").val().toString(); model.ActionId = Unibase.Platform.Automation.Components.PropertyChange.Instance().ActionId; model.RuleId = 0; model.Users = ""; model.NotificationGroupId = $('#ddl_NotificationGrp').val() == undefined ? 0 : Number($('#ddl_NotificationGrp').val()); if (model.NotificationGroupId == 0) { MessageHelper.Instance().showError("Please Select Notification Group", "Validate_NotificationAction"); return; } let query = queryelmnt.queryBuilder('getSQL', false, true); if (query != null) { model.SqlWhere = queryelmnt.queryBuilder('getSQL', false, true).sql.replace(/\n/g, " ").replace(/LIKE/g, "ILIKE"); ; model.SqlWhereJson = JSON.stringify(queryelmnt.queryBuilder('getSQL', false, true)); } model.ResultActionId = Number($("#ddl_ResultAction option:selected").val()); if (model.ResultActionId != 0) { model.ResultActionName = $("#ddl_ResultAction option:selected").text(); } else { model.ResultActionName = ""; } model.DelayTime = 0; model.ParentActionId = Unibase.Platform.Automation.Components.PropertyChange.Instance().ParentActionId; model.AutoApproved = $('#chkAutoApprovedPropertyChange').is(':checked'); model.RowIndex = Unibase.Platform.Automation.Components.PropertyChange.Instance().RowIndex; if (Unibase.Platform.Automation.Components.PropertyChange.Instance().IsAutomationMode) { if (Unibase.Platform.Automation.Components.PropertyChange.Instance().AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.NormalMode) { Unibase.Platform.Automation.Components.Rule.Instance().RuleActionsArray(model); $('#' + containerid).modal('hide'); $('#' + containerid).remove(); Unibase.Platform.Automation.Components.Conditions.conditionArray = []; } else { model.RuleId = eval("bizgaze_automation_flow_main.getruleid()"); Automation.Managers.RuleManager.Instance().saveRuleAction(model).then(function (response) { if (response.status == Unibase.Data.Status.Error) { MessageHelper.Instance().showError(response.message, "Validate_PropertyChnageAction"); } else { MessageHelper.Instance().showSuccess(response.message, "Validate_PropertyChnageAction"); $('#' + containerid).modal('hide'); $('#' + containerid).remove(); Unibase.Platform.Automation.Components.Conditions.conditionArray = []; var actionname = response.result.RuleActionName; eval("bizgaze_automation_flow_main.savePropertyChangeblock('" + response.result.RuleActionId + "','" + actionname + "')"); } }); } } else { model.RuleId = Unibase.Platform.Automation.Components.PropertyChange.Instance().RuleId; model.EventGroupId = Unibase.Platform.Automation.Components.PropertyChange.Instance().EventGroupId; model.RuleEventId = Unibase.Platform.Automation.Components.PropertyChange.Instance().RuleEventId; model.ActionId = Unibase.Platform.Automation.Components.PropertyChange.Instance().ActionId; model.ParentActionId = Unibase.Platform.Automation.Components.PropertyChange.Instance().ParentActionId; Automation.Managers.RuleManager.Instance().saveRuleAction(model).then(function (response) { if (response.status == Unibase.Data.Status.Error) { MessageHelper.Instance().showError(response.message, "Validate_PropertyChnageAction"); } else { MessageHelper.Instance().showSuccess(response.message, "Validate_PropertyChnageAction"); $('#' + containerid).modal('hide'); $('#' + containerid).remove(); Unibase.Platform.Automation.Components.Conditions.conditionArray = []; } }); } } static Instance() { if (this.instance === undefined) { this.instance = new PropertyChange(); } return this.instance; } } Components.PropertyChange = PropertyChange; })(Components = Automation.Components || (Automation.Components = {})); })(Automation = Platform.Automation || (Platform.Automation = {})); })(Platform = Unibase.Platform || (Unibase.Platform = {})); })(Unibase || (Unibase = {}));