var Unibase;
(function (Unibase) {
let Apps;
(function (Apps) {
let Automation;
(function (Automation) {
class RuleReConfigure extends Unibase.Platform.Core.BaseComponent {
jsFiles() {
return ["platform/tag/managers/tagmanager.js", "platform/apps/managers/appmanager.js", "apps/transact/managers/interfaces/automation/irulemanager.js", "apps/transact/managers/automation/rulemanager.js"];
}
cssFiles() {
return [];
}
html(id, containerid) {
var html = `
`;
return html;
}
load(id, containerid, callback) {
$("#btnClose").click(function () {
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
});
var instance = this;
var appid = instance.appSettings.InstalledAppId;
$("#reconfigure").click(function () {
Unibase.Platform.Apps.Managers.AppManager.Instance().getInstallApp(appid).then(function (resu) {
if (resu.result.AppTitle == "Credit Limit Rule") {
Bizgaze.Apps.Transact.Managers.RuleManager.Instance().refreshCreditRule(0).then(function (res) {
MessageHelper.Instance().showSuccess("We Will Notify Once The Process Is Done", '');
Unibase.Platform.Helpers.NavigationHelper.Instance().closePopUp();
});
}
else {
if (resu.result.AppTitle == "Order Approval Rules") {
Bizgaze.Apps.Transact.Managers.RuleManager.Instance().refreshcreditlimitrules("0", "OrderApproval Rule", 0).then(function (response) {
MessageHelper.Instance().showSuccess("We Will Notify Once The Process Is Done", '');
Unibase.Platform.Helpers.NavigationHelper.Instance().closePopUp();
});
}
else if (resu.result.AppTitle == "Price Code Rules") {
Bizgaze.Apps.Transact.Managers.RuleManager.Instance().refreshPriceCodeRule(0).then(function (res) {
MessageHelper.Instance().showSuccess("We Will Notify Once The Process Is Done", '');
Unibase.Platform.Helpers.NavigationHelper.Instance().closePopUp();
});
}
else {
Bizgaze.Apps.Transact.Managers.RuleManager.Instance().refreshcreditlimitrules("0", "PaymentTerm Rule", 0).then(function (res) {
MessageHelper.Instance().showSuccess("We Will Notify Once The Process Is Done", '');
Unibase.Platform.Helpers.NavigationHelper.Instance().closePopUp();
});
}
}
});
});
}
refreshWidgets() {
var Installedappid = Unibase.Themes.Providers.DetailHelper.installedAppId;
var ModalContainers = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds;
var ContainerId = ModalContainers[ModalContainers.length - 1];
Unibase.Themes.Compact.Components.Details.Instance().loadWidgets(Installedappid, Number($(".nav-link.active").find("#hf_PortletId").val()), "#" + ContainerId);
var detailInstance = Unibase.Themes.Compact.Components.Details.Instance();
var panel = "#" + detailInstance._containerId;
var obj = Unibase.Themes.Compact.Components.Details.Instance();
obj._recordId = Unibase.Themes.Providers.DetailHelper.recordId;
obj._installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
detailInstance.loadAppDefaultWidget(obj, panel, detailInstance._containerId, function () {
});
}
updatePriceCodeRuleContact(ContactDefaultId, ContactId, LobId, IsPriceCodeAutomated, IsPriceCodeExcluded) {
let instance = this;
let Msg = "";
if (IsPriceCodeAutomated == 0) {
Msg = "Do you really want to Delete Contact from this Rule ?";
}
else {
if (!IsPriceCodeExcluded) {
Msg = "Do you really want to Exclude Contact from this Rule ?";
IsPriceCodeExcluded = true;
}
else {
Msg = "Do you really want to Include Contact into this Rule ?";
IsPriceCodeExcluded = false;
}
}
bootbox.confirm(Msg, function (result) {
if (result) {
let PriceCodeRuleId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.filter(function (o) { return o.Key === "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_pricecoderuleid"; })[0].Value;
let PriceCodeId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.filter(function (o) { return o.Key === "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_pricecodeid"; })[0].Value;
let postData = {
ContactDefaultId: ContactDefaultId,
PriceCodeRuleId: PriceCodeRuleId,
ContactIds: (ContactId).toString(),
IsPriceCodeAutomated: IsPriceCodeAutomated,
IsPriceCodeExcluded: IsPriceCodeExcluded,
LobId: LobId,
PriceCodeId: PriceCodeId,
ContactId: Number(ContactId)
};
Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/interfaces/automation/irulemanager.js", "apps/transact/managers/automation/rulemanager.js"], function () {
Bizgaze.Apps.Transact.Managers.RuleManager.Instance().UpdatePriceCodeRuleContact(postData).then(function (res) {
instance.refreshWidgets();
});
});
}
});
}
updateCreditLimitRuleContact(ContactDetailId, ContactId, CreditLimit, IsAutomated, IsExcluded) {
let instance = this;
let Msg = "";
if (IsAutomated == 0) {
Msg = "Do you really want to Delete Contact from this Rule ?";
}
else {
if (!IsExcluded) {
Msg = "Do you really want to Exclude Contact from this Rule ?";
IsExcluded = true;
}
else {
Msg = "Do you really want to Include Contact into this Rule ?";
IsExcluded = false;
}
}
bootbox.confirm(Msg, function (result) {
if (result) {
var CreditRuleId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.filter(function (o) { return o.Key === "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_creditruleid"; })[0].Value;
let postData = {
ContactDetailId: ContactDetailId,
CreditRuleId: CreditRuleId,
ContactIds: ContactId.toString(),
CreditLimit: CreditLimit,
IsAutomated: IsAutomated,
IsExcluded: IsExcluded,
ContactId: Number(ContactId)
};
Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/interfaces/automation/irulemanager.js", "apps/transact/managers/automation/rulemanager.js"], function () {
Bizgaze.Apps.Transact.Managers.RuleManager.Instance().UpdateCreditLimitRuleContact(postData).then(function (res) {
instance.refreshWidgets();
});
});
}
});
}
updatePaymentTermRuleContact(ContactDefaultId, ContactId, LobId, IsPaymentTermAutomated, IsPaymentTermExcluded) {
let instance = this;
let Msg = "";
if (IsPaymentTermAutomated == 0) {
Msg = "Do you really want to Delete Contact from this Rule ?";
}
else {
if (!IsPaymentTermExcluded) {
Msg = "Do you really want to Exclude Contact from this Rule ?";
IsPaymentTermExcluded = true;
}
else {
Msg = "Do you really want to Include Contact into this Rule ?";
IsPaymentTermExcluded = false;
}
}
bootbox.confirm(Msg, function (result) {
if (result) {
let PaymentTermRuleId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.filter(function (o) { return o.Key === "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_paymenttermruleid"; })[0].Value;
let PaymentTermId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.filter(function (o) { return o.Key === "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_paymenttermid"; })[0].Value;
let postData = {
ContactDefaultId: ContactDefaultId,
PaymentTermRuleId: PaymentTermRuleId,
ContactIds: (ContactId).toString(),
IsPaymentTermAutomated: IsPaymentTermAutomated,
IsPaymentTermExcluded: IsPaymentTermExcluded,
LobId: LobId,
PaymentTermId: PaymentTermId,
ContactId: Number(ContactId)
};
Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/interfaces/automation/irulemanager.js", "apps/transact/managers/automation/rulemanager.js"], function () {
Bizgaze.Apps.Transact.Managers.RuleManager.Instance().UpdatePaymentTermRuleContact(postData).then(function (res) {
instance.refreshWidgets();
});
});
}
});
}
updateOrderApprovalRuleContact(ContactDefaultId, ContactId, LobId, IsOrderApprovalAutomated, IsOrderApprovalExcluded) {
let instance = this;
let Msg = "";
if (IsOrderApprovalAutomated == 0) {
Msg = "Do you really want to Delete Contact from this Rule ?";
}
else {
if (!IsOrderApprovalExcluded) {
Msg = "Do you really want to Exclude Contact from this Rule ?";
IsOrderApprovalExcluded = true;
}
else {
Msg = "Do you really want to Include Contact into this Rule ?";
IsOrderApprovalExcluded = false;
}
}
bootbox.confirm(Msg, function (result) {
if (result) {
let OrderApprovalRuleId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.filter(function (o) { return o.Key === "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_orderapprovalruleid"; })[0].Value;
let postData = {
ContactDefaultId: ContactDefaultId,
OrderApprovalRuleId: OrderApprovalRuleId,
ContactIds: (ContactId).toString(),
IsOrderApprovalAutomated: IsOrderApprovalAutomated,
IsOrderApprovalExcluded: IsOrderApprovalExcluded,
LobId: 0,
OrderApprovalId: 0,
ContactId: Number(ContactId)
};
Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/interfaces/automation/irulemanager.js", "apps/transact/managers/automation/rulemanager.js"], function () {
Bizgaze.Apps.Transact.Managers.RuleManager.Instance().UpdateOrderApprovalRuleContact(postData).then(function (res) {
instance.refreshWidgets();
});
});
}
});
}
reconfigurePaymentTerm() {
$(".li_DetailSetting_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_Re-Configure").click(function () {
Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/automation/rulemanager.js", function () {
let pkid = Unibase.Themes.Providers.DetailHelper.recordId;
MessageHelper.Instance().showSuccess("We Will Notify Once The Process Is Done", '');
Bizgaze.Apps.Transact.Managers.RuleManager.Instance().refreshPaymentTermRule(pkid);
});
});
}
reconfigureOrderApprovalRule() {
$(".li_DetailSetting_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_Re-Configure").click(function () {
Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/automation/rulemanager.js", function () {
let pkid = Unibase.Themes.Providers.DetailHelper.recordId;
MessageHelper.Instance().showSuccess("We Will Notify Once The Process Is Done", '');
Bizgaze.Apps.Transact.Managers.RuleManager.Instance().refreshOrderApprovalRule(pkid);
});
});
}
reconfigureCreditLimitRule() {
$(".li_DetailSetting_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_Re-Configure").click(function () {
Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/automation/rulemanager.js", function () {
let pkid = Unibase.Themes.Providers.DetailHelper.recordId;
MessageHelper.Instance().showSuccess("We Will Notify Once The Process Is Done", '');
Bizgaze.Apps.Transact.Managers.RuleManager.Instance().refreshCreditRule(pkid);
});
});
}
reconfigurePriceCodeRule() {
$(".li_DetailSetting_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_Re-Configure").click(function () {
Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/automation/rulemanager.js", function () {
let pkid = Unibase.Themes.Providers.DetailHelper.recordId;
MessageHelper.Instance().showSuccess("We Will Notify Once The Process Is Done", '');
Bizgaze.Apps.Transact.Managers.RuleManager.Instance().refreshPriceCodeRule(pkid);
});
});
}
reconfigureSkuRecommendation() {
$(".li_DetailSetting_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_Re-Configure").click(function () {
Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/automation/rulemanager.js", function () {
let pkid = Unibase.Themes.Providers.DetailHelper.recordId;
MessageHelper.Instance().showSuccess("We Will Notify Once The Process Is Done", '');
Bizgaze.Apps.Transact.Managers.RuleManager.Instance().refreshSkuRecommendation(pkid);
});
});
}
static Instance() {
if (this._instance === undefined)
this._instance = new RuleReConfigure();
return this._instance;
}
}
Automation.RuleReConfigure = RuleReConfigure;
})(Automation = Apps.Automation || (Apps.Automation = {}));
})(Apps = Unibase.Apps || (Unibase.Apps = {}));
})(Unibase || (Unibase = {}));