Built files from Bizgaze WebServer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

templatenotes.js 53KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  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 TemplateNotes extends Platform.Core.BaseComponent {
  19. jsFiles() {
  20. var jsfiles = ["platform/automation/managers/rulemanager.js",
  21. "platform/datasources/managers/doctypemanager.js",
  22. "platform/analytics/managers/reportmanager.js",
  23. "platform/forms/managers/formmanager.js",
  24. "platform/automation/requests/eventtemplatenote.js",
  25. "platform/automation/requests/eventtemplatekey.js",
  26. "platform/automation/requests/eventtemplate.js"
  27. ];
  28. return jsfiles;
  29. }
  30. cssFiles() {
  31. return [];
  32. }
  33. html(id, containerid) {
  34. let html = `<form id="frmUnibase_TemplateNotes" data-validate="parsley" data-isdynamic="false">
  35. <div class="card bg-light">
  36. <div class="b-b bg-white card-header header">
  37. <strong class="text-dark title" id="templateheadertext">Create TemplateNotes</strong>
  38. <span class="pull-right" id="Notes">
  39. <a href="javascript:;" id="link_ResetNotes" class="pull-right ml-4">Reset Notes</a>
  40. <a href="javascript:;" id="link_RefreshNotes" class="pull-right mr-4">Refresh Notes</a>
  41. </span>
  42. </div>
  43. <div class="card-body scrollable" style="overflow-y: scroll;">
  44. <div class="bg-white card" id="TemplateNotess">
  45. <div id="unibase_ValidationSummary" class="clear"></div>
  46. <div class="card-body">
  47. <div class="row">
  48. <div class="col-sm-4">
  49. DocType
  50. <select id="Doctype_AutoComplete" class="required form-control value-control" data-isdynamic="true" onchange="Unibase.Platform.Automation.Components.TemplateNotes.Instance().ChangeDoctype()">
  51. <option value="0">Select</option>
  52. </select>
  53. <input type="hidden" id="hf_DocType" />
  54. </div>
  55. <div class="col-sm-3">
  56. Language
  57. <select id="Language_AutoComplete" class="required form-control value-control" data-isdynamic="true">
  58. <option value="0">Select</option>
  59. <option value="1">English</option>
  60. <option value="2">Hindi</option>
  61. <option value="3">Telugu</option>
  62. </select>
  63. <input type="hidden" id="hf_Language" />
  64. </div>
  65. <div class="col-sm-2 mt-4 d-none" style="position:relative;top:12px"><input type="checkbox" class="chk_GlobalReport"><span class="labledata ml-1">IsGlobalReport</span></div>
  66. <div class="col-sm-3 GlobalReportdiv d-none mt-4">
  67. <select id="GlobalReport_AutoComplete" class="required form-control value-control" data-isdynamic="true"></select>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. <div class="bg-white card hidden" id="divTemplateColumns">
  73. <div class="card-body">
  74. <div class="row">
  75. <div class="col-sm-12 Notes">
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. <div class="bg-white card-footer footer" id="CreateTemplateNotesFooter">
  82. <button id="btnCloseTemplateNotes" class="btn btn-secondary btn-sm mr-auto">Close</button>
  83. <button id="btnSaveTemplateNotes" class="btn btn-primary btn-sm pull-right">Save</button>
  84. </div>
  85. </div>
  86. </form>`;
  87. return html;
  88. }
  89. load(id, containerid, callback) {
  90. return __awaiter(this, void 0, void 0, function* () {
  91. $("#btnCloseTemplateNotes").click(function () {
  92. $('#' + containerid).modal('hide');
  93. $('#' + containerid).remove();
  94. TemplateNotes.EventResponse = [];
  95. Unibase.Platform.Automation.Components.TemplateNotes.DocProperties = [];
  96. });
  97. $("#btnSaveTemplateNotes").click(function () {
  98. Unibase.Platform.Automation.Components.TemplateNotes.Instance().Save(containerid);
  99. });
  100. $('.chk_GlobalReport').change(function () {
  101. if ($(this).is(':checked')) {
  102. $('.GlobalReportdiv').removeClass('d-none');
  103. }
  104. else {
  105. $('.GlobalReportdiv').addClass('d-none');
  106. }
  107. });
  108. $("#link_ResetNotes").click(function () {
  109. let doctypeid = Number($("#Doctype_AutoComplete option:selected").val());
  110. let languageid = Number($("#Language_AutoComplete option:selected").val());
  111. if (doctypeid == 0 || languageid == 0) {
  112. MessageHelper.Instance().showError("Please Select Doctype And Language", "unibase_ValidationSummary");
  113. }
  114. else {
  115. Unibase.Platform.Automation.Components.TemplateNotes.Instance().ResetNotes(doctypeid);
  116. }
  117. });
  118. $("#link_RefreshNotes").click(function () {
  119. let doctypeid = Number($("#Doctype_AutoComplete option:selected").val());
  120. let languageid = Number($("#Language_AutoComplete option:selected").val());
  121. if (doctypeid == 0 || languageid == 0) {
  122. MessageHelper.Instance().showError("Please Select Doctype And Language", "unibase_ValidationSummary");
  123. }
  124. else {
  125. Unibase.Platform.Automation.Managers.RuleManager.Instance().refreshNotes(doctypeid, true).then(function (response) {
  126. MessageHelper.Instance().showSuccess("Successfully reset notes", '');
  127. });
  128. }
  129. });
  130. Unibase.Platform.DataSources.Managers.DocTypeManager.Instance().getDoctypes().then(function (response) {
  131. var Data = [];
  132. for (let i = 0; i < response.result.length; i++) {
  133. var result = response.result[i];
  134. Data.push({ id: result.DocTypeId, text: result.DocTypeName });
  135. }
  136. $("#Doctype_AutoComplete").select2({
  137. placeholder: 'Select Doctype',
  138. data: Data,
  139. });
  140. });
  141. yield Unibase.Platform.Analytics.Managers.ReportManager.Instance().getReports().then(function (response) {
  142. for (let i = 0; i < response.length; i++) {
  143. var result = response[i];
  144. Unibase.Platform.Automation.Components.TemplateNotes.Reports.push({ id: result.ReportId, text: result.ReportName });
  145. }
  146. });
  147. $("#GlobalReport_AutoComplete").select2({
  148. placeholder: 'Select Report',
  149. data: Unibase.Platform.Automation.Components.TemplateNotes.Reports,
  150. });
  151. $("#Language_AutoComplete").change(function () {
  152. $('.templatemaindiv').html('');
  153. Unibase.Platform.Automation.Components.TemplateNotes.Instance().GetTemplateNotes().then(function () {
  154. Unibase.Platform.Automation.Components.TemplateNotes.Instance().LoadTemplateKeys();
  155. });
  156. });
  157. if (id != 0) {
  158. Unibase.Platform.Automation.Components.TemplateNotes.Instance().Edit(id);
  159. }
  160. });
  161. }
  162. ChangeDoctype() {
  163. $(".Notes").html("");
  164. $('#Language_AutoComplete').val(0);
  165. $("#divTemplateColumns").addClass("hidden");
  166. Unibase.Platform.Automation.Components.TemplateNotes.DocProperties = [];
  167. Unibase.Platform.Automation.Components.TemplateNotes.Instance().LoadDoctypeColumns();
  168. }
  169. loadForm(FormId, Pk_Value, AppConfigurationId, Callback, ElementId) {
  170. TemplateNotes.Instance().init(Pk_Value, null);
  171. }
  172. init(id, callback) {
  173. this.render(id, callback);
  174. }
  175. render(id, callback) {
  176. this.navigationHelper.popup(id, '', Unibase.Platform.Automation.Components.TemplateNotes.Instance(), null, Platform.Helpers.Size.DockLeft);
  177. }
  178. EventAliasName(id) {
  179. if ($('#IsAlias_' + id).is(':checked')) {
  180. $('#txt_EventAlias_' + id).val('');
  181. $('#txt_EventAlias_' + id).removeClass('d-none');
  182. }
  183. else {
  184. $('#txt_EventAlias_' + id).addClass('d-none');
  185. }
  186. }
  187. loadEventsTemplateForm(iscreate) {
  188. var Pk_Value = 0;
  189. if (!iscreate) {
  190. Pk_Value = Unibase.Themes.Providers.DetailHelper.recordId;
  191. }
  192. this.init(Pk_Value, null);
  193. }
  194. DeleteEventTemplateKey(index, keyindex) {
  195. bootbox.confirm("Do You Want To Delete?", function (result) {
  196. if (result) {
  197. var indx = Number(index);
  198. var kyindx = Number(keyindex);
  199. var templatekeyid = $('.templatekeyhidden_' + indx + '_' + kyindx).val();
  200. if (Number(templatekeyid) != 0) {
  201. Unibase.Platform.Automation.Managers.RuleManager.Instance().DeleteTemplateKeys(Number(templatekeyid)).then(function (response) {
  202. });
  203. }
  204. $('#row_' + indx + '_' + kyindx).remove();
  205. $('.deletetrash_' + indx + '_' + kyindx).remove();
  206. }
  207. else {
  208. return;
  209. }
  210. });
  211. }
  212. ResetNotes(doctypeid) {
  213. bootbox.confirm("Do You Want To Reset Notes? All Notes Will Be Revert", function (result) {
  214. if (result) {
  215. Unibase.Platform.Automation.Managers.RuleManager.Instance().refreshNotes(doctypeid, false).then(function (response) {
  216. MessageHelper.Instance().showSuccess("Successfully reset notes", '');
  217. });
  218. }
  219. else {
  220. return;
  221. }
  222. });
  223. }
  224. LoadDoctypeColumns() {
  225. return __awaiter(this, void 0, void 0, function* () {
  226. let doctypeid = Number($("#Doctype_AutoComplete option:selected").val());
  227. let doctypename = $("#Doctype_AutoComplete option:selected").text();
  228. return yield Unibase.Platform.DataSources.Managers.DocTypeManager.Instance().getDocProperties(doctypeid).then(function (response) {
  229. let html = "";
  230. html += '<div class="row TemplateNotesRow" id="TemplateNote_0"><div class="col-sm-5 mt-3"><div class="row"><span class="chk mr-4 col-sm-4"><input type="checkbox" class="Chk_Alias ml-2" id="IsAlias_0" onclick=" Unibase.Platform.Automation.Components.TemplateNotes.Instance().EventAliasName(0)"><label class="isaliasname ml-1" style="color:black">IsAlias</label></span><span class="col-sm-6"><label id="TemplateColumn_0">' + doctypename + ' Created</label><label class="hidden" id="Templatelable_0">' + doctypename + '_Created</label><label class="hidden h_templateid" id="TemplateId_0"></label><label class="hidden" id="EventId_0"></label><label class="hidden" id="TemplateNoteId_0"></label></div></div>' +
  231. '<div class="col-sm-6"><input type="text" id="txt_templatenote_0" class="form-control templatenotes" /></span></div>' +
  232. '<div class="col-sm-1 mt-2" id="AddKey"><span class="pull-right"><a id="" title="Create"><i class="fa fa-plus keysymbol" id="faplus_0" onclick=Unibase.Platform.Automation.Components.TemplateNotes.Instance().EditKeys(0)></i></a></span></div>' +
  233. '</div><div class="row eventaliasnamediv mb-1 mt-1 ml-1"><input type="text" id="txt_EventAlias_0" class="form-control d-none col-sm-5 eventaliastext" placeholder="Event Alias-Name"></div>' +
  234. '<div class="row templatemaindiv" id="Templatekeys_0"></div>';
  235. html += '<div class="row TemplateNotesRow" id="TemplateNote_1"><div class="col-sm-5 mt-3"><div class="row"><span class="chk mr-4 col-sm-4"><input type="checkbox" class="Chk_Alias ml-2" id="IsAlias_1" onclick=" Unibase.Platform.Automation.Components.TemplateNotes.Instance().EventAliasName(1)"><label class="isaliasname ml-1" style="color:black">IsAlias</label></span><span class="col-sm-6"><label id="TemplateColumn_1">' + doctypename + ' Deleted</label><label class="hidden" id="Templatelable_1">' + doctypename + '_Deleted</label><label class="hidden h_templateid" id="TemplateId_1"></label><label class="hidden" id="EventId_1"></label><label class="hidden" id="TemplateNoteId_1"></label></div></div>' +
  236. '<div class="col-sm-6"><input type="text" id="txt_templatenote_1" class="form-control templatenotes" /></span></div>' +
  237. '<div class="col-sm-1 mt-2" id="AddKey"><span class="pull-right"><a id="" title="Create"><i class="fa fa-plus keysymbol" id="faplus_1" onclick="Unibase.Platform.Automation.Components.TemplateNotes.Instance().EditKeys(1)"></i></a></span></div>' +
  238. '</div><div class="row eventaliasnamediv mb-1 ml-1 mt-1"><input type="text" id="txt_EventAlias_1" class="form-control d-none col-sm-5 eventaliastext" placeholder="Event Alias-Name"></div>' +
  239. '<div class="row templatemaindiv" id="Templatekeys_1"></div>';
  240. var res = response.result;
  241. if (response.result.length > 0) {
  242. res = response.result.filter(x => x.IsExcludeFromAudit == false);
  243. }
  244. for (let k = 0; k < response.result.length; k++) {
  245. var controls = response.result[k];
  246. Unibase.Platform.Automation.Components.TemplateNotes.DocProperties.push({ id: controls.DocPropertyId, text: controls.DocPropertyName });
  247. }
  248. for (var i = 0; i < res.length; i++) {
  249. Unibase.Platform.Automation.Components.TemplateNotes.index = i + 2;
  250. html += '<div class="row TemplateNotesRow" id="TemplateNote_' + Unibase.Platform.Automation.Components.TemplateNotes.index + '"><div class="col-sm-5 mt-3"><div class="row"><span class="chk mr-4 col-sm-4"><input type="checkbox" class="Chk_Alias ml-2" id="IsAlias_' + Unibase.Platform.Automation.Components.TemplateNotes.index + '"onclick="Unibase.Platform.Automation.Components.TemplateNotes.Instance().EventAliasName(' + Unibase.Platform.Automation.Components.TemplateNotes.index + ')"><label class="isaliasname ml-1" style="color:black">IsAlias</label></span><span class="col-sm-6"><label id="TemplateColumn_' + Unibase.Platform.Automation.Components.TemplateNotes.index + '">' + res[i].PropColumnName + ' Updated </label><label class="hidden" id="Templatelable_' + Unibase.Platform.Automation.Components.TemplateNotes.index + '">' + doctypename + "_" + res[i].PropColumnName + '_Updated</label><label class="hidden h_templateid" id="TemplateId_' + Unibase.Platform.Automation.Components.TemplateNotes.index + '"></label><label class="hidden" id="EventId_' + Unibase.Platform.Automation.Components.TemplateNotes.index + '"></label><label class="hidden" id="TemplateNoteId_' + Unibase.Platform.Automation.Components.TemplateNotes.index + '"></label></span></div></div>' +
  251. '<div class="col-sm-6"><input type="text" id="txt_templatenote_' + Unibase.Platform.Automation.Components.TemplateNotes.index + '" class="form-control templatenotes" /></div>' +
  252. '<div class="col-sm-1 mt-2" id="AddKey"><span class="pull-right"><a id="" title="Create"><i class="fa fa-plus keysymbol" id="faplus_' + Unibase.Platform.Automation.Components.TemplateNotes.index + '" onclick="Unibase.Platform.Automation.Components.TemplateNotes.Instance().EditKeys(' + Unibase.Platform.Automation.Components.TemplateNotes.index + ')"></i></a></span></div>' +
  253. '</div><div class="row eventaliasnamediv mb-1 mt-1 ml-1"><input type="text" id="txt_EventAlias_' + Unibase.Platform.Automation.Components.TemplateNotes.index + '" class="form-control d-none col-sm-5 eventaliastext" palceholder="Event Alias-Name"></div>' +
  254. '<div class="row templatemaindiv" id="Templatekeys_' + Unibase.Platform.Automation.Components.TemplateNotes.index + '"></div>';
  255. }
  256. $(".Notes").append(html);
  257. $("#divTemplateColumns").removeClass("hidden");
  258. });
  259. });
  260. }
  261. EditKeys(index) {
  262. if ($("#faplus_" + index).hasClass("fa-pencil")) {
  263. $('#Templatekeys_' + index).removeClass('d-none');
  264. $("#faplus_" + index).addClass("fa-plus").removeClass('fa-pencil');
  265. return;
  266. }
  267. Unibase.Platform.Automation.Components.TemplateNotes.Instance().AddKey(index);
  268. }
  269. LoadTemplateKeys() {
  270. return __awaiter(this, void 0, void 0, function* () {
  271. let rows = $(".TemplateNotesRow").length;
  272. for (var i = 0; i < rows; i++) {
  273. let templateid = Number($("#TemplateId_" + i + "").text());
  274. yield Unibase.Platform.Automation.Managers.RuleManager.Instance().getEventTemplateKeys(templateid).then(function (response) {
  275. if (response != null && response.length > 0) {
  276. for (var j = 0; j < response.length; j++) {
  277. var html = "";
  278. var data = response[j];
  279. let index = i;
  280. Unibase.Platform.Automation.Components.TemplateNotes.keysindex = j + 1;
  281. if (data.ReportId != 0) {
  282. var func = () => __awaiter(this, void 0, void 0, function* () { return yield Unibase.Platform.Automation.Components.TemplateNotes.Instance().OnChangeReport(index, Unibase.Platform.Automation.Components.TemplateNotes.keysindex); });
  283. func();
  284. }
  285. html += '<div class="TemplateKeysRow_' + index + ' row col-sm-12" id="row_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '"><input type="hidden" class="templatekeyhidden_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" value=' + data.TemplateKeyId + '>' +
  286. '<div class="col-sm-2"><input type="text" id="txt_KeyName_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" class="form-control required value-control floating-label-control" data-isdynamic="false"></div>' +
  287. '<div class="col-sm-2"><div id="div_DocProperties" class="floating-label-form-group-with-value floating-validate" style="border-bottom:0;"><select id="select2_DocProperties_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" class="select2_0_DocProperties value-control form-control text-control" style="width:100%;" onchange="Unibase.Platform.Automation.Components.TemplateNotes.Instance().OnChangeDocproperties(' + index + ', ' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + ');"><option value="0">Select</option></select><input type="hidden" id="hfSelect2Id_DocProperties_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" value="0" class="form-control text-control" data-isdynamic="true" /></div></div>' +
  288. '<div class="col-sm-2 hidden" id="Report_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '"><div id="div_Reports" class="floating-label-form-group-with-value floating-validate" style="border-bottom:0;"><select id="select2_Reports_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" class="select2_0_Reports value-control form-control text-control" style="width:100%;" onchange="Unibase.Platform.Automation.Components.TemplateNotes.Instance().OnChangeReport(' + index + ', ' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + ');"><option value="0">Select</option></select><input type="hidden" id="hfSelect2Id_Reports_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" value="0" class="form-control text-control" data-isdynamic="true" /></div></div>' +
  289. '<div class="col-sm-2 hidden" id="ReportColumn_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '"><div id="div_ReportColumns" class="floating-label-form-group-with-value floating-validate" style="border-bottom:0;"><select id="select2_ReportColumns_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" class="select2_0_ReportColumns value-control form-control text-control" style="width:100%;" onchange=""><option value="0">Select</option></select><input type="hidden" id="hfSelect2Id_ReportColumns_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" value="0" class="form-control text-control" data-isdynamic="true" /></div></div>' +
  290. '<div class="col-sm-2 hidden" id="ResultColumn_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '"><div id="div_ResultColumns" class="floating-label-form-group-with-value floating-validate" style="border-bottom:0;"><select id="select2_ResultColumns_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" class="select2_0_ResultColumns value-control form-control text-control" style="width:100%;" onchange="Unibase.Platform.Automation.Components.TemplateNotes.Instance().OnChangeResultColumn(' + index + ', ' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + ');"><option value="0">Select</option></select><input type="hidden" id="hfSelect2Id_ResultColumns_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" value="0" class="form-control text-control" data-isdynamic="true" /></div></div>' +
  291. '<div class="col-sm-1 mt-2"><div class="custom-control custom-checkbox checkbox-primary"><input type="checkbox" name="Keys" onclick="Unibase.Platform.Automation.Components.TemplateNotes.Instance().Cheked(' + index + ',' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + ');" class="custom-control-input" id="chk_Key_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '"><label class="custom-control-label" id="lblcontact" for="chk_Key_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '"></label></div></div>' +
  292. '<div class="deletetrash_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + 'col-sm-1 mt-2"><i class="fa fa-trash pull right deleteeventkey" id = "fatrash_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" onclick=" Unibase.Platform.Automation.Components.TemplateNotes.Instance().DeleteEventTemplateKey(' + index + ', ' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + ')"></i></div></div>';
  293. $('#faplus_' + index).removeClass('fa-plus').addClass('fa-pencil');
  294. $("#Templatekeys_" + index + "").append(html).addClass('d-none');
  295. $("#txt_KeyName_" + index + "_" + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + "").val(data.KeyName);
  296. Unibase.Platform.Automation.Components.TemplateNotes.Instance().LoadDocPropertys(index, Unibase.Platform.Automation.Components.TemplateNotes.keysindex);
  297. $("#select2_Reports_" + index + "_" + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + "").select2({
  298. placeholder: 'Select Report',
  299. data: Unibase.Platform.Automation.Components.TemplateNotes.Reports,
  300. });
  301. var docperopertyoption = new Option(data.DocpropertyName, data.DocpropertyId.toString(), true, true);
  302. $("#select2_DocProperties_" + index + "_" + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + " option[value=" + data.DocpropertyId + "]").prop("selected", true);
  303. if (data.ReportId != 0) {
  304. $("#Report_" + index + "_" + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + "").removeClass("hidden");
  305. $("#ReportColumn_" + index + "_" + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + "").removeClass("hidden");
  306. $("#ResultColumn_" + index + "_" + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + "").removeClass("hidden");
  307. $("#chk_Key_" + index + "_" + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + "").prop("checked", true);
  308. var reportoption = new Option(data.ReportName, data.ReportId.toString(), true, true);
  309. $("#select2_Reports_" + index + "_" + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + "").append(reportoption);
  310. var reportcolumnoption = new Option(data.ReportColumnName, data.ReportColumnId.toString(), true, true);
  311. $("#select2_ReportColumns_" + index + "_" + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + "").append(reportcolumnoption);
  312. var resultcolumnoption = new Option(data.ResultColumnName, data.ResultColumnId.toString(), true, true);
  313. $("#select2_ResultColumns_" + index + "_" + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + "").append(resultcolumnoption);
  314. }
  315. }
  316. }
  317. else {
  318. $('#faplus_' + i).removeClass('fa-pencil').addClass('fa-plus');
  319. }
  320. });
  321. }
  322. });
  323. }
  324. GetTemplateNotes() {
  325. return __awaiter(this, void 0, void 0, function* () {
  326. let doctypeid = Number($("#Doctype_AutoComplete option:selected").val());
  327. let languageid = Number($("#Language_AutoComplete option:selected").val());
  328. return yield Unibase.Platform.Automation.Managers.RuleManager.Instance().getEventTemplateNotesByLanguageId(doctypeid, languageid).then(function (response) {
  329. if (response != null && response.length > 0) {
  330. TemplateNotes.EventResponse = response;
  331. let rows = $(".TemplateNotesRow").length;
  332. for (var i = 0; i < rows; i++) {
  333. var eventname = $("#Templatelable_" + i + "").text();
  334. var event = response.filter(x => x.EventName == eventname.toLocaleLowerCase())[0];
  335. if (event != undefined) {
  336. let notestext = event.NotesText;
  337. let eventid = event.EventId;
  338. let templateid = event.TemplateId;
  339. let templatenoteid = event.TemplateNoteId;
  340. $("#txt_templatenote_" + i + "").val(notestext);
  341. $("#TemplateId_" + i + "").text(templateid);
  342. $("#EventId_" + i + "").text(eventid);
  343. $("#TemplateNoteId_" + i + "").text(templatenoteid);
  344. if (event.EventAliasName != '') {
  345. $('#IsAlias_' + i).prop("checked", true);
  346. $('#txt_EventAlias_' + i).removeClass('d-none').val(event.EventAliasName);
  347. }
  348. }
  349. }
  350. }
  351. else {
  352. $('.templatenotes').val('');
  353. $('.h_templateid').text(0);
  354. $('.Chk_Alias').prop("checked", false);
  355. $('.eventaliastext').addClass('d-none').val('');
  356. }
  357. });
  358. });
  359. }
  360. LoadDocPropertys(index, keyindex) {
  361. var html = '<option value="0">select DocProperty</option>';
  362. var docs = Unibase.Platform.Automation.Components.TemplateNotes.DocProperties;
  363. for (let i = 0; i < docs.length; i++) {
  364. html += '<option value=' + docs[i].id + '>' + docs[i].text + '</opion>';
  365. }
  366. $("#select2_DocProperties_" + index + "_" + keyindex + "").html('').html(html);
  367. }
  368. AddKey(index) {
  369. Unibase.Platform.Automation.Components.TemplateNotes.keysflag = 0;
  370. let html = "";
  371. Unibase.Platform.Automation.Components.TemplateNotes.keysindex = $(".TemplateKeysRow_" + index + "").length;
  372. if (!Unibase.Platform.Automation.Components.TemplateNotes.keyscount) {
  373. Unibase.Platform.Automation.Components.TemplateNotes.keysindex = Unibase.Platform.Automation.Components.TemplateNotes.keysindex + 1;
  374. }
  375. else {
  376. Unibase.Platform.Automation.Components.TemplateNotes.keysindex = Unibase.Platform.Automation.Components.TemplateNotes.keyscount;
  377. }
  378. html += '<div class="TemplateKeysRow_' + index + ' row col-sm-12 templatekey_rowdata" id="row_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '">' +
  379. '<div class="col-sm-2"><input type="text" id="txt_KeyName_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" class="form-control required value-control floating-label-control" data-isdynamic="false"></div>' +
  380. '<div class="col-sm-2"><div id="div_DocProperties" class="floating-label-form-group-with-value floating-validate" style="border-bottom:0;"><select id="select2_DocProperties_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" class="select2_0_DocProperties value-control form-control text-control" style="width:100%;" onchange="Unibase.Platform.Automation.Components.TemplateNotes.Instance().OnChangeDocproperties(' + index + ', ' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + ');"><option value="0">Select</option></select><input type="hidden" id="hfSelect2Id_DocProperties_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" value="0" class="form-control text-control" data-isdynamic="true" /></div></div>' +
  381. '<div class="col-sm-2 hidden" id="Report_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '"><div id="div_Reports" class="floating-label-form-group-with-value floating-validate" style="border-bottom:0;"><select id="select2_Reports_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" class="select2_0_Reports value-control form-control text-control" style="width:100%;" onchange="Unibase.Platform.Automation.Components.TemplateNotes.Instance().OnChangeReport(' + index + ', ' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + ');"><option value="0">Select</option></select><input type="hidden" id="hfSelect2Id_Reports_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" value="0" class="form-control text-control" data-isdynamic="true" /></div></div>' +
  382. '<div class="col-sm-2 hidden" id="ReportColumn_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '"><div id="div_ReportColumns" class="floating-label-form-group-with-value floating-validate" style="border-bottom:0;"><select id="select2_ReportColumns_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" class="select2_0_ReportColumns value-control form-control text-control" style="width:100%;" onchange=""><option value="0">Select</option></select><input type="hidden" id="hfSelect2Id_ReportColumns_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" value="0" class="form-control text-control" data-isdynamic="true" /></div></div>' +
  383. '<div class="col-sm-2 hidden" id="ResultColumn_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '"><div id="div_ResultColumns" class="floating-label-form-group-with-value floating-validate" style="border-bottom:0;"><select id="select2_ResultColumns_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" class="select2_0_ResultColumns value-control form-control text-control" style="width:100%;" onchange="Unibase.Platform.Automation.Components.TemplateNotes.Instance().OnChangeResultColumn(' + index + ', ' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + ');"><option value="0">Select</option></select><input type="hidden" id="hfSelect2Id_ResultColumns_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" value="0" class="form-control text-control" data-isdynamic="true" /></div></div>' +
  384. '<div class="col-sm-1 mt-2"><div class="custom-control custom-checkbox checkbox-primary"><input type="checkbox" name="Keys" onclick="Unibase.Platform.Automation.Components.TemplateNotes.Instance().Cheked(' + index + ',' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + ');" class="custom-control-input" id="chk_Key_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '"><label class="custom-control-label" id="lblcontact" for="chk_Key_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '"></label></div></div>' +
  385. '<div class="deletetrash_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + ' col-sm-1 mt-2" ><i class="fa fa-trash pull right deleteeventkey" id = "fatrash_' + index + '_' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + '" onclick=" Unibase.Platform.Automation.Components.TemplateNotes.Instance().DeleteEventTemplateKey(' + index + ', ' + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + ')"></i></div></div>';
  386. if (Unibase.Platform.Automation.Components.TemplateNotes.keysflag == 0) {
  387. $("#Templatekeys_" + index + "").append(html);
  388. $("#txt_KeyName_" + index + "_" + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + "").val("Key" + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + "");
  389. Unibase.Platform.Automation.Components.TemplateNotes.Instance().LoadDocPropertys(index, Unibase.Platform.Automation.Components.TemplateNotes.keysindex);
  390. $("#select2_Reports_" + index + "_" + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + "").select2({
  391. placeholder: 'Select Report',
  392. data: Unibase.Platform.Automation.Components.TemplateNotes.Reports,
  393. });
  394. if ($('.chk_GlobalReport').is(':checked')) {
  395. var reportid = $("#select2_Reports_" + index + "_" + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + " option:selected").val();
  396. var reportname = $("#select2_Reports_" + index + "_" + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + " option:selected").text();
  397. var reportoption = new Option(reportname, reportid.toString(), true, true);
  398. $("#select2_Reports_" + index + "_" + Unibase.Platform.Automation.Components.TemplateNotes.keysindex + "").append(reportoption);
  399. }
  400. Unibase.Platform.Automation.Components.TemplateNotes.keyscount = 0;
  401. Unibase.Platform.Automation.Components.TemplateNotes.keysflag = 0;
  402. }
  403. else {
  404. Unibase.Platform.Automation.Components.TemplateNotes.keysindex = Unibase.Platform.Automation.Components.TemplateNotes.keysindex - 1;
  405. }
  406. }
  407. Cheked(index, KeyNum) {
  408. if ($("#chk_Key_" + index + "_" + KeyNum + "").prop("checked") == true) {
  409. $("#Report_" + index + "_" + KeyNum + "").removeClass("hidden");
  410. $("#ReportColumn_" + index + "_" + KeyNum + "").removeClass("hidden");
  411. $("#ResultColumn_" + index + "_" + KeyNum + "").removeClass("hidden");
  412. }
  413. else {
  414. $("#Report_" + index + "_" + KeyNum + "").addClass("hidden");
  415. $("#ReportColumn_" + index + "_" + KeyNum + "").addClass("hidden");
  416. $("#ResultColumn_" + index + "_" + KeyNum + "").addClass("hidden");
  417. }
  418. }
  419. Save(containerid) {
  420. var languageid = Number($('#Language_AutoComplete option:selected').val());
  421. if (languageid != 0) {
  422. let eventtemplates = [];
  423. let eventtemplatesarray = Unibase.Platform.Automation.Components.TemplateNotes.Instance().EventTemplatesArray();
  424. for (let i = 0; i < eventtemplatesarray.length; i++) {
  425. eventtemplates.push({
  426. TemplateId: eventtemplatesarray[i].TemplateId,
  427. EventId: eventtemplatesarray[i].EventId,
  428. EventAliasName: eventtemplatesarray[i].EventAliasName,
  429. EventTempNotes: eventtemplatesarray[i].EventTempNotes,
  430. EventTempKeys: eventtemplatesarray[i].EventTempKeys
  431. });
  432. }
  433. Unibase.Platform.Automation.Managers.RuleManager.Instance().saveEventTemplates(eventtemplates).then(function (response) {
  434. Unibase.Platform.Automation.Components.TemplateNotes.DocProperties = [];
  435. TemplateNotes.EventResponse = [];
  436. $('#' + containerid).modal('hide');
  437. $('#' + containerid).remove();
  438. MessageHelper.Instance().showSuccess("SucessFully Saved", "");
  439. });
  440. }
  441. else {
  442. MessageHelper.Instance().showError("Mandatory fields are missing", "unibase_ValidationSummary");
  443. }
  444. }
  445. Edit(id) {
  446. Unibase.Platform.DataSources.Managers.DocTypeManager.Instance().getDoctype(id).then(function (response) {
  447. var doctypeoption = new Option(response.result.DocTypeName, response.result.DocTypeId.toString(), true, true);
  448. $("#Doctype_AutoComplete").append(doctypeoption);
  449. Unibase.Platform.Automation.Components.TemplateNotes.Instance().LoadDoctypeColumns().then(function () {
  450. $("#hf_Language").val(1);
  451. $("#Language_AutoComplete").val(Number($("#hf_Language").val()));
  452. Unibase.Platform.Automation.Components.TemplateNotes.Instance().GetTemplateNotes().then(function () {
  453. Unibase.Platform.Automation.Components.TemplateNotes.Instance().LoadTemplateKeys();
  454. });
  455. });
  456. });
  457. }
  458. OnChangeDocproperties(index, Keyindex) {
  459. $("#txt_KeyName_" + index + "_" + Keyindex + "").val($("#select2_DocProperties_" + index + "_" + Keyindex + " option:selected").text());
  460. }
  461. OnChangeReport(index, Keyindex) {
  462. return __awaiter(this, void 0, void 0, function* () {
  463. let reportid = Number($("#select2_Reports_" + index + "_" + Keyindex + " option:selected").val());
  464. var reportcolumndata = [];
  465. $("#select2_ReportColumns_" + index + "_" + Keyindex + "").empty();
  466. $("#select2_ResultColumns_" + index + "_" + Keyindex + "").empty();
  467. return yield Unibase.Platform.Analytics.Managers.ReportManager.Instance().getColumns(reportid).then(function (response) {
  468. var res = response.result;
  469. if (res != null) {
  470. for (let i = 0; i < res.length; i++) {
  471. reportcolumndata.push({ id: res[i].ReportColumnId, text: res[i].ReportColumnName });
  472. }
  473. $("#select2_ReportColumns_" + index + "_" + Keyindex + "").select2({
  474. placeholder: 'Select ReportColumn',
  475. data: reportcolumndata,
  476. });
  477. $("#select2_ResultColumns_" + index + "_" + Keyindex + "").select2({
  478. placeholder: 'Select ResultColumn',
  479. data: reportcolumndata,
  480. });
  481. }
  482. });
  483. });
  484. }
  485. OnChangeResultColumn(index, Keyindex) {
  486. $("#txt_KeyName_" + index + "_" + Keyindex + "").val($("#select2_ResultColumns_" + index + "_" + Keyindex + " option:selected").text());
  487. }
  488. EventTemplatesArray() {
  489. let eventtemplatesarray = [];
  490. $(".TemplateNotesRow").each(function () {
  491. let eventtemplatenotearray = [];
  492. let eventtemplatekeysarray = [];
  493. let eventtemplateobj = {};
  494. let eventtemplatenoteobj = {};
  495. let id = $(this).find(".TemplateNotesRow");
  496. let index = (id.prevObject[0].id).split('_');
  497. index = Number(index[1]);
  498. let keys = $(".TemplateKeysRow_" + index + "").length;
  499. var languageid = Number($('#Language_AutoComplete option:selected').val());
  500. for (var i = 0; i < keys; i++) {
  501. let eventtemplatekeysobj = {};
  502. let len = i + 1;
  503. var templatekey = $('.templatekeyhidden_' + index + '_' + len).val() == undefined ? 0 : Number($('.templatekeyhidden_' + index + '_' + len).val());
  504. eventtemplatekeysobj.TemplateId = Number($("#TemplateId_" + index + "").text());
  505. eventtemplatekeysobj.ReportId = Number($("#select2_Reports_" + index + "_" + len + " option:selected").val());
  506. eventtemplatekeysobj.ReportColumnId = Number($("#select2_ReportColumns_" + index + "_" + len + " option:selected").val());
  507. eventtemplatekeysobj.ResultColumnId = Number($("#select2_ResultColumns_" + index + "_" + len + " option:selected").val());
  508. eventtemplatekeysobj.DocpropertyId = Number($("#select2_DocProperties_" + index + "_" + len + " option:selected").val());
  509. eventtemplatekeysobj.KeyName = $("#txt_KeyName_" + index + "_" + len + "").val().toString();
  510. eventtemplatekeysobj.TemplateKeyId = templatekey;
  511. eventtemplatekeysarray.push(eventtemplatekeysobj);
  512. }
  513. eventtemplatenoteobj.TemplateNoteId = Number($("#TemplateNoteId_" + index + "").text());
  514. eventtemplatenoteobj.NotesText = $("#txt_templatenote_" + index + "").val().toString();
  515. eventtemplatenoteobj.LanguageId = languageid;
  516. eventtemplatenoteobj.IsSystemGenerated = false;
  517. var eventindex = TemplateNotes.EventResponse.findIndex(x => x.NotesText.toLowerCase() == eventtemplatenoteobj.NotesText.toLowerCase());
  518. if (eventindex != -1) {
  519. eventtemplatenoteobj.IsSystemGenerated = TemplateNotes.EventResponse[eventindex].IsSystemGenerated;
  520. }
  521. eventtemplatenotearray.push(eventtemplatenoteobj);
  522. eventtemplateobj.EventId = Number($("#EventId_" + index + "").text());
  523. eventtemplateobj.TemplateId = Number($("#TemplateId_" + index + "").text());
  524. eventtemplateobj.EventTempNotes = eventtemplatenotearray;
  525. eventtemplateobj.EventTempKeys = eventtemplatekeysarray;
  526. eventtemplateobj.EventAliasName = ($('#txt_EventAlias_' + index).text() == undefined || $('#txt_EventAlias_' + index).val() == null || $('#txt_EventAlias_' + index).val() == "") ? '' : $('#txt_EventAlias_' + index).val().toString();
  527. eventtemplatesarray.push(eventtemplateobj);
  528. });
  529. return eventtemplatesarray;
  530. }
  531. static Instance() {
  532. if (this.instance === undefined) {
  533. this.instance = new TemplateNotes();
  534. }
  535. return this.instance;
  536. }
  537. }
  538. TemplateNotes.index = 0;
  539. TemplateNotes.keysindex = 0;
  540. TemplateNotes.keysflag = 0;
  541. TemplateNotes.DocProperties = [];
  542. TemplateNotes.Reports = [];
  543. TemplateNotes.EventResponse = [];
  544. Components.TemplateNotes = TemplateNotes;
  545. })(Components = Automation.Components || (Automation.Components = {}));
  546. })(Automation = Platform.Automation || (Platform.Automation = {}));
  547. })(Platform = Unibase.Platform || (Unibase.Platform = {}));
  548. })(Unibase || (Unibase = {}));