This commit is contained in:
2023-03-11 17:30:20 +00:00
commit b6c4e025bc
5124 changed files with 1153349 additions and 0 deletions
@@ -0,0 +1,433 @@
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 ApiIntegrator extends Platform.Core.BaseComponent {
constructor() {
super(...arguments);
this.RowIndex = 0;
this.RuleProviderId = 0;
this.AutomationMode = 0;
this.RuleInstance = Unibase.Platform.Automation.Components.Rule.Instance();
}
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/apps/managers/stagemanager.js", "platform/automation/components/rulebuilder/rulebuilder.rule.js", "platform/automation/components/rulebuilder/notificationgroup.js", "platform/automation/managers/notificationgroupmanager.js"
];
return jsfiles;
}
cssFiles() {
return [];
}
html(id, containerid) {
let html = `<form id="frmUnibase_ApiIntegrator" 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="Spn_ApiIntegrator">Create Api Integrator</strong></div>
<div class="card-body scrollable" style="overflow-y: scroll;">
<div class="bg-white card" id="divApiIntegrator">
<div id="Validate_ApiAction" class="clear"></div>
<div class="card-body">
<div class="row">
<div class="col-sm-12">
<div class="floating-label-form-group">
<label for="lbl" id="lbl_RuleActionName">Action<span class="text-danger required" id="spnIsRequired_RuleActionName"> *</span></label>
<input type="text" id="txtApiIntegrator_RuleActionName" class="form-control value-control required floating-label-control" placeholder="Action *" data-placeholder="Enter Action" data-label="Action *">
<input type="hidden" id="hf_RuleActionName" />
</div></div></div>
<div class="row">
<div class="col-sm-12">
<div id="div_Subject" class="floating-label-form-group">
<label for="lbl_ApiParameter" id="lbl_ApiParameter">Api Parameter</label>
<div class="input-group">
<input type="text" id="txtApiIntegrator_ApiParameter" class="col-sm-9 form-control value-control floating-label-control" data-placeholder="Enter ApiParameter" placeholder="ApiParameter" data-label="ApiParameter">
<select id="ddl_ApiParameters" class="col-sm-3 form-control value-control">
<option value="0">Select Token</option>
</select></div></div></div></div>
<div class="row">
<div id="div_NotificationGrp" class="floating-label-form-group col-sm-6 floating-label-form-group-with-value">
<label for="lbl_NotificationGrp" id="lbl_NotificationGroup">Notification Group<span class="text-danger"> *</span></label>
<select id="ddl_NotificationGrp" class="form-control"><option value="0">Select Group</option></select>
</div><div class="col-sm-6 createbtn_grp"><button class="badge badge-primary mt-30 ml-15" id="creategrp_btn">Create Group</button></div></div>
<div class="row">
<div class="col-sm-6">
<div class="input-group">
<label for="Doctype" class="font-bold">Services <span class="text-danger">*</span></label>
<select id="txtAutoComplete_Services" class="form-control text-control required" style="width:100%;" placeholder="Services" data-placeholder="Services" data-label="" data-istagselect="true"></select>
<input type="hidden" id="hf_Autocomplete_Services" class="form-control value-control" data-isdynamic="true"/></div></div>
<div class="ResultActions col-sm-6 hidden">
<div id="div_ResultAction" class=" floating-label-form-group floating-label-form-group-with-value">
<label for="lbl" id="lbl_ResultAction">Result Action</label>
<select id="ddl_ResultAction" class="form-control">
<option value="0">Select</option></select>
<label for="Validation" id="lblValidation_ResultAction"></label><input type="hidden" id="hfFormPropertyId" value="0"/></div></div></div>
</div></div>
<div class="bg-white card Advanced_optionsdata">
<div class="card-header"><i class="fa fa-angle-down arrowicon mr-1" onclick="Unibase.Platform.Automation.Components.ApiIntegrator.Instance().Toggleadvancedoptions()"></i>Advanced Options</div>
<div class="card-body Advanced_options hidden">
<div class="row">
<div class="col-sm-6 floating-label-form-group floating-label-form-group-with-value">
<label class="Message_type">Message Type</label>
<select class="form-control" id="message_result">
<option value="0">Success</option>
<option value="1">Warning</option>
<option value="2">Error</option>
</select>
</div>
<div class="col-sm-6">
<input type="checkbox" class="test_data mt-50" id="chkAutoApprovedApiIntegrator" checked>Perform this Action
</div>
</div>
</div>
</div>
<div class="bg-white card" id="ActionConditionsDivdata">
<div class="card-header"><i class="fa fa-angle-down conditionicon mr-1" style="font-size:20px" onclick="Unibase.Platform.Automation.Components.ApiIntegrator.Instance().ToggleApiIntegratorConditions();"></i>Condition Details</div>
<div class="card-body hidden" id="ActionConditionsDiv">
<div class="ActionConditions">
<!--For Action Conditions-->
</div>
</div>
</div>
<div class="bg-white card" id="SelectstagesDiv">
<div class="card-header">Stage Event</div>
<div class="card-body">
<div class="stages_drp row"><div class="col-sm-6"><label class="from_label">From Stage</label><select class="from_stage_apiintegrator form-control"></select></div><div class="col-sm-6"><label class="_label">To Stage</label><select class="to_stage_apiintegrator form-control"></select></div></div>
</div></div>
</div>
<div class="bg-white card-footer footer" id="CreateApiIntegratorFooter">
<a href="javascript:;" id="btnCloseApiIntegrator" class="btn btn-light btn-sm mr-auto ">Close</a>
<a href="javascript:;" id="btnSaveApiIntegrator" class="btn btn-primary btn-sm"> Save</a>
</div>
</div>
</form>`;
return html;
}
load(id, containerid, callback) {
return __awaiter(this, void 0, void 0, function* () {
var instance = this;
Unibase.Platform.Automation.Components.ApiIntegrator.Instance().ActionId = instance.ActionId;
Unibase.Platform.Automation.Components.ApiIntegrator.Instance().RuleActionData = instance.RuleActionData;
Unibase.Platform.Automation.Components.ApiIntegrator.Instance().RowIndex = instance.RowIndex;
Unibase.Platform.Automation.Components.ApiIntegrator.Instance().AutomationMode = instance.AutomationMode;
Unibase.Platform.Automation.Components.ApiIntegrator.Instance().RuleProviderId = instance.RuleProviderId;
Unibase.Platform.Automation.Components.ApiIntegrator.Instance().ParentActionId = instance.ParentActionId;
Unibase.Platform.Automation.Components.ApiIntegrator.Instance().IsAutomationMode = instance.IsAutomationMode;
yield Unibase.Platform.Automation.Components.NotificationGroup.Instance().LoadNotificationGroups();
if (instance.AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.AdvancedMode) {
eval('bizgaze_automation_flow_main.getcontainerid("' + containerid + '")');
}
$('#creategrp_btn').click(function () {
Unibase.Platform.Automation.Components.NotificationGroup.Instance().init(0, null, true);
});
$("#btnCloseApiIntegrator").click(function () {
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
if (Unibase.Platform.Automation.Components.ApiIntegrator.Instance().AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.NormalMode) {
if (Unibase.Platform.Automation.Components.ApiIntegrator.Instance().AutomationMode) {
if (Unibase.Platform.Automation.Components.ApiIntegrator.Instance().IsAutomationMode) {
Unibase.Platform.Automation.Components.Rule.Instance().ChangeAction(instance.RowIndex, id);
}
}
}
else {
eval("bizgaze_automation_flow_main.getpopupclosed()");
}
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
});
$("#btnSaveApiIntegrator").click(function () {
let appcontrolid = "frmUnibase_ApiIntegrator";
let result = Unibase.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation(appcontrolid);
if (result == false) {
MessageHelper.Instance().showError("Mandatory fields are missing", "Validate_ApiAction");
return false;
}
else {
Unibase.Platform.Automation.Components.ApiIntegrator.Instance().SaveApiIntegrator(id, containerid);
}
});
$("#ddl_ApiParameters").change(function () {
var textAreaTxt = $("#txtApiIntegrator_ApiParameter").val().toString();
var txtToAdd = '{{' + $("#ddl_ApiParameters option:selected").text() + '}}';
var firsttext = textAreaTxt.slice(0, ApiIntegrator.Instance().tokenposition);
var lasttext = textAreaTxt.slice(ApiIntegrator.Instance().tokenposition, textAreaTxt.length);
$("#txtApiIntegrator_ApiParameter").val(firsttext + txtToAdd + lasttext);
$("#ddl_ApiParameters").val(0);
});
$("#txtApiIntegrator_ApiParameter").focusout(function (event) {
ApiIntegrator.Instance().tokenposition = event["target"]["selectionStart"];
});
if (instance.RuleInstance.IsStageChangeEvent()) {
$('#SelectstagesDiv').removeClass('d-none');
yield Unibase.Platform.Automation.Components.ApiIntegrator.Instance().LoadAppStages();
}
else {
$('#SelectstagesDiv').addClass('d-none');
}
if (instance.ParentActionId != 0) {
yield Unibase.Platform.Automation.Components.ContactSelection.Instance().getResultActions(instance.ParentActionId);
yield Unibase.Platform.Automation.Components.ApiIntegrator.Instance().GetRuleActionInfo(Number(instance.ParentActionId));
$('#ddl_NotificationGrp').prop("disabled", true);
$('#creategrp_btn').addClass('d-none');
}
if (id != "") {
setTimeout(function () { Unibase.Platform.Automation.Components.ApiIntegrator.Instance().EditApiIntegrator(id); }, 10);
}
let rpid = instance.RuleProviderId;
if (rpid != 0) {
Unibase.Platform.Automation.Components.ApiIntegrator.Instance().LoadApiParameters(rpid);
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(rpid, null);
}
if (instance.RuleActionData.length != 0) {
Unibase.Platform.Automation.Components.ApiIntegrator.Instance().LoadApiIntegratorData(instance.RuleActionData);
}
var url = _appsettings.server_url() + '/apis/v4/unibase/integrations/integrator/servicintegratorautocomplete/integratorid/0';
AutoCompleteHelper.getHelper().Create("#txtAutoComplete_Services", "#hf_Autocomplete_Services", url, function (response) {
var data = response;
});
});
}
ToggleApiIntegratorConditions() {
$('#ActionConditionsDiv').toggleClass("hidden");
if ($('.conditionicon').hasClass('fa-angle-down')) {
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.ApiIntegrator.Instance().RuleProviderId, null);
}
else {
$('.conditionicon').removeClass('fa-angle-up').addClass('fa-angle-down');
}
}
Toggleadvancedoptions() {
if ($('.arrowicon').hasClass('fa-angle-down')) {
$('.arrowicon').removeClass('fa-angle-down').addClass('fa-angle-up');
}
else {
$('.arrowicon').removeClass('fa-angle-up').addClass('fa-angle-down');
}
$('.Advanced_options').toggleClass("hidden");
}
LoadAppStages() {
return __awaiter(this, void 0, void 0, function* () {
var html = '';
var fromstage = '<option value="0">Select FromStage</option>';
var tostage = '<option value="0">Select ToStage</option>';
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>';
}
}
$('.from_stage_apiintegrator').html(fromstage + html);
$('.to_stage_apiintegrator').html(tostage + html);
});
});
}
EditApiIntegrator(id) {
let actionid = Number(id);
$("#Spn_ApiIntegrator").text("Edit Api Integrator");
Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleAction(actionid).then(function (response) {
$("#txtApiIntegrator_RuleActionName").val(response.RuleActionName);
$("#txtApiIntegrator_ApiParameter").val(response.BString2);
$('#ddl_NotificationGrp option[value=' + response.NotificationGroupId + ']').prop('selected', true);
if (response.ResultActionId != null) {
$('#ddl_ResultAction').val(response.ResultActionId);
}
if (!Unibase.Platform.Automation.Components.ApiIntegrator.Instance().IsAutomationMode) {
Unibase.Platform.Automation.Components.ApiIntegrator.Instance().RuleId = response.RuleId;
Unibase.Platform.Automation.Components.ApiIntegrator.Instance().RuleEventId = response.RuleEventId;
Unibase.Platform.Automation.Components.ApiIntegrator.Instance().EventGroupId = response.EventGroupId;
Unibase.Platform.Automation.Components.ApiIntegrator.Instance().ActionId = response.ActionId;
Unibase.Platform.Automation.Components.ApiIntegrator.Instance().ParentActionId = response.ParentActionId;
}
if (response.ExecuteStatusId != Number(Unibase.Platform.Automation.Enums.ExecuteActionStatus.Approved))
$("#chkAutoApprovedApiIntegrator").prop("checked", false);
else
$("#chkAutoApprovedApiIntegrator").prop("checked", true);
let id = Number(response.BString4);
Unibase.Platform.Integrations.Managers.IntegrationManager.Instance().getServiceIntegratorById(id).then(function (res) {
var serviceoption = new Option(res.result.ServiceIntegratorName, res.result.ServiceIntegratorId.toString(), true);
$("#txtAutoComplete_Services").append(serviceoption);
});
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(response.RuleProviderId, response.SqlWhere);
if (response.SqlWhere != null && response.SqlWhere != "") {
$("#ActionConditionsDiv").removeClass("hidden");
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
}
if (response.FromStage != null && response.ToStage != null) {
$('.from_stage_apiintegrator option[value=' + response.FromStage + ' ]').prop('selected', true);
$('to_stage_apiintegrator option[value=' + response.ToStage + ']').prop('selected', true);
}
$('#message_result').val(Number(response.BString5));
eval('_floatingLabelHelper.init();');
});
}
LoadApiIntegratorData(Data) {
for (var i = 0; i < Data.length; i++) {
$("#txtApiIntegrator_RuleActionName").val(Data[i].RuleActionName);
$("#txtApiIntegrator_ApiParameter").val(Data[i].BString1);
let id = Number(Data[i].BString4);
Unibase.Platform.Integrations.Managers.IntegrationManager.Instance().getServiceIntegratorById(id).then(function (res) {
var serviceoption = new Option(res.result.ServiceIntegratorName, res.result.ServiceIntegratorId.toString(), true);
$("#txtAutoComplete_Services").append(serviceoption);
});
if (!Data[i].AutoApproved)
$("#chkAutoApprovedApiIntegrator").prop("checked", false);
else
$("#chkAutoApprovedApiIntegrator").prop("checked", true);
if (Data[i].SqlWhere != "" && Data[i].SqlWhere != null) {
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.ApiIntegrator.Instance().RuleProviderId, Data[i].SqlWhere);
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
$("#ActionConditionsDiv").removeClass("hidden");
}
eval('_floatingLabelHelper.init();');
}
}
SaveApiIntegrator(ApiIntegratorid, containerid) {
var instance = this;
let ruleactionid = Number(ApiIntegratorid);
let queryelmnt = $("#builder");
let model = new Unibase.Platform.Automation.Requests.RuleAction();
model.RuleActionId = ruleactionid;
model.RuleActionName = $("#txtApiIntegrator_RuleActionName").val().toString();
model.BString1 = $("#txtApiIntegrator_ApiParameter").val().toString();
model.BString2 = $("#txtApiIntegrator_ApiParameter").val().toString();
model.BString4 = $("#txtAutoComplete_Services").val().toString();
model.BString5 = $('#message_result option:selected').val().toString();
model.ActionId = Unibase.Platform.Automation.Components.ApiIntegrator.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_ApiAction");
return;
}
if (instance.RuleInstance.IsStageChangeEvent()) {
model.FromStage = $('.from_stage_apiintegrator option:selected').val() != "0" ? Number($('.from_stage_apiintegrator option:selected').val()) : 0;
model.ToStage = $('.to_stage_apiintegrator option:selected').val() != "0" ? Number($('.to_stage_apiintegrator option:selected').val()) : 0;
}
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));
}
else {
model.SqlWhere = "";
model.SqlWhereJson = "";
}
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.ApiIntegrator.Instance().ParentActionId;
model.AutoApproved = $('#chkAutoApprovedApiIntegrator').is(':checked');
model.RowIndex = Unibase.Platform.Automation.Components.ApiIntegrator.Instance().RowIndex;
if (Unibase.Platform.Automation.Components.ApiIntegrator.Instance().IsAutomationMode) {
if (Unibase.Platform.Automation.Components.ApiIntegrator.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_ApiAction");
}
else {
MessageHelper.Instance().showSuccess(response.message, "Validate_ApiAction");
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
var actionname = response.result.RuleActionName;
eval("bizgaze_automation_flow_main.saveApiIntegratorblock('" + response.result.RuleActionId + "','" + actionname + "')");
}
});
}
}
else {
model.RuleId = Unibase.Platform.Automation.Components.ApiIntegrator.Instance().RuleId;
model.EventGroupId = Unibase.Platform.Automation.Components.ApiIntegrator.Instance().EventGroupId;
model.RuleEventId = Unibase.Platform.Automation.Components.ApiIntegrator.Instance().RuleEventId;
model.ActionId = Unibase.Platform.Automation.Components.ApiIntegrator.Instance().ActionId;
model.ParentActionId = Unibase.Platform.Automation.Components.ApiIntegrator.Instance().ParentActionId;
Automation.Managers.RuleManager.Instance().saveRuleAction(model).then(function (response) {
if (response.status == Unibase.Data.Status.Error) {
MessageHelper.Instance().showError(response.message, "Validate_ApiAction");
}
else {
MessageHelper.Instance().showSuccess(response.message, "Validate_ApiAction");
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
}
});
}
}
LoadApiParameters(ruleproviderid) {
Unibase.Platform.Automation.Managers.RuleManager.Instance().getTokens(ruleproviderid).then(function (response) {
let ApiParameters = document.getElementById('ddl_ApiParameters');
$('#ddl_ApiParameters').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);
}
});
}
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 = '<option value=' + response.NotificationGroupId + ' selected>' + response.NotificationGroupName + '</option>';
$('#ddl_NotificationGrp').html('').html(html);
}
});
});
}
static Instance() {
if (this.instance === undefined) {
this.instance = new ApiIntegrator();
}
return this.instance;
}
}
Components.ApiIntegrator = ApiIntegrator;
})(Components = Automation.Components || (Automation.Components = {}));
})(Automation = Platform.Automation || (Platform.Automation = {}));
})(Platform = Unibase.Platform || (Unibase.Platform = {}));
})(Unibase || (Unibase = {}));
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,712 @@
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 SendEmail extends Platform.Core.BaseComponent {
constructor() {
super(...arguments);
this.RuleProviderId = 0;
this.RowIndex = 0;
this.AutomationMode = 0;
this.RuleInstance = Unibase.Platform.Automation.Components.Rule.Instance();
this.formpropertyid = "ExternalAttachments";
}
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",
"apps/communications/managers/mails/mailmanager.js",
"platform/templates/enums/templatetype.js",
"platform/templates/managers/templatemanager.js", "libs/notificationbuilder/notificationbuilder.js", "platform/apps/managers/stagemanager.js", "platform/automation/components/rulebuilder/rulebuilder.rule.js", "platform/automation/components/externalrecipients.js", "platform/automation/components/rulebuilder/notificationgroup.js", "platform/automation/managers/notificationgroupmanager.js"
];
return jsfiles;
}
cssFiles() {
return [];
}
html(id, containerid) {
let html = `<form id="frmUnibase_SendEmail" 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="Spn_SendEmail">Create Email</strong>
</div>
<div class="card-body scrollable" style="overflow-y: scroll;">
<div class="bg-white card" id="divSendEmail">
<div id="Validate_EmailAction" class="clear"></div>
<div class="card-body">
<div class="row">
<div class="col-sm-12">
<div class="floating-label-form-group">
<label for="lbl" id="lbl_RuleActionName">Action<span class="text-danger required" id="spnIsRequired_RuleActionName"> *</span></label>
<input type="text" id="txtEmail_RuleActionName" class="form-control value-control required floating-label-control" placeholder="Action *" data-placeholder="Enter Action" data-label="Action *">
<input type="hidden" id="hf_RuleActionName" />
</div>
</div>
</div>
<div class="row">
<div id="div_NotificationGrp" class="floating-label-form-group col-sm-6 floating-label-form-group-with-value">
<label for="lbl_NotificationGrp" id="lbl_NotificationGroup">Notification Group<span class="text-danger"> *</span></label>
<select id="ddl_NotificationGrp" class="form-control"><option value="0">Select Group</option></select>
</div><div class="col-sm-6 createbtn_grp"><button class="badge badge-primary mt-30 ml-15" id="creategrp_btn">Create Group</button></div></div>
<div class="row">
<div class="ResultActions col-sm-6 hidden">
<div id="div_ResultAction" class=" floating-label-form-group floating-label-form-group-with-value">
<label for="lbl" id="lbl_ResultAction">Result Action</label>
<select id="ddl_ResultAction" class="form-control">
<option value="">-- Select --</option>
</select>
<label for="Validation" id="lblValidation_ResultAction"></label><input type="hidden" id="hfFormPropertyId" value="" />
</div>
</div>
</div>
</div>
</div>
<div class="bg-white card" id="EmailDetailsDiv">
<div class="card-header">Mail Details</div>
<div class="card-body">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label>Template</label>
<select id="Autocomplete_Template" class="form-control value-control" data-isdynamic="true"></select>
<input type="hidden" id="hf_Template" />
</div>
</div>
</div>
<div class="row">
<div id="div_MailBody" class="TextEditor col-sm-12">
<inpu type="hidden" id="txthdn__MailBody" class="value-control" value="">
<span class="text-danger" id="spnIsRequired__MailBody"></span>
<div class="type-control summernote__MailBody" style="display: block;" id="summernote__MailBody" data-propdoctypename="MailBody" data-required="" placeholder="Mail Body" data-placeholder="Mail Body" data-label="Mail Body"></div>
<label for="Validation" id="lblValidation"></label>
</input>
</div>
</div>
</div>
</div>
<div class="bg-white card" id="AttachmentsDiv">
<div class="card-header">Attachments</div>
<div class="card-body" id="ExternalAttachments">
</div>
</div>
<div class="bg-white card Advanced_optionsdata">
<div class="card-header"><i class="fa fa-angle-down arrowicon mr-1" onclick="Unibase.Platform.Automation.Components.SendEmail.Instance().Toggleadvancedoptions()"></i>Advanced Options</div>
<div class="card-body Advanced_options hidden">
<div class="row">
<div class="col-sm-6 floating-label-form-group floating-label-form-group-with-value">
<label class="Message_type">Message Type</label>
<select class="form-control" id="message_result">
<option value="0">Success</option>
<option value="1">Warning</option>
<option value="2">Error</option>
</select>
</div>
<div class="col-sm-6">
<input type="checkbox" class="test_data mt-50" id="chkAutoApprovedEmail" checked>Perform this Action
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="input-group">
<label for="lbl_InternalTemplate" id="lbl_InternalTemplate">Internal Template</label>
<select id="Autocomplete_InternalTemplate" class="form-control text-control" style="width:100%;" placeholder="InternalTemplate" data-placeholder="InternalTemplate" data-label="" data-istagselect="true"></select>
<input type="hidden" id="hf_InternalTemplate" class="form-control value-control" data-isdynamic="true" />
</div>
</div>
<div class="col-sm-6">
<input type="checkbox" class="refattchments mt-50" id="chkIsRefAttachments">IsRefAttachments
</div>
<div class="col-sm-6">
<input type="checkbox" class="isbulk_send mt-50 " id="isbulksend" checked><span class="ml-5">Is Bulk</span>
</div>
</div>
</div>
</div>
<div class="bg-white card hidden" id="DocTypesDiv">
<div class="card-header">DocTypes</div>
<div class="card-body">
<div class="SelectDocType col-sm-12">
<!--For Mapping of datalists-->
</div>
</div>
</div>
<div class="bg-white card" id="ActionConditionsDivdata">
<div class="card-header"><i class="fa fa-angle-down conditionicon mr-1" style="font-size:20px" onclick="Unibase.Platform.Automation.Components.SendEmail.Instance().ToggleSendEmailConditions();"></i>Condition Details</div>
<div class="card-body hidden" id="ActionConditionsDiv">
<div class="ActionConditions">
<!--For Action Conditions-->
</div>
</div>
</div><div class="bg-white card" id="SelectstagesDiv">
<div class="card-header">Stage Event</div>
<div class="card-body">
<div class="stages_drp row"><div class="col-sm-6"><label class="from_label">From Stage</label><select class="from_stage_email form-control"></select></div><div class="col-sm-6"><label class="_label">To Stage</label><select class="to_stage_email form-control"></select></div></div>
</div></div>
<div class="bg-white card" id="SelectRoleDiv">
<div class="card-header">Send To Details</div>
<div class="card-body">
<div class="ContactSelection col-sm-12">
<!--For ContactSelection page-->
</div>
</div>
</div>
<div class="bg-white card" id="external_recipientsdiv">
<div class="card-header">External Recipients</div>
<div class="card-body">
<div class="reportautocomplete">
<div class="row">
<div class="col-sm-6">
<div class="input-group">
<label for="Report" class="font-bold">External Report</label>
<select id="txtAutoComplete_ReportsExternal" class="form-control text-control" style="width:100%;" placeholder="Report" data-placeholder="Report" data-label="" data-istagselect="true"></select>
<input type="hidden" id="hf_Autocomplete_ReportsExternal" class="form-control value-control" data-isdynamic="true" /></div></div></div></div>
<div class="external_reportcolumns mt-4"><div class="row externalreport_row"></div></div></div></div>
<div class="bg-white card col-sm-3 hidden" id="btn_ExternalRecipients">
<button type="button" class="btn btn-primary" onclick="Unibase.Platform.Automation.Components.SendEmail.Instance().ToggleExternalRecipients();">External Recipients</button>
</div>
<div class="bg-white card hidden" id="ExternalRecipientsDiv">
<div class="card-header">External Recipients</div>
<div class="card-body">
<div class="ExternalRecipients">
</div>
</div>
</div><div class="bg-white card hidden" id="external_reportcolumnsdiv">
<div class="card-header">External ReportContacts</div>
<div class="card-body">
</div>
</div>
<div class="bg-white card col-sm-3" id="btn_SendFrom">
<button type="button" class="btn btn-primary" onclick="Unibase.Platform.Automation.Components.SendEmail.Instance().ToggleEmailSendFrom();">Send From</button>
</div>
<div class="bg-white card hidden" id="SendFromDiv">
<div class="card-header">Send From Details</div>
<div class="card-body">
<div class="row SendFrom">
<div class="col-sm-6">
<div class="input-group">
<label for="lbl_MailServer" id="lbl_MailServer">Mail Server<span class="text-danger" id="span_MailServer">*</span></label>
<select id="Autocomplete_MailServer" class="form-control text-control required" style="width:100%;" placeholder="MailServer" data-placeholder="MailServer" data-label="" data-istagselect="true"></select>
<input type="hidden" id="hf_MailServer" class="form-control value-control" data-isdynamic="true" />
</div>
</div>
<div class="col-sm-6">
<div class="input-group">
<label for="lbl_MailAccount" id="lbl_MailAccount">Mail Account<span class="text-danger" id="span_MailAccount">*</span></label>
<select id="Autocomplete_MailAccount" class="form-control text-control required" style="width:100%;" placeholder="MailAccount" data-placeholder="MailAccount" data-label="" data-istagselect="true"></select>
<input type="hidden" id="hf_MailAccount" class="form-control value-control" data-isdynamic="true" />
</div>
</div>
</div>
</div>
</div>
</div>
<div class="bg-white card-footer footer" id="CreateEmailFooter">
<a href="javascript:;" id="btnCloseEmail" class="btn btn-light btn-sm mr-auto "> Close</a>
<a href="javascript:;" id="btnSaveEmail" class="btn btn-primary btn-sm"> Save</a>
</div>
</div>
</form>`;
return html;
}
load(id, containerid, callback) {
return __awaiter(this, void 0, void 0, function* () {
var instance = this;
Unibase.Platform.Automation.Components.SendEmail.Instance().ActionId = instance.ActionId;
Unibase.Platform.Automation.Components.SendEmail.Instance().RuleActionData = instance.RuleActionData;
Unibase.Platform.Automation.Components.SendEmail.Instance().RowIndex = instance.RowIndex;
Unibase.Platform.Automation.Components.SendEmail.Instance().AutomationMode = instance.AutomationMode;
Unibase.Platform.Automation.Components.SendEmail.Instance().ParentActionId = instance.ParentActionId;
Unibase.Platform.Automation.Components.SendEmail.Instance().IsAutomationMode = instance.IsAutomationMode;
yield Unibase.Platform.Automation.Components.NotificationGroup.Instance().LoadNotificationGroups();
Unibase.Platform.Automation.Components.ExternalRecipients.Instance().loadreports();
if (instance.AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.AdvancedMode) {
eval('bizgaze_automation_flow_main.getcontainerid("' + containerid + '")');
}
$("#btnCloseEmail").click(function () {
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
if (Unibase.Platform.Automation.Components.SendEmail.Instance().AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.NormalMode) {
if (Unibase.Platform.Automation.Components.SendEmail.Instance().AutomationMode) {
if (Unibase.Platform.Automation.Components.SendEmail.Instance().IsAutomationMode) {
Unibase.Platform.Automation.Components.Rule.Instance().ChangeAction(instance.RowIndex, id);
}
}
}
else {
eval("bizgaze_automation_flow_main.getpopupclosed()");
}
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
});
$("#txtAutoComplete_ReportsExternal").change(function () {
var reportid = Number($('#txtAutoComplete_ReportsExternal option:selected').val());
Unibase.Platform.Automation.Components.ExternalRecipients.Instance().loadexternalreportcolumns(reportid);
});
$("#btnSaveEmail").click(function () {
let appcontrolid = "frmUnibase_SendEmail";
let result = Unibase.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation(appcontrolid);
if (result == false) {
MessageHelper.Instance().showError("Mandatory fields are missing", "Validate_EmailAction");
return false;
}
else {
Unibase.Platform.Automation.Components.SendEmail.Instance().SaveEmailAction(id, containerid);
}
});
$('#creategrp_btn').click(function () {
Unibase.Platform.Automation.Components.NotificationGroup.Instance().init(0, null, true);
});
if (instance.RuleInstance.IsStageChangeEvent()) {
$('#SelectstagesDiv').removeClass('d-none');
yield Unibase.Platform.Automation.Components.SendEmail.Instance().LoadAppStages();
}
else {
$('#SelectstagesDiv').addClass('d-none');
}
var url = _appsettings.server_url() + '/apis/v4/bizgaze/communications/mail/mailserverautocomplete';
AutoCompleteHelper.getHelper().Create("#Autocomplete_MailServer", "#hf_MailServer", url, function (response) {
var data = response;
});
var url = _appsettings.server_url() + '/apis/v4/unibase/platform/templates/getprintprovidersautocomplete';
AutoCompleteHelper.getHelper().Create("#Autocomplete_InternalTemplate", "#hf_InternalTemplate", url, function (response) {
var data = response;
});
$("#Autocomplete_Template").change(function () {
let templateid = Number($("#Autocomplete_Template option:selected").val());
Unibase.Platform.Templates.Managers.TemplateManager.Instance().getTemplateText(Number(templateid)).then(function (response) {
if (response.result != null) {
var templatetext = HtmlHelper.getHelper().decode(response.result.TemplateText);
$('.summernote__MailBody').summernote("code", templatetext);
}
});
});
var _fileCacheHelper = Platform.Helpers.FileCacheHelper.Instance();
yield _fileCacheHelper.loadJsFileAsync("platform/automation/components/contactselection.js", function () {
let contactselectionhtml = Unibase.Platform.Automation.Components.ContactSelection.Instance().init(instance.RuleProviderId);
jQuery(".ContactSelection").html(contactselectionhtml);
});
yield _fileCacheHelper.loadJsFileAsync("platform/automation/components/externalrecipients.js", function () {
let externalrecipientshtml = Unibase.Platform.Automation.Components.ExternalRecipients.Instance().init(instance.RuleProviderId);
jQuery(".ExternalRecipients").html(externalrecipientshtml);
Unibase.Platform.Automation.Components.ExternalRecipients.Instance().load(instance.RuleProviderId);
});
yield _fileCacheHelper.loadJsFileAsync("platform/automation/components/actions/externalattachments.js", function () {
let IsMultiple = true;
let ValidationDiv = "Validate_EmailAction";
let externalattchmentshtml = Unibase.Platform.Automation.Components.ExternalAttachments.Instance().init(Unibase.Platform.Automation.Components.SendEmail.Instance().formpropertyid, IsMultiple, ValidationDiv);
jQuery("#ExternalAttachments").html(externalattchmentshtml);
$(".drag").css("border", "3px dashed #cccccc");
Unibase.Platform.Automation.Components.ExternalAttachments.Instance().dragNdrop(Unibase.Platform.Automation.Components.SendEmail.Instance().formpropertyid);
});
if (instance.ParentActionId != 0) {
yield Unibase.Platform.Automation.Components.ContactSelection.Instance().getResultActions(instance.ParentActionId);
yield Unibase.Platform.Automation.Components.SendTask.Instance().GetRuleActionInfo(Number(instance.ParentActionId));
$('#ddl_NotificationGrp').prop("disabled", true);
$('#creategrp_btn').addClass('d-none');
}
if (instance.RuleActionData.length == 0 && id == "") {
Unibase.Platform.Automation.Components.SendEmail.Instance().getDefaultMailServer();
}
if (id != "") {
setTimeout(function () { Unibase.Platform.Automation.Components.SendEmail.Instance().EditEmailAction(id); }, 10);
}
if (instance.RuleProviderId != 0) {
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(instance.RuleProviderId, null);
Unibase.Platform.Automation.Managers.RuleManager.Instance().getTokens(instance.RuleProviderId).then(function (response) {
var Data = new Array();
for (let i = 0; i <= response.length - 1; i++) {
var result = response[i];
Data.push(result);
}
Unibase.Platform.Automation.Components.SendEmail.Instance().loadSummernote(Data);
});
Unibase.Platform.Automation.Components.SendEmail.Instance().loadTemplates(instance.RuleProviderId);
}
if (instance.RuleActionData.length != 0) {
Unibase.Platform.Automation.Components.SendEmail.Instance().LoadEmailData(instance.RuleActionData);
}
});
}
Toggleadvancedoptions() {
if ($('.arrowicon').hasClass('fa-angle-down')) {
$('.arrowicon').removeClass('fa-angle-down').addClass('fa-angle-up');
}
else {
$('.arrowicon').removeClass('fa-angle-up').addClass('fa-angle-down');
}
$('.Advanced_options').toggleClass("hidden");
}
ToggleSendEmailConditions() {
$('#ActionConditionsDiv').toggleClass("hidden");
if ($('.conditionicon').hasClass('fa-angle-down')) {
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.SendEmail.Instance().RuleProviderId, null);
}
else {
$('.conditionicon').removeClass('fa-angle-up').addClass('fa-angle-down');
}
}
ToggleExternalRecipients() {
$("#ExternalRecipientsDiv").toggle(function () {
$("#btn_ExternalRecipients").addClass("hidden");
$("#ExternalRecipientsDiv").removeClass("hidden");
});
}
ToggleEmailSendFrom() {
$("#SendFromDiv").toggle(function () {
$("#btn_SendFrom").addClass("hidden");
$("#SendFromDiv").removeClass("hidden");
});
}
EditEmailAction(id) {
let actionid = Number(id);
$("#Spn_SendEmail").text("Edit Email");
Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleAction(actionid).then(function (response) {
$("#txtEmail_RuleActionName").val(response.RuleActionName);
$('#ddl_NotificationGrp option[value=' + response.NotificationGroupId + ']').prop('selected', true);
if (!Unibase.Platform.Automation.Components.SendEmail.Instance().IsAutomationMode) {
Unibase.Platform.Automation.Components.SendEmail.Instance().RuleId = response.RuleId;
Unibase.Platform.Automation.Components.SendEmail.Instance().RuleEventId = response.RuleEventId;
Unibase.Platform.Automation.Components.SendEmail.Instance().EventGroupId = response.EventGroupId;
Unibase.Platform.Automation.Components.SendEmail.Instance().ActionId = response.ActionId;
Unibase.Platform.Automation.Components.SendEmail.Instance().ParentActionId = response.ParentActionId;
}
if (response.ExecuteStatusId != Number(Unibase.Platform.Automation.Enums.ExecuteActionStatus.Approved))
$("#chkAutoApprovedEmail").prop("checked", false);
else
$("#chkAutoApprovedEmail").prop("checked", true);
if (response.String5 != "true")
$("#chkIsRefAttachments").prop("checked", false);
else
$("#chkIsRefAttachments").prop("checked", true);
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckContactColumns(response.Users);
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckSecondaryContactColumns(response.SecondaryUsers);
Unibase.Platform.Automation.Components.ContactSelection.Instance().BindRecipients(response.RuleActionId);
$('#btn_SendFrom').addClass('hidden');
$('#SendFromDiv').removeClass('hidden');
$('.summernote__MailBody').summernote("code", response.BString2);
$('#message_result').val(Number(response.BString5));
if (response.ResultActionId != null) {
$('#ddl_ResultAction').val(response.ResultActionId);
}
if (response.SqlWhere != null && response.SqlWhere != "") {
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
$("#ActionConditionsDiv").removeClass("hidden");
}
if (response.BString3 != "" && response.BString3 != null) {
Unibase.Platform.Automation.Components.ExternalAttachments.Instance().bindEditFormDetails((Unibase.Platform.Automation.Components.SendEmail.Instance().formpropertyid), response.BString3);
}
if (response.String7) {
$('.isbulk_send').prop("checked", true);
}
if (response.FromStage != null && response.ToStage != null) {
$('.from_stage_email option[value=' + response.FromStage + ' ]').prop('selected', true);
$('to_stage_email option[value=' + response.ToStage + ']').prop('selected', true);
}
if (response.ExternalReportId != 0) {
$('#txtAutoComplete_ReportsExternal option[value=' + response.ExternalReportId + ']').prop("selected", true);
}
Unibase.Apps.Communications.Managers.MailManager.Instance().getMailAccount(Number(response.String3)).then(function (mailresponse) {
if (mailresponse.status == Unibase.Data.Status.Success) {
var mailserveroption = new Option(mailresponse.result.ServerName, mailresponse.result.MailServerId.toString(), true);
$("#Autocomplete_MailServer").append(mailserveroption);
var mailaccountoption = new Option(mailresponse.result.UserName, mailresponse.result.MailAccountId.toString(), true);
$("#Autocomplete_MailAccount").append(mailaccountoption);
}
});
let templateid = Number(response.BString1);
Unibase.Platform.Templates.Managers.TemplateManager.Instance().getTemplateText(templateid).then(function (res) {
var mailtemplate = new Option(res.result.TemplateName, res.result.TemplateId.toString(), true);
$("#Autocomplete_Template").append(mailtemplate);
});
if (response.String1 != "" && response.String1 != null) {
let printProviderId = Number(response.String1);
Unibase.Platform.Templates.Managers.TemplateManager.Instance().getPrintProvider(printProviderId).then(function (res) {
var mailtemplate = new Option(res.result.ProviderName, res.result.PrintProviderId.toString(), true);
$("#Autocomplete_InternalTemplate").append(mailtemplate);
});
}
var decodedData = unescape(response.BString2);
var decode = HtmlHelper.getHelper().decode(decodedData);
$('.summernote__MailBody').summernote("code", decode);
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(response.RuleProviderId, response.SqlWhere);
eval('_floatingLabelHelper.init();');
});
}
LoadAppStages() {
return __awaiter(this, void 0, void 0, function* () {
var html = '';
var fromstage = '<option value="0">Select FromStage</option>';
var tostage = '<option value="0">Select ToStage</option>';
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>';
}
}
$('.from_stage_email').html(fromstage + html);
$('.to_stage_email').html(tostage + html);
});
});
}
LoadEmailData(Data) {
for (var i = 0; i < Data.length; i++) {
$("#txtEmail_RuleActionName").val(Data[i].RuleActionName);
if (!Data[i].AutoApproved)
$("#chkAutoApprovedEmail").prop("checked", false);
else
$("#chkAutoApprovedEmail").prop("checked", true);
if (Data[i].String5 != "true")
$("#chkIsRefAttachments").prop("checked", false);
else
$("#chkIsRefAttachments").prop("checked", true);
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckContactColumns(Data[i].Users);
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckSecondaryContactColumns(Data[i].SecondaryUsers);
if (Data[i].SqlWhere != "" && Data[i].SqlWhere != null) {
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.SendEmail.Instance().RuleProviderId, Data[i].SqlWhere);
$("#btn_ActionConditions").addClass("hidden");
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
$("#ActionConditionsDiv").removeClass("hidden");
}
if (Data[i].BString3 != "" && Data[i].BString3 != null) {
Unibase.Platform.Automation.Components.ExternalAttachments.Instance().bindEditFormDetails((Unibase.Platform.Automation.Components.SendEmail.Instance().formpropertyid), Data[i].BString3);
}
Unibase.Apps.Communications.Managers.MailManager.Instance().getMailAccount(Number(Data[i].String3)).then(function (mailresponse) {
if (mailresponse.status == Unibase.Data.Status.Success) {
var mailserveroption = new Option(mailresponse.result.ServerName, mailresponse.result.MailServerId.toString(), true);
$("#Autocomplete_MailServer").append(mailserveroption);
var url = _appsettings.server_url() + '/apis/v4/bizgaze/communications/mail/getMailAccountAutocomplete/mailServerId/' + Number($("#Autocomplete_MailServer option:selected").val());
AutoCompleteHelper.getHelper().Create("#Autocomplete_MailAccount", "#hf_MailAccount", url, function (res) {
var data = res;
var mailaccountoption = new Option(mailresponse.result.UserName, mailresponse.result.MailAccountId.toString(), true);
$("#Autocomplete_MailAccount").append(mailaccountoption);
});
}
});
let templateid = Number(Data[i].BString1);
Unibase.Platform.Templates.Managers.TemplateManager.Instance().getTemplateText(templateid).then(function (res) {
var mailtemplate = new Option(res.result.TemplateName, res.result.TemplateId.toString(), true);
$("#Autocomplete_Template").append(mailtemplate);
});
if (Data[i].String1 != "" && Data[i].String1 != null) {
let printProviderId = Number(Data[i].String1);
Unibase.Platform.Templates.Managers.TemplateManager.Instance().getPrintProvider(printProviderId).then(function (res) {
var mailtemplate = new Option(res.result.ProviderName, res.result.PrintProviderId.toString(), true);
$("#Autocomplete_InternalTemplate").append(mailtemplate);
});
}
var decodedData = unescape(Data[i].BString2);
var decode = HtmlHelper.getHelper().decode(decodedData);
$('.summernote__MailBody').summernote("code", decode);
eval('_floatingLabelHelper.init();');
}
}
getDefaultMailServer() {
Unibase.Apps.Communications.Managers.MailManager.Instance().getUserDefaultMailAccount().then(function (response) {
if (response.status == Unibase.Data.Status.Success) {
var mailserveroption = new Option(response.result.ServerName, response.result.MailServerId.toString(), true);
$("#Autocomplete_MailServer").append(mailserveroption);
var mailaccountoption = new Option(response.result.UserName, response.result.MailAccountId.toString(), true);
$("#Autocomplete_MailAccount").append(mailaccountoption);
}
});
}
SaveEmailAction(emailid, containerid) {
var instance = this;
let ruleactionid = Number(emailid);
let queryelmnt = $("#builder");
let recipients = Unibase.Platform.Automation.Components.ContactSelection.Instance().GetRecipients();
let contactcolumns = Unibase.Platform.Automation.Components.ContactSelection.Instance().getContactColumns();
let secondarycontactcolumns = Unibase.Platform.Automation.Components.ContactSelection.Instance().getSecondaryContactColumns();
let externalroles = Unibase.Platform.Automation.Components.ExternalRecipients.Instance().GetExternalRoles();
let externalusers = Unibase.Platform.Automation.Components.ExternalRecipients.Instance().GetExternalUsers();
let model = new Unibase.Platform.Automation.Requests.RuleAction();
let ExternalAttachments = Unibase.Platform.Automation.Components.ExternalAttachments.Instance().getFiles(Unibase.Platform.Automation.Components.SendEmail.Instance().formpropertyid);
var externalrecipients = Unibase.Platform.Automation.Components.ExternalRecipients.Instance().getexternalrecipients();
var template = "";
var code = $(".summernote__MailBody").summernote('code');
template = HtmlHelper.getHelper().encode(code);
template = template.trim();
model.RuleActionId = ruleactionid;
model.ActionId = Unibase.Platform.Automation.Components.SendEmail.Instance().ActionId;
model.RuleId = 0;
model.NotificationGroupId = $('#ddl_NotificationGrp').val() == undefined ? 0 : Number($('#ddl_NotificationGrp').val());
if (model.NotificationGroupId == 0) {
MessageHelper.Instance().showError("Please Select Notification Group", "Validate_EmailAction");
return;
}
if (instance.RuleInstance.IsStageChangeEvent()) {
model.FromStage = $('.from_stage_email option:selected').val() != "0" ? Number($('.from_stage_email option:selected').val()) : 0;
model.ToStage = $('.to_stage_email option:selected').val() != "0" ? Number($('.to_stage_email option:selected').val()) : 0;
}
model.RuleActionName = $("#txtEmail_RuleActionName").val().toString();
model.String1 = $("#Autocomplete_InternalTemplate option:selected").val() == undefined || null ? "" : $("#Autocomplete_InternalTemplate option:selected").val().toString();
model.BString1 = $("#Autocomplete_Template option:selected").val() == undefined || null ? "" : $("#Autocomplete_Template option:selected").val().toString();
model.BString2 = template;
model.BString3 = ExternalAttachments.length > 0 ? JSON.stringify(ExternalAttachments) : "";
model.BString4 = "";
model.BString5 = $('#message_result option:selected').val().toString();
model.BString6 = externalroles;
model.BString7 = externalusers;
model.String3 = $("#Autocomplete_MailAccount option:selected").val() == undefined || null ? "" : $("#Autocomplete_MailAccount option:selected").val().toString();
model.String4 = Number($("#Autocomplete_MailServer option:selected").val());
model.String5 = $('#chkIsRefAttachments').is(':checked').toString();
model.String7 = $('.isbulk_send').is(":checked");
model.ExternalReportId = ($("#txtAutoComplete_ReportsExternal option:selected").val() == undefined) ? 0 : Number($("#txtAutoComplete_ReportsExternal option:selected").val());
model.ExternalReportColumnId = Number($("#txtAutoComplete_ReportColumns option:selected").val());
model.ProviderColumnId = Number($("#txtAutoComplete_ProviderColumns option:selected").val());
model.Users = contactcolumns;
model.SecondaryUsers = secondarycontactcolumns;
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));
}
else {
model.SqlWhere = "";
model.SqlWhereJson = "";
}
model.ResultActionId = $("#ddl_ResultAction option:selected").val() == undefined ? 0 : 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.SendEmail.Instance().ParentActionId;
model.AutoApproved = $('#chkAutoApprovedEmail').is(':checked');
model.RecipientsData = recipients;
model.ExternalRecipients = externalrecipients;
model.RowIndex = Unibase.Platform.Automation.Components.SendEmail.Instance().RowIndex;
if (Unibase.Platform.Automation.Components.SendEmail.Instance().IsAutomationMode) {
if (Unibase.Platform.Automation.Components.SendEmail.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_EmailAction");
}
else {
MessageHelper.Instance().showSuccess(response.message, "Validate_EmailAction");
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
var actionname = response.result.RuleActionName;
eval("bizgaze_automation_flow_main.saveemailblock('" + response.result.RuleActionId + "','" + actionname + "')");
}
});
}
}
else {
model.RuleId = Unibase.Platform.Automation.Components.SendEmail.Instance().RuleId;
model.EventGroupId = Unibase.Platform.Automation.Components.SendEmail.Instance().EventGroupId;
model.RuleEventId = Unibase.Platform.Automation.Components.SendEmail.Instance().RuleEventId;
model.ActionId = Unibase.Platform.Automation.Components.SendEmail.Instance().ActionId;
model.ParentActionId = Unibase.Platform.Automation.Components.SendEmail.Instance().ParentActionId;
Automation.Managers.RuleManager.Instance().saveRuleAction(model).then(function (response) {
if (response.status == Unibase.Data.Status.Error) {
MessageHelper.Instance().showError(response.message, "Validate_EmailAction");
}
else {
MessageHelper.Instance().showSuccess(response.message, "Validate_EmailAction");
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
}
});
}
}
loadSummernote(Data) {
$(".summernote__MailBody").summernote({
height: 100,
minHeight: null,
maxHeight: null,
placeholder: "Mail Body",
disableDragAndDrop: true,
codemirror: {
mode: 'text/html',
lineNumbers: true
},
toolbar: [
['font', ['bold', 'italic', 'underline']],
['color', ['color']],
['view', ['fullscreen', 'codeview', 'help']],
],
hint: {
match: /\B[@!](\w*)$/,
search: function (keyword, callback) {
callback($.grep(Data, function (i) {
var user = i;
return user.indexOf(keyword) === 0;
}));
},
content: function (i) {
var user = i;
return $('<span>{{' + user + '}}</span>')[0];
}
}
});
}
loadTemplates(ruleproviderid) {
let templatetypeid = Number(Unibase.Platform.Templates.Enums.TemplateType.Mail);
Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleProvider(ruleproviderid).then(function (response) {
var url = _appsettings.server_url() + '/apis/v4/unibase/platform/templates/gettemplatesautocomplatebytemplatetype/installedappid/' + response.InstalledAppId + '/templatetypeid/' + templatetypeid;
AutoCompleteHelper.getHelper().Create("#Autocomplete_Template", "#hf_Template", url, function (response) {
var data = response;
});
});
}
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 = '<option value=' + response.NotificationGroupId + ' selected>' + response.NotificationGroupName + '</option>';
$('#ddl_NotificationGrp').html('').html(html);
}
});
});
}
static Instance() {
if (this.instance === undefined) {
this.instance = new SendEmail();
}
return this.instance;
}
}
Components.SendEmail = SendEmail;
})(Components = Automation.Components || (Automation.Components = {}));
})(Automation = Platform.Automation || (Platform.Automation = {}));
})(Platform = Unibase.Platform || (Unibase.Platform = {}));
})(Unibase || (Unibase = {}));
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,444 @@
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 ExecuteQuery 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 = `<form id="frmUnibase_ExecuteQuery" 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="Spn_ExecuteQuery">Create Execute Query</strong>
</div>
<div class="card-body scrollable" style="overflow-y: scroll;">
<div class="bg-white card" id="divExecuteQuery">
<div id="Validate_ExecuteQueryAction" class="clear"></div>
<div class="card-body">
<div class="row">
<div class="col-sm-12">
<div class="floating-label-form-group">
<label for="lbl" id="lbl_RuleActionName">Action<span class="text-danger required" id="spnIsRequired_RuleActionName"> *</span></label>
<input type="text" id="txtExecuteQuery_RuleActionName" class="form-control value-control required floating-label-control" placeholder="Action *" data-placeholder="Enter Action" data-label="Action *">
<input type="hidden" id="hf_RuleActionName" />
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div id="div_QueryType" class=" floating-label-form-group floating-label-form-group-with-value">
<label for="lbl" id="lbl_QueryType">Query Type</label>
<select id="ddl_QueryType" class="form-control">
<option value="1">Query</option>
<option value="2">Procedure</option>
</select>
<label for="Validation" id="lblValidation_QueryType"></label><input type="hidden" id="hfFormPropertyId" value="0" />
</div>
</div>
<div class="col-sm-6">
<div class="custom-control custom-checkbox checkbox-primary mt-40">
<input type="checkbox" class="custom-control-input" id="chkIsAsync">
<label class="custom-control-label" for="chkIsAsync">IsAsync</label>&nbsp
</div>
</div>
</div>
<div class="row">
<div id="div_Query" class="TextEditor col-sm-12">
<inpu type="hidden" id="txthdn__Query" class="value-control" value="">
<span class="text-danger" id="spnIsRequired__Query"></span>
<div class="type-control summernote__Query" style="display: block;" id="summernote__Query" data-propdoctypename="Query" data-required="" placeholder="Query" data-placeholder="Query" data-label="Query"></div>
<label for="Validation" id="lblValidation"></label>
</inpu>
</div>
</div>
<div class="row">
<div id="div_NotificationGrp" class="floating-label-form-group col-sm-6 floating-label-form-group-with-value">
<label for="lbl_NotificationGrp" id="lbl_NotificationGroup">Notification Group<span class="text-danger"> *</span></label>
<select id="ddl_NotificationGrp" class="form-control"><option value="0">Select Group</option></select>
</div><div class="col-sm-6 createbtn_grp"><button class="badge badge-primary mt-30 ml-15" id="creategrp_btn">Create Group</button></div></div>
<div class="row">
<div class="ResultActions col-sm-6 hidden">
<div id="div_ResultAction" class=" floating-label-form-group floating-label-form-group-with-value">
<label for="lbl" id="lbl_ResultAction">Result Action</label>
<select id="ddl_ResultAction" class="form-control">
<option value="0">Select</option>
</select>
<label for="Validation" id="lblValidation_ResultAction"></label><input type="hidden" id="hfFormPropertyId" value="0" />
</div>
</div>
<!---- <div class="col-sm-6">
<div class="custom-control custom-checkbox divEnablePieces checkbox-primary mt-25">
<input type="checkbox" class="custom-control-input" id="chkAutoApprovedExecuteQuery" checked>
<label class="custom-control-label" for="chkAutoApprovedExecuteQuery">Perform this Action</label>&nbsp
</div>
</div>---->
</div>
</div>
</div>
<div class="bg-white card Advanced_optionsdata">
<div class="card-header"><i class="fa fa-angle-down arrowicon mr-1" onclick="Unibase.Platform.Automation.Components.ExecuteQuery.Instance().Toggleadvancedoptions()"></i>Advanced Options</div>
<div class="card-body Advanced_options hidden">
<div class="row">
<div class="col-sm-6 floating-label-form-group floating-label-form-group-with-value">
<label class="Message_type">Message Type</label>
<select class="form-control" id="message_result">
<option value="0">Success</option>
<option value="1">Warning</option>
<option value="2">Error</option>
</select>
</div>
<div class="col-sm-6">
<input type="checkbox" class="test_data mt-50" id="chkAutoApprovedExecuteQuery" checked>Perform this Action
<!---<label class="check_action">Perform this Action</label>---->
</div>
</div>
</div>
</div>
<div class="bg-white card" id="ActionConditionsDivdata">
<div class="card-header"><i class="fa fa-angle-down conditionicon mr-1" style="font-size:20px" onclick="Unibase.Platform.Automation.Components.ExecuteQuery.Instance().ToggleExecuteQueryConditions();"></i>Condition Details</div>
<div class="card-body hidden" id="ActionConditionsDiv">
<div class="ActionConditions">
<!--For Action Conditions-->
</div>
</div>
</div>
</div>
<div class="bg-white card-footer footer" id="CreateExecuteQueryFooter">
<a href="javascript:;" id="btnCloseExecuteQuery" class="btn btn-light btn-sm mr-auto "> Close</a>
<a href="javascript:;" id="btnSaveExecuteQuery" class="btn btn-primary btn-sm"> Save</a>
</div>
</div>
</form>`;
return html;
}
load(id, containerid, callback) {
return __awaiter(this, void 0, void 0, function* () {
var instance = this;
Unibase.Platform.Automation.Components.ExecuteQuery.Instance().ActionId = instance.ActionId;
Unibase.Platform.Automation.Components.ExecuteQuery.Instance().RuleActionData = instance.RuleActionData;
Unibase.Platform.Automation.Components.ExecuteQuery.Instance().RowIndex = instance.RowIndex;
Unibase.Platform.Automation.Components.ExecuteQuery.Instance().AutomationMode = instance.AutomationMode;
Unibase.Platform.Automation.Components.ExecuteQuery.Instance().RuleProviderId = instance.RuleProviderId;
Unibase.Platform.Automation.Components.ExecuteQuery.Instance().ParentActionId = instance.ParentActionId;
Unibase.Platform.Automation.Components.ExecuteQuery.Instance().IsAutomationMode = instance.IsAutomationMode;
yield Unibase.Platform.Automation.Components.NotificationGroup.Instance().LoadNotificationGroups();
if (instance.AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.AdvancedMode) {
eval('bizgaze_automation_flow_main.getcontainerid("' + containerid + '")');
}
$("#btnCloseExecuteQuery").click(function () {
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
if (Unibase.Platform.Automation.Components.ExecuteQuery.Instance().AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.NormalMode) {
if (Unibase.Platform.Automation.Components.ExecuteQuery.Instance().AutomationMode) {
if (Unibase.Platform.Automation.Components.ExecuteQuery.Instance().IsAutomationMode) {
Unibase.Platform.Automation.Components.Rule.Instance().ChangeAction(instance.RowIndex, id);
}
}
}
else {
eval("bizgaze_automation_flow_main.getpopupclosed()");
}
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
});
$("#btnSaveExecuteQuery").click(function () {
let appcontrolid = "frmUnibase_ExecuteQuery";
let result = Unibase.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation(appcontrolid);
if (result == false) {
MessageHelper.Instance().showError("Mandatory fields are missing", "Validate_ExecuteQueryAction");
return false;
}
else {
Unibase.Platform.Automation.Components.ExecuteQuery.Instance().SaveExecuteQuery(id, containerid);
}
});
$("#ddl_QueryType").val(1);
if (instance.ParentActionId != 0) {
Unibase.Platform.Automation.Components.ContactSelection.Instance().getResultActions(instance.ParentActionId);
yield Unibase.Platform.Automation.Components.ExecuteQuery.Instance().GetRuleActionInfo(Number(instance.ParentActionId));
$('#ddl_NotificationGrp').prop("disabled", true);
$('#creategrp_btn').addClass('d-none');
}
$('#creategrp_btn').click(function () {
Unibase.Platform.Automation.Components.NotificationGroup.Instance().init(0, null, true);
});
if (id != "") {
setTimeout(function () { Unibase.Platform.Automation.Components.ExecuteQuery.Instance().EditExecuteQuery(id); }, 10);
}
let rpid = instance.RuleProviderId;
if (rpid != 0) {
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(rpid, null);
Unibase.Platform.Automation.Managers.RuleManager.Instance().getTokens(instance.RuleProviderId).then(function (response) {
var Data = new Array();
for (let i = 0; i <= response.length - 1; i++) {
var result = response[i];
Data.push(result);
}
Unibase.Platform.Automation.Components.ExecuteQuery.Instance().loadSummernote(Data);
});
}
if (instance.RuleActionData.length != 0) {
Unibase.Platform.Automation.Components.ExecuteQuery.Instance().LoadExecuteQueryData(instance.RuleActionData);
}
});
}
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 = '<option value=' + response.NotificationGroupId + ' selected>' + response.NotificationGroupName + '</option>';
$('#ddl_NotificationGrp').html('').html(html);
}
});
});
}
ToggleExecuteQueryConditions() {
$('#ActionConditionsDiv').toggleClass("hidden");
if ($('.conditionicon').hasClass('fa-angle-down')) {
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.ExecuteQuery.Instance().RuleProviderId, null);
}
else {
$('.conditionicon').removeClass('fa-angle-up').addClass('fa-angle-down');
}
}
Toggleadvancedoptions() {
if ($('.arrowicon').hasClass('fa-angle-down')) {
$('.arrowicon').removeClass('fa-angle-down').addClass('fa-angle-up');
}
else {
$('.arrowicon').removeClass('fa-angle-up').addClass('fa-angle-down');
}
$('.Advanced_options').toggleClass("hidden");
}
EditExecuteQuery(id) {
let actionid = Number(id);
$("#Spn_ExecuteQuery").text("Edit Execute Query");
Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleAction(actionid).then(function (response) {
$("#txtExecuteQuery_RuleActionName").val(response.RuleActionName);
$('#ddl_NotificationGrp option[value=' + response.NotificationGroupId + ']').prop('selected', true);
if (!Unibase.Platform.Automation.Components.ExecuteQuery.Instance().IsAutomationMode) {
Unibase.Platform.Automation.Components.ExecuteQuery.Instance().RuleId = response.RuleId;
Unibase.Platform.Automation.Components.ExecuteQuery.Instance().RuleEventId = response.RuleEventId;
Unibase.Platform.Automation.Components.ExecuteQuery.Instance().EventGroupId = response.EventGroupId;
Unibase.Platform.Automation.Components.ExecuteQuery.Instance().ActionId = response.ActionId;
Unibase.Platform.Automation.Components.ExecuteQuery.Instance().ParentActionId = response.ParentActionId;
}
$("#ddl_QueryType").val(response.String4);
$("#ddl_QueryType").attr("disabled", "disabled");
$('#message_result').val(Number(response.BString5));
if (response.ResultActionId != null) {
$('#ddl_ResultAction').val(response.ResultActionId);
}
if (response.ExecuteStatusId != Number(Unibase.Platform.Automation.Enums.ExecuteActionStatus.Approved))
$("#chkAutoApprovedExecuteQuery").prop("checked", false);
else
$("#chkAutoApprovedExecuteQuery").prop("checked", true);
if (response.BString2 == "1") {
$("#chkIsAsync").prop("checked", true);
}
else {
$("#chkIsAsync").prop("checked", false);
}
$('.summernote__Query').summernote("code", response.BString1);
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(response.RuleProviderId, response.SqlWhere);
$("#btn_ActionConditions").addClass("hidden");
if (response.SqlWhere != null && response.SqlWhere != "") {
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
$("#ActionConditionsDiv").removeClass("hidden");
}
eval('_floatingLabelHelper.init();');
});
}
LoadExecuteQueryData(Data) {
for (var i = 0; i < Data.length; i++) {
$("#txtExecuteQuery_RuleActionName").val(Data[i].RuleActionName);
$("#txtExecuteQuery_ApiParameter").val(Data[i].BString1);
if (!Data[i].AutoApproved)
$("#chkAutoApprovedExecuteQuery").prop("checked", false);
else
$("#chkAutoApprovedExecuteQuery").prop("checked", true);
if (Data[i].BString2 == "1") {
$("#chkIsAsync").prop("checked", true);
}
else {
$("#chkIsAsync").prop("checked", false);
}
$('.summernote__Query').summernote("code", Data[i].BString1);
if (Data[i].SqlWhere != "" && Data[i].SqlWhere != null) {
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.ExecuteQuery.Instance().RuleProviderId, Data[i].SqlWhere);
$("#btn_ActionConditions").addClass("hidden");
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
$("#ActionConditionsDiv").removeClass("hidden");
}
eval('_floatingLabelHelper.init();');
}
}
SaveExecuteQuery(ExecuteQueryid, containerid) {
let ruleactionid = Number(ExecuteQueryid);
var contents = $('.summernote__Query').summernote('code');
var plainText = $("<p>" + contents + "</p>").text();
let queryelmnt = $("#builder");
let model = new Unibase.Platform.Automation.Requests.RuleAction();
model.RuleActionId = ruleactionid;
model.RuleActionName = $("#txtExecuteQuery_RuleActionName").val().toString();
model.BString1 = plainText;
model.String4 = Number($("#ddl_QueryType option:selected").val());
model.BString5 = $('#message_result option:selected').val().toString();
model.ActionId = Unibase.Platform.Automation.Components.ExecuteQuery.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_ExecuteQueryAction");
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));
}
else {
model.SqlWhere = "";
model.SqlWhereJson = "";
}
model.ResultActionId = Number($("#ddl_ResultAction option:selected").val());
if (model.ResultActionId != 0) {
model.ResultActionName = $("#ddl_ResultAction option:selected").text();
}
else {
model.ResultActionName = "";
}
if ($('#chkIsAsync').is(':checked')) {
model.BString2 = "1";
}
else {
model.BString2 = "0";
}
model.DelayTime = 0;
model.ParentActionId = Unibase.Platform.Automation.Components.ExecuteQuery.Instance().ParentActionId;
model.AutoApproved = $('#chkAutoApprovedExecuteQuery').is(':checked');
model.RowIndex = Unibase.Platform.Automation.Components.ExecuteQuery.Instance().RowIndex;
if (Unibase.Platform.Automation.Components.ExecuteQuery.Instance().IsAutomationMode) {
if (Unibase.Platform.Automation.Components.ExecuteQuery.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_ExecuteQueryAction");
}
else {
MessageHelper.Instance().showSuccess(response.message, "Validate_ExecuteQueryAction");
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
var actionname = response.result.RuleActionName;
eval("bizgaze_automation_flow_main.saveExecuteQueryblock('" + response.result.RuleActionId + "','" + actionname + "')");
}
});
}
}
else {
model.RuleId = Unibase.Platform.Automation.Components.ExecuteQuery.Instance().RuleId;
model.EventGroupId = Unibase.Platform.Automation.Components.ExecuteQuery.Instance().EventGroupId;
model.RuleEventId = Unibase.Platform.Automation.Components.ExecuteQuery.Instance().RuleEventId;
model.ActionId = Unibase.Platform.Automation.Components.ExecuteQuery.Instance().ActionId;
model.ParentActionId = Unibase.Platform.Automation.Components.ExecuteQuery.Instance().ParentActionId;
Automation.Managers.RuleManager.Instance().saveRuleAction(model).then(function (response) {
if (response.status == Unibase.Data.Status.Error) {
MessageHelper.Instance().showError(response.message, "Validate_ExecuteQueryAction");
}
else {
MessageHelper.Instance().showSuccess(response.message, "Validate_ExecuteQueryAction");
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
}
});
}
}
loadSummernote(Data) {
$(".summernote__Query").summernote({
height: 100,
minHeight: null,
maxHeight: null,
placeholder: "Query",
disableDragAndDrop: true,
codemirror: {
mode: 'text/html',
lineNumbers: true
},
toolbar: [
['font', ['bold', 'italic', 'underline']],
['color', ['color']],
['view', ['fullscreen', 'codeview', 'help']],
],
hint: {
match: /\B[@!](\w*)$/,
search: function (keyword, callback) {
callback($.grep(Data, function (i) {
var user = i;
return user.indexOf(keyword) === 0;
}));
},
content: function (i) {
var user = i;
return $('<span>@' + user + '</span>')[0];
}
}
});
}
static Instance() {
if (this.instance === undefined) {
this.instance = new ExecuteQuery();
}
return this.instance;
}
}
Components.ExecuteQuery = ExecuteQuery;
})(Components = Automation.Components || (Automation.Components = {}));
})(Automation = Platform.Automation || (Platform.Automation = {}));
})(Platform = Unibase.Platform || (Unibase.Platform = {}));
})(Unibase || (Unibase = {}));
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,694 @@
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 SendNotification extends Platform.Core.BaseComponent {
constructor() {
super(...arguments);
this.RowIndex = 0;
this.RuleProviderId = 0;
this.AutomationMode = 0;
this.RuleInstance = Unibase.Platform.Automation.Components.Rule.Instance();
}
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/apps/managers/stagemanager.js", "platform/automation/components/rulebuilder/rulebuilder.rule.js", "platform/automation/components/rulebuilder/notificationgroup.js", "platform/automation/managers/notificationgroupmanager.js"
];
return jsfiles;
}
cssFiles() {
return [];
}
html(id, containerid) {
let html = `<form id="frmUnibase_SendNotification" 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="Spn_SendNotification">Create Notification</strong>
</div>
<div class="card-body scrollable" style="overflow-y: scroll;">
<div class="bg-white card" id="divSendNotification">
<div id="Validate_NotificationAction" class="clear"></div>
<div class="card-body">
<div class="row">
<div class="col-sm-12">
<div class="floating-label-form-group">
<label for="lbl_RuleActionName" id="lbl_RuleActionName">Action<span class="text-danger">*</span></label>
<input type="text" id="txtNotifications_RuleActionName" class="form-control required value-control floating-label-control" data-isdynamic="false" placeholder="Action *" data-placeholder="Enter Action" data-label="Action *" />
<input type="hidden" id="hf_RuleActionName" />
<label for="Validation" id="lblValidation_RuleActionName"></label>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div id="div_Subject" class="floating-label-form-group">
<label for="lbl_MessageSubject" id="lbl_MessageSubject">Subject<span class="text-danger"> *</span></label>
<div class="input-group">
<input type="text" id="txtNotifications_MessageSubject" class="col-sm-9 form-control value-control required floating-label-control" data-placeholder="Enter Subject" placeholder="Subject *" data-label="Subject *">
<select id="ddl_SubjectTokens" class="col-sm-3 form-control value-control">
<option value="0">Select Token</option>
</select>
</div>
</div>
</div>
</div>
<div class="row mt-3">
<div class="col-sm-12">
<div id="div_Body" class="floating-label-form-group">
<label for="lbl_MessageBody" id="lbl_MessageBody">Body<span class="text-danger"> *</span></label>
<div class="input-group">
<!--- <input type="text" id="txtNotifications_MessageBody" class="col-sm-9 form-control value-control required floating-label-control" data-placeholder="Enter Body" placeholder="Body *" data-label="Body *">--->
<textarea id="txtNotifications_MessageBody" class="form-control value-control required floating-label-control" style="width:50%;" placeholder="Body" data-placeholder="Notification Body" data-label="Body*"></textarea>
<select id="ddl_BodyTokens" class="col-sm-3 form-control value-control">
<option value="0">Select Token</option>
</select>
</div>
</div>
</div>
</div>
<div class="row">
<div id="div_NotificationGrp" class="floating-label-form-group col-sm-6 floating-label-form-group-with-value">
<label for="lbl_NotificationGrp" id="lbl_NotificationGroup">Notification Group<span class="text-danger"> *</span></label>
<select id="ddl_NotificationGrp" class="form-control"><option value="0">Select Group</option></select>
</div><div class="col-sm-6 createbtn_grp"><button class="badge badge-primary mt-30 ml-15" id="creategrp_btn">Create Group</button></div></div>
<div class="row">
<div class="ResultActions col-sm-6 hidden">
<div id="div_ResultAction" class=" floating-label-form-group floating-label-form-group-with-value">
<label for="lbl" id="lbl_ResultAction">Result Action</label>
<select id="ddl_ResultAction" class="form-control">
<option value="0">Select</option>
</select>
<label for="Validation" id="lblValidation_ResultAction"></label><input type="hidden" id="hfFormPropertyId" value="0" />
</div>
</div>
</div>
</div>
</div>
<div class="bg-white card Advanced_optionsdata">
<div class="card-header"><i class="fa fa-angle-down arrowicon mr-1" onclick="Unibase.Platform.Automation.Components.SendNotification.Instance().Toggleadvancedoptions()"></i>Advanced Options</div>
<div class="card-body Advanced_options hidden">
<div class="row">
<div class="col-sm-6">
<div id="div_NotificationType" class=" floating-label-form-group floating-label-form-group-with-value">
<label for="lbl" id="lbl_NotificationType">Notification Type</label>
<select id="ddl_NotificationType" class="form-control">
<option value="0">Select</option>
<option value="1">List</option>
<option value="2">Details</option>
<option value="3">FileDownload</option>
<option value="4">FilePreview</option>
<option value="5">FolderPreview</option>
<option value="6">Create</option>
</select>
<input type="hidden" id="hf_NotificationType" value="2" />
</div>
</div>
<div class="col-sm-6">
<div id="div_RefColumn" class=" floating-label-form-group floating-label-form-group-with-value">
<label for="lbl" id="lbl_RefColumn">Ref Column</label>
<select id="ddl_RefColumn" class="form-control"> </select>
<input type="hidden" id="hf_RefColumn" value="" />
</div>
</div>
</div>
<div class="row hidden mt-2" id="createform_row">
<div class="col-sm-6">
<div id="div_createinstalledid" class=" floating-label-form-group floating-label-form-group-with-value">
<label for="lbl">Installed App</label>
<select id="ddl_createinstalledid" class="form-control text-control" style="width:100%;">
</select>
</div>
</div>
<div class="col-sm-6">
<div id="div_Form" class=" floating-label-form-group floating-label-form-group-with-value">
<label for="lbl" id="lbl_RefColumn">Create Form</label>
<select id="ddl_Form" class="form-control"></select>
<input type="hidden" id="hf_createForm" value=""/>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6 floating-label-form-group floating-label-form-group-with-value">
<label class="Message_type">Message Type</label>
<select class="form-control" id="message_result">
<option value="0">Success</option>
<option value="1">Warning</option>
<option value="2">Error</option>
</select>
</div>
<div class="col-sm-6">
<input type="checkbox" class="test_data mt-50" id="chkAutoApprovedNotification"checked>Perform this Action
</div>
</div>
<!---parent options---->
<div class="row">
<div class="col-sm-6 mt-50">
<input type="checkbox" class="isparent"><span class="ml-2">IsParent</span>
</div>
<div class="col-sm-6 floating-label-form-group-with-value Parentcolumns_info d-none">
<label class="Parent_pkid ml-2 mt-2">Parent Pkid</label>
<select class="form-control" id="parent_pkid">
</select>
</div>
</div>
<!---end---->
</div>
</div>
<div class="bg-white card hidden" id="DocTypesDiv">
<div class="card-header">DocTypes</div>
<div class="card-body">
<div class="SelectDocType col-sm-12">
<!--For Mapping of datalists-->
</div>
</div>
</div>
<div class="bg-white card" id="ActionConditionsDivdata">
<div class="card-header"><i class="fa fa-angle-down conditionicon mr-1" style="font-size:20px" onclick="Unibase.Platform.Automation.Components.SendNotification.Instance().ToggleNotificationConditions();"></i>Condition Details</div>
<div class="card-body hidden" id="ActionConditionsDiv">
<div class="ActionConditions">
<!--For Action Conditions-->
</div>
</div>
</div><div class="bg-white card" id="SelectstagesDiv">
<div class="card-header">Stage Event</div>
<div class="card-body">
<div class="stages_drp row"><div class="col-sm-6"><label class="from_label">From Stage</label><select class="from_stage_notification form-control"></select></div><div class="col-sm-6"><label class="_label">To Stage</label><select class="to_stage_notification form-control"></select></div></div>
</div></div>
<div class="bg-white card" id="SelectRoleDiv">
<div class="card-header">Send To Details</div>
<div class="card-body">
<div class="ContactSelection col-sm-12">
<!--For ContactSelection page-->
</div>
</div>
</div>
<div class="bg-white card col-sm-3 hidden" id="btn_ExternalRecipients">
<button type="button" class="btn btn-primary" onclick="Unibase.Platform.Automation.Components.SendNotification.Instance().ToggleExternalRecipients();">External Recipients</button>
</div>
<div class="bg-white card hidden" id="ExternalRecipientsDiv">
<div class="card-header">External Recipients</div>
<div class="card-body">
<div class="ExternalRecipients">
</div>
</div>
</div>
</div>
<div class="bg-white card-footer footer" id="CreateNotificationFooter">
<a href="javascript:;" id="btnCloseNotification" class="btn btn-light btn-sm mr-auto "> Close</a>
<a href="javascript:;" id="btnSaveNotification" class="btn btn-primary btn-sm"> Save</a>
</div>
</div>
</form>`;
return html;
}
load(id, containerid, callback) {
return __awaiter(this, void 0, void 0, function* () {
var instance = this;
Unibase.Platform.Automation.Components.SendNotification.Instance().ActionId = instance.ActionId;
Unibase.Platform.Automation.Components.SendNotification.Instance().RuleActionData = instance.RuleActionData;
Unibase.Platform.Automation.Components.SendNotification.Instance().RowIndex = instance.RowIndex;
Unibase.Platform.Automation.Components.SendNotification.Instance().AutomationMode = instance.AutomationMode;
Unibase.Platform.Automation.Components.SendNotification.Instance().RuleProviderId = instance.RuleProviderId;
Unibase.Platform.Automation.Components.SendNotification.Instance().ParentActionId = instance.ParentActionId;
Unibase.Platform.Automation.Components.SendNotification.Instance().IsAutomationMode = instance.IsAutomationMode;
yield Unibase.Platform.Automation.Components.NotificationGroup.Instance().LoadNotificationGroups();
if (instance.AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.AdvancedMode) {
eval('bizgaze_automation_flow_main.getcontainerid("' + containerid + '")');
}
if (instance.ParentActionId != 0) {
yield Unibase.Platform.Automation.Components.ContactSelection.Instance().getResultActions(instance.ParentActionId);
yield Unibase.Platform.Automation.Components.SendNotification.Instance().GetRuleActionInfo(Number(instance.ParentActionId));
$('#ddl_NotificationGrp').prop("disabled", true);
$('#creategrp_btn').addClass('d-none');
}
var _fileCacheHelper = Platform.Helpers.FileCacheHelper.Instance();
yield _fileCacheHelper.loadJsFileAsync("platform/automation/components/contactselection.js", function () {
jQuery(".ContactSelection").html(Unibase.Platform.Automation.Components.ContactSelection.Instance().init(instance.RuleProviderId));
if (instance.RuleActionData.length != 0) {
Unibase.Platform.Automation.Components.SendNotification.Instance().LoadNotificationData(instance.RuleActionData);
}
});
yield _fileCacheHelper.loadJsFileAsync("platform/automation/components/externalrecipients.js", function () {
jQuery(".ExternalRecipients").html(Unibase.Platform.Automation.Components.ExternalRecipients.Instance().init(instance.RuleProviderId));
Unibase.Platform.Automation.Components.ExternalRecipients.Instance().load(instance.RuleProviderId);
});
var url = _appsettings.server_url() + '/apis/v4/unibase/platform/apps/installedappautocomplete';
AutoCompleteHelper.getHelper().Create("#ddl_createinstalledid", "#hf_Autocomplete_InstalledApp", url, function (response) {
var data = response;
});
$('#creategrp_btn').click(function () {
Unibase.Platform.Automation.Components.NotificationGroup.Instance().init(0, null, true);
});
$("#btnCloseNotification").click(function () {
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
if (Unibase.Platform.Automation.Components.SendNotification.Instance().AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.NormalMode) {
if (Unibase.Platform.Automation.Components.SendNotification.Instance().AutomationMode) {
if (Unibase.Platform.Automation.Components.SendNotification.Instance().IsAutomationMode) {
Unibase.Platform.Automation.Components.Rule.Instance().ChangeAction(instance.RowIndex, id);
}
}
}
else {
eval("bizgaze_automation_flow_main.getpopupclosed()");
}
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
});
$('.isparent').change(function () {
if ($('.isparent').is(':checked')) {
$('.Parentcolumns_info').removeClass('d-none');
}
else {
$('.Parentcolumns_info').addClass('d-none');
}
});
if (instance.RuleInstance.IsStageChangeEvent()) {
$('#SelectstagesDiv').removeClass('d-none');
yield Unibase.Platform.Automation.Components.SendNotification.Instance().LoadAppStages();
}
else {
$('#SelectstagesDiv').addClass('d-none');
}
$("#btnSaveNotification").click(function () {
let appcontrolid = "frmUnibase_SendNotification";
let result = Unibase.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation(appcontrolid);
if (result == false) {
MessageHelper.Instance().showError("Mandatory fields are missing", "Validate_NotificationAction");
return false;
}
else {
Unibase.Platform.Automation.Components.SendNotification.Instance().SaveNotificationAction(id, containerid);
}
});
$("#ddl_SubjectTokens").change(function () {
var textAreaTxt = $("#txtNotifications_MessageSubject").val().toString();
var txtToAdd = '{{' + $("#ddl_SubjectTokens option:selected").text() + '}}';
var firsttext = textAreaTxt.slice(0, SendNotification.Instance().tokenposition);
var lasttext = textAreaTxt.slice(SendNotification.Instance().tokenposition, textAreaTxt.length);
$("#txtNotifications_MessageSubject").val(firsttext + txtToAdd + lasttext);
$("#ddl_SubjectTokens").val(0);
});
$("#ddl_BodyTokens").change(function (event) {
var textAreaTxt = $("#txtNotifications_MessageBody").val().toString();
var txtToAdd = '{{' + $("#ddl_BodyTokens option:selected").text() + '}}';
var firsttext = textAreaTxt.slice(0, SendNotification.Instance().tokenposition);
var lasttext = textAreaTxt.slice(SendNotification.Instance().tokenposition, textAreaTxt.length);
$("#txtNotifications_MessageBody").val(firsttext + txtToAdd + lasttext);
$("#ddl_BodyTokens").val(0);
});
$("#txtNotifications_MessageBody").focusout(function (event) {
SendNotification.Instance().tokenposition = event["target"]["selectionStart"];
});
$("#txtNotifications_MessageSubject").focusout(function (event) {
SendNotification.Instance().tokenposition = event["target"]["selectionStart"];
});
$("#ddl_NotificationType").val($("#hf_NotificationType").val());
let rpid = instance.RuleProviderId;
if (rpid != 0) {
Unibase.Platform.Automation.Components.SendNotification.Instance().LoadMsgSubjectTokens(rpid);
Unibase.Platform.Automation.Components.SendNotification.Instance().LoadMsgBodyTokens(rpid);
yield Unibase.Platform.Automation.Components.SendNotification.Instance().LoadParentTokens(rpid);
Unibase.Platform.Automation.Components.SendNotification.Instance().LoadRefColumns(rpid);
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(rpid, null);
}
if (id != "") {
Unibase.Platform.Automation.Components.SendNotification.Instance().EditNotificationAction(id, containerid);
}
$("#ddl_createinstalledid").change(function () {
$('#ddl_Form').html('');
var installedid = Number($("#ddl_createinstalledid option:selected").val());
if (installedid != 0) {
Unibase.Platform.Automation.Managers.RuleManager.Instance().getCreateFormsByInstalledAppId(installedid).then(function (response) {
if (response.result != null) {
var html = '';
for (let i = 0; i < response.result.length; i++) {
html += '<option value=' + response.result[i].Appconfigid + '>' + response.result[i].FormName + '</option>';
}
$('#ddl_Form').append(html);
}
});
}
});
$('#ddl_NotificationType').change(function () {
if ($("#ddl_NotificationType").val() == "6") {
$('#createform_row').removeClass('hidden');
}
else {
$('#createform_row').addClass('hidden');
}
});
});
}
ToggleNotificationConditions() {
$('#ActionConditionsDiv').toggleClass("hidden");
if ($('.conditionicon').hasClass('fa-angle-down')) {
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.SendNotification.Instance().RuleProviderId, null);
}
else {
$('.conditionicon').removeClass('fa-angle-up').addClass('fa-angle-down');
}
}
ToggleExternalRecipients() {
$("#ExternalRecipientsDiv").toggle(function () {
$("#btn_ExternalRecipients").addClass("hidden");
$("#ExternalRecipientsDiv").removeClass("hidden");
});
}
LoadAppStages() {
return __awaiter(this, void 0, void 0, function* () {
var html = '';
var fromstage = '<option value="0">Select FromStage</option>';
var tostage = '<option value="0">Select ToStage</option>';
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>';
}
}
$('.from_stage_notification').html(fromstage + html);
$('.to_stage_notification').html(tostage + html);
});
});
}
Toggleadvancedoptions() {
if ($('.arrowicon').hasClass('fa-angle-down')) {
$('.arrowicon').removeClass('fa-angle-down').addClass('fa-angle-up');
}
else {
$('.arrowicon').removeClass('fa-angle-up').addClass('fa-angle-down');
}
$('.Advanced_options').toggleClass("hidden");
}
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 = '<option value=' + response.NotificationGroupId + ' selected>' + response.NotificationGroupName + '</option>';
$('#ddl_NotificationGrp').html('').html(html);
}
});
});
}
EditNotificationAction(id, containerid) {
let actionid = Number(id);
$("#Spn_SendNotification").text("Edit Notification");
Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleAction(actionid).then(function (response) {
$("#txtNotifications_RuleActionName").val(response.RuleActionName);
$("#txtNotifications_MessageSubject").val(response.BString1);
$("#txtNotifications_MessageBody").val(response.BString2);
$("#ddl_NotificationType").val(response.String4);
$("#hf_RefColumn").val(response.BString3);
$('#message_result').val(Number(response.BString5));
$('#ddl_NotificationGrp option[value=' + response.NotificationGroupId + ']').prop('selected', true);
if (response.ResultActionId != null && response.ResultActionId != "") {
$('#ddl_ResultAction').val(response.ResultActionId);
}
if (!Unibase.Platform.Automation.Components.SendNotification.Instance().IsAutomationMode) {
Unibase.Platform.Automation.Components.SendNotification.Instance().RuleId = response.RuleId;
Unibase.Platform.Automation.Components.SendNotification.Instance().RuleEventId = response.RuleEventId;
Unibase.Platform.Automation.Components.SendNotification.Instance().EventGroupId = response.EventGroupId;
Unibase.Platform.Automation.Components.SendNotification.Instance().ActionId = response.ActionId;
Unibase.Platform.Automation.Components.SendNotification.Instance().ParentActionId = response.ParentActionId;
}
if (response.ExecuteStatusId != Number(Unibase.Platform.Automation.Enums.ExecuteActionStatus.Approved))
$("#chkAutoApprovedNotification").prop("checked", false);
else
$("#chkAutoApprovedNotification").prop("checked", true);
$("#div_Subject").addClass('floating-label-form-group-with-value');
$("#div_Body").addClass('floating-label-form-group-with-value');
Unibase.Platform.Automation.Components.ContactSelection.Instance().BindRecipients(response.RuleActionId);
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckContactColumns(response.Users);
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckSecondaryContactColumns(response.SecondaryUsers);
$("#btn_ActionConditions").addClass("hidden");
if (response.SqlWhere != null && response.SqlWhere != "") {
$("#ActionConditionsDiv").removeClass("hidden");
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
}
if (response.FromStage != 0 && response.ToStage != 0) {
$('.from_stage_notification option[value=' + response.FromStage + ' ]').prop('selected', true);
$('to_stage_notification option[value=' + response.ToStage + ']').prop('selected', true);
}
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(response.RuleProviderId, response.SqlWhere);
$("#btn_ActionConditions").addClass("hidden");
if (response.String6 != null && response.String6 != "") {
$('#createform_row').removeClass('hidden');
Unibase.Platform.Forms.Managers.FormManager.Instance().getFormByAppConfiguration(Number(response.String6)).then(function (responsedata) {
if (responsedata.result != null) {
$('#ddl_Form').append('<option value=' + response.String6 + ' option:selected>' + responsedata.result.FormName + '</option>');
Unibase.Platform.Apps.Managers.AppManager.Instance().getInstallApp(Number(responsedata.result.InstalledAppId)).then(function (resultinfo) {
if (resultinfo.result != null) {
$('#ddl_createinstalledid').append('<option value="' + resultinfo.result.InstalledAppId + '" option:selected>' + resultinfo.result.AppTitle + '</option>');
}
});
}
});
}
if (response.IsParent) {
$('.isparent').prop("checked", true);
$('.Parentcolumns_info').removeClass('d-none');
if (response.String2 != null)
$('#parent_pkid').find("#" + response.String2 + "").attr("selected", "true");
}
eval('_floatingLabelHelper.init();');
});
}
LoadNotificationData(Data) {
for (var i = 0; i < Data.length; i++) {
$("#txtNotifications_RuleActionName").val(Data[i].RuleActionName);
$("#txtNotifications_MessageSubject").val(Data[i].BString1);
$("#txtNotifications_MessageBody").val(Data[i].BString2);
$("#ddl_NotificationType").val(Data[i].String4);
$("#hf_RefColumn").val(Data[i].BString3);
if (!Data[i].AutoApproved)
$("#chkAutoApprovedNotification").prop("checked", false);
else
$("#chkAutoApprovedNotification").prop("checked", true);
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckContactColumns(Data[i].Users);
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckSecondaryContactColumns(Data[i].SecondaryUsers);
$("#div_Subject").addClass('floating-label-form-group-with-value');
$("#div_Body").addClass('floating-label-form-group-with-value');
if (Data[i].RecipientsData != null) {
$("#select2_Roles").val(Data[i].RecipientsData.RoleRecipients).trigger('change');
$("#select2_Users").val(Data[i].RecipientsData.UserRecipients).trigger('change');
}
if (Data[i].SqlWhere != "" && Data[i].SqlWhere != null) {
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.SendNotification.Instance().RuleProviderId, Data[i].SqlWhere);
$("#btn_ActionConditions").addClass("hidden");
$("#ActionConditionsDiv").removeClass("hidden");
}
eval('_floatingLabelHelper.init();');
}
}
SaveNotificationAction(notificationid, containerid) {
var instance = this;
let ruleactionid = Number(notificationid);
let queryelmnt = $("#builder");
let recipients = Unibase.Platform.Automation.Components.ContactSelection.Instance().GetRecipients();
let contactcolumns = Unibase.Platform.Automation.Components.ContactSelection.Instance().getContactColumns();
let secondarycontactcolumns = Unibase.Platform.Automation.Components.ContactSelection.Instance().getSecondaryContactColumns();
let externalroles = Unibase.Platform.Automation.Components.ExternalRecipients.Instance().GetExternalRoles();
let externalusers = Unibase.Platform.Automation.Components.ExternalRecipients.Instance().GetExternalUsers();
let model = new Unibase.Platform.Automation.Requests.RuleAction();
model.RuleActionId = ruleactionid;
model.RuleActionName = $("#txtNotifications_RuleActionName").val().toString();
model.String4 = Number($("#ddl_NotificationType option:selected").val());
model.BString1 = $("#txtNotifications_MessageSubject").val().toString();
model.BString2 = $("#txtNotifications_MessageBody").val().toString();
model.BString3 = $('#ddl_RefColumn option:selected').val() == undefined ? null : $('#ddl_RefColumn option:selected').val().toString();
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;
}
if (instance.RuleInstance.IsStageChangeEvent()) {
model.FromStage = $('.from_stage_notificaction option:selected').val() != "0" ? Number($('.from_stage_notification option:selected').val()) : 0;
model.ToStage = $('.to_stage_notification option:selected').val() != "0" ? Number($('.to_stage_notification option:selected').val()) : 0;
}
model.BString6 = externalroles;
model.BString7 = externalusers;
model.BString5 = $('#message_result option:selected').val().toString();
model.ExternalReportId = ($("#txtAutoComplete_Reports option:selected").val() == undefined) ? 0 : Number($("#txtAutoComplete_Reports option:selected").val());
model.ExternalReportColumnId = Number($("#txtAutoComplete_ReportColumns option:selected").val());
model.ProviderColumnId = Number($("#txtAutoComplete_ProviderColumns option:selected").val());
model.ActionId = Unibase.Platform.Automation.Components.SendNotification.Instance().ActionId;
model.RuleId = 0;
model.Users = contactcolumns;
model.SecondaryUsers = secondarycontactcolumns;
model.String2 = $('#parent_pkid option:selected').text() == "Select Token" ? null : $('#parent_pkid option:selected').text();
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));
}
else {
model.SqlWhere = "";
model.SqlWhereJson = "";
}
if ($("#ddl_NotificationType").val() == "6") {
model.String6 = $('#ddl_Form option:selected').val() == undefined || $('#ddl_Form option:selected').val() == null ? "" : $('#ddl_Form option:selected').val().toString();
}
else {
model.String6 = "";
}
model.String7 = true;
model.IsParent = $('.isparent').is(":checked");
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.SendNotification.Instance().ParentActionId;
model.AutoApproved = $('#chkAutoApprovedNotification').is(':checked');
model.RecipientsData = recipients;
model.RowIndex = Unibase.Platform.Automation.Components.SendNotification.Instance().RowIndex;
if (Unibase.Platform.Automation.Components.SendNotification.Instance().IsAutomationMode) {
if (Unibase.Platform.Automation.Components.SendNotification.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_NotificationAction");
}
else {
MessageHelper.Instance().showSuccess(response.message, "Validate_NotificationAction");
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
var actionname = response.result.RuleActionName;
eval("bizgaze_automation_flow_main.savenotificationblock('" + response.result.RuleActionId + "','" + actionname + "')");
}
});
}
}
else {
model.RuleId = Unibase.Platform.Automation.Components.SendNotification.Instance().RuleId;
model.EventGroupId = Unibase.Platform.Automation.Components.SendNotification.Instance().EventGroupId;
model.RuleEventId = Unibase.Platform.Automation.Components.SendNotification.Instance().RuleEventId;
model.ActionId = Unibase.Platform.Automation.Components.SendNotification.Instance().ActionId;
model.ParentActionId = Unibase.Platform.Automation.Components.SendNotification.Instance().ParentActionId;
Automation.Managers.RuleManager.Instance().saveRuleAction(model).then(function (response) {
if (response.status == Unibase.Data.Status.Error) {
MessageHelper.Instance().showError(response.message, "Validate_NotificationAction");
}
else {
MessageHelper.Instance().showSuccess(response.message, "Validate_NotificationAction");
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
}
});
}
}
LoadMsgSubjectTokens(ruleproviderid) {
Unibase.Platform.Automation.Managers.RuleManager.Instance().getTokens(ruleproviderid).then(function (response) {
let cmbConditionProperties = document.getElementById('ddl_SubjectTokens');
$('#ddl_SubjectTokens').empty();
var defaultOpt1 = document.createElement("option");
defaultOpt1.text = "Select Token";
defaultOpt1.value = "0";
cmbConditionProperties.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();
cmbConditionProperties.appendChild(opt);
}
});
}
LoadMsgBodyTokens(ruleproviderid) {
Unibase.Platform.Automation.Managers.RuleManager.Instance().getTokens(ruleproviderid).then(function (response) {
let cmbConditionProperties = document.getElementById('ddl_BodyTokens');
$('#ddl_BodyTokens').empty();
var defaultOpt1 = document.createElement("option");
defaultOpt1.text = "Select Token";
defaultOpt1.value = "0";
cmbConditionProperties.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();
cmbConditionProperties.appendChild(opt);
}
});
}
LoadParentTokens(ruleproviderid) {
return __awaiter(this, void 0, void 0, function* () {
yield Unibase.Platform.Automation.Managers.RuleManager.Instance().getTokens(ruleproviderid).then(function (response) {
$('#parent_pkid').html('');
var html = "<option value='0'>Select Token</option>";
for (let i = 0; i <= response.length - 1; i++) {
html += '<option id=' + response[i] + ' value=' + response[i] + '>' + response[i] + '</option>';
}
$('#parent_pkid').append(html);
});
});
}
LoadRefColumns(ruleproviderid) {
Unibase.Platform.Automation.Managers.RuleManager.Instance().getTokens(ruleproviderid).then(function (response) {
let cmbConditionProperties = document.getElementById('ddl_RefColumn');
$('#ddl_RefColumn').empty();
var defaultOpt1 = document.createElement("option");
defaultOpt1.text = "Select";
defaultOpt1.value = "";
cmbConditionProperties.appendChild(defaultOpt1);
for (let i = 0; i <= response.length - 1; i++) {
var opt = document.createElement("option");
opt.text = response[i];
opt.value = response[i];
cmbConditionProperties.appendChild(opt);
}
if ($("#hf_RefColumn").val() == "") {
$("#ddl_RefColumn").val(null);
}
else {
$("#ddl_RefColumn").val($("#hf_RefColumn").val());
}
});
}
static Instance() {
if (this.instance === undefined) {
this.instance = new SendNotification();
}
return this.instance;
}
}
Components.SendNotification = SendNotification;
})(Components = Automation.Components || (Automation.Components = {}));
})(Automation = Platform.Automation || (Platform.Automation = {}));
})(Platform = Unibase.Platform || (Unibase.Platform = {}));
})(Unibase || (Unibase = {}));
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,443 @@
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 = `<form id="frmUnibase_PropertyChange" 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="Spn_PropertyChange">Create PropertyChange</strong>
</div>
<div class="card-body scrollable" style="overflow-y: scroll;">
<div class="bg-white card" id="divPropertyChange">
<div id="Validate_PropertyChnageAction" class="clear"></div>
<div class="card-body">
<div class="row">
<div class="col-sm-12">
<div class="floating-label-form-group">
<label for="lbl" id="lbl_RuleActionName">Action<span class="text-danger required" id="spnIsRequired_RuleActionName"> *</span></label>
<input type="text" id="txtPropertyChange_RuleActionName" class="form-control value-control required floating-label-control" placeholder="Action *" data-placeholder="Enter Action" data-label="Action *">
<input type="hidden" id="hf_RuleActionName" />
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="input-group">
<label for="InstalledApps" class="font-bold">InstalledApps<span class="text-danger">*</span></label>
<select id="txtAutoComplete_InstalledApps" class="form-control text-control required" style="width:100%;" placeholder="InstalledApps" data-placeholder="InstalledApps" data-label="" data-istagselect="true"></select>
<input type="hidden" id="hf_Autocomplete_InstalledApps" class="form-control value-control" data-isdynamic="true" />
</div>
</div>
<div class="col-sm-6">
<div class="input-group">
<label for="AppDoctypes" class="font-bold">AppDoctypes<span class="text-danger">*</span></label>
<select id="txtAutoComplete_AppDoctypes" class="form-control text-control required" style="width:100%;" placeholder="AppDoctypes" data-placeholder="AppDoctypes" data-label="" data-istagselect="true"></select>
<input type="hidden" id="hf_Autocomplete_AppDoctypes" class="form-control value-control" data-isdynamic="true" />
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="input-group">
<label for="DocProperties" class="font-bold">DocProperties<span class="text-danger">*</span></label>
<select id="txtAutoComplete_DocProperties" class="form-control text-control required" style="width:100%;" placeholder="DocProperties" data-placeholder="DocProperties" data-label="" data-istagselect="true"></select>
<input type="hidden" id="hf_Autocomplete_DocProperties" class="form-control value-control" data-isdynamic="true" />
</div>
</div>
<div class="col-sm-6">
<div class="floating-label-form-group">
<label for="txt_Property" id="lbl_Property">Property Name<span class="text-danger">*</span></label>
<input type="text" id="txt_Property" class="form-control required value-control floating-label-control" data-isdynamic="false" placeholder="Property Name*" data-placeholder="Enter Property Name" data-label="Property Name*" />
<input type="hidden" id="hf_Property" />
<label for="Validation" id="lblValidation_Property"></label>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div id="div_Parameter" class="floating-label-form-group">
<label for="lbl_ApiParameter" id="lbl_ApiParameter">Parameter<span class="text-danger"> *</span></label>
<div class="input-group">
<input type="text" id="txtPropertyChange_Parameter" class="col-sm-9 form-control value-control required floating-label-control" data-placeholder="Enter Parameter" placeholder="Parameter *" data-label="Parameter *">
<select id="ddl_PropertyChangeParameters" class="col-sm-3 form-control value-control">
<option value="0">Select Token</option>
</select>
</div>
</div>
</div>
</div>
<div class="row">
<div id="div_NotificationGrp" class="floating-label-form-group col-sm-6 floating-label-form-group-with-value">
<label for="lbl_NotificationGrp" id="lbl_NotificationGroup">Notification Group<span class="text-danger"> *</span></label>
<select id="ddl_NotificationGrp" class="form-control"><option value="0">Select Group</option></select>
</div><div class="col-sm-6 createbtn_grp"><button class="badge badge-primary mt-30 ml-15" id="creategrp_btn">Create Group</button></div></div>
<div class="row">
<div class="ResultActions col-sm-6 hidden">
<div id="div_ResultAction" class=" floating-label-form-group floating-label-form-group-with-value">
<label for="lbl" id="lbl_ResultAction">Result Action</label>
<select id="ddl_ResultAction" class="form-control">
<option value="0">Select</option>
</select>
<label for="Validation" id="lblValidation_ResultAction"></label><input type="hidden" id="hfFormPropertyId" value="0" />
</div>
</div>
<div class="col-sm-6">
<div class="custom-control custom-checkbox divEnablePieces checkbox-primary mt-20">
<input type="checkbox" class="custom-control-input" id="chkAutoApprovedPropertyChange" checked>
<label class="custom-control-label" for="chkAutoApprovedPropertyChange">Perform this Action</label>&nbsp
</div>
</div>
</div>
</div>
</div>
<div class="bg-white card col-sm-3" id="btn_ActionConditions">
<button type="button" class="btn btn-primary" onclick="Unibase.Platform.Automation.Components.PropertyChange.Instance().TogglePropertyChangeConditions();">Conditions</button>
</div>
<div class="bg-white card hidden" id="ActionConditionsDiv">
<div class="card-header">Condition Details</div>
<div class="card-body">
<div class="ActionConditions">
<!--For Action Conditions-->
</div>
</div>
</div>
</div>
<div class="bg-white card-footer footer" id="CreatePropertyChangeFooter">
<a href="javascript:;" id="btnClosePropertyChange" class="btn btn-light btn-sm mr-auto "> Close</a>
<a href="javascript:;" id="btnSavePropertyChange" class="btn btn-primary btn-sm"> Save</a>
</div>
</div>
</form>`;
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 = '<option value=' + response.NotificationGroupId + ' selected>' + response.NotificationGroupName + '</option>';
$('#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 = {}));
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,646 @@
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 SendSms extends Platform.Core.BaseComponent {
constructor() {
super(...arguments);
this.RuleProviderId = 0;
this.RowIndex = 0;
this.AutomationMode = 0;
this.RuleInstance = Unibase.Platform.Automation.Components.Rule.Instance();
}
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/floatinglabels/floatinglabel.js",
"apps/communications/managers/sms/smsmanager.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/templates/enums/templatetype.js",
"platform/templates/managers/templatemanager.js", "libs/notificationbuilder/notificationbuilder.js", "platform/apps/managers/stagemanager.js", "platform/automation/components/rulebuilder/rulebuilder.rule.js", "platform/automation/components/externalrecipients.js", "platform/automation/components/rulebuilder/notificationgroup.js", "platform/automation/managers/notificationgroupmanager.js"
];
return jsfiles;
}
cssFiles() {
return [];
}
html(id, containerid) {
let html = `<form id="frmUnibase_SendSms" 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="Spn_SendSMS">Create Sms</strong>
</div>
<div class="card-body scrollable" style="overflow-y: scroll;">
<div class="bg-white card" id="divSendSms">
<div id="Validate_SmsAction" class="clear"></div>
<div class="card-body">
<div class="row">
<div class="col-sm-12">
<div class="floating-label-form-group">
<label for="lbl" id="lbl_RuleActionName">Action<span class="text-danger required" id="spnIsRequired_RuleActionName"> *</span></label>
<input type="text" id="txtSms_RuleActionName" class="form-control value-control required floating-label-control" placeholder="Action *" data-placeholder="Enter Action" data-label="Action *">
<input type="hidden" id="hf_RuleActionName" />
</div>
</div>
</div>
<div class="row">
<div id="div_NotificationGrp" class="floating-label-form-group col-sm-6 floating-label-form-group-with-value">
<label for="lbl_NotificationGrp" id="lbl_NotificationGroup">Notification Group<span class="text-danger"> *</span></label>
<select id="ddl_NotificationGrp" class="form-control"><option value="0">Select Group</option></select>
</div><div class="col-sm-6 createbtn_grp"><button class="badge badge-primary mt-30 ml-15" id="creategrp_btn">Create Group</button></div></div>
<div class="row">
<div class="ResultActions col-sm-6 hidden">
<div id="div_ResultAction" class=" floating-label-form-group floating-label-form-group-with-value">
<label for="lbl" id="lbl_ResultAction">Result Action</label>
<select id="ddl_ResultAction" class="form-control">
<option value="">-- Select --</option>
</select>
<label for="Validation" id="lblValidation_ResultAction"></label><input type="hidden" id="hfFormPropertyId" value="" />
</div>
</div>
</div>
</div>
</div>
<div class="bg-white card" id="SMSDetailsDiv">
<div class="card-header">SMS Details</div>
<div class="card-body">
<div class="row">
<div class="col-sm-6">
<label for="lbl_Template" id="lbl_Template" class="font-bold">Template</label>
<select id="Autocomplete_Template" class="form-control value-control" data-isdynamic="true">
</select>
<input type="hidden" id="hf_Template" />
</div>
</div><br />
<div class="row">
<div id="div_SMSBody" class="TextEditor col-sm-12">
<inpu type="hidden" id="txthdn__SMSBody" class="value-control" value="">
<span class="text-danger" id="spnIsRequired__SMSBody"></span>
<div class="type-control summernote__SMSBody" style="display: block;" id="summernote__SMSBody" data-propdoctypename="SMSBody" data-required="" placeholder="SMS Body" data-placeholder="SMS Body" data-label="SMS Body"></div>
<label for="Validation" id="lblValidation"></label>
</inpu>
</div>
</div>
</div>
</div>
<div class="bg-white card Advanced_optionsdata">
<div class="card-header"><i class="fa fa-angle-down arrowicon mr-1" style="font-size:20px" onclick="Unibase.Platform.Automation.Components.SendSms.Instance().Toggleadvancedoptions()"></i>Advanced Options</div>
<div class="card-body Advanced_options hidden">
<div class="row">
<div class="col-sm-6 floating-label-form-group floating-label-form-group-with-value">
<label class="Message_type">Message Type</label>
<select class="form-control" id="message_result">
<option value="0">Success</option>
<option value="1">Warning</option>
<option value="2">Error</option>
</select>
</div>
<div class="col-sm-6">
<input type="checkbox" class="test_data mt-50" id="chkAutoApprovedSMS" checked>Perform this Action
</div>
</div>
</div>
</div>
<div class="bg-white card hidden" id="DocTypesDiv">
<div class="card-header">DocTypes</div>
<div class="card-body">
<div class="SelectDocType col-sm-12">
<!--For Mapping of datalists-->
</div>
</div>
</div>
<div class="bg-white card" id="ActionConditionsDivdata">
<div class="card-header"><i class="fa fa-angle-down conditionicon mr-1" style="font-size:20px" onclick="Unibase.Platform.Automation.Components.SendSms.Instance().ToggleSendSmsConditions();"></i>Condition Details</div>
<div class="card-body hidden" id="ActionConditionsDiv">
<div class="ActionConditions">
<!--For Action Conditions-->
</div>
</div>
</div>
<div class="bg-white card" id="SelectstagesDiv">
<div class="card-header">Stage Event</div>
<div class="card-body">
<div class="stages_drp row"><div class="col-sm-6"><label class="from_label">From Stage</label><select class="from_stage_sms form-control"></select></div><div class="col-sm-6"><label class="_label">To Stage</label><select class="to_stage_sms form-control"></select></div></div>
</div></div>
<div class="bg-white card" id="SelectRoleDiv">
<div class="card-header">Send To Details</div>
<div class="card-body">
<div class="ContactSelection col-sm-12">
<!--For ContactSelection page-->
</div>
</div>
</div>
<div class="bg-white card" id="external_recipientsdiv">
<div class="card-header">External Recipients</div>
<div class="card-body">
<div class="reportautocomplete">
<div class="row">
<div class="col-sm-6">
<div class="input-group">
<label for="Report" class="font-bold">External Report</label>
<select id="txtAutoComplete_ReportsExternal" class="form-control text-control" style="width:100%;" placeholder="Report" data-placeholder="Report" data-label="" data-istagselect="true"></select>
<input type="hidden" id="hf_Autocomplete_ReportsExternal" class="form-control value-control" data-isdynamic="true" /></div></div></div></div>
<div class="external_reportcolumns mt-4"><div class="row externalreport_row"></div></div></div></div>
<div class="bg-white card col-sm-3 hidden" id="btn_ExternalRecipients">
<button type="button" class="btn btn-primary" onclick="Unibase.Platform.Automation.Components.SendSms.Instance().ToggleExternalRecipients();">External Recipients</button>
</div>
<div class="bg-white card hidden" id="ExternalRecipientsDiv">
<div class="card-header">External Recipients</div>
<div class="card-body">
<div class="ExternalRecipients">
</div>
</div>
</div>
<div class="bg-white card col-sm-3" id="btn_SendFrom">
<button type="button" class="btn btn-primary" onclick="Unibase.Platform.Automation.Components.SendSms.Instance().ToggleSmsSendFrom();">Send From</button>
</div>
<div class="bg-white card hidden" id="SendFromDetailsDiv">
<div class="card-header">Send From Details</div>
<div class="card-body">
<div class="row SendFrom">
<div class="col-sm-6">
<div class="input-group">
<label for="lbl_ProviderName" id="lbl_ProviderName">Provider Name <span class="text-danger" id="span_ProviderName">*</span></label>
<select id="Autocomplete_ProviderName" class="form-control text-control required" style="width:100%;" placeholder="ProviderName" data-placeholder="ProviderName" data-label="" data-istagselect="true"></select>
<input type="hidden" id="hf_ProviderName" class="form-control value-control" data-isdynamic="true" />
</div>
</div>
<div class="col-sm-6">
<div class="input-group">
<label for="lbl_SendSmsFrom" id="lbl_SendFrom">Sender Name<span class="text-danger" id="span_smssendfrom">*</span></label>
<select id="Autocomplete_SenderName" class="form-control text-control required" style="width:100%;" placeholder="Sender Name" data-placeholder="Sender Name" data-label="" data-istagselect="true"></select>
<input type="hidden" id="hf_SenderName" class="form-control value-control" data-isdynamic="true" />
</div>
</div>
</div>
</div>
</div>
</div>
<div class="bg-white card-footer footer" id="CreateSmsFooter">
<a href="javascript:;" id="btnCloseSms" class="btn btn-light btn-sm mr-auto "> Close</a>
<a href="javascript:;" id="btnSaveSms" class="btn btn-primary btn-sm"> Save</a>
</div>
</div>
</form>`;
return html;
}
load(id, containerid, callback) {
return __awaiter(this, void 0, void 0, function* () {
var instance = this;
Unibase.Platform.Automation.Components.SendSms.Instance().ActionId = instance.ActionId;
Unibase.Platform.Automation.Components.SendSms.Instance().RuleActionData = instance.RuleActionData;
Unibase.Platform.Automation.Components.SendSms.Instance().RowIndex = instance.RowIndex;
Unibase.Platform.Automation.Components.SendSms.Instance().AutomationMode = instance.AutomationMode;
Unibase.Platform.Automation.Components.SendSms.Instance().ParentActionId = instance.ParentActionId;
Unibase.Platform.Automation.Components.SendSms.Instance().IsAutomationMode = instance.IsAutomationMode;
yield Unibase.Platform.Automation.Components.NotificationGroup.Instance().LoadNotificationGroups();
Unibase.Platform.Automation.Components.ExternalRecipients.Instance().loadreports();
if (instance.AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.AdvancedMode) {
eval('bizgaze_automation_flow_main.getcontainerid("' + containerid + '")');
}
$("#btnCloseSms").click(function () {
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
if (Unibase.Platform.Automation.Components.SendSms.Instance().AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.NormalMode) {
if (Unibase.Platform.Automation.Components.SendSms.Instance().AutomationMode) {
if (Unibase.Platform.Automation.Components.SendSms.Instance().IsAutomationMode) {
Unibase.Platform.Automation.Components.Rule.Instance().ChangeAction(instance.RowIndex, id);
}
}
}
else {
eval("bizgaze_automation_flow_main.getpopupclosed()");
}
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
});
$('#creategrp_btn').click(function () {
Unibase.Platform.Automation.Components.NotificationGroup.Instance().init(0, null, true);
});
$("#txtAutoComplete_ReportsExternal").change(function () {
var reportid = Number($('#txtAutoComplete_ReportsExternal option:selected').val());
Unibase.Platform.Automation.Components.ExternalRecipients.Instance().loadexternalreportcolumns(reportid);
});
$("#btnSaveSms").click(function () {
let appcontrolid = "frmUnibase_SendSms";
let result = Unibase.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation(appcontrolid);
if (result == false) {
MessageHelper.Instance().showError("Mandatory fields are missing", "Validate_SmsAction");
return false;
}
else {
Unibase.Platform.Automation.Components.SendSms.Instance().SaveSmsAction(id, containerid);
}
});
if (instance.RuleInstance.IsStageChangeEvent()) {
$('#SelectstagesDiv').removeClass('d-none');
yield Unibase.Platform.Automation.Components.SendSms.Instance().LoadAppStages();
}
else {
$('#SelectstagesDiv').addClass('d-none');
}
var _fileCacheHelper = Platform.Helpers.FileCacheHelper.Instance();
yield _fileCacheHelper.loadJsFileAsync("platform/automation/components/contactselection.js", function () {
jQuery(".ContactSelection").html(Unibase.Platform.Automation.Components.ContactSelection.Instance().init(instance.RuleProviderId));
});
yield _fileCacheHelper.loadJsFileAsync("platform/automation/components/externalrecipients.js", function () {
jQuery(".ExternalRecipients").html(Unibase.Platform.Automation.Components.ExternalRecipients.Instance().init(instance.RuleProviderId));
Unibase.Platform.Automation.Components.ExternalRecipients.Instance().load(instance.RuleProviderId);
});
if (instance.ParentActionId != 0) {
Unibase.Platform.Automation.Components.ContactSelection.Instance().getResultActions(instance.ParentActionId);
yield Unibase.Platform.Automation.Components.SendSms.Instance().GetRuleActionInfo(Number(instance.ParentActionId));
$('#ddl_NotificationGrp').prop("disabled", true);
$('#creategrp_btn').addClass('d-none');
}
if (id != "") {
setTimeout(function () { Unibase.Platform.Automation.Components.SendSms.Instance().EditSmsAction(id); }, 10);
}
if (instance.RuleProviderId != 0) {
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(instance.RuleProviderId, null);
Unibase.Platform.Automation.Managers.RuleManager.Instance().getTokens(instance.RuleProviderId).then(function (response) {
var Data = new Array();
for (let i = 0; i <= response.length - 1; i++) {
var result = response[i];
Data.push(result);
}
Unibase.Platform.Automation.Components.SendSms.Instance().loadSummernote(Data);
});
Unibase.Platform.Automation.Components.SendSms.Instance().loadTemplates(instance.RuleProviderId);
}
var url = _appsettings.server_url() + '/apis/v4/bizgaze/communications/sms/SmsProvidersAutocomplete';
AutoCompleteHelper.getHelper().Create("#Autocomplete_ProviderName", "#hf_ProviderName", url, function (response) {
var data = response;
});
$("#Autocomplete_ProviderName").change(function () {
var url = _appsettings.server_url() + '/apis/v4/bizgaze/communications/sms/SmsSenderAutocomplete/smsproviderid/' + Number($("#Autocomplete_ProviderName option:selected").val());
AutoCompleteHelper.getHelper().Create("#Autocomplete_SenderName", "#hf_SenderName", url, function (response) {
var data = response;
});
});
$("#Autocomplete_Template").change(function () {
let templateid = Number($("#Autocomplete_Template option:selected").val());
Unibase.Platform.Templates.Managers.TemplateManager.Instance().getTemplateText(Number(templateid)).then(function (response) {
if (response.result != null) {
var templatetext = HtmlHelper.getHelper().decode(response.result.TemplateText);
$('.summernote__SMSBody').summernote("code", templatetext);
}
});
});
if (instance.RuleActionData.length == 0 && id == "") {
Unibase.Platform.Automation.Components.SendSms.Instance().getDefaultSmsSender();
}
if (instance.RuleActionData.length != 0) {
Unibase.Platform.Automation.Components.SendSms.Instance().LoadSmsData(instance.RuleActionData);
}
});
}
Toggleadvancedoptions() {
if ($('.arrowicon').hasClass('fa-angle-down')) {
$('.arrowicon').removeClass('fa-angle-down').addClass('fa-angle-up');
}
else {
$('.arrowicon').removeClass('fa-angle-up').addClass('fa-angle-down');
}
$('.Advanced_options').toggleClass("hidden");
}
ToggleSendSmsConditions() {
$('#ActionConditionsDiv').toggleClass("hidden");
if ($('.conditionicon').hasClass('fa-angle-down')) {
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.SendSms.Instance().RuleProviderId, null);
}
else {
$('.conditionicon').removeClass('fa-angle-up').addClass('fa-angle-down');
}
}
LoadAppStages() {
return __awaiter(this, void 0, void 0, function* () {
var html = '';
var fromstage = '<option value="0">Select FromStage</option>';
var tostage = '<option value="0">Select ToStage</option>';
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>';
}
}
$('.from_stage_sms').html(fromstage + html);
$('.to_stage_sms').html(tostage + html);
});
});
}
ToggleExternalRecipients() {
$("#ExternalRecipientsDiv").toggle(function () {
$("#btn_ExternalRecipients").addClass("hidden");
$("#ExternalRecipientsDiv").removeClass("hidden");
});
}
ToggleSmsSendFrom() {
$("#SendFromDetailsDiv").toggle(function () {
$("#btn_SendFrom").addClass("hidden");
$("#SendFromDetailsDiv").removeClass("hidden");
});
}
EditSmsAction(id) {
return __awaiter(this, void 0, void 0, function* () {
let actionid = Number(id);
$("#Spn_SendSMS").text("Edit Sms");
yield Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleAction(actionid).then(function (response) {
$("#txtSms_RuleActionName").val(response.RuleActionName);
$('#message_result').val(Number(response.BString5));
$('#ddl_NotificationGrp option[value=' + response.NotificationGroupId + ']').prop('selected', true);
if (response.ResultActionId != null) {
$('#ddl_ResultAction').val(response.ResultActionId);
}
if (!Unibase.Platform.Automation.Components.SendSms.Instance().IsAutomationMode) {
Unibase.Platform.Automation.Components.SendSms.Instance().RuleId = response.RuleId;
Unibase.Platform.Automation.Components.SendSms.Instance().RuleEventId = response.RuleEventId;
Unibase.Platform.Automation.Components.SendSms.Instance().EventGroupId = response.EventGroupId;
Unibase.Platform.Automation.Components.SendSms.Instance().ActionId = response.ActionId;
Unibase.Platform.Automation.Components.SendSms.Instance().ParentActionId = response.ParentActionId;
}
if (response.ExecuteStatusId != Number(Unibase.Platform.Automation.Enums.ExecuteActionStatus.Approved))
$("#chkAutoApprovedSMS").prop("checked", false);
else
$("#chkAutoApprovedSMS").prop("checked", true);
$("#btn_SendFrom").addClass("hidden");
$("#SendFromDetailsDiv").removeClass("hidden");
if (response.FromStage != 0 && response.ToStage != 0) {
$('.from_stage_sms option[value=' + response.FromStage + ' ]').prop('selected', true);
$('to_stage_sms option[value=' + response.ToStage + ']').prop('selected', true);
}
if (response.ExternalReportId != 0) {
$('#txtAutoComplete_ReportsExternal option[value=' + response.ExternalReportId + ']').prop("selected", true);
}
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckContactColumns(response.Users);
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckSecondaryContactColumns(response.SecondaryUsers);
Unibase.Platform.Automation.Components.ContactSelection.Instance().BindRecipients(response.RuleActionId);
Unibase.Apps.Communications.Managers.SmsManager.Instance().getSmsSender(Number(response.String3)).then(function (response) {
if (response.status == Unibase.Data.Status.Success) {
var smsprovideroption = new Option(response.result.SmsProviderName, response.result.SmsProviderId.toString(), true);
$("#Autocomplete_ProviderName").append(smsprovideroption);
var url = _appsettings.server_url() + '/apis/v4/bizgaze/communications/sms/SmsSenderAutocomplete/smsproviderid/' + Number($("#Autocomplete_ProviderName option:selected").val());
AutoCompleteHelper.getHelper().Create("#Autocomplete_SenderName", "#hf_SenderName", url, function (res) {
var data = res;
var smssenderoption = new Option(response.result.SmsSenderName, response.result.SmsSenderId.toString(), true);
$("#Autocomplete_SenderName").append(smssenderoption);
});
}
});
let templateid = Number(response.BString1);
Unibase.Platform.Templates.Managers.TemplateManager.Instance().getTemplateText(templateid).then(function (res) {
var smstemplate = new Option(res.result.TemplateName, res.result.TemplateId.toString(), true);
$("#Autocomplete_Template").append(smstemplate);
});
$('.summernote__SMSBody').summernote("code", response.BString2);
if (response.SqlWhere != null && response.SqlWhere != "") {
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
$("#ActionConditionsDiv").removeClass("hidden");
}
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(response.RuleProviderId, response.SqlWhere);
eval('_floatingLabelHelper.init();');
});
});
}
LoadSmsData(Data) {
for (var i = 0; i < Data.length; i++) {
$("#txtSms_RuleActionName").val(Data[i].RuleActionName);
if (!Data[i].AutoApproved)
$("#chkAutoApprovedSMS").prop("checked", false);
else
$("#chkAutoApprovedSMS").prop("checked", true);
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckContactColumns(Data[i].Users);
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckSecondaryContactColumns(Data[i].SecondaryUsers);
if (Data[i].SqlWhere != "" && Data[i].SqlWhere != null) {
$(".conditionicon").addClass("fa-angle-up").removeClass('fa-fa-angle-down');
$("#ActionConditionsDiv").removeClass("hidden");
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.SendSms.Instance().RuleProviderId, Data[i].SqlWhere);
}
Unibase.Apps.Communications.Managers.SmsManager.Instance().getSmsSender(Number(Data[i].String3)).then(function (response) {
if (response.status == Unibase.Data.Status.Success) {
var smsprovideroption = new Option(response.result.SmsProviderName, response.result.SmsProviderId.toString(), true);
$("#Autocomplete_ProviderName").append(smsprovideroption);
var url = _appsettings.server_url() + '/apis/v4/bizgaze/communications/sms/SmsSenderAutocomplete/smsproviderid/' + Number($("#Autocomplete_ProviderName option:selected").val());
AutoCompleteHelper.getHelper().Create("#Autocomplete_SenderName", "#hf_SenderName", url, function (res) {
var data = res;
var smssenderoption = new Option(response.result.SmsSenderName, response.result.SmsSenderId.toString(), true);
$("#Autocomplete_SenderName").append(smssenderoption);
});
}
});
let templateid = Number(Data[i].BString1);
Unibase.Platform.Templates.Managers.TemplateManager.Instance().getTemplateText(templateid).then(function (res) {
var smstemplate = new Option(res.result.TemplateName, res.result.TemplateId.toString(), true);
$("#Autocomplete_Template").append(smstemplate);
});
$('.summernote__SMSBody').summernote("code", Data[i].BString2);
eval('_floatingLabelHelper.init();');
}
}
getDefaultSmsSender() {
Unibase.Apps.Communications.Managers.SmsManager.Instance().getDefaultSmsSender().then(function (response) {
if (response.status == Unibase.Data.Status.Success) {
var smsprovideroption = new Option(response.result.SmsProviderName, response.result.SmsProviderId.toString(), true);
$("#Autocomplete_ProviderName").append(smsprovideroption);
var url = _appsettings.server_url() + '/apis/v4/bizgaze/communications/sms/SmsSenderAutocomplete/smsproviderid/' + Number($("#Autocomplete_ProviderName option:selected").val());
AutoCompleteHelper.getHelper().Create("#Autocomplete_SenderName", "#hf_SenderName", url, function (res) {
var data = res;
var smssenderoption = new Option(response.result.SmsSenderName, response.result.SmsSenderId.toString(), true);
$("#Autocomplete_SenderName").append(smssenderoption);
});
}
});
}
SaveSmsAction(smsid, containerid) {
var instance = this;
let ruleactionid = Number(smsid);
let queryelmnt = $("#builder");
let recipients = Unibase.Platform.Automation.Components.ContactSelection.Instance().GetRecipients();
let contactcolumns = Unibase.Platform.Automation.Components.ContactSelection.Instance().getContactColumns();
let secondarycontactcolumns = Unibase.Platform.Automation.Components.ContactSelection.Instance().getSecondaryContactColumns();
var externalrecipients = Unibase.Platform.Automation.Components.ExternalRecipients.Instance().getexternalrecipients();
let externalroles = Unibase.Platform.Automation.Components.ExternalRecipients.Instance().GetExternalRoles();
let externalusers = Unibase.Platform.Automation.Components.ExternalRecipients.Instance().GetExternalUsers();
var contents = $('.summernote__SMSBody').summernote('code');
var plainText = $("<p>" + contents + "</p>").text();
let model = new Unibase.Platform.Automation.Requests.RuleAction();
model.RuleActionId = ruleactionid;
model.ActionId = Unibase.Platform.Automation.Components.SendSms.Instance().ActionId;
model.RuleId = 0;
model.NotificationGroupId = $('#ddl_NotificationGrp').val() == undefined ? 0 : Number($('#ddl_NotificationGrp').val());
if (model.NotificationGroupId == 0) {
MessageHelper.Instance().showError("Please Select Notification Group", "Validate_SmsAction");
return;
}
if (instance.RuleInstance.IsStageChangeEvent()) {
model.FromStage = $('.from_stage_sms option:selected').val() != "0" ? Number($('.from_stage option:selected').val()) : 0;
model.ToStage = $('.to_stage_sms option:selected').val() != "0" ? Number($('.to_stage option:selected').val()) : 0;
}
model.RuleActionName = $("#txtSms_RuleActionName").val().toString();
model.Users = contactcolumns;
model.String4 = Number($("#Autocomplete_ProviderName option:selected").val());
model.String3 = $("#Autocomplete_SenderName option:selected").val().toString();
model.BString1 = $("#Autocomplete_Template option:selected").val() == undefined || null ? "0" : $("#Autocomplete_Template option:selected").val().toString();
model.BString2 = plainText;
model.BString6 = externalroles;
model.BString7 = externalusers;
model.BString5 = $('#message_result option:selected').val().toString();
model.ExternalReportId = ($("#txtAutoComplete_ReportsExternal option:selected").val() == undefined) ? 0 : Number($("#txtAutoComplete_ReportsExternal option:selected").val());
model.ExternalReportColumnId = Number($("#txtAutoComplete_ReportColumns option:selected").val());
model.ProviderColumnId = Number($("#txtAutoComplete_ProviderColumns option:selected").val());
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));
}
else {
model.SqlWhere = "";
model.SqlWhereJson = "";
}
model.ResultActionId = $("#ddl_ResultAction option:selected").val() == undefined ? 0 : 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.SendSms.Instance().ParentActionId;
model.AutoApproved = $('#chkAutoApprovedSMS').is(':checked');
model.RecipientsData = recipients;
model.SecondaryUsers = secondarycontactcolumns;
model.ExternalRecipients = externalrecipients;
model.RowIndex = Unibase.Platform.Automation.Components.SendSms.Instance().RowIndex;
if (Unibase.Platform.Automation.Components.SendSms.Instance().IsAutomationMode) {
if (Unibase.Platform.Automation.Components.SendSms.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_SmsAction");
}
else {
MessageHelper.Instance().showSuccess(response.message, "Validate_SmsAction");
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
var actionname = response.result.RuleActionName;
eval("bizgaze_automation_flow_main.savesmsblock('" + response.result.RuleActionId + "','" + actionname + "')");
}
});
}
}
else {
model.RuleId = Unibase.Platform.Automation.Components.SendSms.Instance().RuleId;
model.EventGroupId = Unibase.Platform.Automation.Components.SendSms.Instance().EventGroupId;
model.RuleEventId = Unibase.Platform.Automation.Components.SendSms.Instance().RuleEventId;
model.ActionId = Unibase.Platform.Automation.Components.SendSms.Instance().ActionId;
model.ParentActionId = Unibase.Platform.Automation.Components.SendSms.Instance().ParentActionId;
Automation.Managers.RuleManager.Instance().saveRuleAction(model).then(function (response) {
if (response.status == Unibase.Data.Status.Error) {
MessageHelper.Instance().showError(response.message, "Validate_SmsAction");
}
else {
MessageHelper.Instance().showSuccess(response.message, "Validate_SmsAction");
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
}
});
}
}
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 = '<option value=' + response.NotificationGroupId + ' selected>' + response.NotificationGroupName + '</option>';
$('#ddl_NotificationGrp').html('').html(html);
}
});
});
}
loadSummernote(Data) {
$(".summernote__SMSBody").summernote({
height: 100,
minHeight: null,
maxHeight: null,
placeholder: "SMS Body",
disableDragAndDrop: true,
codemirror: {
mode: 'text/html',
lineNumbers: true
},
toolbar: [
['font', ['bold', 'italic', 'underline']],
['color', ['color']],
['view', ['fullscreen', 'codeview', 'help']],
],
hint: {
match: /\B[@!](\w*)$/,
search: function (keyword, callback) {
callback($.grep(Data, function (i) {
var user = i;
return user.indexOf(keyword) === 0;
}));
},
content: function (i) {
var user = i;
return $('<span>{{' + user + '}}</span>')[0];
}
}
});
}
loadTemplates(ruleproviderid) {
let templatetypeid = Number(Unibase.Platform.Templates.Enums.TemplateType.SMS);
Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleProvider(ruleproviderid).then(function (response) {
var url = _appsettings.server_url() + '/apis/v4/unibase/platform/templates/gettemplatesautocomplatebytemplatetype/installedappid/' + response.InstalledAppId + '/templatetypeid/' + templatetypeid;
AutoCompleteHelper.getHelper().Create("#Autocomplete_Template", "#hf_Template", url, function (response) {
var data = response;
});
});
}
static Instance() {
if (this.instance === undefined) {
this.instance = new SendSms();
}
return this.instance;
}
}
Components.SendSms = SendSms;
})(Components = Automation.Components || (Automation.Components = {}));
})(Automation = Platform.Automation || (Platform.Automation = {}));
})(Platform = Unibase.Platform || (Unibase.Platform = {}));
})(Unibase || (Unibase = {}));
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,376 @@
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 StageChange extends Platform.Core.BaseComponent {
constructor() {
super(...arguments);
this.RuleProviderId = 0;
this.RowIndex = 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/apps/managers/stagemanager.js",
"platform/forms/components/formviewer/formviewer.js",
"libs/parsley/parsley.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 = `<form id="frmUnibase_StageChange" 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="Spn_StageChange">Create StageChange</strong>
</div>
<div class="card-body scrollable" style="overflow-y: scroll;">
<div class="bg-white card" id="divStageChange">
<div id="Validate_StageChangeAction" class="clear"></div>
<div class="card-body">
<div class="row">
<div class="col-sm-12">
<div class="floating-label-form-group">
<label for="lbl" id="lbl_RuleActionName">Action<span class="text-danger required" id="spnIsRequired_RuleActionName"> *</span></label>
<input type="text" id="txtStageChanges_RuleActionName" class="form-control value-control required floating-label-control" placeholder="Action *" data-placeholder="Enter Action" data-label="Action *">
<input type="hidden" id="hf_RuleActionName" />
</div>
</div>
</div>
<div class="row">
<div id="div_NotificationGrp" class="floating-label-form-group col-sm-6 floating-label-form-group-with-value">
<label for="lbl_NotificationGrp" id="lbl_NotificationGroup">Notification Group<span class="text-danger"> *</span></label>
<select id="ddl_NotificationGrp" class="form-control"><option value="0">Select Group</option></select>
</div><div class="col-sm-6 createbtn_grp"><button class="badge badge-primary mt-30 ml-15" id="creategrp_btn">Create Group</button></div></div>
<div class="row mt-10">
<div class="col-sm-6">
<label>Stage Name<span class="text-danger">*</span></label>
<select id="ddl_StageName" class="required form-control value-control" data-isdynamic="true">
</select>
<input type="hidden" id="hf_StageName" />
</div>
<div class="ResultActions col-sm-6 hidden">
<div id="div_ResultAction" class=" floating-label-form-group floating-label-form-group-with-value">
<label for="lbl" id="lbl_ResultAction">Result Action</label>
<select id="ddl_ResultAction" class="form-control">
<option value="">-- Select --</option>
</select>
<label for="Validation" id="lblValidation_ResultAction"></label><input type="hidden" id="hfFormPropertyId" value="" />
</div>
</div>
</div>
</div>
</div>
<div class="bg-white card Advanced_optionsdata">
<div class="card-header"><i class="fa fa-angle-down arrowicon mr-1" onclick="Unibase.Platform.Automation.Components.StageChange.Instance().Toggleadvancedoptions()"></i>Advanced Options</div>
<div class="card-body Advanced_options hidden">
<div class="row">
<div class="col-sm-6 floating-label-form-group floating-label-form-group-with-value">
<label class="Message_type">Message Type</label>
<select class="form-control" id="message_result">
<option value="0">Success</option>
<option value="1">Warning</option>
<option value="2">Error</option>
</select>
</div>
<div class="col-sm-6">
<input type="checkbox" class="test_data mt-50" id="chkAutoApprovedStageChange"checked>Perform this Action
</div>
</div>
</div>
</div>
<div class="bg-white card" id="ActionConditionsDivdata">
<div class="card-header"><i class="fa fa-angle-down conditionicon mr-1" style="font-size:20px" onclick="Unibase.Platform.Automation.Components.StageChange.Instance().ToggleStageChangeConditions();"></i>Condition Details</div>
<div class="card-body hidden" id="ActionConditionsDiv">
<div class="ActionConditions">
<!--For Action Conditions-->
</div>
</div>
</div>
</div>
<div class="bg-white card-footer footer" id="CreateStageChangeFooter">
<a href="javascript:;" id="btnCloseStageChange" class="btn btn-light btn-sm mr-auto "> Close</a>
<a href="javascript:;" id="btnSaveStageChange" class="btn btn-primary btn-sm"> Save</a>
</div>
</div>
</form>`;
return html;
}
load(id, containerid, callback) {
return __awaiter(this, void 0, void 0, function* () {
var instance = this;
Unibase.Platform.Automation.Components.StageChange.Instance().ActionId = instance.ActionId;
Unibase.Platform.Automation.Components.StageChange.Instance().RuleProviderId = instance.RuleProviderId;
Unibase.Platform.Automation.Components.StageChange.Instance().RuleActionData = instance.RuleActionData;
Unibase.Platform.Automation.Components.StageChange.Instance().RowIndex = instance.RowIndex;
Unibase.Platform.Automation.Components.StageChange.Instance().AutomationMode = instance.AutomationMode;
Unibase.Platform.Automation.Components.StageChange.Instance().ParentActionId = instance.ParentActionId;
Unibase.Platform.Automation.Components.StageChange.Instance().IsAutomationMode = instance.IsAutomationMode;
yield Unibase.Platform.Automation.Components.NotificationGroup.Instance().LoadNotificationGroups();
if (instance.AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.AdvancedMode) {
eval('bizgaze_automation_flow_main.getcontainerid("' + containerid + '")');
}
$("#btnCloseStageChange").click(function () {
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
if (Unibase.Platform.Automation.Components.StageChange.Instance().AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.NormalMode) {
if (Unibase.Platform.Automation.Components.StageChange.Instance().AutomationMode) {
if (Unibase.Platform.Automation.Components.StageChange.Instance().IsAutomationMode) {
Unibase.Platform.Automation.Components.Rule.Instance().ChangeAction(instance.RowIndex, id);
}
}
}
else {
eval("bizgaze_automation_flow_main.getpopupclosed()");
}
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
});
$("#btnSaveStageChange").click(function () {
let appcontrolid = "frmUnibase_StageChange";
let result = Unibase.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation(appcontrolid);
if (result == false) {
MessageHelper.Instance().showError("Mandatory fields are missing", "Validate_StageChangeAction");
return false;
}
else {
Unibase.Platform.Automation.Components.StageChange.Instance().SaveStageChangeAction(id, containerid);
}
});
if (instance.ParentActionId != 0) {
yield Unibase.Platform.Automation.Components.ContactSelection.Instance().getResultActions(instance.ParentActionId);
yield Unibase.Platform.Automation.Components.StageChange.Instance().GetRuleActionInfo(Number(instance.ParentActionId));
$('#ddl_NotificationGrp').prop("disabled", true);
$('#creategrp_btn').addClass('d-none');
}
$('#creategrp_btn').click(function () {
Unibase.Platform.Automation.Components.NotificationGroup.Instance().init(0, null, true);
});
if (id != "") {
setTimeout(function () { Unibase.Platform.Automation.Components.StageChange.Instance().EditStageChangeAction(id); }, 10);
}
if (instance.RuleProviderId != 0) {
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(instance.RuleProviderId, null);
Unibase.Platform.Automation.Components.StageChange.Instance().LoadStages(instance.RuleProviderId);
}
if (instance.RuleActionData.length != 0) {
Unibase.Platform.Automation.Components.StageChange.Instance().LoadStageChangeData(instance.RuleActionData);
}
});
}
ToggleStageChangeConditions() {
$('#ActionConditionsDiv').toggleClass("hidden");
if ($('.conditionicon').hasClass('fa-angle-down')) {
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.StageChange.Instance().RuleProviderId, null);
}
else {
$('.conditionicon').removeClass('fa-angle-up').addClass('fa-angle-down');
}
}
EditStageChangeAction(id) {
let actionid = Number(id);
$("#Spn_StageChange").text("Edit StageChange");
Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleAction(actionid).then(function (response) {
$("#txtStageChanges_RuleActionName").val(response.RuleActionName);
if (!Unibase.Platform.Automation.Components.StageChange.Instance().IsAutomationMode) {
Unibase.Platform.Automation.Components.StageChange.Instance().RuleId = response.RuleId;
Unibase.Platform.Automation.Components.StageChange.Instance().RuleEventId = response.RuleEventId;
Unibase.Platform.Automation.Components.StageChange.Instance().EventGroupId = response.EventGroupId;
Unibase.Platform.Automation.Components.StageChange.Instance().ActionId = response.ActionId;
Unibase.Platform.Automation.Components.StageChange.Instance().ParentActionId = response.ParentActionId;
}
$('#ddl_NotificationGrp option[value=' + response.NotificationGroupId + ']').prop('selected', true);
if (response.ExecuteStatusId != Number(Unibase.Platform.Automation.Enums.ExecuteActionStatus.Approved))
$("#chkAutoApprovedStageChange").prop("checked", false);
else
$("#chkAutoApprovedStageChange").prop("checked", true);
$("#hf_StageName").val(response.ApproveStageId);
Unibase.Platform.Automation.Components.StageChange.Instance().LoadStages(Unibase.Platform.Automation.Components.StageChange.Instance().RuleProviderId);
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(response.RuleProviderId, response.SqlWhere);
$("#btn_ActionConditions").addClass("hidden");
$('#message_result').val(Number(response.BString5));
if (response.ResultActionId != null) {
$('#ddl_ResultAction').val(response.ResultActionId);
}
if (response.SqlWhere != null && response.SqlWhere != "") {
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
$("#ActionConditionsDiv").removeClass("hidden");
}
eval('_floatingLabelHelper.init();');
});
}
Toggleadvancedoptions() {
if ($('.arrowicon').hasClass('fa-angle-down')) {
$('.arrowicon').removeClass('fa-angle-down').addClass('fa-angle-up');
}
else {
$('.arrowicon').removeClass('fa-angle-up').addClass('fa-angle-down');
}
$('.Advanced_options').toggleClass("hidden");
}
LoadStageChangeData(Data) {
for (var i = 0; i < Data.length; i++) {
$("#txtStageChanges_RuleActionName").val(Data[i].RuleActionName);
if (!Data[i].AutoApproved)
$("#chkAutoApprovedStageChange").prop("checked", false);
else
$("#chkAutoApprovedStageChange").prop("checked", true);
$("#hf_StageName").val(Data[i].ApproveStageId);
Unibase.Platform.Automation.Components.StageChange.Instance().LoadStages(Unibase.Platform.Automation.Components.StageChange.Instance().RuleProviderId);
if (Data[i].SqlWhere != "" && Data[i].SqlWhere != null) {
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.StageChange.Instance().RuleProviderId, Data[i].SqlWhere);
$("#btn_ActionConditions").addClass("hidden");
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
$("#ActionConditionsDiv").removeClass("hidden");
}
eval('_floatingLabelHelper.init();');
}
}
SaveStageChangeAction(stagechangeid, containerid) {
let ruleactionid = Number(stagechangeid);
let queryelmnt = $("#builder");
let model = new Unibase.Platform.Automation.Requests.RuleAction();
model.RuleActionId = ruleactionid;
model.ActionId = Unibase.Platform.Automation.Components.StageChange.Instance().ActionId;
model.RuleId = 0;
model.RuleActionName = $("#txtStageChanges_RuleActionName").val().toString();
model.ResultActionId = 0;
model.NotificationGroupId = $('#ddl_NotificationGrp').val() == undefined ? 0 : Number($('#ddl_NotificationGrp').val());
if (model.NotificationGroupId == 0) {
MessageHelper.Instance().showError("Please Select Notification Group", "Validate_StageChangeAction");
return;
}
model.BString5 = $('#message_result option:selected').val().toString();
model.ApproveStageId = Number($("#ddl_StageName option:selected").val());
model.ParentActionId = Unibase.Platform.Automation.Components.StageChange.Instance().ParentActionId;
model.ResultActionId = Number($("#ddl_ResultAction option:selected").val());
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));
}
else {
model.SqlWhere = "";
model.SqlWhereJson = "";
}
if (model.ResultActionId != 0) {
model.ResultActionName = $("#ddl_ResultAction option:selected").text();
}
else {
model.ResultActionName = "";
}
model.AutoApproved = $('#chkAutoApprovedStageChange').is(':checked');
model.RowIndex = Unibase.Platform.Automation.Components.StageChange.Instance().RowIndex;
if (Unibase.Platform.Automation.Components.StageChange.Instance().IsAutomationMode) {
if (Unibase.Platform.Automation.Components.StageChange.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_StageChangeAction");
}
else {
MessageHelper.Instance().showSuccess(response.message, "Validate_StageChangeAction");
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
var actionname = response.result.RuleActionName;
eval("bizgaze_automation_flow_main.savestagechangeblock('" + response.result.RuleActionId + "','" + actionname + "')");
}
});
}
}
else {
model.RuleId = Unibase.Platform.Automation.Components.StageChange.Instance().RuleId;
model.EventGroupId = Unibase.Platform.Automation.Components.StageChange.Instance().EventGroupId;
model.RuleEventId = Unibase.Platform.Automation.Components.StageChange.Instance().RuleEventId;
model.ActionId = Unibase.Platform.Automation.Components.StageChange.Instance().ActionId;
model.ParentActionId = Unibase.Platform.Automation.Components.StageChange.Instance().ParentActionId;
Automation.Managers.RuleManager.Instance().saveRuleAction(model).then(function (response) {
if (response.status == Unibase.Data.Status.Error) {
MessageHelper.Instance().showError(response.message, "Validate_StageChangeAction");
}
else {
MessageHelper.Instance().showSuccess(response.message, "Validate_StageChangeAction");
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
}
});
}
}
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 = '<option value=' + response.NotificationGroupId + ' selected>' + response.NotificationGroupName + '</option>';
$('#ddl_NotificationGrp').html('').html(html);
}
});
});
}
LoadStages(ruleproviderid) {
Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleProvider(ruleproviderid).then(function (response) {
if (response != null) {
Unibase.Platform.Apps.Managers.StageManager.Instance().getStages(response.InstalledAppId).then(function (response) {
let cmbstages = document.getElementById('ddl_StageName');
$('#ddl_StageName').empty();
var defaultOpt1 = document.createElement("option");
defaultOpt1.text = "Select";
defaultOpt1.value = "";
cmbstages.appendChild(defaultOpt1);
var stages = response.result;
for (let i = 0; i <= stages.length - 1; i++) {
var opt = document.createElement("option");
var doctype = stages[i];
opt.text = doctype.StageName;
opt.value = doctype.StageId.toString();
cmbstages.appendChild(opt);
}
if ($("#hf_StageName").val() == "") {
$("#ddl_StageName").val(null);
}
else {
$("#ddl_StageName").val(Number($("#hf_StageName").val()));
}
});
}
});
}
static Instance() {
if (this.instance === undefined) {
this.instance = new StageChange();
}
return this.instance;
}
}
Components.StageChange = StageChange;
})(Components = Automation.Components || (Automation.Components = {}));
})(Automation = Platform.Automation || (Platform.Automation = {}));
})(Platform = Unibase.Platform || (Unibase.Platform = {}));
})(Unibase || (Unibase = {}));
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,691 @@
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 SendTask extends Platform.Core.BaseComponent {
constructor() {
super(...arguments);
this.RuleProviderId = 0;
this.RowIndex = 0;
this.AutomationMode = 0;
this.RuleInstance = Unibase.Platform.Automation.Components.Rule.Instance();
}
jsFiles() {
var jsfiles = ["platform/automation/managers/rulemanager.js",
"platform/automation/enums/automationmode.js", "platform/forms/managers/formmanager.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/apps/managers/stagemanager.js", "platform/automation/components/rulebuilder/rulebuilder.rule.js", "platform/automation/components/rulebuilder/notificationgroup.js", "platform/automation/managers/notificationgroupmanager.js"
];
return jsfiles;
}
cssFiles() {
return [];
}
html(id, containerid) {
let html = `<form id="frmUnibase_SendTask" 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="Spn_SendTask">Create Task</strong>
</div>
<div class="card-body scrollable" style="overflow-y: scroll;">
<div class="bg-white card" id="divSendTask">
<div id="Validate_TaskAction" class="clear"></div>
<div class="card-body">
<div class="row">
<div class="col-sm-12">
<div class="floating-label-form-group">
<label for="lbl" id="lbl_RuleActionName">Action<span class="text-danger required" id="spnIsRequired_RuleActionName"> *</span></label>
<input type="text" id="txtTask_RuleActionName" class="form-control value-control required floating-label-control" placeholder="Action *" data-placeholder="Enter Action" data-label="Action *">
<input type="hidden" id="hf_RuleActionName" />
</div></div></div>
<div class="row">
<div class="col-sm-12">
<div id="div_Subject" class="floating-label-form-group">
<label for="lbl_MessageSubject" id="lbl_MessageSubject">Subject<span class="text-danger"> *</span></label>
<div class="input-group">
<input type="text" id="txtTask_MessageSubject" class="col-sm-9 form-control value-control required floating-label-control" data-placeholder="Enter Subject" placeholder="Subject *" data-label="Subject *">
<select id="ddl_SubjectTokens" class="col-sm-3 form-control value-control">
<option value="0">Select Token</option></select></div></div></div></div>
<div class="row mt-3"><div class="col-sm-12">
<div id="div_Body" class="floating-label-form-group">
<label for="lbl_MessageBody" id="lbl_MessageBody">Body<span class="text-danger"> *</span></label><div class="input-group">
<!---<input type="text" id="txtTask_MessageBody" class="col-sm-9 form-control value-control required floating-label-control" data-placeholder="Enter Body" placeholder="Body *" data-label="Body *">---->
<textarea id="txtTask_MessageBody" class="form-control value-control required floating-label-control"style="width:50%;" placeholder="Body" data-placeholder="Task Body" data-label="Body*"></textarea>
<select id="ddl_BodyTokens" class="col-sm-3 form-control value-control">
<option value="0">Select Token</option></select></div></div></div></div>
<div class="row">
<div id="div_NotificationGrp" class="floating-label-form-group col-sm-6 floating-label-form-group-with-value">
<label for="lbl_NotificationGrp" id="lbl_NotificationGroup">Notification Group<span class="text-danger"> *</span></label>
<select id="ddl_NotificationGrp" class="form-control"><option value="0">Select Group</option></select>
</div><div class="col-sm-6 createbtn_grp"><button class="badge badge-primary mt-30 ml-15" id="creategrp_btn">Create Group</button></div></div>
<div class="row">
<div class="ResultActions col-sm-6 hidden">
<div id="div_ResultAction" class=" floating-label-form-group floating-label-form-group-with-value">
<label for="lbl" id="lbl_ResultAction">Result Action</label>
<select id="ddl_ResultAction" class="form-control">
<option value="">-- Select --</option></select>
<label for="Validation" id="lblValidation_ResultAction"></label><input type="hidden" id="hfFormPropertyId" value="" /></div></div></div></div></div>
<div class="bg-white card Advanced_optionsdata">
<div class="card-header"><i class="fa fa-angle-down arrowicon mr-1" style="font-size:20px" onclick="Unibase.Platform.Automation.Components.SendTask.Instance().Toggleadvancedoptions()"></i>Advanced Options</div>
<div class="card-body Advanced_options hidden">
<div class="row">
<div class="col-sm-6">
<div class="input-group">
<label for="ApprovalForm" class="font-bold">Approval Form</label>
<select id="txtAutocomplete_ApprovalForm" class="form-control text-control" style="width:100%;" placeholder="ApprovalForm" data-placeholder="ApprovalForm" data-label="" data-istagselect="true"></select>
<input type="hidden" id="hf_Autocomplete_ApprovalForm" class="form-control value-control" data-isdynamic="true" />
</div>
</div>
<div class="col-sm-6">
<div class="input-group">
<label for="ApprovalFormPrimaryId" class="font-bold">Form PrimaryColumn</label>
<select id="txtAutocomplete_ApprovalFormPrimaryId" class="form-control text-control" style="width:100%;" placeholder="PrimaryColumn" data-placeholder="PrimaryColumn" data-label="" data-istagselect="true"></select>
<input type="hidden" id="hf_Autocomplete_ApprovalFormPrimaryId" class="form-control value-control" data-isdynamic="true" />
</div>
</div>
</div>
<!---rejectform--->
<div class="row mt-3">
<div class="col-sm-6">
<div class="input-group">
<label for="RejectForm" class="font-bold">Reject Form</label>
<select id="txtAutocomplete_RejectForm" class="form-control text-control" style="width:100%;" placeholder="RejectForm" data-placeholder="RejectForm" data-label="" data-istagselect="true"></select>
<input type="hidden" id="hf_Autocomplete_RejectForm" class="form-control value-control" data-isdynamic="true" />
</div>
</div>
<div class="col-sm-6">
<div class="input-group">
<label for="RejectFormPrimaryId" class="font-bold">Form PrimaryColumn</label>
<select id="txtAutocomplete_RejectFormPrimaryId" class="form-control text-control" style="width:100%;" placeholder="PrimaryColumn" data-placeholder="PrimaryColumn" data-label="" data-istagselect="true"></select>
<input type="hidden" id="hf_Autocomplete_RejectFormPrimaryId" class="form-control value-control" data-isdynamic="true" />
</div>
</div>
</div>
<!-----end--->
<!---user-defined text for buttons---->
<div class="row mt-3">
<div class="col-sm-6">
<div class="Approvalbtn_div">
<label for="ApprovalbtnText" class="font-bold">Approval Btn Text</label>
<input type="text" id="Approval_btn_text" class="form-control value-control" value="Confirm"/>
</div>
</div>
<div class="col-sm-6">
<div class="Rejectlbtn_div">
<label for="RejectlbtnText" class="font-bold">Reject Btn Text</label>
<input type="text" id="Reject_btn_text" class="form-control value-control" value="Reject"/>
</div>
</div>
</div>
<!----end--->
<div class="row mt-3">
<div class="col-sm-6 floating-label-form-group floating-label-form-group-with-value">
<label class="Message_type">Message Type</label>
<select class="form-control" id="message_result">
<option value="0">Success</option>
<option value="1">Warning</option>
<option value="2">Error</option>
</select>
</div>
<div class="col-sm-3">
<input type="checkbox" class="test_data mt-50" id="chkAutoApprovedTask"checked>Perform this Action
</div>
<div class="col-sm-3 mt-50">
<input type="checkbox" class="isparent"><span class="ml-2">IsParent</span>
</div>
</div>
<!---parent options---->
<div class="row mt-3 Parentcolumns_info d-none">
<div class="col-sm-6 floating-label-form-group-with-value">
<label class="Parent_pkid">Parent Pkid</label>
<select class="form-control" id="parent_pkid">
</select>
</div><div class="col-sm-6 floating-label-form-group-with-value">
<label class="Parent_refguid">Parent Versionguid</label>
<select class="form-control" id="parent_versionguid">
</select>
</div>
</div>
<!---end---->
</div>
</div>
<div class="bg-white card hidden" id="DocTypesDiv">
<div class="card-header">DocTypes</div>
<div class="card-body">
<div class="SelectDocType col-sm-12">
<!--For Mapping of datalists-->
</div>
</div>
</div>
<div class="bg-white card" id="ActionConditionsDivdata">
<div class="card-header"><i class="fa fa-angle-down conditionicon mr-1" style="font-size:20px" onclick="Unibase.Platform.Automation.Components.SendTask.Instance().ToggleTaskConditions();"></i>Condition Details</div>
<div class="card-body hidden" id="ActionConditionsDiv">
<div class="ActionConditions">
<!--For Action Conditions-->
</div>
</div>
</div>
<div class="bg-white card" id="SelectstagesDiv">
<div class="card-header">Stage Event</div>
<div class="card-body">
<div class="stages_drp row"><div class="col-sm-6"><label class="from_label">From Stage</label><select class="from_stage_task form-control"></select></div><div class="col-sm-6"><label class="_label">To Stage</label><select class="to_stage_task form-control"></select></div></div>
</div></div>
<div class="bg-white card" id="SelectRoleDiv">
<div class="card-header">Send To Details</div>
<div class="card-body">
<div class="ContactSelection col-sm-12">
<!--For ContactSelection page-->
</div>
</div>
</div>
<div class="bg-white card col-sm-3 hidden" id="btn_ExternalRecipients">
<button type="button" class="btn btn-primary" onclick="Unibase.Platform.Automation.Components.SendTask.Instance().ToggleExternalRecipients();">External Recipients</button>
</div>
<div class="bg-white card hidden" id="ExternalRecipientsDiv">
<div class="card-header">External Recipients</div>
<div class="card-body">
<div class="ExternalRecipients">
</div>
</div>
</div>
</div>
<div class="bg-white card-footer footer" id="CreateTaskFooter">
<a href="javascript:;" id="btnCloseTask" class="btn btn-light btn-sm mr-auto "> Close</a>
<a href="javascript:;" id="btnSaveTask" class="btn btn-primary btn-sm"> Save</a>
</div>
</div>
</form>`;
return html;
}
load(id, containerid, callback) {
return __awaiter(this, void 0, void 0, function* () {
var instance = this;
Unibase.Platform.Automation.Components.SendTask.Instance().ActionId = instance.ActionId;
Unibase.Platform.Automation.Components.SendTask.Instance().RuleActionData = instance.RuleActionData;
Unibase.Platform.Automation.Components.SendTask.Instance().RowIndex = instance.RowIndex;
Unibase.Platform.Automation.Components.SendTask.Instance().AutomationMode = instance.AutomationMode;
Unibase.Platform.Automation.Components.SendTask.Instance().ParentActionId = instance.ParentActionId;
Unibase.Platform.Automation.Components.SendTask.Instance().IsAutomationMode = instance.IsAutomationMode;
yield Unibase.Platform.Automation.Components.NotificationGroup.Instance().LoadNotificationGroups();
if (instance.AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.AdvancedMode) {
eval('bizgaze_automation_flow_main.getcontainerid("' + containerid + '")');
}
if (instance.RuleInstance.IsStageChangeEvent()) {
$('#SelectstagesDiv').removeClass('d-none');
yield Unibase.Platform.Automation.Components.SendTask.Instance().LoadAppStages();
}
else {
$('#SelectstagesDiv').addClass('d-none');
}
$("#btnCloseTask").click(function () {
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
if (Unibase.Platform.Automation.Components.SendTask.Instance().AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.NormalMode) {
if (Unibase.Platform.Automation.Components.SendTask.Instance().AutomationMode) {
if (Unibase.Platform.Automation.Components.SendTask.Instance().IsAutomationMode) {
Unibase.Platform.Automation.Components.Rule.Instance().ChangeAction(instance.RowIndex, id);
}
}
}
else {
eval("bizgaze_automation_flow_main.getpopupclosed()");
}
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
});
$('#creategrp_btn').click(function () {
Unibase.Platform.Automation.Components.NotificationGroup.Instance().init(0, null, true);
});
$("#btnSaveTask").click(function () {
let appcontrolid = "frmUnibase_SendTask";
let result = Unibase.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation(appcontrolid);
if (result == false) {
MessageHelper.Instance().showError("Mandatory fields are missing", "Validate_TaskAction");
return false;
}
else {
Unibase.Platform.Automation.Components.SendTask.Instance().SaveTaskAction(id, containerid);
}
});
$('.isparent').change(function () {
if ($('.isparent').is(':checked')) {
$('.Parentcolumns_info').removeClass('d-none');
}
else {
$('.Parentcolumns_info').addClass('d-none');
}
});
$("#ddl_SubjectTokens").change(function () {
var textAreaTxt = $("#txtTask_MessageSubject").val().toString();
var txtToAdd = '{{' + $("#ddl_SubjectTokens option:selected").text() + '}}';
var firsttext = textAreaTxt.slice(0, SendTask.Instance().tokenposition);
var lasttext = textAreaTxt.slice(SendTask.Instance().tokenposition, textAreaTxt.length);
$("#txtTask_MessageSubject").val(firsttext + txtToAdd + lasttext);
$("#ddl_SubjectTokens").val(0);
});
$("#ddl_BodyTokens").change(function () {
var textAreaTxt = $("#txtTask_MessageBody").val().toString();
var txtToAdd = '{{' + $("#ddl_BodyTokens option:selected").text() + '}}';
var firsttext = textAreaTxt.slice(0, SendTask.Instance().tokenposition);
var lasttext = textAreaTxt.slice(SendTask.Instance().tokenposition, textAreaTxt.length);
$("#txtTask_MessageBody").val(firsttext + txtToAdd + lasttext);
$("#ddl_BodyTokens").val(0);
});
$("#txtTask_MessageBody").focusout(function (event) {
SendTask.Instance().tokenposition = event["target"]["selectionStart"];
});
$("#txtTask_MessageSubject").focusout(function (event) {
SendTask.Instance().tokenposition = event["target"]["selectionStart"];
});
var _fileCacheHelper = Platform.Helpers.FileCacheHelper.Instance();
yield _fileCacheHelper.loadJsFileAsync("platform/automation/components/contactselection.js", function () {
jQuery(".ContactSelection").html(Unibase.Platform.Automation.Components.ContactSelection.Instance().init(instance.RuleProviderId));
});
yield _fileCacheHelper.loadJsFileAsync("platform/automation/components/externalrecipients.js", function () {
jQuery(".ExternalRecipients").html(Unibase.Platform.Automation.Components.ExternalRecipients.Instance().init(instance.RuleProviderId));
Unibase.Platform.Automation.Components.ExternalRecipients.Instance().load(instance.RuleProviderId);
});
let rpid = Number(instance.RuleProviderId);
if (rpid != 0) {
Unibase.Platform.Automation.Components.SendTask.Instance().LoadMsgSubjectTokens(rpid);
Unibase.Platform.Automation.Components.SendTask.Instance().LoadMsgBodyTokens(rpid);
Unibase.Platform.Automation.Components.SendTask.Instance().LoadApprovalForm(rpid);
Unibase.Platform.Automation.Components.SendTask.Instance().LoadParentTokens(rpid);
Unibase.Platform.Automation.Components.SendTask.Instance().LoadApprovalFormProperties(rpid);
Unibase.Platform.Automation.Components.SendTask.Instance().LoadRejectForm(rpid);
Unibase.Platform.Automation.Components.SendTask.Instance().loadRejectFormProperties(rpid);
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(rpid, null);
}
if (instance.RuleActionData.length != 0) {
Unibase.Platform.Automation.Components.SendTask.Instance().LoadTaskData(instance.RuleActionData);
}
if (instance.ParentActionId != 0) {
yield Unibase.Platform.Automation.Components.ContactSelection.Instance().getResultActions(instance.ParentActionId);
yield Unibase.Platform.Automation.Components.SendTask.Instance().GetRuleActionInfo(Number(instance.ParentActionId));
$('#ddl_NotificationGrp').prop("disabled", true);
$('#creategrp_btn').addClass('d-none');
}
if (id != "") {
setTimeout(function () { Unibase.Platform.Automation.Components.SendTask.Instance().EditTaskAction(id); }, 10);
}
});
}
LoadAppStages() {
return __awaiter(this, void 0, void 0, function* () {
var html = '';
var fromstage = '<option value="0">Select FromStage</option>';
var tostage = '<option value="0">Select ToStage</option>';
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>';
}
}
$('.from_stage_task').html(fromstage + html);
$('.to_stage_task').html(tostage + html);
});
});
}
ToggleTaskConditions() {
$('#ActionConditionsDiv').toggleClass("hidden");
if ($('.conditionicon').hasClass('fa-angle-down')) {
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.SendTask.Instance().RuleProviderId, null);
}
else {
$('.conditionicon').removeClass('fa-angle-up').addClass('fa-angle-down');
}
}
ToggleExternalRecipients() {
$("#ExternalRecipientsDiv").toggle(function () {
$("#btn_ExternalRecipients").addClass("hidden");
$("#ExternalRecipientsDiv").removeClass("hidden");
});
}
Toggleadvancedoptions() {
if ($('.arrowicon').hasClass('fa-angle-down')) {
$('.arrowicon').removeClass('fa-angle-down').addClass('fa-angle-up');
}
else {
$('.arrowicon').removeClass('fa-angle-up').addClass('fa-angle-down');
}
$('.Advanced_options').toggleClass("hidden");
}
EditTaskAction(id) {
let actionid = Number(id);
$("#Spn_SendTask").text("Edit Task");
Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleAction(actionid).then(function (response) {
$("#txtTask_RuleActionName").val(response.RuleActionName);
$("#txtTask_MessageSubject").val(response.BString1);
$("#txtTask_MessageBody").val(response.BString2);
$('#ddl_NotificationGrp option[value=' + response.NotificationGroupId + ']').prop('selected', true);
if (!Unibase.Platform.Automation.Components.SendTask.Instance().IsAutomationMode) {
Unibase.Platform.Automation.Components.SendTask.Instance().RuleId = response.RuleId;
Unibase.Platform.Automation.Components.SendTask.Instance().RuleEventId = response.RuleEventId;
Unibase.Platform.Automation.Components.SendTask.Instance().EventGroupId = response.EventGroupId;
Unibase.Platform.Automation.Components.SendTask.Instance().ActionId = response.ActionId;
Unibase.Platform.Automation.Components.SendTask.Instance().ParentActionId = response.ParentActionId;
}
if (response.ExecuteStatusId != Number(Unibase.Platform.Automation.Enums.ExecuteActionStatus.Approved))
$("#chkAutoApprovedTask").prop("checked", false);
else
$("#chkAutoApprovedTask").prop("checked", true);
$("#div_Subject").addClass('floating-label-form-group-with-value');
$("#div_Body").addClass('floating-label-form-group-with-value');
$("#txtAutocomplete_ApprovalForm").val("" + response.BString8 + "");
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckContactColumns(response.Users);
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckSecondaryContactColumns(response.SecondaryUsers);
Unibase.Platform.Automation.Components.ContactSelection.Instance().BindRecipients(response.RuleActionId);
if (response.SqlWhere != null && response.SqlWhere != "") {
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
$("#ActionConditionsDiv").removeClass("hidden");
}
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(response.RuleProviderId, response.SqlWhere);
$('#message_result').val(Number(response.BString5));
if (response.ResultActionId != null) {
$('#ddl_ResultAction').val(response.ResultActionId);
}
Unibase.Platform.Forms.Managers.FormManager.Instance().getForm(Number(response.BString8)).then(function (responseinfo) {
if (responseinfo.result != null) {
var apprlform = new Option(responseinfo.result.FormName, responseinfo.result.FormId.toString(), true);
$("#txtAutocomplete_ApprovalForm").append(apprlform);
$("#txtAutocomplete_ApprovalFormPrimaryId").html('<option selected>' + response.BString9 + '</option>');
}
});
Unibase.Platform.Forms.Managers.FormManager.Instance().getForm(Number(response.BString10)).then(function (responseinfo) {
if (responseinfo.result != null) {
var rejectform = new Option(responseinfo.result.FormName, responseinfo.result.FormId.toString(), true);
$("#txtAutocomplete_RejectForm").append(rejectform);
$("#txtAutocomplete_RejectFormPrimaryId").html('<option selected>' + response.BString11 + '</option>');
}
});
if (response.FromStage != 0 && response.ToStage != 0) {
$('.from_stage_task option[value=' + response.FromStage + ']').prop("selected", true);
$('.to_stage_task option[value=' + response.ToStage + ']').prop("selected", true);
}
if (response.BString12 != null && response.BString12 != "") {
$('#Approval_btn_text').val(response.BString12);
}
if (response.BString13 != null && response.BString13 != "") {
$('#Reject_btn_text').val(response.BString13);
}
if (response.IsParent) {
$('.isparent').prop("checked", true);
$('.Parentcolumns_info').removeClass('d-none');
if (response.String2 != null)
$('#parent_pkid option[value=' + response.String2 + ']').attr("selected", "true");
if (response.String3 != null)
$('#parent_versionguid option[value=' + response.String3 + ']').attr("selected", "true");
}
eval('_floatingLabelHelper.init();');
});
}
LoadParentTokens(ruleproviderid) {
Unibase.Platform.Automation.Managers.RuleManager.Instance().getTokens(ruleproviderid).then(function (response) {
$('#parent_pkid').empty();
$('#parent_versionguid').empty();
var optionshtml = '<option value="0">Select Token</option>';
for (let i = 0; i <= response.length - 1; i++) {
optionshtml += '<option id=' + response[i] + ' value="' + response[i] + '">' + response[i] + '</option>';
}
$('#parent_pkid').append(optionshtml);
$('#parent_versionguid').append(optionshtml);
});
}
LoadTaskData(Data) {
for (var i = 0; i < Data.length; i++) {
$("#txtTask_RuleActionName").val(Data[i].RuleActionName);
$("#txtTask_MessageSubject").val(Data[i].BString1);
$("#txtTask_MessageBody").val(Data[i].BString2);
if (!Data[i].AutoApproved)
$("#chkAutoApprovedTask").prop("checked", false);
else
$("#chkAutoApprovedTask").prop("checked", true);
$("#div_Subject").addClass('floating-label-form-group-with-value');
$("#div_Body").addClass('floating-label-form-group-with-value');
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckContactColumns(Data[i].Users);
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckSecondaryContactColumns(Data[i].SecondaryUsers);
if (Data[i].SqlWhere != "" && Data[i].SqlWhere != null) {
$(".conditionicon").addClass("fa-angle-up").removeClass('fa-fa-angle-down');
$("#ActionConditionsDiv").removeClass("hidden");
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.SendTask.Instance().RuleProviderId, Data[i].SqlWhere);
}
eval('_floatingLabelHelper.init();');
}
}
SaveTaskAction(taskid, containerid) {
var instance = this;
let ruleactionid = Number(taskid);
let queryelmnt = $("#builder");
let recipients = Unibase.Platform.Automation.Components.ContactSelection.Instance().GetRecipients();
let contactcolumns = Unibase.Platform.Automation.Components.ContactSelection.Instance().getContactColumns();
let secondarycontactcolumns = Unibase.Platform.Automation.Components.ContactSelection.Instance().getSecondaryContactColumns();
let externalroles = Unibase.Platform.Automation.Components.ExternalRecipients.Instance().GetExternalRoles();
let externalusers = Unibase.Platform.Automation.Components.ExternalRecipients.Instance().GetExternalUsers();
let approvalFormId = $("#txtAutocomplete_ApprovalForm option:selected").val() == undefined ? '' : $("#txtAutocomplete_ApprovalForm option:selected").val();
let model = new Unibase.Platform.Automation.Requests.RuleAction();
model.RuleActionId = ruleactionid;
model.ActionId = Unibase.Platform.Automation.Components.SendTask.Instance().ActionId;
model.RuleId = 0;
model.NotificationGroupId = $('#ddl_NotificationGrp').val() == undefined ? 0 : Number($('#ddl_NotificationGrp').val());
if (model.NotificationGroupId == 0) {
MessageHelper.Instance().showError("Please Select Notification Group", "Validate_TaskAction");
return;
}
model.RuleActionName = $("#txtTask_RuleActionName").val().toString();
model.BString1 = $("#txtTask_MessageSubject").val().toString();
model.BString2 = $("#txtTask_MessageBody").val().toString();
if (instance.RuleInstance.IsStageChangeEvent()) {
model.FromStage = $('.from_stage_task option:selected').val() != "0" ? Number($('.from_stage_task option:selected').val()) : 0;
model.ToStage = $('.to_stage_task option:selected').val() != "0" ? Number($('.to_stage_task option:selected').val()) : 0;
}
model.BString6 = externalroles;
model.BString7 = externalusers;
model.BString8 = approvalFormId.toString();
model.BString10 = $('#txtAutocomplete_RejectForm option:selected').val() == undefined ? null : $('#txtAutocomplete_RejectForm option:selected').val().toString();
model.BString11 = $('#txtAutocomplete_RejectFormPrimaryId option:selected').text() == "Select FormProperty" ? null : $('#txtAutocomplete_RejectFormPrimaryId option:selected').text().toString();
model.BString12 = $('#Approval_btn_text').val().toString();
model.BString13 = $('#Reject_btn_text').val().toString();
model.String2 = $('#parent_pkid option:selected').text() == "Select Token" || undefined || "" ? "" : $('#parent_pkid option:selected').text();
model.String3 = $('#parent_versionguid option:selected').text() == "Select Token" || undefined || "" ? "" : $('#parent_versionguid option:selected').text();
model.BString5 = $('#message_result option:selected').val().toString();
if ($('#txtAutocomplete_ApprovalFormPrimaryId option:selected').text() != "Select FormProperty") {
model.BString9 = $('#txtAutocomplete_ApprovalFormPrimaryId option:selected').text();
}
model.ExternalReportId = ($("#txtAutoComplete_Reports option:selected").val() == undefined) ? 0 : Number($("#txtAutoComplete_Reports option:selected").val());
model.ExternalReportColumnId = Number($("#txtAutoComplete_ReportColumns option:selected").val());
model.ProviderColumnId = Number($("#txtAutoComplete_ProviderColumns option:selected").val());
model.ApproveStageId = 0;
model.RejectStageId = 0;
model.Users = contactcolumns;
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));
}
else {
model.SqlWhere = "";
model.SqlWhereJson = "";
}
model.IsParent = $('.isparent').is(':checked');
model.ResultActionId = $("#ddl_ResultAction option:selected").val() == undefined ? 0 : Number($("#ddl_ResultAction option:selected").val());
model.ResultActionId = $("#ddl_ResultAction option:selected").val() == undefined ? 0 : 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.SendTask.Instance().ParentActionId;
model.AutoApproved = $('#chkAutoApprovedTask').is(':checked');
model.RecipientsData = recipients;
model.SecondaryUsers = secondarycontactcolumns;
model.RowIndex = Unibase.Platform.Automation.Components.SendTask.Instance().RowIndex;
if (Unibase.Platform.Automation.Components.SendTask.Instance().IsAutomationMode) {
if (Unibase.Platform.Automation.Components.SendTask.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_TaskAction");
}
else {
MessageHelper.Instance().showSuccess(response.message, "Validate_TaskAction");
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
var actionname = response.result.RuleActionName;
eval("bizgaze_automation_flow_main.savetaskblock('" + response.result.RuleActionId + "','" + actionname + "')");
}
});
}
}
else {
model.RuleId = Unibase.Platform.Automation.Components.SendTask.Instance().RuleId;
model.EventGroupId = Unibase.Platform.Automation.Components.SendTask.Instance().EventGroupId;
model.RuleEventId = Unibase.Platform.Automation.Components.SendTask.Instance().RuleEventId;
model.ActionId = Unibase.Platform.Automation.Components.SendTask.Instance().ActionId;
model.ParentActionId = Unibase.Platform.Automation.Components.SendTask.Instance().ParentActionId;
Automation.Managers.RuleManager.Instance().saveRuleAction(model).then(function (response) {
if (response.status == Unibase.Data.Status.Error) {
MessageHelper.Instance().showError(response.message, "Validate_TaskAction");
}
else {
MessageHelper.Instance().showSuccess(response.message, "Validate_TaskAction");
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
}
});
}
}
LoadMsgSubjectTokens(ruleproviderid) {
Unibase.Platform.Automation.Managers.RuleManager.Instance().getTokens(ruleproviderid).then(function (response) {
let cmbConditionProperties = document.getElementById('ddl_SubjectTokens');
$('#ddl_SubjectTokens').empty();
var defaultOpt1 = document.createElement("option");
defaultOpt1.text = "Select Token";
defaultOpt1.value = "0";
cmbConditionProperties.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();
cmbConditionProperties.appendChild(opt);
}
});
}
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 = '<option value=' + response.NotificationGroupId + ' selected>' + response.NotificationGroupName + '</option>';
$('#ddl_NotificationGrp').html('').html(html);
}
});
});
}
LoadMsgBodyTokens(ruleproviderid) {
Unibase.Platform.Automation.Managers.RuleManager.Instance().getTokens(ruleproviderid).then(function (response) {
let cmbConditionProperties = document.getElementById('ddl_BodyTokens');
$('#ddl_BodyTokens').empty();
var defaultOpt1 = document.createElement("option");
defaultOpt1.text = "Select Token";
defaultOpt1.value = "0";
cmbConditionProperties.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();
cmbConditionProperties.appendChild(opt);
}
});
}
LoadApprovalForm(ruleproviderid) {
Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleProvider(ruleproviderid).then(function (response) {
var url = _appsettings.server_url() + '/apis/v4/unibase/platform/forms/getforms/installedappid/' + response.InstalledAppId + '/appid/' + 0;
AutoCompleteHelper.getHelper().Create("#txtAutocomplete_ApprovalForm", "#hf_Autocomplete_ApprovalForm", url, function (response) {
});
});
}
LoadRejectForm(ruleproviderid) {
Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleProvider(ruleproviderid).then(function (response) {
var url = _appsettings.server_url() + '/apis/v4/unibase/platform/forms/getforms/installedappid/' + response.InstalledAppId + '/appid/' + 0;
AutoCompleteHelper.getHelper().Create("#txtAutocomplete_RejectForm", "#hf_Autocomplete_RejectForm", url, function (response) {
});
});
}
LoadApprovalFormProperties(ruleproviderid) {
Unibase.Platform.Automation.Managers.RuleManager.Instance().getTokens(ruleproviderid).then(function (response) {
let cmbConditionProperties = document.getElementById('txtAutocomplete_ApprovalFormPrimaryId');
$('#txtAutocomplete_ApprovalFormPrimaryId').empty();
var defaultOpt1 = document.createElement("option");
defaultOpt1.text = "Select FormProperty";
defaultOpt1.value = "0";
cmbConditionProperties.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();
cmbConditionProperties.appendChild(opt);
}
});
}
loadRejectFormProperties(ruleproviderid) {
Unibase.Platform.Automation.Managers.RuleManager.Instance().getTokens(ruleproviderid).then(function (response) {
let cmbConditionProperties = document.getElementById('txtAutocomplete_RejectFormPrimaryId');
$('#txtAutocomplete_RejectFormPrimaryId').empty();
var defaultOpt1 = document.createElement("option");
defaultOpt1.text = "Select FormProperty";
defaultOpt1.value = "0";
cmbConditionProperties.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();
cmbConditionProperties.appendChild(opt);
}
});
}
static Instance() {
if (this.instance === undefined) {
this.instance = new SendTask();
}
return this.instance;
}
}
Components.SendTask = SendTask;
})(Components = Automation.Components || (Automation.Components = {}));
})(Automation = Platform.Automation || (Platform.Automation = {}));
})(Platform = Unibase.Platform || (Unibase.Platform = {}));
})(Unibase || (Unibase = {}));
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,549 @@
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 SendWhatsApp extends Platform.Core.BaseComponent {
constructor() {
super(...arguments);
this.RowIndex = 0;
this.RuleProviderId = 0;
this.AutomationMode = 0;
this.RuleInstance = Unibase.Platform.Automation.Components.Rule.Instance();
}
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/templates/managers/templatemanager.js",
"platform/automation/requests/rulecondition.js",
"platform/forms/components/formviewer/formviewer.js",
"libs/parsley/parsley.min.js", "platform/templates/enums/templatetype.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/apps/managers/stagemanager.js", "platform/automation/components/rulebuilder/rulebuilder.rule.js", "platform/automation/components/rulebuilder/notificationgroup.js", "platform/automation/managers/notificationgroupmanager.js", "apps/communications/managers/whatsapp/whatsappmanager.js"
];
return jsfiles;
}
cssFiles() {
return [];
}
html(id, containerid) {
let html = `<form id="frmUnibase_SendWhatsApp" data-validate="parsley" data-isdynamic="false" name="frmUnibase_SendWhatsApp">
<div class="card bg-light">
<div class="b-b bg-white card-header header">
<strong class="text-dark title" id="Spn_SendWhatsApp">Create WhatsAppReminder</strong>
</div>
<div class="card-body scrollable" style="overflow-y:scroll">
<div class="bg-white card" id="divSendWhatsApp">
<div id="Validate_WhatsAppAction" class="clear"></div>
<div class="card-body">
<div class="row">
<div class="col-sm-12">
<div class="floating-label-form-group">
<label for="lbl_RuleActionName" id="lbl_RuleActionName">Action<span class="text-danger">*</span></label><input type="text" id="txtWhatsApp_RuleActionName" class="form-control required value-control floating-label-control" data-isdynamic="false" placeholder="Action *" data-placeholder="Enter Action" data-label="Action *"> <input type="hidden" id="hf_RuleActionName"><label for="Validation" id="lblValidation_RuleActionName"></label>
</div>
</div>
</div>
<div class="row mt-3">
<div id="div_Template" class="col-sm-4 floating-label-form-group">
<label>Template Name<span class="text-danger">*</span></label><select id="Autocomplete_Template" class="form-control value-control" data-isdynamic="true"></select><input type="hidden" id="hf_Template"/></div>
<div class="col-sm-4">
<div id="div_TemplateType" class="floating-label-form-group floating-label-form-group-with-value">
<label for="lbl_TemplateType" id="lbl_TemplateType">Template Type<span class="text-danger">*</span></label><select id="ddl_TemplateType" class="form-control value-control ml-0 mr-0">
<option value="0">
Select Type
</option>
<option value="Template">
Template
</option>
</select>
</div>
</div>
<div class="col-sm-4">
<div id="div_LanguageCode">
<label for="lbl_LanguageCode" id="lbl_LanguageCode">Language<span class="text-danger">*</span></label><select id="ddl_LanguageCode" class="form-control value-control">
<option value="0">
Select Language
</option>
<option value="en">
English
</option>
</select>
</div>
</div>
</div>
<div class="row mt-3">
<div class="col-sm-10">
<label>Template Body</label><textArea class="col-sm-12 textArea_WhatsappBody" style="height:250px"></textArea></div>
<div class="col-sm-2 mt-3"><select id="ddl_bodyTokens" class="form-control value-control">
<option value="0">
Select Token
</option>
</select></div>
</div>
<div class="row mt-3">
<div id="div_NotificationGrp" class="floating-label-form-group col-sm-6 floating-label-form-group-with-value">
<label for="lbl_NotificationGrp" id="lbl_NotificationGroup">Notification Group<span class="text-danger">*</span></label><select id="ddl_NotificationGrp" class="form-control">
<option value="0">
Select Group
</option>
</select>
</div>
<div class="col-sm-6 createbtn_grp">
<button class="badge badge-primary mt-30 ml-15" id="creategrp_btn">Create Group</button>
</div>
<div class="ResultActions col-sm-6 hidden"><div id="div_ResultAction" class=" floating-label-form-group floating-label-form-group-with-value">
<label for="lbl" id="lbl_ResultAction">Result Action</label>
<select id="ddl_ResultAction" class="form-control">
<option value="0">Select</option></select><label for="Validation" id="lblValidation_ResultAction"></label><input type="hidden" id="hfFormPropertyId" value="0" />
</div></div>
</div>
</div>
</div>
<div class="bg-white card Advanced_optionsdata">
<div class="card-header">
<i class="fa fa-angle-down mr-1" style="font-size:20px" onclick="Unibase.Platform.Automation.Components.SendWhatsApp.Instance().Toggleadvancedoptions();"></i>
Advanced Options
</div>
<div class="card-body Advanced_options hidden">
<div class="row">
<div class="col-sm-6 floating-label-form-group floating-label-form-group-with-value">
<label class="Message_type">Message Type</label><select class="form-control" id="message_result">
<option value="0">
Success
</option>
<option value="1">
Warning
</option>
<option value="2">
Error
</option>
</select>
</div>
<div class="col-sm-6">
<input type="checkbox" class="test_data mt-50" id="chkAutoApprovedWhatsapp" checked="checked">Perform this Action
</div>
</div>
</div>
</div>
<div class="bg-white card" id="ActionConditionsDivdata">
<div class="card-header">
<i class="fa fa-angle-down conditionicon mr-1" style="font-size:20px" onclick="Unibase.Platform.Automation.Components.SendWhatsApp.Instance().ToggleWhatsAppConditions();"></i>
Condition Details
</div>
<div class="card-body hidden" id="ActionConditionsDiv">
<div class="ActionConditions"></div>
</div>
</div>
<div class="bg-white card" id="SelectRoleDiv">
<div class="card-header">
Send To Details
</div>
<div class="card-body">
<div class="ContactSelection col-sm-12"></div>
</div>
</div>
<div class="bg-white card " id="SendFromDetailsDiv">
<div class="card-header">Send From Details</div>
<div class="card-body">
<div class="row SendFrom">
<div class="col-sm-6">
<div class="input-group">
<label for="lbl_ProviderName" id="lbl_ProviderName">Provider Name <span class="text-danger" id="span_ProviderName">*</span></label>
<select id="Autocomplete_ProviderName" class="form-control text-control required" style="width:100%;" placeholder="ProviderName" data-placeholder="ProviderName" data-label="" data-istagselect="true"></select>
<input type="hidden" id="hf_ProviderName" class="form-control value-control" data-isdynamic="true" />
</div>
</div>
<div class="col-sm-6">
<div class="input-group">
<label for="lbl_SendSmsFrom" id="lbl_SendFrom">Sender Name<span class="text-danger" id="span_smssendfrom">*</span></label>
<select id="Autocomplete_SenderName" class="form-control text-control required" style="width:100%;" placeholder="Sender Name" data-placeholder="Sender Name" data-label="" data-istagselect="true"></select>
<input type="hidden" id="hf_SenderName" class="form-control value-control" data-isdynamic="true" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="bg-white card-footer modal-footer pa-10" id="CreateWhatsappFooter">
<a href="javascript:;" id="btnCloseWhatsAppReminder" class="btn btn-light btn-sm mr-auto">Close</a><a href="javascript:;" id="btnSaveWhatsAppReminder" class="btn btn-primary btn-sm">Save</a>
</div>
</form>`;
return html;
}
load(id, containerid, callback) {
return __awaiter(this, void 0, void 0, function* () {
var instance = this;
Unibase.Platform.Automation.Components.SendWhatsApp.Instance().ActionId = instance.ActionId;
Unibase.Platform.Automation.Components.SendWhatsApp.Instance().RuleActionData = instance.RuleActionData;
Unibase.Platform.Automation.Components.SendWhatsApp.Instance().RowIndex = instance.RowIndex;
Unibase.Platform.Automation.Components.SendWhatsApp.Instance().AutomationMode = instance.AutomationMode;
Unibase.Platform.Automation.Components.SendWhatsApp.Instance().RuleProviderId = instance.RuleProviderId;
Unibase.Platform.Automation.Components.SendWhatsApp.Instance().ParentActionId = instance.ParentActionId;
Unibase.Platform.Automation.Components.SendWhatsApp.Instance().IsAutomationMode = instance.IsAutomationMode;
yield Unibase.Platform.Automation.Components.NotificationGroup.Instance().LoadNotificationGroups();
if (instance.AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.AdvancedMode) {
eval('bizgaze_automation_flow_main.getcontainerid("' + containerid + '")');
}
if (instance.ParentActionId != 0) {
yield Unibase.Platform.Automation.Components.ContactSelection.Instance().getResultActions(instance.ParentActionId);
yield Unibase.Platform.Automation.Components.SendWhatsApp.Instance().GetRuleActionInfo(Number(instance.ParentActionId));
$('#ddl_NotificationGrp').prop("disabled", true);
$('#creategrp_btn').addClass('d-none');
}
yield Unibase.Platform.Automation.Components.SendWhatsApp.Instance().loadproviders();
var _fileCacheHelper = Platform.Helpers.FileCacheHelper.Instance();
yield _fileCacheHelper.loadJsFileAsync("platform/automation/components/contactselection.js", function () {
jQuery(".ContactSelection").html(Unibase.Platform.Automation.Components.ContactSelection.Instance().init(instance.RuleProviderId));
if (instance.RuleActionData.length != 0) {
Unibase.Platform.Automation.Components.SendWhatsApp.Instance().LoadWhatsAppData(instance.RuleActionData);
}
});
yield _fileCacheHelper.loadJsFileAsync("platform/automation/components/externalrecipients.js", function () {
jQuery(".ExternalRecipients").html(Unibase.Platform.Automation.Components.ExternalRecipients.Instance().init(instance.RuleProviderId));
Unibase.Platform.Automation.Components.ExternalRecipients.Instance().load(instance.RuleProviderId);
});
$('#creategrp_btn').click(function () {
Unibase.Platform.Automation.Components.NotificationGroup.Instance().init(0, null, true);
});
$("#btnCloseWhatsAppReminder").click(function () {
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
if (Unibase.Platform.Automation.Components.SendWhatsApp.Instance().AutomationMode == Unibase.Platform.Automation.Enums.AutomationMode.NormalMode) {
if (Unibase.Platform.Automation.Components.SendWhatsApp.Instance().AutomationMode) {
if (Unibase.Platform.Automation.Components.SendWhatsApp.Instance().IsAutomationMode) {
Unibase.Platform.Automation.Components.Rule.Instance().ChangeAction(instance.RowIndex, id);
}
}
}
else {
eval("bizgaze_automation_flow_main.getpopupclosed()");
}
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
});
$("#btnSaveWhatsAppReminder").click(function () {
let appcontrolid = "frmUnibase_SendWhatsApp";
let result = Unibase.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation(appcontrolid);
if (result == false) {
MessageHelper.Instance().showError("Mandatory fields are missing", "Validate_WhatsAppAction");
return false;
}
else {
Unibase.Platform.Automation.Components.SendWhatsApp.Instance().SaveWhatsAppReminder(id, containerid);
}
});
$("#ddl_bodyTokens").change(function () {
var textAreaTxt = $(".textArea_WhatsappBody").val() == undefined ? "" : $(".textArea_WhatsappBody").val().toString();
SendWhatsApp.Instance().Parameters = $("#ddl_bodyTokens option:selected").text() + "|";
var txtToAdd = '{{' + $("#ddl_bodyTokens option:selected").text() + '}}';
var firsttext = textAreaTxt.slice(0, SendWhatsApp.Instance().tokenposition);
var lasttext = textAreaTxt.slice(SendWhatsApp.Instance().tokenposition, textAreaTxt.length);
$(".textArea_WhatsappBody").val(firsttext + txtToAdd + lasttext);
$("#ddl_bodyTokens").val(0);
});
$(".textArea_WhatsappBody").focusout(function (event) {
SendWhatsApp.Instance().tokenposition = event["target"]["selectionStart"];
});
$("#Autocomplete_Template").change(function () {
let templateid = Number($("#Autocomplete_Template option:selected").val());
Unibase.Platform.Templates.Managers.TemplateManager.Instance().getTemplateText(Number(templateid)).then(function (response) {
if (response.result != null) {
var templatetext = HtmlHelper.getHelper().decode(response.result.TemplateText);
$('.textArea_WhatsappBody').text(templatetext);
}
});
});
let rpid = instance.RuleProviderId;
if (rpid != 0) {
Unibase.Platform.Automation.Components.SendWhatsApp.Instance().LoadBodyTokens(rpid);
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(rpid, null);
Unibase.Platform.Automation.Components.SendWhatsApp.Instance().loadTemplates(instance.RuleProviderId);
}
if (id != "") {
Unibase.Platform.Automation.Components.SendWhatsApp.Instance().EditWhatsAppReminder(id, containerid);
}
$('#Autocomplete_ProviderName').change(function () {
if (SendWhatsApp.whatsappsenders.length > 0) {
var providerid = Number($('#Autocomplete_ProviderName option:selected').val());
var data = SendWhatsApp.whatsappsenders.filter(x => x.ProviderId = providerid);
var html = '';
for (let i = 0; i < data.length; i++) {
html += '<option value=' + data[i].SenderId + '>' + data[i].SenderName + '</option>';
}
$('#Autocomplete_SenderName').html(html);
}
});
});
}
Toggleadvancedoptions() {
if ($('.arrowicon').hasClass('fa-angle-down')) {
$('.arrowicon').removeClass('fa-angle-down').addClass('fa-angle-up');
}
else {
$('.arrowicon').removeClass('fa-angle-up').addClass('fa-angle-down');
}
$('.Advanced_options').toggleClass("hidden");
}
loadproviders() {
return __awaiter(this, void 0, void 0, function* () {
yield Unibase.Apps.Communications.Managers.WhatsAppManager.Instance().GetWhatAppSenders().then(function (response) {
if (response.result != null) {
SendWhatsApp.whatsappsenders = response.result;
var htmlProvider = '<option value="0">Select Provider</option>';
for (let i = 0; i < response.result.length; i++) {
var data = response.result[i];
htmlProvider += '<option value=' + data.ProviderId + '>' + data.ProviderName + '</option>';
}
$('#Autocomplete_ProviderName').html(htmlProvider);
}
});
});
}
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 = '<option value=' + response.NotificationGroupId + ' selected>' + response.NotificationGroupName + '</option>';
$('#ddl_NotificationGrp').html('').html(html);
}
});
});
}
SaveWhatsAppReminder(id, containerid) {
var instance = this;
let ruleactionid = Number(id);
let queryelmnt = $("#builder");
let recipients = Unibase.Platform.Automation.Components.ContactSelection.Instance().GetRecipients();
let contactcolumns = Unibase.Platform.Automation.Components.ContactSelection.Instance().getContactColumns();
let secondarycontactcolumns = Unibase.Platform.Automation.Components.ContactSelection.Instance().getSecondaryContactColumns();
let externalroles = Unibase.Platform.Automation.Components.ExternalRecipients.Instance().GetExternalRoles();
let externalusers = Unibase.Platform.Automation.Components.ExternalRecipients.Instance().GetExternalUsers();
let model = new Unibase.Platform.Automation.Requests.RuleAction();
model.RuleActionId = ruleactionid;
model.RuleActionName = $("#txtWhatsApp_RuleActionName").val().toString();
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;
}
model.ResultActionId = Number($("#ddl_ResultAction option:selected").val());
if (model.ResultActionId != 0) {
model.ResultActionName = $("#ddl_ResultAction option:selected").text();
}
else {
model.ResultActionName = "";
}
model.BString6 = externalroles;
model.BString7 = externalusers;
model.String1 = $("#Autocomplete_Template option:selected").val() == undefined ? "0" : $("#Autocomplete_Template option:selected").val().toString();
model.String2 = $('#ddl_TemplateType option:selected').val().toString();
model.String3 = $('#ddl_LanguageCode option:selected').val().toString();
if (model.String1 == "0" || model.String2 == "0" || model.String3 == "0") {
MessageHelper.Instance().showError("Please Select Mandatory Fields", "Validate_WhatsAppAction");
return;
}
model.BString10 = $('#Autocomplete_ProviderName option:selected').val() == undefined ? "0" : $('#Autocomplete_ProviderName option:selected').val().toString();
model.BString11 = $('#Autocomplete_SenderName option:selected').val() == undefined ? "0" : $('#Autocomplete_SenderName option:selected').val().toString();
if (model.BString10 == "0" || model.BString11 == "0") {
MessageHelper.Instance().showError("Please Select manag=datory Fields", "Validate_WhatsAppAction");
}
model.String5 = $(".textArea_WhatsappBody").val().toString();
model.String6 = SendWhatsApp.Instance().Parameters;
SendWhatsApp.Instance().Parameters = "";
model.ActionId = Unibase.Platform.Automation.Components.SendWhatsApp.Instance().ActionId;
model.RuleId = 0;
model.Users = contactcolumns;
model.SecondaryUsers = secondarycontactcolumns;
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));
}
else {
model.SqlWhere = "";
model.SqlWhereJson = "";
}
model.String7 = true;
model.DelayTime = 0;
model.ParentActionId = Unibase.Platform.Automation.Components.SendWhatsApp.Instance().ParentActionId;
model.AutoApproved = $('#chkAutoApprovedWhatsapp').is(':checked');
model.RecipientsData = recipients;
model.RowIndex = Unibase.Platform.Automation.Components.SendWhatsApp.Instance().RowIndex;
if (Unibase.Platform.Automation.Components.SendWhatsApp.Instance().IsAutomationMode) {
if (Unibase.Platform.Automation.Components.SendWhatsApp.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_WhatsAppAction");
}
else {
MessageHelper.Instance().showSuccess(response.message, "Validate_WhatsAppAction");
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
var actionname = response.result.RuleActionName;
eval("bizgaze_automation_flow_main.savewhatsappblock('" + response.result.RuleActionId + "','" + actionname + "')");
}
});
}
}
else {
model.RuleId = Unibase.Platform.Automation.Components.SendWhatsApp.Instance().RuleId;
model.EventGroupId = Unibase.Platform.Automation.Components.SendWhatsApp.Instance().EventGroupId;
model.RuleEventId = Unibase.Platform.Automation.Components.SendWhatsApp.Instance().RuleEventId;
model.ActionId = Unibase.Platform.Automation.Components.SendWhatsApp.Instance().ActionId;
model.ParentActionId = Unibase.Platform.Automation.Components.SendWhatsApp.Instance().ParentActionId;
Automation.Managers.RuleManager.Instance().saveRuleAction(model).then(function (response) {
if (response.status == Unibase.Data.Status.Error) {
MessageHelper.Instance().showError(response.message, "Validate_WhatsAppAction");
}
else {
MessageHelper.Instance().showSuccess(response.message, "Validate_WhatsAppAction");
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
Unibase.Platform.Automation.Components.Conditions.conditionArray = [];
}
});
}
}
ToggleWhatsAppConditions() {
$('#ActionConditionsDiv').toggleClass("hidden");
if ($('.conditionicon').hasClass('fa-angle-down')) {
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.SendNotification.Instance().RuleProviderId, null);
}
else {
$('.conditionicon').removeClass('fa-angle-up').addClass('fa-angle-down');
}
}
loadTemplates(ruleproviderid) {
let templatetypeid = Number(Unibase.Platform.Templates.Enums.TemplateType.Mail);
Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleProvider(ruleproviderid).then(function (response) {
var url = _appsettings.server_url() + '/apis/v4/unibase/platform/templates/gettemplatesautocomplatebytemplatetype/installedappid/' + response.InstalledAppId + '/templatetypeid/' + templatetypeid;
AutoCompleteHelper.getHelper().Create("#Autocomplete_Template", "#hf_Template", url, function (response) {
var data = response;
});
});
}
EditWhatsAppReminder(id, containerid) {
let actionid = Number(id);
$("#Spn_SendWhatsApp").text("Edit WhatsAppReminder");
Unibase.Platform.Automation.Managers.RuleManager.Instance().getRuleAction(actionid).then(function (response) {
$("#txtWhatsApp_RuleActionName").val(response.RuleActionName);
$('#ddl_NotificationGrp option[value=' + response.NotificationGroupId + ']').prop('selected', true);
if (!Unibase.Platform.Automation.Components.SendWhatsApp.Instance().IsAutomationMode) {
Unibase.Platform.Automation.Components.SendWhatsApp.Instance().RuleId = response.RuleId;
Unibase.Platform.Automation.Components.SendWhatsApp.Instance().RuleEventId = response.RuleEventId;
Unibase.Platform.Automation.Components.SendWhatsApp.Instance().EventGroupId = response.EventGroupId;
Unibase.Platform.Automation.Components.SendWhatsApp.Instance().ActionId = response.ActionId;
Unibase.Platform.Automation.Components.SendWhatsApp.Instance().ParentActionId = response.ParentActionId;
}
if (response.ExecuteStatusId != Number(Unibase.Platform.Automation.Enums.ExecuteActionStatus.Approved))
$("#chkAutoApprovedWhatsapp").prop("checked", false);
else
$("#chkAutoApprovedWhatsapp").prop("checked", true);
$('.textArea_WhatsappBody').val(response.String5);
$('#ddl_TemplateType').val(response.String2);
$('#ddl_LanguageCode').val(response.String3);
$('#Autocomplete_ProviderName').val(response.BString10);
var datainfo = SendWhatsApp.whatsappsenders.find(x => x.SenderId == Number(response.BString11));
$('#Autocomplete_SenderName').html('<option value=' + datainfo.SenderId + ' selected>' + datainfo.SenderName + '</option>');
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckContactColumns(response.Users);
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckSecondaryContactColumns(response.SecondaryUsers);
Unibase.Platform.Automation.Components.ContactSelection.Instance().BindRecipients(response.RuleActionId);
if (response.ResultActionId != null) {
$('#ddl_ResultAction').val(response.ResultActionId);
}
if (response.SqlWhere != null && response.SqlWhere != "") {
$('.conditionicon').removeClass('fa-angle-down').addClass('fa-angle-up');
$("#ActionConditionsDiv").removeClass("hidden");
}
let templateid = Number(response.String1);
Unibase.Platform.Templates.Managers.TemplateManager.Instance().getTemplateText(templateid).then(function (res) {
var whatsapptemplate = new Option(res.result.TemplateName, res.result.TemplateId.toString(), true);
$("#Autocomplete_Template").append(whatsapptemplate);
});
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(response.RuleProviderId, response.SqlWhere);
eval('_floatingLabelHelper.init();');
});
}
LoadBodyTokens(ruleproviderid) {
Unibase.Platform.Automation.Managers.RuleManager.Instance().getTokens(ruleproviderid).then(function (response) {
let cmbConditionProperties = document.getElementById('ddl_bodyTokens');
$('#ddl_bodyTokens').empty();
var defaultOpt1 = document.createElement("option");
defaultOpt1.text = "Select Token";
defaultOpt1.value = "0";
cmbConditionProperties.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();
cmbConditionProperties.appendChild(opt);
}
});
}
LoadWhatsAppData(Data) {
for (var i = 0; i < Data.length; i++) {
$("#txtWhatsApp_RuleActionName").val(Data[i].RuleActionName);
$("#txtWhatsApp_MessageSubject").val(Data[i].BString1);
$("#txtWhatsApp_MessageBody").val(Data[i].BString2);
if (!Data[i].AutoApproved)
$("#chkAutoApprovedWhatsapp").prop("checked", false);
else
$("#chkAutoApprovedWhatsapp").prop("checked", true);
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckContactColumns(Data[i].Users);
Unibase.Platform.Automation.Components.ContactSelection.Instance().CheckSecondaryContactColumns(Data[i].SecondaryUsers);
$("#div_Subject").addClass('floating-label-form-group-with-value');
$("#div_Body").addClass('floating-label-form-group-with-value');
if (Data[i].RecipientsData != null) {
$("#select2_Roles").val(Data[i].RecipientsData.RoleRecipients).trigger('change');
$("#select2_Users").val(Data[i].RecipientsData.UserRecipients).trigger('change');
}
if (Data[i].SqlWhere != "" && Data[i].SqlWhere != null) {
Unibase.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(Unibase.Platform.Automation.Components.SendNotification.Instance().RuleProviderId, Data[i].SqlWhere);
$("#btn_ActionConditions").addClass("hidden");
$("#ActionConditionsDiv").removeClass("hidden");
}
eval('_floatingLabelHelper.init();');
}
}
static Instance() {
if (this.instance === undefined) {
this.instance = new SendWhatsApp();
}
return this.instance;
}
}
SendWhatsApp.whatsappsenders = [];
Components.SendWhatsApp = SendWhatsApp;
})(Components = Automation.Components || (Automation.Components = {}));
})(Automation = Platform.Automation || (Platform.Automation = {}));
})(Platform = Unibase.Platform || (Unibase.Platform = {}));
})(Unibase || (Unibase = {}));
File diff suppressed because one or more lines are too long
@@ -0,0 +1,448 @@
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 ExternalAttachments {
constructor() {
this.formPropArray = [];
this.files_array = [];
this.documentId = [];
}
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",
];
return jsfiles;
}
cssFiles() {
return [];
}
init(formpropertyid, ismultiple, validationdiv) {
Unibase.Platform.Automation.Components.ExternalAttachments.Instance().getDocumentTypes();
Unibase.Platform.Automation.Components.ExternalAttachments.Instance().assignValues(formpropertyid, ismultiple, validationdiv);
return Unibase.Platform.Automation.Components.ExternalAttachments.Instance().html(formpropertyid);
}
html(formpropertyid) {
let html = "";
html = '<div id="paneldrag" class="col-sm-12 mt-20 drag"><div class="col-sm-12" id="panel"><p>' +
'<div class="text-center"><i class="fa fa-cloud-download fa-3x" aria-hidden="true"></i></div>' +
'<div class="text-center" id="drag" style="font-size:medium">Drag and drop files here</div>' +
'<div class="text-center">Or</div>' +
'</p></div>' +
'<div class="row mb-10" id="UploadDiv_' + formpropertyid + '">' +
'<input type="text" class="hidden" id="hf_file_' + formpropertyid + '" value=""/>' +
'<div class="upload-btn-wrapper text-center container">' +
'<input id="file_' + formpropertyid + '" title="" type="file" onclick="this.value=null;" class="hidden d-none fileUpload_ form-control value-control" data-isrequired=" " data-propertyname=" " data-isdefault=" " data-propdoctypename="" data-required="" data-regularexp="" data-validatemsg="" data-formdata="" value="Unibase.Forms.Controls.FileDragNDrop.Instance().fileDragNDropObj(' + formpropertyid + ');"/>' +
'<input type="button" value="Browse" class="btn btn-primary btn-lg center-block" id="browse_' + formpropertyid + '" />' +
'</div></div></div>' +
'<div class="row ml-15 fileuploads_ filename" id="fileuploads_' + formpropertyid + '"><div class="row col-sm-12 ml-10 mt-10 pull-center thumb_doc"><div class="col-sm-12 row pl-0"><div class="input-group">' +
'<span class="Selectedfile_ text-dark hidden"><h5 class="Selection mb-10 mt-10">Selected Files :</h5> <span class="Selectedfile"></span></span>' +
'</div></div><div class="row col-sm-12 pl-0 pr-0">' +
'<ul id="ulselectedfiles_' + formpropertyid + '" class="list-group mb-n mt-n-15 no-border ulselectedfiles col-sm-12 pl-0 pr-0">' +
'<li class="hidden no-border"></li>' +
'</ul></div></div></div>';
return html;
}
fileDragNDropObj(formpropertyid) {
var instance = this;
var fileArray = [];
fileArray = instance.files_array[formpropertyid];
for (var i = 0; i < instance.rmvFiles_array.length; i++) {
var documentFileId = instance.rmvFiles_array[i].DocumentFileId;
if (documentFileId != 0) {
var fileReq = {
FileId: documentFileId,
FilePath: instance.rmvFiles_array[i].name,
};
fileArray.push(fileReq);
}
}
var fileObj = [...fileArray];
fileObj.unshift({
FileId: instance.documentId[formpropertyid],
});
return fileObj;
}
dragNdrop(formpropertyid) {
var instance = this;
$('#paneldrag').on('dragover', function (e) {
debugger;
e.preventDefault();
e.stopPropagation();
});
$('#paneldrag').on('dragenter', function (e) {
e.preventDefault();
e.stopPropagation();
});
$('#paneldrag').on('drop', function (e) {
if (e.originalEvent.dataTransfer) {
if (e.originalEvent.dataTransfer.files.length) {
e.preventDefault();
e.stopPropagation();
if (instance.ismultiple == false) {
instance.SingleUploadFile(e.originalEvent.dataTransfer.files, formpropertyid);
}
else if (instance.ismultiple == true) {
instance.MultipleUploadFile(e.originalEvent.dataTransfer.files, formpropertyid);
$("#file_" + formpropertyid).attr("multiple", "multiple");
}
else {
instance.SingleUploadFile(e.originalEvent.dataTransfer.files, formpropertyid);
}
}
}
});
$("#browse_" + formpropertyid + "").click(function () {
$("#file_" + formpropertyid).click();
});
$("#file_" + formpropertyid + "").change(function () {
Unibase.Platform.Automation.Components.ExternalAttachments.Instance().UploadFile(formpropertyid);
});
window.addEventListener("dragover", function (e) {
e = e || event;
e.preventDefault();
}, false);
window.addEventListener("drop", function (e) {
e = e || event;
e.preventDefault();
}, false);
}
UploadFile(formpropertyid) {
var instance = this;
if (instance.ismultiple == false) {
$('#fileuploads_' + formpropertyid).find('.Selection').text("Selected File :");
$('#fileuploads_' + formpropertyid).find('.Selection').addClass("text-dark");
instance.SingleUploadFile(null, formpropertyid);
}
else if (instance.ismultiple == true) {
instance.MultipleUploadFile(null, formpropertyid);
$("#file_" + formpropertyid).attr("multiple", "multiple");
}
else {
instance.SingleUploadFile(null, formpropertyid);
$('#fileuploads_' + formpropertyid).find('.Selection').text("Selected File :");
$('#fileuploads_' + formpropertyid).find('.Selection').addClass("text-dark");
}
}
SingleUploadFile(event, formpropertyid) {
var instance = this;
var fileUpload = $("#file_" + formpropertyid).get(0);
var files = fileUpload.files;
if (event != null)
files = event;
instance.singlefile = "";
var flag = 0;
if (files.length > 0) {
var html = "";
for (var i = 0; i < files.length; i++) {
flag = 0;
if (flag == 0) {
instance.itemid++;
var imgShow = '';
if (!files[i].type.match('image.*')) {
if (files[i].type.match('pdf.*')) {
imgShow = 'tenants/default/documenttypes/pdf.png';
}
else if (files[i].type.match('wordprocessingml.*') || files[i].type.match('text.*')) {
imgShow = 'tenants/default/documenttypes/word.png';
}
else if (files[i].type.match('spreadsheetml.*')) {
imgShow = 'tenants/default/documenttypes/excel.png';
}
else if (files[i].type.match('excel.*')) {
imgShow = 'tenants/default/documenttypes/excel.png';
}
else
imgShow = 'tenants/default/documenttypes/unknown.png';
}
else {
var tmppath = URL.createObjectURL(files[i]);
imgShow = tmppath;
}
var filename = encodeURIComponent(files[i].name).replace(/\'/g, "%2E");
html = '<li class="list-group-item b-a clear pl-0 pr-0" style="border: none !important">' +
'<span id="fileuploads_' + formpropertyid + '_' + instance.itemid + '" class="block fileuploads_' + instance.itemid + ' filename">' +
'<span class="pull-left">' +
'<span class="fa fa-trash-o fa-lg text-danger mr-15" style="cursor:pointer" href="javascript:;" onclick="javascript:Unibase.Platform.Automation.Components.ExternalAttachments.Instance().removeFile(\'' + formpropertyid + '\',' + instance.itemid + ',\'' + filename + '\'' + ',' + 0 + ');" title = "Click to Delete"></span>' +
'<img style="height:35px;width:35px;vertical-align:middle;" onerror="ReloadImage(event)" alt="" src="' + imgShow + '">' +
'<span class="ml-20 fileName">' + files[i].name + '</span>' +
'</span></span></li>';
instance.singlefile = files[i];
$('#ulselectedfiles_' + formpropertyid).html(html);
$('#fileuploads_' + formpropertyid).find('.Selectedfile_').removeClass("hidden");
var item = { Files: instance.singlefile };
instance.getBase64(item).then(function (response) {
var fileInfo = response;
instance.files_array[formpropertyid] = [];
instance.files_array[formpropertyid].push(fileInfo);
$("#hf_file_" + formpropertyid).val("fileexists");
});
}
}
}
}
MultipleUploadFile(event, formpropertyid) {
var instance = this;
var errormsg = Unibase.Platform.Automation.Components.ExternalAttachments.Instance().validationdiv;
var fileUpload = $("#file_" + formpropertyid).get(0);
var files = fileUpload.files;
if (event != null)
files = event;
var file = "";
var flag = 0;
if (files.length > 0) {
var xyz = "";
var html = "";
for (var i = 0; i < files.length; i++) {
flag = 0;
$("#ulselectedfiles_" + formpropertyid + " li").each(function (index, element) {
if (index != 0 && flag == 0) {
var filesSelected = $(this).find(".fileName").text();
if (files[i].name == filesSelected) {
xyz += files[i].name + " ";
MessageHelper.Instance().showError(xyz + " files already exist", "" + errormsg);
flag = 1;
}
}
});
if (flag == 0) {
instance.itemid++;
var imgShow = '';
var filename = files[i].name;
var fileExt = files[i].name.split(".");
if (files[i].type.match('image.*')) {
var tmppath = URL.createObjectURL(files[i]);
}
var docData = instance.documenttypes.find(x => x.documenttypename == fileExt[fileExt.length - 1].toLowerCase());
if (docData != null) {
if (docData.documentgroup == "Pdf") {
imgShow = 'tenants/default/documenttypes/pdf.png';
}
else if (docData.documentgroup == "Image") {
imgShow = tmppath;
}
else if (docData.documentgroup == "Word") {
imgShow = 'tenants/default/documenttypes/word.png';
}
else if (docData.documentgroup == "Excel") {
imgShow = 'tenants/default/documenttypes/excel.png';
}
else if (docData.documentgroup == "Video") {
imgShow = 'tenants/default/documenttypes/video.png';
}
else if (docData.documentgroup == "Audio") {
imgShow = 'tenants/default/documenttypes/audio.png';
}
}
else
imgShow = 'tenants/default/documenttypes/unknown.png';
filename = encodeURIComponent(filename).replace(/\'/g, "%2E");
html = '<li class="list-group-item b-a clear pl-0 pr-0" style="border: none !important">' +
'<span id="fileuploads_' + formpropertyid + '_' + instance.itemid + '" class="block fileuploads_' + instance.itemid + ' filename">' +
'<span class="pull-left col-sm-12 pl-0 pr-0">' +
'<span class="fa fa-trash-o fa-lg text-danger mr-15" style="cursor:pointer" ; href="javascript:;" onclick="javascript:Unibase.Platform.Automation.Components.ExternalAttachments.Instance().removeFile(\'' + formpropertyid + '\',' + instance.itemid + ',\'' + filename + '\'' + ',' + 0 + ');" title="Click to Delete"></span>' +
'<img class="mr-20" style="height:35px;width:35px;vertical-align:middle;" onerror="ReloadImage(event)" alt="" src="' + imgShow + '">' +
'<span class="fileName">' + files[i].name + '</span>' +
'</span></span></li>';
$('#ulselectedfiles_' + formpropertyid).append(html);
file = files[i];
$('#fileuploads_' + formpropertyid).find('.Selectedfile_').removeClass("hidden");
var item = { Files: file };
instance.getBase64(item).then(function (response) {
var fileInfo = response;
instance.files_array[formpropertyid].push(fileInfo);
$("#hf_file_" + formpropertyid).val("fileexists");
});
}
}
}
}
assignValues(formpropertyid, ismultiple, validationdiv) {
var instance = this;
instance.itemid = 0;
instance.files_array[formpropertyid] = [];
instance.documentId[formpropertyid] = 0;
instance.rmvFiles_array = [];
instance.ismultiple = ismultiple;
instance.singlefile = "";
instance.validationdiv = validationdiv;
}
getBase64(item) {
return __awaiter(this, void 0, void 0, function* () {
var fileName = "";
fileName = item.Files.DocumentFileName;
if (fileName == undefined)
fileName = item.Files.name;
var refId = 0;
if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length > 0) {
var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
refId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_recordid").Value);
}
let file = item.Files;
let fileInfo = item.Files.name.split('.');
let fileType = ".unknown";
if (fileInfo.length > 0) {
fileType = fileInfo[fileInfo.length - 1];
fileInfo.splice(fileInfo.length - 1, 1);
fileName = fileInfo.join('.');
}
return new Promise((resolve, reject) => {
let content = '';
const reader = new FileReader();
reader.readAsDataURL(item.Files);
reader.onloadend = function () {
var base64String = reader.result.toString().replace(/^data:.+;base64,/, '');
var fileReq = {
FileData: base64String,
FileName: fileName,
FileType: fileType,
RefId: refId,
ByteData: null
};
resolve(fileReq);
};
reader.onerror = function (e) {
reject(e);
};
});
});
}
removeFile(formpropertyid, itemid, name, DocumentFileId) {
name = decodeURIComponent(name.replace(/\%2E/g, "'"));
var instance = this;
instance.rmvFiles_array.push({ DocumentFileId: DocumentFileId, name: name });
$("#fileuploads_" + formpropertyid + "_" + itemid).addClass("hidden");
$("#fileuploads_" + formpropertyid + "_" + itemid).parents('.list-group-item').remove();
var fileIndex = instance.files_array[formpropertyid].findIndex(x => x.FileName == name);
instance.files_array[formpropertyid].splice(fileIndex, 1);
if ($('#ulselectedfiles_' + formpropertyid + ' li').length == 1) {
$('#fileuploads_' + formpropertyid).find('.Selectedfile_').addClass("hidden");
}
}
getDocumentTypes() {
Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFileAsync("platform/files/managers/filemanager.js", function () {
Unibase.Platform.Files.Managers.FileManager.Instance().getDocumentTypes().then(function (response) {
Unibase.Platform.Automation.Components.ExternalAttachments.Instance().documenttypes = response.result;
});
});
}
getFiles(formpropertyid) {
return Unibase.Platform.Automation.Components.ExternalAttachments.Instance().files_array[formpropertyid];
}
bindEditFormDetails(formpropertyid, propval) {
var instance = this;
propval = propval.replaceAll("\\", "/");
var documentInfo = "";
documentInfo = JSON.parse(propval);
instance.documentId[formpropertyid] = documentInfo.DocumentId;
instance.bindData(documentInfo, formpropertyid);
}
bindData(documentInfo, formpropertyid) {
var instance = this;
var filesList = documentInfo;
for (var i = 0; i < documentInfo.length; i++) {
var isRequired = $("#file_" + formpropertyid).data("isrequired");
if (isRequired) {
$("#file_" + formpropertyid).removeClass("required");
}
var documentImage = '';
var imgSrc = "";
var DocumentGroup = "";
if (filesList[i].FileType != "") {
if (filesList[i].FileType == "png" || filesList[i].FileType == "jpg") {
DocumentGroup = "Image";
}
else if (filesList[i].FileType == "xlsx" || filesList[i].FileType == "csv") {
DocumentGroup = "Excel";
}
else if (filesList[i].FileType == "pdf") {
DocumentGroup = "Pdf";
}
else if (filesList[i].FileType == "docx") {
DocumentGroup = "Word";
}
else if (filesList[i].FileType == "mp4") {
DocumentGroup = "Video";
}
else if (filesList[i].FileType == "mp3") {
DocumentGroup = "Audio";
}
else {
DocumentGroup = "Unknown";
}
}
if (DocumentGroup != "") {
if (DocumentGroup == "Unknown")
documentImage = 'tenants/default/documenttypes/unknown.png';
else if (DocumentGroup == "Image") {
var byteCharacters = atob(filesList[i].FileData);
var byteNumbers = new Array(byteCharacters.length);
for (var k = 0; k < byteCharacters.length; k++) {
byteNumbers[k] = byteCharacters.charCodeAt(k);
}
var byteArray = new Uint8Array(byteNumbers);
var fileTemp = new Blob([byteArray], { type: filesList[i].DocumentGroup + '/' + filesList[i].FileType + ';base64' });
imgSrc = URL.createObjectURL(fileTemp);
documentImage = imgSrc;
}
else if (DocumentGroup == "Excel")
documentImage = 'tenants/default/documenttypes/excel.png';
else if (DocumentGroup == "Pdf")
documentImage = 'tenants/default/documenttypes/pdf.png';
else if (DocumentGroup == "Word")
documentImage = 'tenants/default/documenttypes/word.png';
else if (DocumentGroup == "Video")
documentImage = 'tenants/default/documenttypes/video.png';
else if (DocumentGroup == "Audio")
documentImage = 'tenants/default/documenttypes/audio.png';
}
instance.itemid++;
var docFileName = filesList[i].FileName;
var name = docFileName;
var html = '<li class="list-group-item b-a clear pl-0 pr-0" style="border: none !important">' +
'<span id="fileuploads_' + formpropertyid + '_' + instance.itemid + '" class="block fileuploads_' + instance.itemid + ' filename">' +
'<span class="pull-left col-sm-12 pl-0 pr-0">' +
'<span class="fa fa-trash-o fa-lg text-danger mr-15" style="cursor:pointer" ; href="javascript:;" onclick="javascript:Unibase.Platform.Automation.Components.ExternalAttachments.Instance().removeFile(\'' + formpropertyid + '\',' + instance.itemid + ',\'' + name + '\'' + ',' + filesList[i].DocumentFileId + ');" title="Click to Delete"></span>' +
'<img class="mr-20" style="height:35px;width:35px;vertical-align:middle;" onerror="ReloadImage(event)" alt="" src="' + documentImage + '">' +
'<span class="fileName">' + docFileName + '</span>' +
'</span></span></li>';
$('#ulselectedfiles_' + formpropertyid).append(html);
$('#fileuploads_' + formpropertyid).find('.Selectedfile_').removeClass("hidden");
instance.files_array[formpropertyid].push(filesList[i]);
}
}
static Instance() {
if (this.instance === undefined) {
this.instance = new ExternalAttachments();
}
return this.instance;
}
}
Components.ExternalAttachments = ExternalAttachments;
})(Components = Automation.Components || (Automation.Components = {}));
})(Automation = Platform.Automation || (Platform.Automation = {}));
})(Platform = Unibase.Platform || (Unibase.Platform = {}));
})(Unibase || (Unibase = {}));
File diff suppressed because one or more lines are too long
@@ -0,0 +1,185 @@
var Unibase;
(function (Unibase) {
let Platform;
(function (Platform) {
let Automation;
(function (Automation) {
let Components;
(function (Components) {
class ExternalFollowers {
GetFollowersByPkId() {
if (Platform.TimeLine.Components.TimeLine.Instance().Followers.length > 0) {
var value = "";
var valuetext = "";
var valuecontainerid = ExternalFollowers.ToMailContainerId;
var addName = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_additionalname");
if (addName != undefined) {
var dataop = addName.Value;
var addEmail = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_additionalemail");
var addUserId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_additionalcontactid").Value;
if (addEmail != undefined && ExternalFollowers.IsMail) {
dataop = addEmail.Value;
valuetext += dataop + "|";
}
else if (ExternalFollowers.IsSms) {
valuetext += dataop + "|";
valuecontainerid = ExternalFollowers.ToSmsContainerId;
}
if (dataop != "") {
var option = new Option(dataop, addUserId, true, true);
$("#" + valuecontainerid).append(option);
value += addUserId + "|";
}
}
for (let i = 0; i < Platform.TimeLine.Components.TimeLine.Instance().Followers.length; i++) {
var data = Platform.TimeLine.Components.TimeLine.Instance().Followers[i];
var dataoption = ExternalFollowers.IsMail ? data.EmailAddress :
data.UserName;
if (dataoption == "" || dataoption == "undefined") {
continue;
}
var option = new Option(dataoption, data.UserId, true, true);
value += data.UserId + "|";
valuetext += dataoption + "|";
if (ExternalFollowers.IsMail) {
$("#" + ExternalFollowers.ToMailContainerId).append(option);
}
else if (ExternalFollowers.IsSms) {
$("#" + ExternalFollowers.ToSmsContainerId).append(option);
valuecontainerid = ExternalFollowers.ToSmsContainerId;
}
else if (ExternalFollowers.IsCalls) {
$("#" + ExternalFollowers.TocallsContainerId).append(option);
valuecontainerid = ExternalFollowers.TocallsContainerId;
}
else if (ExternalFollowers.IsTask) {
$("#" + ExternalFollowers.TasksContainerId).append(option);
}
else if (ExternalFollowers.IsMeeting) {
$("#" + ExternalFollowers.MeetingsContainerId).append(option);
valuecontainerid = ExternalFollowers.MeetingsContainerId;
}
}
$("#" + valuecontainerid).parent().children('.value-control').val(value).attr("data-text", valuetext).trigger("change");
}
}
GetFollowersByVersionGuid() {
var hiddenvalues = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_versionguid");
if (hiddenvalues != undefined) {
Unibase.Platform.Automation.Managers.RuleManager.Instance().GetFollwersByVersionGuid(hiddenvalues.Value).then(function (response) {
var html = '';
if (response.result != null) {
}
});
}
}
GetToEmailContainer(tocontainerid) {
ExternalFollowers.IsTask = false;
ExternalFollowers.IsMail = true;
ExternalFollowers.IsSms = false;
ExternalFollowers.IsCalls = false;
ExternalFollowers.IsMeeting = false;
ExternalFollowers.ToMailContainerId = tocontainerid.attr("id");
}
GetBccEmailContainer(bcccontainerid) {
ExternalFollowers.BccMailContainerId = bcccontainerid.attr("id");
}
GetCcMailContainer(cccontainerid) {
ExternalFollowers.CcMailContainerId = cccontainerid.attr("id");
}
GetSmsToContainer(containerid) {
ExternalFollowers.IsTask = false;
ExternalFollowers.IsMail = false;
ExternalFollowers.IsSms = true;
ExternalFollowers.IsCalls = false;
ExternalFollowers.IsMeeting = false;
ExternalFollowers.ToSmsContainerId = containerid.attr("id");
}
GetCallsToContainer(containerId) {
ExternalFollowers.TocallsContainerId = containerId.attr("id");
ExternalFollowers.IsMail = false;
ExternalFollowers.IsSms = false;
ExternalFollowers.IsCalls = true;
ExternalFollowers.IsTask = false;
ExternalFollowers.IsMeeting = false;
}
GetTasksFollowersContainer(containerid) {
ExternalFollowers.TasksContainerId = containerid.attr("id");
;
ExternalFollowers.IsMail = false;
ExternalFollowers.IsSms = false;
ExternalFollowers.IsCalls = false;
ExternalFollowers.IsTask = true;
ExternalFollowers.IsMeeting = false;
}
GetMeetingFollowersContainer(containerid) {
ExternalFollowers.MeetingsContainerId = containerid.attr("id");
;
ExternalFollowers.IsMail = false;
ExternalFollowers.IsSms = false;
ExternalFollowers.IsCalls = false;
ExternalFollowers.IsTask = false;
ExternalFollowers.IsMeeting = true;
}
setDefaultMailAccount(mailcontainerid) {
var _fileCacheHelper = Platform.Helpers.FileCacheHelper.Instance();
_fileCacheHelper.loadJsFileAsync("apps/communications/managers/mails/mailmanager.js", function () {
Unibase.Apps.Communications.Managers.MailManager.Instance().getUserDefaultMailAccount().then(function (response) {
if (response.result != null) {
var option = new Option(response.result.UserName, response.result.MailAccountId, true, true);
var id = $(mailcontainerid).attr("id");
$("#" + id).append(option);
}
});
});
}
setDefaultSmsAccount(smscontainerid) {
var _fileCacheHelper = Platform.Helpers.FileCacheHelper.Instance();
_fileCacheHelper.loadJsFileAsync("apps/communications/managers/sms/smsmanager.js", function () {
Unibase.Apps.Communications.Managers.SmsManager.Instance().getDefaultSmsSender().then(function (response) {
if (response.result != null) {
var option = new Option(response.result.SmsSenderName, response.result.SmsSenderId, true, true);
var id = $(smscontainerid).attr("id");
$("#" + id).append(option);
}
});
});
}
GetDefaultTemplatesByInstalledAppId(containerid, templatetype) {
var id = containerid;
$(id).children().children('.appwise_templates').html('');
var _fileCacheHelper = Platform.Helpers.FileCacheHelper.Instance();
var installedappid = Unibase.Themes.Providers.DetailHelper.installedAppId;
_fileCacheHelper.loadJsFiles(["platform/templates/managers/templatemanager.js", "platform/templates/enums/templatetype.js"], function () {
Unibase.Platform.Templates.Managers.TemplateManager.Instance().getTemplates(installedappid).then(function (response) {
if (response.result != null) {
var html = '<option value="0"data-html="">Select Template</option>';
var result = response.result.filter(x => x.TemplateTypeId == templatetype);
if (result.length == 0) {
html = '<option value="0"data-html="">No Data</option>';
}
for (let i = 0; i < result.length; i++) {
html += '<option value=' + result[i].TemplateId + ' data-html=' + result[i].TemplateText + '>' + result[i].TemplateName + '</option>';
}
$(id).children().children('.appwise_templates').html(html);
}
});
});
}
static Instance() {
if (this.instance == undefined) {
this.instance = new ExternalFollowers();
}
return this.instance;
}
}
ExternalFollowers.IsMail = false;
ExternalFollowers.IsCalls = false;
ExternalFollowers.IsSms = false;
ExternalFollowers.IsTask = false;
ExternalFollowers.IsMeeting = false;
Components.ExternalFollowers = ExternalFollowers;
})(Components = Automation.Components || (Automation.Components = {}));
})(Automation = Platform.Automation || (Platform.Automation = {}));
})(Platform = Unibase.Platform || (Unibase.Platform = {}));
})(Unibase || (Unibase = {}));
File diff suppressed because one or more lines are too long