var Unibase; (function (Unibase) { let Platform; (function (Platform) { let Automation; (function (Automation) { let Components; (function (Components) { class RuleBuilder extends Platform.Core.BaseComponent { constructor() { super(...arguments); this.RuleFlow = []; } jsFiles() { var jsfiles = ["platform/automation/managers/rulemanager.js", "libs/notificationbuilder/notificationbuilder.js", "platform/automation/components/eventtemplate.js"]; return jsfiles; } cssFiles() { var cssfiles = ["libs/flowy/styles.css", "libs/notificationbuilder/notificationbuilder.css"]; return cssfiles; } html(id, containerid) { let html = `
DiscardSave Flow

`; return html; } load(id, containerid, callback) { var instance = this; $("#discard").click(function () { let ruleid = eval("bizgaze_automation_flow_main.getruleid()"); if (ruleid != 0) { bootbox.confirm("All items will be deleted, Do You Want To Continue?", function (result) { if (result) { $('.treebody').html(''); eval("bizgaze_automation_flow_main.getcloseadvmode()"); $('#' + containerid).modal('hide'); $('#' + containerid).remove(); } else { return; } }); } else { $('.treebody').html(''); eval("bizgaze_automation_flow_main.getcloseadvmode()"); $('#' + containerid).modal('hide'); $('#' + containerid).remove(); } }); $("#publish").click(function () { instance.SaveRuleFlow(containerid); }); Unibase.Platform.Automation.Components.RuleBuilder.Instance().loadinstalledappsfordrpdown(); if (id != 0) { Unibase.Platform.Automation.Components.RuleBuilder.Instance().EditRuleFlow(id); } else { eval("load()"); } } loadScript(url, callback) { let script = document.createElement("script"); script.type = "text/javascript"; if (script.readyState) { script.onreadystatechange = function () { if (script.readyState == "loaded" || script.readyState == "complete") { script.onreadystatechange = null; callback(); } }; } else { script.onload = function () { callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); } removejscssfile(filename, filetype) { var targetelement = (filetype == "js") ? "script" : (filetype == "css") ? "link" : "none"; var targetattr = (filetype == "js") ? "src" : (filetype == "css") ? "href" : "none"; var allsuspects = document.getElementsByTagName(targetelement); for (var i = allsuspects.length; i >= 0; i--) { if (allsuspects[i] && allsuspects[i].getAttribute(targetattr) != null && allsuspects[i].outerHTML.includes(filename)) { allsuspects[i].parentNode.removeChild(allsuspects[i]); } } } loadinstalledappsfordrpdown() { var url = _appsettings.server_url() + '/apis/v4/unibase/platform/apps/installedappautocomplete'; AutoCompleteHelper.getHelper().Create("#installedapp_dropdown", "#hf_Autocomplete_InstalledApp", url, function (response) { var data = response; }); } SearchBlocks() { var input, filter, div, subdiv, a, i; input = document.getElementById("SearchBlocks"); filter = input.value.toUpperCase(); div = document.getElementById("blocklist"); subdiv = div.getElementsByClassName("blockelem create-flowy noselect"); for (i = 0; i < subdiv.length; i++) { if (subdiv[i].firstElementChild.value.toUpperCase() == filter) { a = subdiv[i]; if (a.innerHTML.indexOf(filter) > -1) { subdiv[i].style.display = ""; } } else { a = subdiv[i]; if (a.firstElementChild.value.toUpperCase().indexOf(filter) > -1) { subdiv[i].style.display = ""; } else { subdiv[i].style.display = "none"; } } } } render(id, callback) { this.navigationHelper.popup(id, '', Unibase.Platform.Automation.Components.RuleBuilder.Instance(), null, Platform.Helpers.Size.ExtraLarge); } SaveRuleFlow(containerid) { let ruleid = eval("bizgaze_automation_flow_main.getruleid()"); let output = eval("bizgaze_automation_flow_main.output()"); let ruleflow = JSON.stringify(output); let model = new Unibase.Platform.Automation.Requests.Rule(); model.RuleId = eval("bizgaze_automation_flow_main.getruleid()"); model.RuleFlow = ruleflow; if (ruleflow != undefined && ruleid != 0) { Automation.Managers.RuleManager.Instance().saveRuleFlow(model).then(function (response) { if (response.status == Unibase.Data.Status.Error) { MessageHelper.Instance().showError(response.message, "Validate_RuleBuilder"); } else { MessageHelper.Instance().showSuccess(response.message, "Validate_RuleBuilder"); eval("bizgaze_automation_flow_main.getcloseadvmode()"); $('#' + containerid).modal('hide'); $('#' + containerid).remove(); Unibase.Platform.Helpers.NavigationHelper.Instance().loadDetail(ruleid, Unibase.Platform.Automation.Components.Rule.installedappid, null); } }); } else { MessageHelper.Instance().showError("Please Create Rule", "Validate_RuleBuilder"); } } EditRuleFlow(id) { Unibase.Platform.Automation.Managers.RuleManager.Instance().getRule(id).then(function (response) { eval("bizgaze_automation_flow_main.appendruleid('" + response.RuleId + "')"); eval("bizgaze_automation_flow_main.appendruleproviderid('" + response.RuleProviderId + "')"); Unibase.Platform.Automation.Components.RuleBuilder.Instance().RuleFlow = response.RuleFlow; eval(" bizgaze_automation_flow_main.import(" + response.RuleFlow + ")"); eval("load()"); }); } static Instance() { if (this.instance === undefined) { this.instance = new RuleBuilder(); } return this.instance; } } Components.RuleBuilder = RuleBuilder; })(Components = Automation.Components || (Automation.Components = {})); })(Automation = Platform.Automation || (Platform.Automation = {})); })(Platform = Unibase.Platform || (Unibase.Platform = {})); })(Unibase || (Unibase = {}));