Built files from Bizgaze WebServer
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

notifications.contactselection.js 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  2. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3. return new (P || (P = Promise))(function (resolve, reject) {
  4. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  5. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  6. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  7. step((generator = generator.apply(thisArg, _arguments || [])).next());
  8. });
  9. };
  10. var Unibase;
  11. (function (Unibase) {
  12. let Platform;
  13. (function (Platform) {
  14. let Automation;
  15. (function (Automation) {
  16. let Components;
  17. (function (Components) {
  18. class NotificationsContactSelection {
  19. constructor() {
  20. this.RecipientProviders = [];
  21. }
  22. init(rpid, ruleactionid) {
  23. return __awaiter(this, void 0, void 0, function* () {
  24. Unibase.Platform.Automation.Components.NotificationsContactSelection.Instance().loadRecipients(ruleactionid);
  25. Unibase.Platform.Automation.Components.NotificationsContactSelection.Instance().LoadContactColumns(rpid, ruleactionid);
  26. return Unibase.Platform.Automation.Components.NotificationsContactSelection.Instance().html(ruleactionid);
  27. });
  28. }
  29. loadRecipients(ruleactionid) {
  30. return __awaiter(this, void 0, void 0, function* () {
  31. return yield Unibase.Platform.Automation.Managers.RuleManager.Instance().getRecipientProviders().then(function (response) {
  32. Unibase.Platform.Automation.Components.NotificationsContactSelection.Instance().RecipientProviders = response;
  33. for (var i = 0; i <= response.length - 1; i++) {
  34. let html = '';
  35. 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>' +
  36. '<input type="hidden" id="hdnselect2_' + ruleactionid + '_' + response[i].RecipientName + '" class="value-control" value="0">' +
  37. '<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>' +
  38. '</div></div>';
  39. $(".recipients_" + ruleactionid).append(html);
  40. let selectid = "select2_" + ruleactionid + "_" + response[i].RecipientName + "";
  41. let selectlable = response[i].DisplayName;
  42. let recipientProviderid = response[i].RecipientProviderId;
  43. Unibase.Platform.Automation.Components.NotificationsContactSelection.Instance().RecipientsData(selectid, selectlable, recipientProviderid);
  44. }
  45. });
  46. });
  47. }
  48. html(ruleactionid) {
  49. return __awaiter(this, void 0, void 0, function* () {
  50. 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>';
  51. return yield html;
  52. });
  53. }
  54. RecipientsData(selectid, selectlable, recipientProviderid) {
  55. return __awaiter(this, void 0, void 0, function* () {
  56. var url = _appsettings.server_url() + '/apis/v4/unibase/notificationrule/platform/RecipientsAutoComplete/RecipientProviderId/' + recipientProviderid;
  57. return yield AutoCompleteHelper.getHelper().Create("#" + selectid, "hdn" + selectid, url, function (response) {
  58. var data = response;
  59. });
  60. });
  61. }
  62. GetRecipients(RuleActionId) {
  63. var obj = new Object();
  64. $(".recipient").each(function () {
  65. let id = $(this).find(".recipient");
  66. let index = (id.prevObject[0].id).split('_');
  67. index = index[1];
  68. let propname = $(this).find(".propname").text();
  69. let recipientname = $(this).find(".recipientname").text();
  70. let selectid = "select2_" + RuleActionId + "_" + recipientname;
  71. let recipients = Unibase.Platform.Automation.Components.NotificationsContactSelection.Instance().getSelectedRecipients(selectid);
  72. obj[propname] = recipients;
  73. });
  74. return obj;
  75. }
  76. BindRecipients(ruleactionid) {
  77. return __awaiter(this, void 0, void 0, function* () {
  78. var recipientproviders = Unibase.Platform.Automation.Components.NotificationsContactSelection.Instance().RecipientProviders;
  79. return yield Unibase.Platform.Automation.Managers.RuleManager.Instance().getActionRecipient(ruleactionid).then(function (response) {
  80. for (var i = 0; i < recipientproviders.length; i++) {
  81. let recipients = response[recipientproviders[i].ColumnName];
  82. let IdColumn = recipientproviders[i].IdColumn;
  83. let RecipientProviderId = Number(recipientproviders[i].RecipientProviderId);
  84. Unibase.Platform.Automation.Components.NotificationsContactSelection.Instance().BindRecipientOptions(RecipientProviderId, recipients, IdColumn, recipientproviders[i].RecipientName, ruleactionid);
  85. }
  86. });
  87. });
  88. }
  89. BindRecipientOptions(RecipientProviderId, recipients, IdColumn, RecipientName, ruleactionid) {
  90. return __awaiter(this, void 0, void 0, function* () {
  91. return yield Unibase.Platform.Automation.Managers.RuleManager.Instance().getSelectedRecipientsData(RecipientProviderId, recipients, IdColumn).then(function (response) {
  92. if (response != "" && response.result.length > 0) {
  93. var Result = response.result;
  94. for (var j = 0; j < Result.length; j++) {
  95. var recipient = Result[j];
  96. var newOption = new Option(recipient.AutoCompleteTextColumn, recipient.AutoCompleteIdColumn, true, true);
  97. $("#select2_" + ruleactionid + "_" + RecipientName + "").append(newOption).trigger('change');
  98. }
  99. }
  100. });
  101. });
  102. }
  103. getSelectedRecipients(selectid) {
  104. let Recipientcount = new Array();
  105. Recipientcount = $('#' + selectid).val();
  106. let Recipient = "";
  107. for (var i = 0; i < Recipientcount.length; i++) {
  108. Recipient += "|" + Recipientcount[i];
  109. }
  110. if (Recipient != "")
  111. Recipient += "|";
  112. return Recipient;
  113. }
  114. LoadContactColumns(rpid, ruleactionid) {
  115. return __awaiter(this, void 0, void 0, function* () {
  116. let ruleproviderid = rpid;
  117. return yield Unibase.Platform.Automation.Managers.RuleManager.Instance().getContactColumns(ruleproviderid).then(function (response) {
  118. if (response != null) {
  119. let html = '';
  120. let secondaryhtml = '';
  121. for (let i = 0; i <= response.length - 1; i++) {
  122. 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>&nbsp</div></div>';
  123. 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>&nbsp</div></div>';
  124. }
  125. $("#contactcolumns_" + ruleactionid).append(html);
  126. $("#secondarycontactcolumns_" + ruleactionid).append(secondaryhtml);
  127. }
  128. });
  129. });
  130. }
  131. getContactColumns(RuleActionId) {
  132. var contactcolumns = "";
  133. $.each($("input[name='Contactcolumns_" + RuleActionId + "']:checked"), function () {
  134. var Contact = $(this).parents("label");
  135. Contact = Contact.prevObject[0].labels[0].innerText;
  136. contactcolumns += "|" + Contact;
  137. });
  138. if (contactcolumns != "")
  139. contactcolumns += "|";
  140. return contactcolumns;
  141. }
  142. getSecondaryContactColumns(RuleActionId) {
  143. var contactcolumns = "";
  144. $.each($("input[name='SecondaryContactcolumns_" + RuleActionId + "']:checked"), function () {
  145. var Contact = $(this).parents("label");
  146. Contact = Contact.prevObject[0].labels[0].innerText;
  147. contactcolumns += "|" + Contact;
  148. });
  149. if (contactcolumns != "")
  150. contactcolumns += "|";
  151. return contactcolumns;
  152. }
  153. CheckContactColumns(Users, ruleactionid) {
  154. if (Users != null)
  155. var contacts = Users.split("|");
  156. for (var i = 0; i < contacts.length; i++) {
  157. if (contacts[i] != "") {
  158. var id = contacts[i].toLowerCase();
  159. $('#chk_' + id + '_' + ruleactionid).prop("checked", true);
  160. }
  161. }
  162. }
  163. CheckSecondaryContactColumns(Users, ruleactionid) {
  164. if (Users != null)
  165. var contacts = Users.split("|");
  166. for (var i = 0; i < contacts.length; i++) {
  167. if (contacts[i] != "") {
  168. var id = contacts[i].toLowerCase();
  169. $('#chk_sec_' + id + '_' + ruleactionid).prop("checked", true);
  170. }
  171. }
  172. }
  173. static Instance() {
  174. if (this.instance === undefined) {
  175. this.instance = new NotificationsContactSelection();
  176. }
  177. return this.instance;
  178. }
  179. }
  180. Components.NotificationsContactSelection = NotificationsContactSelection;
  181. })(Components = Automation.Components || (Automation.Components = {}));
  182. })(Automation = Platform.Automation || (Platform.Automation = {}));
  183. })(Platform = Unibase.Platform || (Unibase.Platform = {}));
  184. })(Unibase || (Unibase = {}));