var __awaiter=this&&this.__awaiter||function(n,t,i,r){function u(n){return n instanceof i?n:new i(function(t){t(n)})}return new(i||(i=Promise))(function(i,f){function o(n){try{e(r.next(n))}catch(t){f(t)}}function s(n){try{e(r["throw"](n))}catch(t){f(t)}}function e(n){n.done?i(n.value):u(n.value).then(o,s)}e((r=r.apply(n,t||[])).next())})},Unibase;(function(n){let t;(function(t){let i;(function(i){let r;(function(r){class u extends t.Core.BaseComponent{constructor(){super(...arguments);this.RowIndex=0;this.RuleProviderId=0;this.AutomationMode=0}jsFiles(){return["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"]}cssFiles(){return[]}html(){return`
Create PropertyChange
 
`}load(t,i){return __awaiter(this,void 0,void 0,function*(){var r=this,f;n.Platform.Automation.Components.PropertyChange.Instance().ActionId=r.ActionId;n.Platform.Automation.Components.PropertyChange.Instance().RuleActionData=r.RuleActionData;n.Platform.Automation.Components.PropertyChange.Instance().RowIndex=r.RowIndex;n.Platform.Automation.Components.PropertyChange.Instance().AutomationMode=r.AutomationMode;n.Platform.Automation.Components.PropertyChange.Instance().RuleProviderId=r.RuleProviderId;n.Platform.Automation.Components.PropertyChange.Instance().ParentActionId=r.ParentActionId;n.Platform.Automation.Components.PropertyChange.Instance().IsAutomationMode=r.IsAutomationMode;yield n.Platform.Automation.Components.NotificationGroup.Instance().LoadNotificationGroups();$("#btnClosePropertyChange").click(function(){$("#"+i).modal("hide");$("#"+i).remove();n.Platform.Automation.Components.PropertyChange.Instance().AutomationMode==n.Platform.Automation.Enums.AutomationMode.NormalMode&&n.Platform.Automation.Components.PropertyChange.Instance().AutomationMode&&n.Platform.Automation.Components.PropertyChange.Instance().IsAutomationMode&&n.Platform.Automation.Components.Rule.Instance().ChangeAction(r.RowIndex,t);n.Platform.Automation.Components.Conditions.conditionArray=[]});$("#btnSavePropertyChange").click(function(){let r=n.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation("frmUnibase_PropertyChange");if(r==!1)return MessageHelper.Instance().showError("Mandatory fields are missing","Validate_PropertyChnageAction"),!1;n.Platform.Automation.Components.PropertyChange.Instance().SavePropertyChange(t,i)});$("#ddl_PropertyChangeParameters").change(function(){var n=$("#txtPropertyChange_Parameter").val(),t="{{"+$("#ddl_PropertyChangeParameters option:selected").text()+"}}";$("#txtPropertyChange_Parameter").val(n+t);$("#ddl_PropertyChangeParameters").val(0)});t!=""&&n.Platform.Automation.Components.PropertyChange.Instance().EditPropertyChange(t);let u=r.RuleProviderId;u!=0&&(n.Platform.Automation.Components.PropertyChange.Instance().LoadPropertyChangeParameters(u),n.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(u,null));r.RuleActionData.length!=0&&n.Platform.Automation.Components.PropertyChange.Instance().LoadPropertyChangeData(r.RuleActionData);$("#creategrp_btn").click(function(){n.Platform.Automation.Components.NotificationGroup.Instance().init(0,null,!0)});r.ParentActionId!=0&&(n.Platform.Automation.Components.ContactSelection.Instance().getResultActions(r.ParentActionId),yield n.Platform.Automation.Components.PropertyChange.Instance().GetRuleActionInfo(Number(r.ParentActionId)),$("#ddl_NotificationGrp").prop("disabled",!0),$("#creategrp_btn").addClass("d-none"));f=_appsettings.server_url()+"/apis/v4/unibase/platform/apps/installedappautocomplete";AutoCompleteHelper.getHelper().Create("#txtAutoComplete_InstalledApps","#hf_Autocomplete_InstalledApps",f,function(n){var t=n});$("#txtAutoComplete_InstalledApps").change(function(){n.Platform.Automation.Components.PropertyChange.Instance().OnChangeInstalledApp()});$("#txtAutoComplete_AppDoctypes").change(function(){n.Platform.Automation.Components.PropertyChange.Instance().OnChangeDoctype()})})}OnChangeInstalledApp(){return __awaiter(this,void 0,void 0,function*(){$("#txtAutoComplete_AppDoctypes").val(0);var n=_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",n,function(n){var t=n})})}OnChangeDoctype(){return __awaiter(this,void 0,void 0,function*(){$("#txtAutoComplete_DocProperties").val(0);var n=_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",n,function(n){var t=n})})}TogglePropertyChangeConditions(){$("#ActionConditionsDiv").toggle(function(){$("#btn_ActionConditions").addClass("hidden");$("#ActionConditionsDiv").removeClass("hidden");n.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(n.Platform.Automation.Components.PropertyChange.Instance().RuleProviderId,null)})}LoadPropertyChangeData(t){for(var i=0;i"+n.NotificationGroupName+"<\/option>";$("#ddl_NotificationGrp").html("").html(t)}})})}SavePropertyChange(t,r){let e=Number(t),f=$("#builder"),u=new n.Platform.Automation.Requests.RuleAction;if(u.RuleActionId=e,u.RuleActionName=$("#txtPropertyChange_RuleActionName").val().toString(),u.String1=$("#txtAutoComplete_InstalledApps option:selected").val().toString(),u.String2=$("#txtAutoComplete_AppDoctypes option:selected").val().toString(),u.String3=$("#txtAutoComplete_DocProperties option:selected").val().toString(),u.BString1=$("#txt_Property").val().toString(),u.BString2=$("#txtPropertyChange_Parameter").val().toString(),u.ActionId=n.Platform.Automation.Components.PropertyChange.Instance().ActionId,u.RuleId=0,u.Users="",u.NotificationGroupId=$("#ddl_NotificationGrp").val()==undefined?0:Number($("#ddl_NotificationGrp").val()),u.NotificationGroupId==0){MessageHelper.Instance().showError("Please Select Notification Group","Validate_NotificationAction");return}let o=f.queryBuilder("getSQL",!1,!0);o!=null&&(u.SqlWhere=f.queryBuilder("getSQL",!1,!0).sql.replace(/\n/g," ").replace(/LIKE/g,"ILIKE"),u.SqlWhereJson=JSON.stringify(f.queryBuilder("getSQL",!1,!0)));u.ResultActionId=Number($("#ddl_ResultAction option:selected").val());u.ResultActionName=u.ResultActionId!=0?$("#ddl_ResultAction option:selected").text():"";u.DelayTime=0;u.ParentActionId=n.Platform.Automation.Components.PropertyChange.Instance().ParentActionId;u.AutoApproved=$("#chkAutoApprovedPropertyChange").is(":checked");u.RowIndex=n.Platform.Automation.Components.PropertyChange.Instance().RowIndex;n.Platform.Automation.Components.PropertyChange.Instance().IsAutomationMode?n.Platform.Automation.Components.PropertyChange.Instance().AutomationMode==n.Platform.Automation.Enums.AutomationMode.NormalMode?(n.Platform.Automation.Components.Rule.Instance().RuleActionsArray(u),$("#"+r).modal("hide"),$("#"+r).remove(),n.Platform.Automation.Components.Conditions.conditionArray=[]):(u.RuleId=eval("bizgaze_automation_flow_main.getruleid()"),i.Managers.RuleManager.Instance().saveRuleAction(u).then(function(t){if(t.status==n.Data.Status.Error)MessageHelper.Instance().showError(t.message,"Validate_PropertyChnageAction");else{MessageHelper.Instance().showSuccess(t.message,"Validate_PropertyChnageAction");$("#"+r).modal("hide");$("#"+r).remove();n.Platform.Automation.Components.Conditions.conditionArray=[];var i=t.result.RuleActionName;eval("bizgaze_automation_flow_main.savePropertyChangeblock('"+t.result.RuleActionId+"','"+i+"')")}})):(u.RuleId=n.Platform.Automation.Components.PropertyChange.Instance().RuleId,u.EventGroupId=n.Platform.Automation.Components.PropertyChange.Instance().EventGroupId,u.RuleEventId=n.Platform.Automation.Components.PropertyChange.Instance().RuleEventId,u.ActionId=n.Platform.Automation.Components.PropertyChange.Instance().ActionId,u.ParentActionId=n.Platform.Automation.Components.PropertyChange.Instance().ParentActionId,i.Managers.RuleManager.Instance().saveRuleAction(u).then(function(t){t.status==n.Data.Status.Error?MessageHelper.Instance().showError(t.message,"Validate_PropertyChnageAction"):(MessageHelper.Instance().showSuccess(t.message,"Validate_PropertyChnageAction"),$("#"+r).modal("hide"),$("#"+r).remove(),n.Platform.Automation.Components.Conditions.conditionArray=[])}))}static Instance(){return this.instance===undefined&&(this.instance=new u),this.instance}}r.PropertyChange=u})(r=i.Components||(i.Components={}))})(i=t.Automation||(t.Automation={}))})(t=n.Platform||(n.Platform={}))})(Unibase||(Unibase={}));