123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- 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 NotificationsContactSelection {
- constructor() {
- this.RecipientProviders = [];
- }
- init(rpid, ruleactionid) {
- return __awaiter(this, void 0, void 0, function* () {
- Unibase.Platform.Automation.Components.NotificationsContactSelection.Instance().loadRecipients(ruleactionid);
- Unibase.Platform.Automation.Components.NotificationsContactSelection.Instance().LoadContactColumns(rpid, ruleactionid);
- return Unibase.Platform.Automation.Components.NotificationsContactSelection.Instance().html(ruleactionid);
- });
- }
- loadRecipients(ruleactionid) {
- return __awaiter(this, void 0, void 0, function* () {
- return yield Unibase.Platform.Automation.Managers.RuleManager.Instance().getRecipientProviders().then(function (response) {
- Unibase.Platform.Automation.Components.NotificationsContactSelection.Instance().RecipientProviders = response;
- for (var i = 0; i <= response.length - 1; i++) {
- let html = '';
- html += '<div class="col-sm-6 recipient"><div id="div_' + ruleactionid + '_' + response[i].RecipientName + '" class="floating-label-form-group-with-value floating-validate" style="border-bottom:0;"><label for= "lbl" id = "lbl_' + ruleactionid + '_' + response[i].RecipientName + '" >' + response[i].DisplayName + '</label ><label class="hidden propname">' + response[i].ColumnName + '</label><label class="hidden recipientname">' + response[i].RecipientName + '</label>' +
- '<input type="hidden" id="hdnselect2_' + ruleactionid + '_' + response[i].RecipientName + '" class="value-control" value="0">' +
- '<select id="select2_' + ruleactionid + '_' + response[i].RecipientName + '" class="type-control select2_' + ruleactionid + '_' + response[i].RecipientName + ' form-control text-control" multiple="multiple" style="width:100%;"></select>' +
- '</div></div>';
- $(".recipients_" + ruleactionid).append(html);
- let selectid = "select2_" + ruleactionid + "_" + response[i].RecipientName + "";
- let selectlable = response[i].DisplayName;
- let recipientProviderid = response[i].RecipientProviderId;
- Unibase.Platform.Automation.Components.NotificationsContactSelection.Instance().RecipientsData(selectid, selectlable, recipientProviderid);
- }
- });
- });
- }
- html(ruleactionid) {
- return __awaiter(this, void 0, void 0, function* () {
- let html = '<div class="row recipients_' + ruleactionid + '"></div>' + '<div class="row mt-10" id="contactcolumns_' + ruleactionid + '"></div><div class="my-2">Secondary Contacts:</div><div class="row mt-10" id="secondarycontactcolumns_' + ruleactionid + '"></div>';
- return yield html;
- });
- }
- RecipientsData(selectid, selectlable, recipientProviderid) {
- return __awaiter(this, void 0, void 0, function* () {
- var url = _appsettings.server_url() + '/apis/v4/unibase/notificationrule/platform/RecipientsAutoComplete/RecipientProviderId/' + recipientProviderid;
- return yield AutoCompleteHelper.getHelper().Create("#" + selectid, "hdn" + selectid, url, function (response) {
- var data = response;
- });
- });
- }
- GetRecipients(RuleActionId) {
- var obj = new Object();
- $(".recipient").each(function () {
- let id = $(this).find(".recipient");
- let index = (id.prevObject[0].id).split('_');
- index = index[1];
- let propname = $(this).find(".propname").text();
- let recipientname = $(this).find(".recipientname").text();
- let selectid = "select2_" + RuleActionId + "_" + recipientname;
- let recipients = Unibase.Platform.Automation.Components.NotificationsContactSelection.Instance().getSelectedRecipients(selectid);
- obj[propname] = recipients;
- });
- return obj;
- }
- BindRecipients(ruleactionid) {
- return __awaiter(this, void 0, void 0, function* () {
- var recipientproviders = Unibase.Platform.Automation.Components.NotificationsContactSelection.Instance().RecipientProviders;
- return yield Unibase.Platform.Automation.Managers.RuleManager.Instance().getActionRecipient(ruleactionid).then(function (response) {
- for (var i = 0; i < recipientproviders.length; i++) {
- let recipients = response[recipientproviders[i].ColumnName];
- let IdColumn = recipientproviders[i].IdColumn;
- let RecipientProviderId = Number(recipientproviders[i].RecipientProviderId);
- Unibase.Platform.Automation.Components.NotificationsContactSelection.Instance().BindRecipientOptions(RecipientProviderId, recipients, IdColumn, recipientproviders[i].RecipientName, ruleactionid);
- }
- });
- });
- }
- BindRecipientOptions(RecipientProviderId, recipients, IdColumn, RecipientName, ruleactionid) {
- return __awaiter(this, void 0, void 0, function* () {
- return yield Unibase.Platform.Automation.Managers.RuleManager.Instance().getSelectedRecipientsData(RecipientProviderId, recipients, IdColumn).then(function (response) {
- if (response != "" && response.result.length > 0) {
- var Result = response.result;
- for (var j = 0; j < Result.length; j++) {
- var recipient = Result[j];
- var newOption = new Option(recipient.AutoCompleteTextColumn, recipient.AutoCompleteIdColumn, true, true);
- $("#select2_" + ruleactionid + "_" + RecipientName + "").append(newOption).trigger('change');
- }
- }
- });
- });
- }
- getSelectedRecipients(selectid) {
- let Recipientcount = new Array();
- Recipientcount = $('#' + selectid).val();
- let Recipient = "";
- for (var i = 0; i < Recipientcount.length; i++) {
- Recipient += "|" + Recipientcount[i];
- }
- if (Recipient != "")
- Recipient += "|";
- return Recipient;
- }
- LoadContactColumns(rpid, ruleactionid) {
- return __awaiter(this, void 0, void 0, function* () {
- let ruleproviderid = rpid;
- return yield Unibase.Platform.Automation.Managers.RuleManager.Instance().getContactColumns(ruleproviderid).then(function (response) {
- if (response != null) {
- let html = '';
- let secondaryhtml = '';
- for (let i = 0; i <= response.length - 1; i++) {
- html += '<div class="col-sm-4"><div class="custom-control custom-checkbox divEnablePieces checkbox-primary"><input type="checkbox" class="type-control custom-control-input" id="chk_' + response[i] + '_' + ruleactionid + '" name="Contactcolumns_' + ruleactionid + '" onclick=' + onclick + '><label class="custom-control-label text-capitalize" for="chk_' + response[i] + '_' + ruleactionid + '">' + response[i] + '</label><span></span> </div></div>';
- secondaryhtml += '<div class="col-sm-4"><div class="custom-control custom-checkbox divEnablePieces checkbox-primary"><input type="checkbox" class="type-control custom-control-input" id="chk_sec_' + response[i] + '_' + ruleactionid + '" name="SecondaryContactcolumns_' + ruleactionid + '" onclick=' + onclick + '><label class="text-capitalize custom-control-label" for="chk_sec_' + response[i] + '_' + ruleactionid + '">' + response[i] + '</label><span></span> </div></div>';
- }
- $("#contactcolumns_" + ruleactionid).append(html);
- $("#secondarycontactcolumns_" + ruleactionid).append(secondaryhtml);
- }
- });
- });
- }
- getContactColumns(RuleActionId) {
- var contactcolumns = "";
- $.each($("input[name='Contactcolumns_" + RuleActionId + "']:checked"), function () {
- var Contact = $(this).parents("label");
- Contact = Contact.prevObject[0].labels[0].innerText;
- contactcolumns += "|" + Contact;
- });
- if (contactcolumns != "")
- contactcolumns += "|";
- return contactcolumns;
- }
- getSecondaryContactColumns(RuleActionId) {
- var contactcolumns = "";
- $.each($("input[name='SecondaryContactcolumns_" + RuleActionId + "']:checked"), function () {
- var Contact = $(this).parents("label");
- Contact = Contact.prevObject[0].labels[0].innerText;
- contactcolumns += "|" + Contact;
- });
- if (contactcolumns != "")
- contactcolumns += "|";
- return contactcolumns;
- }
- CheckContactColumns(Users, ruleactionid) {
- if (Users != null)
- var contacts = Users.split("|");
- for (var i = 0; i < contacts.length; i++) {
- if (contacts[i] != "") {
- var id = contacts[i].toLowerCase();
- $('#chk_' + id + '_' + ruleactionid).prop("checked", true);
- }
- }
- }
- CheckSecondaryContactColumns(Users, ruleactionid) {
- if (Users != null)
- var contacts = Users.split("|");
- for (var i = 0; i < contacts.length; i++) {
- if (contacts[i] != "") {
- var id = contacts[i].toLowerCase();
- $('#chk_sec_' + id + '_' + ruleactionid).prop("checked", true);
- }
- }
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new NotificationsContactSelection();
- }
- return this.instance;
- }
- }
- Components.NotificationsContactSelection = NotificationsContactSelection;
- })(Components = Automation.Components || (Automation.Components = {}));
- })(Automation = Platform.Automation || (Platform.Automation = {}));
- })(Platform = Unibase.Platform || (Unibase.Platform = {}));
- })(Unibase || (Unibase = {}));
|