123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950 |
- 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 Rule extends Platform.Core.BaseComponent {
- constructor() {
- super(...arguments);
- this.RuleInstalledAppId = 0;
- this.CurrentEventIndex = 0;
- }
- jsFiles() {
- var jsfiles = ["platform/automation/managers/rulemanager.js",
- "platform/datasources/managers/doctypemanager.js",
- "platform/analytics/managers/reportmanager.js",
- "platform/forms/managers/formmanager.js",
- "platform/automation/enums/eventtype.js",
- "platform/automation/enums/ruletype.js",
- "platform/automation/enums/expop.js",
- "platform/automation/enums/automationmode.js",
- "platform/automation/enums/executeactionstatus.js",
- "platform/automation/components/conditions.js",
- "platform/automation/requests/rule.js",
- "platform/automation/requests/ruleevent.js",
- "platform/automation/requests/ruleaction.js",
- "platform/automation/requests/rulecondition.js",
- "platform/automation/components/rulebuilder/rulebuilder.condition.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",
- "platform/datasources/components/datalistbuilder/querybuilder.js",
- "platform/forms/components/formviewer/formviewer.js",
- "libs/parsley/parsley.min.js", "platform/automation/components/rulebuilder/rulebuilder.js"
- ];
- return jsfiles;
- }
- cssFiles() {
- var cssfiles = ["libs/querybuilder/query-builder.default.css"];
- return cssfiles;
- }
- html(id, containerid) {
- let html = `<form id="frmUnibase_Rule" data-validate="parsley" data-isdynamic="false">
- <div class="card bg-light">
- <div class="b-b bg-white card-header header">
- <strong class="text-dark title" id="Form_Rule">Create Rule</strong>
- <span class="pull-right" id="ModeType">
- <a href="javascript:;" id="link_AdvancedMode" class="pull-right">Advanced Mode</a>
- <a href="javascript:;" id="link_NormalMode" class="pull-right hidden">Normal Mode</a>
- </span>
- </div>
- <div class="card-body scrollable" style="overflow-y: scroll;">
- <div id="Validate_Rule" class="clear"></div>
- <div class="row">
- <div class="col-sm-3" id="InstalledAppsList">
- <div id="Search" class="mb-15 mt-1">
- <input type="text" id="txt_Search" onkeyup="Unibase.Platform.Automation.Components.Rule.Instance().SearchBlocks();" class="form-control value-control floating-label-control" placeholder="Search App">
- </div>
- <div id="txt_noresults" class="hidden" style="text-align:center;">No Results Found</div>
- </div>
- <div class="col-sm-9 hidden" id="RuleSection">
- <div class="bg-white card" id="RuleDetails">
- <div class="card-body">
- <div class="row">
- <div class="col-sm-12">
- <div class="floating-label-form-group">
- <label for="lbl_Rule" id="lbl_Rule">Rule Name<span class="text-danger">*</span></label>
- <input type="text" id="txt_Rule" class="form-control required value-control floating-label-control" data-isdynamic="false" placeholder="Rule Name*" data-placeholder="Enter Rule Name" data-label="Rule Name*" />
- <input type="hidden" id="hf_Rule" />
- <label for="Validation" id="lblValidation_Rule"></label>
- </div>
- </div>
- <div class="col-sm-12">
- Rule Provider<span class="text-danger">*</span>
- <select id="ddl_RuleProvider" class="required form-control value-control" data-isdynamic="true">
- </select>
- <input type="hidden" id="hf_RuleProvider" value="" />
- </div>
- </div>
- </div>
- </div>
- <div class="bg-white card hidden" id="EventModeEvent">
- <div class="card-header">When</div>
- <div class="card-body">
- <div class="row" id="AddEvents">
- <div class="card col-sm-4">
- <div class="card-body">Order Created</div>
- </div>
- </div>
- <div class="row pull-right">
- <button type="button" id="btn_EventNames" class="btn btn-primary" onclick="Unibase.Platform.Automation.Components.Rule.Instance().ToggleEventNames();">Show More</button>
- </div>
- </div>
- </div>
- <div class="bg-white card hidden" id="NormalModeEvent">
- <div class="card-header">
- When
- <span class="pull-right" id="AddEvent">
- <a id="" title="Create" onclick="Unibase.Platform.Automation.Components.Rule.Instance().AddEvent();">
- <i class="fa fa-plus"></i>
- </a>
- </span>
- </div>
- <div class="card-body" id="MultipleEvents">
- <div class="ml-5" id="AddNewEvents">
- <!--- <div class="row eventrow" id="row_0">
- <lable class="hidden" id="EventGroupId_0">0</lable>
- <lable class="hidden" id="RuleActionId_0">0</lable>
- <div class="col-sm-2 mt-10"><label>When </label></div>
- <div class="col-sm-3 mt-10" id="ELable_0" onclick="Unibase.Platform.Automation.Components.Rule.Instance().ToggleEventColumnLable(0);">
- <u><b style="font-weight: bold;" id="EventColumnLable_0"></b></u>
- </div>
- <div class="col-sm-3 hidden" id="EAutocomplete_0">
- <div id="div_EventColumns" class="floating-label-form-group" style="border-bottom:0;"><input type="hidden" class="event_name_0">
- <select id="select2_EventColumns_0" class="select2_0_EventColumns required value-control form-control text-control" multiple="multiple" style="width:100%;" onchange="Unibase.Platform.Automation.Components.Rule.Instance().OnChangeEventColumn(0);"></select>
- <input type="hidden" id="hfSelect2Id_EventColumns_0" value="0" class="form-control text-control" data-isdynamic="true" />
- <input type="hidden" id="hfId_EventColumns" value=""><label for="Validation" id="lblValidation_EventColumns"></label>
- </div>
- </div>
- <div class="col-sm-1 mt-10"><label id="Event_0"></label></div>
- <div class="col-sm-1 mt-10"><label>Then </label></div>
- <div class="col-sm-3 mt-10" id="ALable_0" onclick="Unibase.Platform.Automation.Components.Rule.Instance().ToggleActions(0);"><u><b style="font-weight: bold;" class="" id="ActionLable_0"></b></u></div>
- <div class="col-sm-3 hidden" id="AAutocomplete_0">
- <div class="floating-label-form-group floating-label-form-group-with-value focus">
- <select id="Action_Autocomplete_0" onchange="Unibase.Platform.Automation.Components.Rule.Instance().OnChangeActions(0);" style="-webkit-appearance: none;" class="required form-control value-control" data-isdynamic="true">
- </select>
- <input type="hidden" value="0" id="hf_Action_0" />
- </div>
- </div>
- <div class="col-sm-1 mt-10"><a href="javascript:;" id="link_Configure"><i class="fa fa-cog"></i></a></div>
- <div class="col-sm-1 mt-10"><a id="delete_0" title="Delete" style="cursor:pointer" onclick="Unibase.Platform.Automation.Components.Rule.Instance().DeleteEventGroupRow(0,0);"><i class="fa fa-close"></i></a></div>
- </div>---->
- </div>
- </div>
- </div>
- <div class="bg-white card" id="btn_Conditions">
- <button type="button" class="btn btn-primary" onclick="Unibase.Platform.Automation.Components.Rule.Instance().ToggleGlobalConditions();">Conditions</button>
- </div>
- <div class="bg-white card hidden" id="ConditionDetailsDiv">
- <div class="card-header">Global Condition Details</div>
- <div class="card-body">
- <div class="ConditionDetails">
-
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="bg-white card-footer footer" id="CreateRuleFooter">
- <a href="javascript:;" id="btnCloseRule" class="btn btn-light btn-sm mr-auto "> Close</a>
- <a href="javascript:;" id="btnSaveRule" class="btn btn-primary btn-sm"> Save</a>
- </div>
- </div>
- </form>`;
- return html;
- }
- load(id, containerid, callback) {
- Unibase.Platform.Automation.Components.Rule.AutomationMode = Unibase.Platform.Automation.Enums.AutomationMode.NormalMode;
- Unibase.Platform.Automation.Components.Rule.Instance().GetActions();
- Unibase.Platform.Automation.Components.Rule.RuleId = id;
- Unibase.Platform.Automation.Components.Rule.Instance().default_event();
- $("#btnCloseRule").click(function () {
- $('#' + containerid).modal('hide');
- $('#' + containerid).remove();
- Unibase.Platform.Automation.Components.Rule.keysindex = 0;
- Unibase.Platform.Automation.Components.Rule.keyscount = 0;
- Unibase.Platform.Automation.Components.Rule.keysflag = 0;
- Unibase.Platform.Automation.Components.Rule.RuleId = 0;
- Unibase.Platform.Automation.Components.Rule.ActionsArray = [];
- Unibase.Platform.Automation.Components.Rule.EventColumnData = [];
- Unibase.Platform.Automation.Components.Rule.RuleActionsData = [];
- Unibase.Platform.Automation.Components.RuleCondition.ruleConditionArray = [];
- });
- $("#btnSaveRule").click(function () {
- let appcontrolid = "frmUnibase_Rule";
- let result = Unibase.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation(appcontrolid);
- if (result == false) {
- MessageHelper.Instance().showError("Mandatory fields are missing", "Validate_Rule");
- $(".eventrow").each(function () {
- let id = $(this).find(".eventrow");
- let index = (id.prevObject[0].id).split('_');
- index = index[1];
- let eventcolumns = $("#select2_EventColumns_" + index + "").val();
- if (eventcolumns.length == 0) {
- $("#EventColumnLable_" + index + "").addClass('form-group-required');
- }
- });
- return false;
- }
- else {
- Unibase.Platform.Automation.Components.Rule.Instance().SaveRule(id, containerid);
- }
- });
- $("#link_AdvancedMode").click(function () {
- $("#link_NormalMode").removeClass("hidden");
- $("#link_AdvancedMode").addClass("hidden");
- $('#' + containerid).modal('hide');
- $('#' + containerid).remove();
- Unibase.Platform.Automation.Components.Rule.Instance().AdvancedMode(id, containerid);
- });
- $("#link_NormalMode").click(function () {
- $("#link_NormalMode").addClass("hidden");
- $("#link_AdvancedMode").removeClass("hidden");
- });
- $("#InstalledAppsList").height($(window).outerHeight() - 90).css("overflow", "hidden auto");
- $("#Action_Autocomplete").change(function () {
- $("#ALable").removeClass('hidden');
- $("#AAutocomplete").addClass('hidden');
- $("#ActionLable").text($('#Action_Autocomplete option:selected').text());
- });
- let rule = Unibase.Platform.Automation.Components.Rule.Instance();
- $("#ddl_RuleProvider").change(function () {
- $("#NormalModeEvent").removeClass("hidden");
- $('#AddNewEvents').html('');
- Unibase.Platform.Automation.Components.Rule.EventColumnData = [];
- Unibase.Platform.Automation.Components.Rule.Instance().default_event();
- rule.loadEventColomns();
- rule.loadActions(0);
- rule.loadQueryBuilder(Number($("#ddl_RuleProvider option:selected").val()), null);
- });
- rule.LoadInstalledApps();
- rule.loadActions(0);
- if (id != "") {
- Unibase.Platform.Automation.Components.Rule.Instance().EditRule(id, containerid);
- }
- }
- loadForm(FormId, Pk_Value, AppConfigurationId, Callback, ElementId) {
- Rule.Instance().init(Pk_Value, null);
- Unibase.Platform.Apps.Managers.AppManager.Instance().getAppConfiguration(AppConfigurationId).then(function (response) {
- Unibase.Platform.Automation.Components.Rule.installedappid = response.result.InstalledAppId;
- });
- }
- loadNotificationRule(iscreate) {
- var Pk_Value = 0;
- if (!iscreate) {
- Pk_Value = Unibase.Themes.Providers.DetailHelper.recordId;
- }
- this.navigationHelper.popup(Pk_Value, '', Unibase.Platform.Automation.Components.Rule.Instance(), null, Platform.Helpers.Size.DockLeft);
- }
- init(id, callback) {
- this.render(id, callback);
- }
- render(id, callback) {
- this.navigationHelper.popup(id, '', Unibase.Platform.Automation.Components.Rule.Instance(), null, Platform.Helpers.Size.DockLeft);
- }
- GetActions() {
- Unibase.Platform.Automation.Managers.RuleManager.Instance().getActions().then(function (response) {
- for (var i = 0; i <= response.length - 1; i++) {
- Unibase.Platform.Automation.Components.Rule.ActionsArray.push(response[i]);
- }
- });
- }
- OnChangeEventColumn(index) {
- let eventcolumnscount = new Array();
- eventcolumnscount = $("#select2_EventColumns_" + index + "").val();
- if (eventcolumnscount.length > 0) {
- $("#ELable_" + index + "").removeClass('hidden');
- $("#EAutocomplete_" + index + "").addClass('hidden');
- $("#EventColumnLable_" + index + "").text(Unibase.Platform.Automation.Components.Rule.Instance().GetEventColumns(index));
- $('.event_name_' + index + '').val('').val(Unibase.Platform.Automation.Components.Rule.Instance().GetEventColumns(index));
- }
- }
- OnChangeActions(index) {
- $("#ALable_" + index + "").removeClass('hidden');
- $("#AAutocomplete_" + index + "").addClass('hidden');
- $("#ActionLable_" + index + "").text($('#Action_Autocomplete_' + index + ' option:selected').text());
- $("#ActionLable_" + index + "").removeClass('form-group-required');
- var _fileCacheHelper = Platform.Helpers.FileCacheHelper.Instance();
- let id = Number($("#RuleActionId_" + index + "").text());
- let actionid = Number($('#Action_Autocomplete_' + index + ' option:selected').val());
- let ruleproviderid = Number($("#ddl_RuleProvider option:selected").val());
- var instance = this;
- if (!$("#ConditionDetailsDiv").hasClass("hidden")) {
- Unibase.Platform.Automation.Components.Rule.Instance().SaveQueryString();
- }
- else {
- let queryelmnt = $("#builder");
- queryelmnt.queryBuilder('destroy');
- $("#QueryBuilder").remove();
- }
- Unibase.Platform.Automation.Managers.RuleManager.Instance().getAction(actionid).then(function (response) {
- if (response != null) {
- _fileCacheHelper.loadJsFile(response.JsUrl, function () {
- var namespace = eval(response.JsVariableName);
- var action = new namespace();
- action.RuleProviderId = ruleproviderid;
- action.RowIndex = index;
- action.ActionId = response.ActionId;
- action.RuleActionData = Unibase.Platform.Automation.Components.Rule.RuleActionsData.filter(X => X.RowIndex == index);
- action.AutomationMode = Unibase.Platform.Automation.Components.Rule.AutomationMode;
- action.IsAutomationMode = true;
- action.ParentActionId = 0;
- instance.navigationHelper.popup(id, '', action, function () {
- }, Platform.Helpers.Size.Auto);
- });
- }
- });
- }
- default_event() {
- var html = `<div class="row eventrow" id="row_0">
- <lable class="hidden" id="EventGroupId_0">0</lable>
- <lable class="hidden" id="RuleActionId_0">0</lable>
- <div class="col-sm-2 mt-10"><label>When </label></div>
- <div class="col-sm-3 mt-10" id="ELable_0" onclick="Unibase.Platform.Automation.Components.Rule.Instance().ToggleEventColumnLable(0);">
- <u><b style="font-weight: bold;" id="EventColumnLable_0"></b></u>
- </div>
- <div class="col-sm-3 hidden" id="EAutocomplete_0">
- <div id="div_EventColumns" class="floating-label-form-group" style="border-bottom:0;"><input type="hidden" class="event_name_0">
- <select id="select2_EventColumns_0" class="select2_0_EventColumns required value-control form-control text-control" multiple="multiple" style="width:100%;" onchange="Unibase.Platform.Automation.Components.Rule.Instance().OnChangeEventColumn(0);"></select>
- <input type="hidden" id="hfSelect2Id_EventColumns_0" value="0" class="form-control text-control" data-isdynamic="true" />
- <input type="hidden" id="hfId_EventColumns" value=""><label for="Validation" id="lblValidation_EventColumns"></label>
- </div>
- </div>
- <div class="col-sm-1 mt-10"><label id="Event_0"></label></div>
- <div class="col-sm-1 mt-10"><label>Then </label></div>
- <div class="col-sm-3 mt-10" id="ALable_0" onclick="Unibase.Platform.Automation.Components.Rule.Instance().ToggleActions(0);"><u><b style="font-weight: bold;" class="" id="ActionLable_0"></b></u></div>
- <div class="col-sm-3 hidden" id="AAutocomplete_0">
- <div class="floating-label-form-group floating-label-form-group-with-value focus">
- <select id="Action_Autocomplete_0" onchange="Unibase.Platform.Automation.Components.Rule.Instance().OnChangeActions(0);" style="-webkit-appearance: none;" class="required form-control value-control" data-isdynamic="true">
- </select>
- <input type="hidden" value="0" id="hf_Action_0" />
- </div>
- </div>
- <div class="col-sm-1 mt-10"><a href="javascript:;" id="link_Configure"><i class="fa fa-cog"></i></a></div>
- <div class="col-sm-1 mt-10"><a id="delete_0" title="Delete" style="cursor:pointer" onclick="Unibase.Platform.Automation.Components.Rule.Instance().DeleteEventGroupRow(0,0);"><i class="fa fa-close"></i></a></div>
- </div>`;
- $('#AddNewEvents').append(html);
- }
- ToggleEventNames() {
- if ($("#btn_EventNames").text() == "Show More") {
- $("[id='EventCard']").show();
- $("#btn_EventNames").text("Show Less");
- }
- else {
- $("[id='EventCard']").hide();
- $("#btn_EventNames").text("Show More");
- }
- }
- ToggleGlobalConditions() {
- $("#ConditionDetailsDiv").toggle(function () {
- $("#btn_Conditions").addClass("hidden");
- $("#ConditionDetailsDiv").removeClass("hidden");
- Unibase.Platform.Automation.Components.Rule.Instance().loadQueryBuilder(Number($("#ddl_RuleProvider option:selected").val()), null);
- });
- }
- loadEventColomns() {
- return __awaiter(this, void 0, void 0, function* () {
- var instance = this;
- let ruleproviderid = Number($("#ddl_RuleProvider option:selected").val());
- if (ruleproviderid != 0) {
- return yield Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleProvider(ruleproviderid).then(function (response) {
- Unibase.Platform.Automation.Components.Rule.EventColumnData.push({ id: response.DoctypeName + " Created", text: response.DoctypeName + " Created" });
- Unibase.Platform.Automation.Components.Rule.EventColumnData.push({ id: response.DoctypeName + " Deleted", text: response.DoctypeName + " Deleted" });
- return Unibase.Platform.DataSources.Managers.DocTypeManager.Instance().getDocProperties(response.DoctypeId).then(function (response) {
- let result = response.result;
- for (let i = 0; i < result.length; i++) {
- var EventColumn = result[i];
- Unibase.Platform.Automation.Components.Rule.EventColumnData.push({ id: result[i].PropColumnName + " Changed", text: result[i].PropColumnName + " Changed" });
- }
- Unibase.Platform.Automation.Components.Rule.Instance().BindEventColumns(0);
- });
- });
- }
- });
- }
- BindEventColumns(index) {
- return __awaiter(this, void 0, void 0, function* () {
- $("#EventColumnLable_" + index + "").text(Unibase.Platform.Automation.Components.Rule.EventColumnData[0].id);
- $('.event_name_' + index + '').val('').val(Unibase.Platform.Automation.Components.Rule.EventColumnData[0].id);
- $("#select2_EventColumns_" + index + "").select2({
- placeholder: 'Select',
- data: Unibase.Platform.Automation.Components.Rule.EventColumnData,
- });
- });
- }
- loadActions(index) {
- return __awaiter(this, void 0, void 0, function* () {
- return yield Unibase.Platform.Automation.Managers.RuleManager.Instance().getActions().then(function (response) {
- let cmbActions = document.getElementById('Action_Autocomplete_' + index + '');
- $('#Action_Autocomplete_' + index + '').empty();
- var defaultOpt1 = document.createElement("option");
- defaultOpt1.text = "Select";
- defaultOpt1.value = "0";
- cmbActions.appendChild(defaultOpt1);
- for (let i = 0; i <= response.length - 1; i++) {
- var opt = document.createElement("option");
- opt.text = response[i].ActionName;
- opt.value = response[i].ActionId.toString();
- cmbActions.appendChild(opt);
- }
- $("#Action_Autocomplete_" + index + "").val(Number($("#hf_Action_" + index + "").val()));
- $("#ActionLable_" + index + "").text($("#Action_Autocomplete_" + index + " option:selected").text());
- });
- });
- }
- ToggleEventColumnLable(index) {
- $("#ELable_" + index + "").addClass('hidden');
- $("#EAutocomplete_" + index + "").removeClass('hidden');
- $("#EventColumnLable_" + index + "").removeClass('form-group-required');
- }
- ToggleActions(index) {
- var instance = this;
- instance.CurrentEventIndex = index;
- $("#ALable_" + index + "").addClass('hidden');
- $("#AAutocomplete_" + index + "").removeClass('hidden');
- if ($("#ActionLable_" + index + "").text() != "Select" && $("#ActionLable_" + index + "").text() != "") {
- Unibase.Platform.Automation.Components.Rule.Instance().OnChangeActions(index);
- }
- }
- SaveRule(id, containerid) {
- let ruleid = Number(id);
- let eventgroupdata = [];
- if (!$("#ConditionDetailsDiv").hasClass("hidden")) {
- Unibase.Platform.Automation.Components.Rule.Instance().SaveQueryString();
- }
- let eventsarr = Rule.Instance().EventArray();
- for (let i = 0; i < eventsarr.length; i++) {
- eventgroupdata.push({
- EventGroupId: eventsarr[i].EventGroupId,
- RuleId: eventsarr[i].RuleId,
- RuleEventData: eventsarr[i].RuleEventData,
- RuleActionData: eventsarr[i].RuleActionData,
- RuleConditionData: eventsarr[i].RuleConditionData,
- RuleData: eventsarr[i].RuleData,
- RuleType: eventsarr[i].RuleType
- });
- }
- let model = new Unibase.Platform.Automation.Requests.Rule();
- model.RuleId = ruleid;
- model.RuleName = $("#txt_Rule").val().toString();
- model.RuleProviderId = Number($("#ddl_RuleProvider option:selected").val());
- if (Unibase.Platform.Automation.Components.Rule.QueryString != null) {
- model.SqlWhere = Unibase.Platform.Automation.Components.Rule.QueryString;
- model.SqlWhereJson = JSON.stringify(Unibase.Platform.Automation.Components.Rule.QueryString);
- }
- else {
- model.SqlWhere = '';
- model.SqlWhereJson = '';
- }
- model.EventGroupData = eventgroupdata;
- model.RuleType = Unibase.Platform.Automation.Enums.RuleType.Event;
- model.AutomationModeId = Number(Unibase.Platform.Automation.Components.Rule.AutomationMode);
- Automation.Managers.RuleManager.Instance().saveRule(model).then(function (response) {
- if (response.status == Unibase.Data.Status.Error) {
- MessageHelper.Instance().showError(response.message, "Validate_Rule");
- }
- else {
- MessageHelper.Instance().showSuccess(response.message, "Validate_Rule");
- Unibase.Platform.Automation.Components.Rule.ActionsArray = [];
- Unibase.Platform.Automation.Components.Rule.keysindex = 0;
- Unibase.Platform.Automation.Components.Rule.keyscount = 0;
- Unibase.Platform.Automation.Components.Rule.RuleId = 0;
- Unibase.Platform.Automation.Components.Rule.keysflag = 0;
- Unibase.Platform.Automation.Components.Rule.EventColumnData = [];
- Unibase.Platform.Automation.Components.Rule.RuleActionsData = [];
- Unibase.Platform.Automation.Components.RuleCondition.ruleConditionArray = [];
- $('#' + containerid).modal('hide');
- $('#' + containerid).remove();
- Unibase.Platform.Helpers.NavigationHelper.Instance().loadDetail(response.result.RuleId, Unibase.Platform.Automation.Components.Rule.installedappid, null);
- }
- });
- }
- EditRule(id, containerid) {
- $('#txt_search').attr("disabled", "true");
- $('#ddl_RuleProvider').attr("disabled", "true");
- $('#txt_Rule').attr("disabled", "true");
- let ruleid = Number(id);
- $("#Form_Rule").text("Edit Rule");
- Unibase.Platform.Automation.Managers.RuleManager.Instance().getRule(ruleid).then(function (response) {
- if (response.AutomationModeId == Number(Unibase.Platform.Automation.Enums.AutomationMode.NormalMode)) {
- let ruleid = response.RuleId;
- $("#hf_RuleProvider").val(response.RuleProviderId);
- $("#txt_Rule").val(response.RuleName);
- Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleProvider(response.RuleProviderId).then(function (response) {
- Unibase.Platform.Automation.Components.Rule.Instance().SelectedApp(response.InstalledAppId).then(function () {
- Unibase.Platform.Automation.Components.Rule.Instance().LoadEvents(ruleid);
- Unibase.Platform.Automation.Components.Rule.Instance().RuleInstalledAppId = Number(response.InstalledAppId);
- });
- });
- if (response.SqlWhere != "" && response.SqlWhere != null) {
- $("#btn_Conditions").addClass("hidden");
- $("#ConditionDetailsDiv").removeClass("hidden");
- }
- Unibase.Platform.Automation.Components.Rule.Instance().loadQueryBuilder(response.RuleProviderId, response.SqlWhere);
- }
- else {
- Unibase.Platform.Automation.Components.Rule.Instance().AdvancedMode(response.RuleId, containerid);
- }
- eval('_floatingLabelHelper.init();');
- });
- }
- LoadInstalledApps() {
- Unibase.Platform.Automation.Managers.RuleManager.Instance().getInstalledApps().then(function (response) {
- for (let i = 0; i <= response.length - 1; i++) {
- let html = '<div class="AppRow bg-white card" onclick="Unibase.Platform.Automation.Components.Rule.Instance().SelectedApp(' + response[i].InstalledAppId + ');" id ="div_' + response[i].InstalledAppId + '">' +
- '<div class="card-body">' +
- '<div class="row">' +
- '<div class="col-sm-12">' +
- '<span>' + response[i].AppTitle + '</span>' +
- '</div></div></div></div>';
- $("#InstalledAppsList").append(html);
- html = "";
- }
- });
- }
- LoadAppStages() {
- return __awaiter(this, void 0, void 0, function* () {
- var html = '';
- var installeappid = Unibase.Platform.Automation.Components.Rule.Instance().RuleInstalledAppId;
- yield Unibase.Platform.Apps.Managers.StageManager.Instance().getStages(installeappid).then(function (response) {
- if (response.result != null) {
- for (let i = 0; i < response.result.length; i++) {
- var data = response.result[i];
- html += '<option value=' + data.StageId + '>' + data.StageName + '<option>';
- }
- }
- });
- return html;
- });
- }
- IsStageChangeEvent() {
- var eventname = null;
- if (Unibase.Platform.Automation.Components.Rule.AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.AdvancedMode) {
- var ischildaction = eval('bizgaze_automation_flow_main.IsChildAction()');
- if (ischildaction) {
- return false;
- }
- eventname = $('.event_name').val() == undefined ? null : $('.event_name').val().toString();
- return (eventname == null) ? false : eventname.includes("stageid Changed");
- }
- else {
- var index = Unibase.Platform.Automation.Components.Rule.Instance().CurrentEventIndex;
- eventname = $('.event_name_' + index + '').val() == undefined ? null : $('.event_name_' + index + '').val().toString();
- return (eventname == null) ? false : eventname.includes("stageid Changed");
- }
- }
- SelectedApp(id) {
- return __awaiter(this, void 0, void 0, function* () {
- $(".AppRow").removeAttr("style");
- $("#div_" + id + "").css("border", " 2px solid blue");
- let InstalledappId = Number(id);
- Unibase.Platform.Automation.Components.Rule.Instance().RuleInstalledAppId = Number(InstalledappId);
- var url = _appsettings.server_url() + '/apis/v4/unibase/notificationrule/platform/ruleprovidersautocomplete/InstalledAppId/' + InstalledappId;
- yield Unibase.Platform.Automation.Managers.RuleManager.Instance().loadRuleProviders(id).then(function (response) {
- if (response.length != 0) {
- $("#RuleSection").removeClass("hidden");
- let cmbRuleProviders = document.getElementById('ddl_RuleProvider');
- $('#ddl_RuleProvider').empty();
- var defaultOpt1 = document.createElement("option");
- defaultOpt1.text = "Select";
- defaultOpt1.value = "";
- cmbRuleProviders.appendChild(defaultOpt1);
- for (let i = 0; i <= response.length - 1; i++) {
- var opt = document.createElement("option");
- opt.text = response[i].RuleProviderName;
- opt.value = (response[i].RuleProviderId).toString();
- cmbRuleProviders.appendChild(opt);
- }
- if ($("#hf_RuleProvider").val() == "") {
- $("#ddl_RuleProvider").val(null);
- }
- else {
- $("#ddl_RuleProvider").val(Number($("#hf_RuleProvider").val()));
- }
- return Unibase.Platform.Automation.Components.Rule.Instance().loadEventColomns();
- }
- else {
- MessageHelper.Instance().showError("No RuleProvider Configured For The Selected App.", "Validate_Rule");
- }
- });
- });
- }
- DeleteEventGroupRow(index, EventGroupId) {
- var text = confirm("Are you sure! You want to delete?");
- if (text) {
- if (EventGroupId != 0) {
- Unibase.Platform.Automation.Managers.RuleManager.Instance().deleteEventGroup(EventGroupId).then(function (response) {
- if (response.status == Unibase.Data.Status.Error) {
- MessageHelper.Instance().showError(response.message, "Validate_Rule");
- }
- else {
- $("#row_" + index).remove();
- }
- });
- }
- else {
- $("#row_" + index).remove();
- }
- }
- }
- AddEvent() {
- let PrevActionIndex = Unibase.Platform.Automation.Components.Rule.keysindex - 0;
- if ($("#ActionLable_" + PrevActionIndex).text() != "Select") {
- Unibase.Platform.Automation.Components.Rule.keysflag = 0;
- let html = "";
- let RuleEventId = 0;
- let RuleActionId = 0;
- let EventGroupId = 0;
- if (!Unibase.Platform.Automation.Components.Rule.keyscount) {
- Unibase.Platform.Automation.Components.Rule.keysindex = Unibase.Platform.Automation.Components.Rule.keysindex + 1;
- }
- else {
- Unibase.Platform.Automation.Components.Rule.keysindex = Unibase.Platform.Automation.Components.Rule.keyscount;
- }
- html += '<div class="row eventrow" id="row_' + Unibase.Platform.Automation.Components.Rule.keysindex + '">' +
- '<lable class="hidden" id="EventGroupId_' + Unibase.Platform.Automation.Components.Rule.keysindex + '">' + RuleEventId + '</lable>' +
- '<lable class="hidden" id="RuleActionId_' + Unibase.Platform.Automation.Components.Rule.keysindex + '">' + RuleActionId + '</lable>' +
- '<div class="col-sm-2 mt-10"><label>When </label></div>' +
- '<div class="col-sm-3 mt-10" id="ELable_' + Unibase.Platform.Automation.Components.Rule.keysindex + '" onclick="Unibase.Platform.Automation.Components.Rule.Instance().ToggleEventColumnLable(' + Unibase.Platform.Automation.Components.Rule.keysindex + ');"><u><b style="font-weight: bold;" id="EventColumnLable_' + Unibase.Platform.Automation.Components.Rule.keysindex + '"></b></u></div>' +
- '<div class="col-sm-3 hidden" id="EAutocomplete_' + Unibase.Platform.Automation.Components.Rule.keysindex + '">' +
- '<div id="div_EventColumns" class="floating-label-form-group" style="border-bottom:0;"><input type="hidden" class="event_name_' + Unibase.Platform.Automation.Components.Rule.keysindex + '"><select id="select2_EventColumns_' + Unibase.Platform.Automation.Components.Rule.keysindex + '" class="select2_0_EventColumns required value-control form-control text-control" multiple="multiple" style="width:100%;" onchange="Unibase.Platform.Automation.Components.Rule.Instance().OnChangeEventColumn(' + Unibase.Platform.Automation.Components.Rule.keysindex + ');"></select><input type="hidden" id="hfSelect2Id_EventColumns_' + Unibase.Platform.Automation.Components.Rule.keysindex + '" value="0" class="form-control text-control" data-isdynamic="true" /><input type="hidden" id="hfId_EventColumns" value=""><label for="Validation" id="lblValidation_EventColumns"></label></div></div>' +
- '<div class="col-sm-1 mt-10"><label id="Event_' + Unibase.Platform.Automation.Components.Rule.keysindex + '"></label></div>' +
- '<div class="col-sm-1 mt-10"><label>Then </label></div>' +
- '<div class="col-sm-3 mt-10" id="ALable_' + Unibase.Platform.Automation.Components.Rule.keysindex + '" onclick="Unibase.Platform.Automation.Components.Rule.Instance().ToggleActions(' + Unibase.Platform.Automation.Components.Rule.keysindex + ');"><u><b style="font-weight: bold;" id="ActionLable_' + Unibase.Platform.Automation.Components.Rule.keysindex + '"></b></u></div>' +
- '<div class="col-sm-3 hidden" id="AAutocomplete_' + Unibase.Platform.Automation.Components.Rule.keysindex + '">' +
- '<div class="floating-label-form-group floating-label-form-group-with-value focus">' +
- '<select id="Action_Autocomplete_' + Unibase.Platform.Automation.Components.Rule.keysindex + '" onchange="Unibase.Platform.Automation.Components.Rule.Instance().OnChangeActions(' + Unibase.Platform.Automation.Components.Rule.keysindex + ');" style="-webkit-appearance: none;" class="required form-control value-control" data-isdynamic="true">' +
- '</select>' +
- '<input type="hidden" id="hf_Action_' + Unibase.Platform.Automation.Components.Rule.keysindex + '" />' +
- '</div>' +
- '</div>' +
- '<div class="col-sm-1 mt-10"><a href="javascript:;" id="link_Configure"><i class="fa fa-cog"></i></a></div>' +
- '<div class="col-sm-1 mt-10" > <a id="delete_' + Unibase.Platform.Automation.Components.Rule.keysindex + '" title = "Delete" style="cursor:pointer" onclick = "Unibase.Platform.Automation.Components.Rule.Instance().DeleteEventGroupRow(' + Unibase.Platform.Automation.Components.Rule.keysindex + ',' + EventGroupId + ');" ><i class="fa fa-close"> </i></a></div >' +
- '</div>';
- if (Unibase.Platform.Automation.Components.Rule.keysflag == 0) {
- $("#AddNewEvents").append(html);
- $("#ActionLable_" + Unibase.Platform.Automation.Components.Rule.keysindex + "").text('Select');
- this.BindEventColumns(Unibase.Platform.Automation.Components.Rule.keysindex);
- this.loadActions(Unibase.Platform.Automation.Components.Rule.keysindex);
- Unibase.Platform.Automation.Components.Rule.keyscount = 0;
- Unibase.Platform.Automation.Components.Rule.keysflag = 0;
- }
- else {
- Unibase.Platform.Automation.Components.Rule.keysindex = Unibase.Platform.Automation.Components.Rule.keysindex - 1;
- }
- }
- else {
- $("#ActionLable_" + Unibase.Platform.Automation.Components.Rule.keysindex + "").addClass('form-group-required');
- MessageHelper.Instance().showError("Please Select Action.", "Validate_Rule");
- }
- }
- EventArray() {
- var instance = this;
- let eventgrouparray = [];
- $(".eventrow").each(function () {
- let eventarray = [];
- let eventgroupobj = {};
- let id = $(this).find(".eventrow");
- let index = (id.prevObject[0].id).split('_');
- index = index[1];
- let eventcolumns = Unibase.Platform.Automation.Components.Rule.Instance().GetEventColumns(index).split(",");
- for (var i = 0; i < eventcolumns.length; i++) {
- let eventobj = {};
- let eventtype;
- let etype = eventcolumns[i].split(" ")[1];
- let eventcolumn = "";
- if (etype.toLowerCase() == "created") {
- eventtype = Unibase.Platform.Automation.Enums.EventType.Created;
- }
- else if (etype.toLowerCase() == "deleted") {
- eventtype = Unibase.Platform.Automation.Enums.EventType.Deleted;
- }
- else if (eventcolumns[i].toLowerCase() == "stageid changed") {
- eventtype = Unibase.Platform.Automation.Enums.EventType.StageEvent;
- eventcolumn = eventcolumns[i].split(" ")[0];
- }
- else {
- eventtype = Unibase.Platform.Automation.Enums.EventType.Updated;
- eventcolumn = eventcolumns[i].split(" ")[0];
- }
- eventobj.RuleEventId = 0;
- eventobj.EventColumnName = eventcolumn;
- eventobj.EventType = eventtype;
- eventarray.push(eventobj);
- }
- eventgroupobj.EventGroupId = Number($(this).find("#EventGroupId_" + index + "").text());
- eventgroupobj.RuleEventData = eventarray;
- eventgroupobj.RuleActionData = Unibase.Platform.Automation.Components.Rule.RuleActionsData.filter(X => X.RowIndex == index);
- eventgrouparray.push(eventgroupobj);
- });
- return eventgrouparray;
- }
- LoadEvents(RuleId) {
- return __awaiter(this, void 0, void 0, function* () {
- var groupBy = function (xs, key) {
- return xs.reduce(function (rv, x) {
- (rv[x[key]] = rv[x[key]] || []).push(x);
- return rv;
- }, {});
- };
- Unibase.Platform.Automation.Components.Rule.keysindex = 0;
- $("#row_0").remove();
- yield Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleEvents(RuleId).then(function (response) {
- var result = groupBy(response, "EventGroupId");
- var keys = Object.keys(result);
- for (var i = 0; i <= keys.length - 1; i++) {
- let EventGroupId = Number(keys[i]);
- var reinfo = result[EventGroupId];
- Unibase.Platform.Automation.Components.Rule.keysindex = i + 1;
- Unibase.Platform.Automation.Components.Rule.Instance().LoadEventsHtml(Unibase.Platform.Automation.Components.Rule.keysindex, EventGroupId, reinfo);
- }
- });
- });
- }
- LoadEventsHtml(Index, EventGroupId, reinfo) {
- return __awaiter(this, void 0, void 0, function* () {
- var instance = this;
- instance.CurrentEventIndex = Index;
- Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleActionByEventGroupId(EventGroupId).then(function (response) {
- var html = "";
- html += '<div class="row eventrow" id="row_' + Index + '">' +
- '<lable class="hidden" id="EventGroupId_' + Index + '">' + EventGroupId + '</lable>' +
- '<lable class="hidden" id="RuleActionId_' + Index + '">' + response.RuleActionId + '</lable>' +
- '<div class="col-sm-2 mt-10"><label>When </label></div>' +
- '<div class="col-sm-3 mt-10" id="ELable_' + Index + '" onclick="Unibase.Platform.Automation.Components.Rule.Instance().ToggleEventColumnLable(' + Index + ');"><u><b style="font-weight: bold;" id="EventColumnLable_' + Index + '"></b></u></div>' +
- '<div class="col-sm-3 hidden" id="EAutocomplete_' + Index + '">' +
- '<div id="div_EventColumns" class="floating-label-form-group" style="border-bottom:0;"><input type="hidden" class="event_name_' + Index + '"><select id="select2_EventColumns_' + Index + '" class="select2_0_EventColumns required value - control form - control text - control" multiple="multiple" style="width: 100 %; " onchange="Unibase.Platform.Automation.Components.Rule.Instance().OnChangeEventColumn(' + Index + '); "><option>Select</option></select><input type="hidden" id="hfSelect2Id_EventColumns_' + Index + '" value="0" class="form - control text - control" data-isdynamic="true" /><input type="hidden" id="hfId_EventColumns" value=""><label for="Validation" id="lblValidation_EventColumns"></label></div></div>' +
- '<div class="col-sm-1 mt-10"><label id="Event_' + Index + '"></label></div>' +
- '<div class="col-sm-1 mt-10"><label>Then </label></div>' +
- '<div class="col-sm-3 mt-10" id="ALable_' + Index + '" onclick="Unibase.Platform.Automation.Components.Rule.Instance().ToggleActions(' + Index + ');"><u><b style="font-weight: bold;" id="ActionLable_' + Index + '"></b></u></div>' +
- '<div class="col-sm-3 hidden" id="AAutocomplete_' + Index + '">' +
- '<div class="floating-label-form-group floating-label-form-group-with-value focus">' +
- '<select id="Action_Autocomplete_' + Index + '" onchange="Unibase.Platform.Automation.Components.Rule.Instance().OnChangeActions(' + Index + ');" style="-webkit-appearance: none;" class="required form-control value-control" data-isdynamic="true">' +
- '</select>' +
- '<input type="hidden" id ="hf_Action_' + Index + '" />' +
- '</div>' +
- '</div>' +
- '<div class="col-sm-1 mt-10"><a href="javascript:;" id="link_Configure"><i class="fa fa-cog"></i></a></div>' +
- '<div class="col-sm-1 mt-10"><a id="delete_' + Unibase.Platform.Automation.Components.Rule.keysindex + '" title = "Delete" style="cursor:pointer" onclick = "Unibase.Platform.Automation.Components.Rule.Instance().DeleteEventGroupRow(' + Unibase.Platform.Automation.Components.Rule.keysindex + ',' + EventGroupId + ');" ><i class="fa fa-close"> </i></a></div >' +
- '</div>';
- $("#NormalModeEvent").removeClass("hidden");
- $("#AddNewEvents").append(html);
- $("#hf_Action_" + Index + "").val(response.ActionId);
- let EventColArr = [];
- for (var j = 0; j <= reinfo.length - 1; j++) {
- let eventname = reinfo[j].EventName;
- if (reinfo[j].EventColumnName != null && reinfo[j].EventColumnName != "") {
- eventname = eventname.split("_")[2];
- EventColArr.push("" + eventname + " Changed");
- }
- else {
- let eventtype = eventname.split("_")[2];
- if (eventtype.toLowerCase() == "created") {
- eventname = eventname.split("_created")[0];
- EventColArr.push("" + eventname + " Created");
- }
- else {
- eventname = eventname.split("_deleted")[0];
- EventColArr.push("" + eventname + " Deleted");
- }
- }
- }
- Unibase.Platform.Automation.Components.Rule.Instance().BindEventColumns(Index);
- $("#select2_EventColumns_" + Index + "").val(EventColArr).trigger('change');
- let eventcolumns = Unibase.Platform.Automation.Components.Rule.Instance().GetEventColumns(Index);
- $("#EventColumnLable_" + Index + "").text(eventcolumns);
- $('.event_name_' + Index + '').val('').val(eventcolumns);
- Unibase.Platform.Automation.Components.Rule.Instance().loadActions(Index);
- });
- });
- }
- GetEventColumns(index) {
- let eventcolumnscount = new Array();
- eventcolumnscount = $("#select2_EventColumns_" + index + "").val();
- var eventcolumn = "";
- for (var i = 0; i < eventcolumnscount.length; i++) {
- eventcolumn += eventcolumnscount[i] + ",";
- }
- return eventcolumn.slice(0, -1);
- }
- RuleActionsArray(obj) {
- let ruleactionobj = {};
- ruleactionobj.RuleActionId = obj.RuleActionId;
- ruleactionobj.ActionId = obj.ActionId;
- ruleactionobj.RuleId = obj.RuleId;
- ruleactionobj.RuleActionName = obj.RuleActionName;
- ruleactionobj.String1 = obj.String1;
- ruleactionobj.String2 = obj.String2;
- ruleactionobj.String3 = obj.String3;
- ruleactionobj.String4 = obj.String4;
- ruleactionobj.String5 = obj.String5;
- ruleactionobj.String6 = obj.String6;
- ruleactionobj.String7 = obj.String7;
- ruleactionobj.BString1 = obj.BString1;
- ruleactionobj.BString2 = obj.BString2;
- ruleactionobj.BString3 = obj.BString3;
- ruleactionobj.BString4 = obj.BString4;
- ruleactionobj.BString5 = obj.BString5;
- ruleactionobj.BString6 = obj.BString6;
- ruleactionobj.BString7 = obj.BString7;
- ruleactionobj.BString8 = obj.BString8;
- ruleactionobj.BString9 = obj.BString9;
- ruleactionobj.BString10 = obj.BString10;
- ruleactionobj.BString11 = obj.BString11;
- ruleactionobj.BString12 = obj.BString12;
- ruleactionobj.BString13 = obj.BString13;
- ruleactionobj.Users = obj.Users;
- ruleactionobj.SecondaryUsers = obj.SecondaryUsers;
- ruleactionobj.ParentActionId = obj.ParentActionId;
- ruleactionobj.ResultActionName = obj.ResultActionName;
- ruleactionobj.ResultActionId = obj.ResultActionId;
- ruleactionobj.DelayTime = obj.DelayTime;
- ruleactionobj.ActionConditionData = obj.ActionConditionData;
- ruleactionobj.RowIndex = obj.RowIndex;
- ruleactionobj.AutoApproved = obj.AutoApproved;
- ruleactionobj.RecipientsData = obj.RecipientsData;
- ruleactionobj.SqlWhere = obj.SqlWhere;
- ruleactionobj.SqlWhereJson = obj.SqlWhere;
- ruleactionobj.ExternalReportId = obj.ExternalReportId;
- ruleactionobj.ExternalReportColumnId = obj.ExternalReportColumnId;
- ruleactionobj.ProviderColumnId = obj.ProviderColumnId;
- ruleactionobj.ApproveStageId = obj.ApproveStageId;
- ruleactionobj.IsParent = obj.IsParent;
- ruleactionobj.FromStage = obj.FromStage;
- ruleactionobj.ToStage = obj.ToStage;
- ruleactionobj.NotificationGroupId = obj.NotificationGroupId;
- var Array = Unibase.Platform.Automation.Components.Rule.RuleActionsData.find(x => x.RowIndex == obj.RowIndex);
- if (Array != undefined) {
- Unibase.Platform.Automation.Components.Rule.RuleActionsData[obj.RowIndex] = ruleactionobj;
- }
- else {
- Unibase.Platform.Automation.Components.Rule.RuleActionsData.push(ruleactionobj);
- }
- Unibase.Platform.Automation.Components.Rule.Instance().loadQueryBuilder(Number($("#ddl_RuleProvider option:selected").val()), Unibase.Platform.Automation.Components.Rule.QueryString);
- }
- ChangeAction(index, Id) {
- if (Id == 0) {
- $("#Action_Autocomplete_" + index + "").val($("#hf_Action_" + index + "").val());
- $("#ActionLable_" + index + "").text('Select');
- Unibase.Platform.Automation.Components.Rule.RuleActionsData = Unibase.Platform.Automation.Components.Rule.RuleActionsData.filter(X => X.RowIndex != index);
- }
- Unibase.Platform.Automation.Components.Rule.Instance().loadQueryBuilder(Number($("#ddl_RuleProvider option:selected").val()), Unibase.Platform.Automation.Components.Rule.QueryString);
- }
- AdvancedMode(id, containerid) {
- var _fileCacheHelper = this.fileCacheHelper;
- var instance = this;
- $('#' + containerid).modal('hide');
- $('#' + containerid).remove();
- Unibase.Platform.Automation.Components.Rule.AutomationMode = Unibase.Platform.Automation.Enums.AutomationMode.AdvancedMode;
- var rulebuilder = new Unibase.Platform.Automation.Components.RuleBuilder();
- instance.navigationHelper.popup(id, '', rulebuilder, null, Platform.Helpers.Size.ExtraLarge);
- }
- loadQueryBuilder(ruleproviderid, querystring) {
- return __awaiter(this, void 0, void 0, function* () {
- return yield Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleProvider(ruleproviderid).then(function (response) {
- let ruleconditionhtml = Unibase.Platform.DataSources.Components.QueryBuilder.Instance().html(null, null);
- jQuery(".ConditionDetails").html(ruleconditionhtml);
- var qinstance = Unibase.Platform.DataSources.Components.QueryBuilder.Instance();
- qinstance.QueryBuilder_Columns = [];
- qinstance.QueryBuilder_Filters = [];
- qinstance.queryBuilderString = "";
- if (response.ReportId != 0) {
- qinstance.ReportId = response.ReportId;
- qinstance.loadQueryBuilderDiv(querystring);
- }
- else {
- qinstance.DoctypeId = response.DoctypeId;
- qinstance.loadQueryBuilderDivByDoctypeId(querystring);
- }
- $("#QueryBuilder").removeClass("hidden");
- });
- });
- }
- SaveQueryString() {
- let queryelmnt = $("#builder");
- let query = queryelmnt.queryBuilder('getSQL', false, true);
- if (query != null) {
- Unibase.Platform.Automation.Components.Rule.QueryString = queryelmnt.queryBuilder('getSQL', false, true).sql.replace(/\n/g, " ").replace(/LIKE/g, "ILIKE");
- }
- else {
- Unibase.Platform.Automation.Components.Rule.QueryString = null;
- }
- queryelmnt.queryBuilder('destroy');
- $("#QueryBuilder").remove();
- }
- SearchBlocks() {
- var input, filter, div, subdiv, a, i, count;
- input = document.getElementById("txt_Search");
- filter = input.value.toUpperCase();
- div = document.getElementById("InstalledAppsList");
- subdiv = div.getElementsByClassName("AppRow");
- count = 0;
- for (i = 0; i < subdiv.length; i++) {
- if (subdiv[i].textContent.toUpperCase() == filter) {
- a = subdiv[i];
- if (a.innerHTML.indexOf(filter) > -1) {
- subdiv[i].style.display = "";
- }
- }
- else {
- a = subdiv[i];
- if (a.textContent.toUpperCase().indexOf(filter) > -1) {
- subdiv[i].style.display = "";
- }
- else {
- subdiv[i].style.display = "none";
- count = count + 1;
- }
- }
- if (subdiv.length == count) {
- $("#txt_noresults").removeClass("hidden");
- }
- else if (subdiv.length != count) {
- $("#txt_noresults").addClass("hidden");
- }
- else { }
- }
- }
- EmptyEventColumns() {
- return __awaiter(this, void 0, void 0, function* () {
- Unibase.Platform.Automation.Components.Rule.EventColumnData = [];
- return yield $(".eventrow").each(function () {
- let id = $(this).find(".eventrow");
- let index = (id.prevObject[0].id).split('_');
- index = index[1];
- $("#select2_EventColumns_" + index + "").empty();
- });
- });
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new Rule();
- }
- return this.instance;
- }
- }
- Rule.keysindex = 0;
- Rule.keysflag = 0;
- Rule.AutomationMode = 0;
- Rule.EventColumnData = [];
- Rule.RuleActionsData = [];
- Rule.ActionsArray = [];
- Components.Rule = Rule;
- })(Components = Automation.Components || (Automation.Components = {}));
- })(Automation = Platform.Automation || (Platform.Automation = {}));
- })(Platform = Unibase.Platform || (Unibase.Platform = {}));
- })(Unibase || (Unibase = {}));
|