123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- 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 AdvRule extends Platform.Core.BaseComponent {
- 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/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",
- "platform/forms/components/formviewer/formviewer.js",
- "libs/parsley/parsley.min.js"
- ];
- return jsfiles;
- }
- cssFiles() {
- return [];
- }
- html(id, containerid) {
- let html = `<form id="frmUnibase_AdvRule" 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_AdvRule">Create Rule</strong>
- </div>
- <div class="card-body scrollable" style="overflow-y: scroll;">
- <div class="bg-white card" id="AdvRuleDetails">
- <div id="Validate_AdvRule" class="clear"></div>
- <div class="card-body">
- <div class="row">
- <div class="col-sm-12">
- <div class="floating-label-form-group">
- <label for="lbl_AdvRule" id="lbl_AdvRule">Rule Name<span class="text-danger">*</span></label>
- <input type="text" id="txt_AdvRule" 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_AdvRule" />
- <label for="Validation" id="lblValidation_AdvRule"></label>
- </div>
- </div>
- </div>
- <div class="row mt-10">
- <div class="col-sm-6">
- Installed App<span class="text-danger">*</span>
- <select id="Autocomplete_InstalledApp" class="required form-control value-control" data-isdynamic="true">
- </select>
- <input type="hidden" id="hf_Autocomplete_InstalledApp" value="" />
- </div>
- <div class="col-sm-6">
- Rule Provider<span class="text-danger">*</span>
- <select id="Autocomplete_RuleProvider" class="required form-control value-control" data-isdynamic="true">
- </select>
- <input type="hidden" id="hf_Autocomplete_RuleProvider" value="" />
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="bg-white card-footer footer" id="CreateAdvRuleFooter">
- <a href="javascript:;" id="btnCloseAdvRule" class="btn btn-light btn-sm mr-auto "> Close</a>
- <a href="javascript:;" id="btnSaveAdvRule" class="btn btn-primary btn-sm"> Save</a>
- </div>
- </div>
- </form>`;
- return html;
- }
- load(id, containerid, callback) {
- Unibase.Platform.Automation.Components.AdvRule.AutomationMode = Unibase.Platform.Automation.Enums.AutomationMode.AdvancedMode;
- $("#btnCloseAdvRule").click(function () {
- $('#' + containerid).modal('hide');
- $('#' + containerid).remove();
- });
- $("#btnSaveAdvRule").click(function () {
- let appcontrolid = "frmUnibase_AdvRule";
- let result = Unibase.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation(appcontrolid);
- if (result == false) {
- MessageHelper.Instance().showError("Mandatory fields are missing", "Validate_AdvRule");
- return false;
- }
- else {
- Unibase.Platform.Automation.Components.AdvRule.Instance().SaveRule(id, containerid);
- }
- });
- if (id != "") {
- Unibase.Platform.Automation.Components.AdvRule.Instance().EditRule(id);
- }
- var url = _appsettings.server_url() + '/apis/v4/unibase/platform/apps/installedappautocomplete';
- AutoCompleteHelper.getHelper().Create("#Autocomplete_InstalledApp", "#hf_Autocomplete_InstalledApp", url, function (response) {
- var data = response;
- });
- $("#Autocomplete_InstalledApp").change(function () {
- let InstalledappId = Number($("#Autocomplete_InstalledApp option:selected").val());
- var url = _appsettings.server_url() + '/apis/v4/unibase/notificationrule/platform/ruleprovidersautocomplete/InstalledAppId/' + InstalledappId;
- AutoCompleteHelper.getHelper().Create("#Autocomplete_RuleProvider", "hf_Autocomplete_RuleProvider", url, function (response) {
- var data = response;
- });
- });
- }
- SaveRule(id, containerid) {
- return __awaiter(this, void 0, void 0, function* () {
- let ruleid = Number(id);
- 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());
- model.AutomationModeId = Number(Unibase.Platform.Automation.Enums.AutomationMode.AdvancedMode);
- model.RuleType = Unibase.Platform.Automation.Enums.RuleType.Event;
- yield Automation.Managers.RuleManager.Instance().saveRule(model).then(function (response) {
- if (response.status == Unibase.Data.Status.Error) {
- MessageHelper.Instance().showError(response.message, "Validate_RuleEvent");
- }
- else {
- MessageHelper.Instance().showSuccess(response.message, "Validate_RuleEvent");
- eval("bizgaze_automation_flow_main.saveruleblock('" + response.result.RuleId + "','" + response.result.RuleName + "','" + response.result.RuleProviderId + "')");
- Components.RuleEvent.Instance().SaveRuleEvent(id, containerid);
- }
- });
- });
- }
- EditRule(id) {
- let ruleid = Number(id);
- $("#Form_AdvRule").text("Edit Rule");
- Unibase.Platform.Automation.Managers.RuleManager.Instance().getRule(ruleid).then(function (response) {
- let ruleid = response.RuleId;
- $("#hf_RuleProvider").val(response.RuleProviderId);
- $("#txt_AdvRule").val(response.RuleName);
- Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleProvider(response.RuleProviderId).then(function (response) {
- var installedappoption = new Option(response.AppTitle, response.InstalledAppId.toString(), true);
- $("#Autocomplete_InstalledApp").append(installedappoption);
- var ruleprovideroption = new Option(response.RuleProviderName, response.RuleProviderId.toString(), true);
- $("#Autocomplete_RuleProvider").append(ruleprovideroption);
- eval('_floatingLabelHelper.init();');
- });
- });
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new AdvRule();
- }
- return this.instance;
- }
- }
- AdvRule.AutomationMode = 0;
- Components.AdvRule = AdvRule;
- })(Components = Automation.Components || (Automation.Components = {}));
- })(Automation = Platform.Automation || (Platform.Automation = {}));
- })(Platform = Unibase.Platform || (Unibase.Platform = {}));
- })(Unibase || (Unibase = {}));
|