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.

reportfolder.js 34KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  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 Analytics;
  15. (function (Analytics) {
  16. let Components;
  17. (function (Components) {
  18. class ReportFolder extends Platform.Core.BaseComponent {
  19. constructor() {
  20. super(...arguments);
  21. this.reportFoldersHtml = '';
  22. this.IsAppRefresh = false;
  23. this.parentArray = [{ id: 0, folderName: null, parentid: null }];
  24. this.groupName = '';
  25. this.allViewableReports = [];
  26. this.loadFolder = [];
  27. this.noReportsGroup = [];
  28. this.allReports = [];
  29. this.allReportsGroup = [];
  30. }
  31. jsFiles() {
  32. var jsFiles = [];
  33. return jsFiles;
  34. }
  35. cssFiles() {
  36. return [];
  37. }
  38. html(id, containerid) {
  39. var instance = this;
  40. let html = ``;
  41. return html;
  42. }
  43. load(id, containerid, callback) {
  44. var instance = this;
  45. }
  46. init(containerid) {
  47. var instance = this;
  48. instance.loadFolders(containerid);
  49. $('.clear_icon').click(function () {
  50. $("#ListSearch").val('');
  51. $(".clear_icon").addClass("d-none");
  52. Unibase.Platform.Analytics.Components.ReportFolder.Instance().searchReports(`${containerid}`);
  53. });
  54. }
  55. loadFolders(containerid) {
  56. var instance = this;
  57. let html = `<div class="card mb-0 border-0 BindData_` + containerid + ` findcontainer h-100" style="background:0 0">
  58. <div class="card-header px-40 pb-0 search-bar-main-wrapper position-sticky t-0 bg-white z-index-2 border-0 viewer-header" id="ViewerHeader_` + containerid + `">
  59. <div class="card-header-top d-flex justify-content-between align-items-center line-loader-container p-relative">
  60. <div class=line-loader></div>
  61. <div id=div_ErrorMessage class=form-error-message style=margin-left:-5px;z-index:100></div>
  62. <div class="align-items-center d-flex "><a class="btn btn-flush-biz-theme btn-icon back_report btn-rounded flush-soft-hover d-26 hidden mr-2" onclick="Unibase.Platform.Analytics.Components.ReportFolder.Instance().loadBackFolder('${containerid}')"><span class="btn-icon-wrap"><i data-icon="l"></i></span></a><h6 class="font-weight-700 folders_head_text">Report Folders</h6></div>
  63. <div class="card-search-bar report-tree-view-search" id=cardSearchBar${containerid}>
  64. <div class="search-wrapper d-flex w-100" id=searchWrapper${containerid}>
  65. <input class="form-control txt_global_search report_folder_search" id=ListSearch placeholder="Search Reports" autocomplete=off onkeyup="Unibase.Platform.Analytics.Components.ReportFolder.Instance().searchReports('${containerid}')">
  66. <i class="fa fa-search search-left-icon biz-highlight-bg-color"></i>
  67. <div class="biz-highlight-bg-color main-search-loader search-clear-icon hidden"></div>
  68. <a href=javascript:; class="search-clear-icon biz-highlight-bg-color clear_icon position-absolute r-0 t-0 mt-3 d-none" id="search-clear-icon` + containerid + `" ><i class="zmdi zmdi-close"></i></a>
  69. </div>
  70. </div>
  71. <div class="text-right">`;
  72. if (_appsettings.active_identity().isAdmin) {
  73. html += `<a title="Create Folder" onclick="Unibase.Platform.Analytics.Components.ReportFolder._instance.renameFolder()" class="btn btn-raised btn-raised-hover font-13 p-2"><i class="la la-folder-plus font-25"></i>New</a>`;
  74. }
  75. html += `</div>
  76. </div>
  77. <div class="biz-highlight-text-color d-none"></div>
  78. </div>
  79. <div class="card-body userDesignWidgetCardBody p-2 pt-0">
  80. <ul class="userdesignreport_folders_${containerid} userdesignreport_folders px-3" id="userdesignreport_folders"></ul>
  81. </div>
  82. </div>`;
  83. $(`.${containerid}`).append(html);
  84. let height = $(`.${containerid}`).siblings('#hf_portletwidgetheight').val();
  85. if (height != '0px') {
  86. $('.userDesignWidgetCardBody').css({ "height": `` + height + ``, "overflow-x": "hidden" }).addClass("biz-custom-scrollbar");
  87. }
  88. if ((this.reportFoldersHtml != '' && this.reportFoldersHtml != null) && !this.IsAppRefresh) {
  89. $('#userdesignreport_folders').html(this.reportFoldersHtml);
  90. this.parentArray = [{ id: 0, folderName: null, parentid: null }];
  91. this.allViewableReports.splice(0, this.allViewableReports.length - 1);
  92. this.noReportsGroup.splice(0, this.noReportsGroup.length - 1);
  93. }
  94. else {
  95. this.IsAppRefresh = false;
  96. let html = `<div class="bg-white pt-0 py-4 report-folders-widget"><div><nav aria-label="breadcrumb"><ol class="breadcrumb folders_header bg-transparent mb-0"></ol></nav></div><ul class="folder-main-div row r-gap-20 mx-0"></ul><ul class=" row r-gap-20 reports-main-div mt-20 mx-0"></ul><div class="reports-global-search mt-3 px-3" style="display: none;"><a href="javascript:;" class="text-underline searchFromAllReports">Search from all reports</a></div><div class=" row r-gap-20 reports-main-div-search mt-20 mx-0"></div></div>`;
  97. $('#userdesignreport_folders').append(html);
  98. if (this.parentArray.length > 1) {
  99. for (let i = this.parentArray.length; i != 1; i--) {
  100. this.parentArray.shift();
  101. }
  102. }
  103. this.allReports = [];
  104. this.loadFolder = [];
  105. this.allViewableReports = [];
  106. this.noReportsGroup = [];
  107. instance.loadReportFolder(0, containerid);
  108. instance.loadAllReports(containerid);
  109. $('.searchFromAllReports').on('click', function () {
  110. let searchDiv = $(`#${containerid}`).find('.reports-main-div-search');
  111. if (searchDiv.is(":visible")) {
  112. searchDiv.hide();
  113. }
  114. else {
  115. searchDiv.show();
  116. }
  117. });
  118. }
  119. }
  120. loadAllReports(containerid) {
  121. return __awaiter(this, void 0, void 0, function* () {
  122. const allResponse = yield Unibase.Platform.Analytics.Managers.ReportManager.Instance().getViewableReports();
  123. this.allReports.push(allResponse.result);
  124. });
  125. }
  126. showGlobalReports(containerid) {
  127. let searchDiv = $(`#${containerid}`).find('.reports-main-div-search');
  128. if (searchDiv.is(":visible")) {
  129. searchDiv.hide();
  130. }
  131. else {
  132. searchDiv.show();
  133. }
  134. }
  135. searchReports(containerid) {
  136. $(".clear_icon").removeClass("d-none");
  137. const searchText = $(`#${containerid}`).find('.report_folder_search').val().toString().trim().toLowerCase();
  138. if (searchText == '') {
  139. $('.reports-main-div').show();
  140. $(`#${containerid}`).find('.reports-global-search').hide();
  141. $(`#${containerid}`).find('.reports-main-div-search').hide();
  142. $(`#${containerid}`).find('.search-clear-icon').addClass('d-none');
  143. }
  144. else {
  145. $(`#${containerid}`).find('.reports-global-search').show();
  146. if ($(`#${containerid}`).find('.reports-global-search .no-current-reports').length == 0) {
  147. $(`#${containerid}`).find('.reports-global-search').prepend('<div class="no-current-reports mb-3"><div class="w-100 mb-2"><h6 class="font-weight-700">Reports</h6></div><div>No Reports Found</div></div>');
  148. }
  149. }
  150. $(`#${containerid}`).find('.folder-main-div li').each(function () {
  151. let folderName = $(this).attr('data-groupname').toLowerCase();
  152. if (folderName.includes(searchText) == false) {
  153. $(this).hide();
  154. }
  155. else {
  156. $(this).show();
  157. }
  158. });
  159. $(`#${containerid}`).find('.reports-main-div li').each(function () {
  160. let reportName = $(this).attr('data-reportname').toLowerCase();
  161. if (reportName.includes(searchText) == false) {
  162. $(this).hide();
  163. $('.no-current-reports').show();
  164. }
  165. else {
  166. $(this).show();
  167. $('.reports-main-div').show();
  168. $('.no-current-reports').hide();
  169. }
  170. });
  171. let searchReports = [];
  172. for (let i = 0; i < this.allReports[0].length; i++) {
  173. let reportName;
  174. if (this.allReports[0][i].DisplayName == "" || this.allReports[0][i].DisplayName == null) {
  175. reportName = this.allReports[0][i].ReportName.toLowerCase();
  176. }
  177. else {
  178. reportName = this.allReports[0][i].DisplayName.toLowerCase();
  179. }
  180. if (searchText != '') {
  181. if (reportName.includes(searchText)) {
  182. searchReports.push(this.allReports[0][i]);
  183. }
  184. }
  185. }
  186. this.loadReporthtml(searchReports, '', containerid);
  187. if (!$('.reports-main-div li').is(':visible') || $('.reports-main-div li').length == 0) {
  188. $('.reports-main-div').hide();
  189. }
  190. if ($(`#${containerid}`).find('.reports-main-div li').length === 0 || !$(`#${containerid}`).find('.reports-main-div li').is(':visible')) {
  191. if (searchText != '') {
  192. $(`#${containerid}`).find('.reports-global-search').show();
  193. }
  194. }
  195. else {
  196. $(`#${containerid}`).find('.reports-global-search').hide();
  197. }
  198. if (this.parentArray.length === 1) {
  199. $(`#${containerid}`).find('.reports-global-search').hide();
  200. }
  201. else if ($(`#${containerid}`).find('.reports-main-div-search').is(":visible")) {
  202. $(`#${containerid}`).find('.reports-main-div-search').show();
  203. }
  204. else {
  205. $(`#${containerid}`).find('.reports-main-div-search').hide();
  206. }
  207. }
  208. loadReportGroup(parentid) {
  209. return __awaiter(this, void 0, void 0, function* () {
  210. const allReportGroups = yield Unibase.Platform.Analytics.Managers.ReportManager.Instance().getReportGroups();
  211. this.allReportsGroup.push(allReportGroups);
  212. let noReportFolder = allReportGroups.result.filter((report, index, self) => this.allReports[0].find(grp => grp.ParentGroupId === report.reportgroupid) && report.parentgroupid === parentid && self.find(x => x.parentgroupid === report.reportgroupid));
  213. noReportFolder = noReportFolder.filter(obj1 => { return !this.allReports[0].some(obj2 => obj2.ReportGroupId === obj1.reportgroupid); });
  214. this.noReportsGroup.unshift(noReportFolder);
  215. });
  216. }
  217. loadReportFolder(parentid, containerid) {
  218. return __awaiter(this, void 0, void 0, function* () {
  219. var instance = this;
  220. Unibase.Platform.Helpers.NavigationHelper.Instance().showLoading();
  221. const response = yield Unibase.Platform.Analytics.Managers.ReportManager.Instance().getViewableReportsByparentgroupid(parentid);
  222. if (this.allViewableReports.length == 0) {
  223. this.allViewableReports.unshift(response.result);
  224. }
  225. yield this.loadReportGroup(parentid);
  226. let loadedReportFolders = response.result;
  227. if (loadedReportFolders.length > 0) {
  228. if (this.allViewableReports[this.allViewableReports.length - 1].length != loadedReportFolders.length) {
  229. this.allViewableReports.unshift(loadedReportFolders);
  230. }
  231. if (this.allViewableReports.length > 1) {
  232. this.loadReporthtml(this.allViewableReports[1], parentid, containerid);
  233. }
  234. this.loadReportFolderhtml(this.allViewableReports[0], containerid);
  235. }
  236. else {
  237. this.loadReporthtml(this.allViewableReports[0], parentid, containerid);
  238. $('.folder-main-div').html('');
  239. }
  240. this.breadcrumb(containerid);
  241. Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading();
  242. });
  243. }
  244. loadReportFolderhtml(response, containerid) {
  245. $(`#${containerid}`).find('.report_folder_search').val('');
  246. let filterReportGroups = response.filter((report, index, self) => index === self.findIndex((x) => (x.ReportGroupId === report.ReportGroupId)));
  247. let folder = this.noReportsGroup[0];
  248. for (let i = 0; i < folder.length; i++) {
  249. let groupname = folder[i].groupname;
  250. let displayname = folder[i].displayname;
  251. let reportgroupid = folder[i].reportgroupid;
  252. filterReportGroups.unshift({ ReportGroupId: reportgroupid, GroupName: groupname, GroupDisplayName: displayname });
  253. }
  254. var html = '';
  255. $('.folder-main-div').html('');
  256. let folder_count = filterReportGroups.length;
  257. if (folder_count === 0) {
  258. $('.reports-main-div').removeClass('mt-20');
  259. }
  260. else {
  261. $('.reports-main-div').addClass('mt-20');
  262. }
  263. for (let i = 0; i < folder_count; i++) {
  264. let folderName = filterReportGroups[i]['GroupDisplayName'];
  265. if (folderName == "") {
  266. folderName = filterReportGroups[i]['GroupName'];
  267. }
  268. let parentid = filterReportGroups[i]['ParentGroupId'];
  269. let reportgroupid = filterReportGroups[i]['ReportGroupId'];
  270. html += `<li class="col-md-3 col-lg-2 col-sm-4 col-6" data-groupname="${folderName}"><div class="text-center" data-reportgroupid="${reportgroupid}" data-parentid="${parentid}" ><a href="javascript:;" ondblclick="Unibase.Platform.Analytics.Components.ReportFolder._instance.loadClickFolder('${parentid}', '${reportgroupid}', '${containerid}', '${folderName}')" class="p-2 d-flex align-items-center c-gap-5 report_folder btn btn-outline-primary" ><i class="fa fa-folder font-23" aria-hidden="true" ></i><div class="text-truncate font-13">${folderName}</div></a></div></li>`;
  271. }
  272. $('.folder-main-div').append(html);
  273. $('.report_folder').click(function () {
  274. $(this).parents('.folder-main-div').find('a.active').removeClass('active');
  275. });
  276. if (_appsettings.active_identity().isAdmin) {
  277. $('.report_folder').contextmenu(function () {
  278. event.preventDefault;
  279. $(this).parents('.folder-main-div').find('a.active').removeClass('active');
  280. $(this).addClass('active');
  281. let reportgroupid = $(this).parent().data('reportgroupid');
  282. let folderName = $(this).find('div').text();
  283. Unibase.Platform.Analytics.Components.ReportFolder.Instance().renameFolder(folderName, reportgroupid);
  284. return false;
  285. });
  286. }
  287. if (this.reportFoldersHtml === '') {
  288. this.reportFoldersHtml = $('#userdesignreport_folders').html();
  289. }
  290. }
  291. loadReporthtml(reports_response, parentid, containerid) {
  292. let uniqueReports;
  293. let reports_count;
  294. if (parentid == '') {
  295. uniqueReports = reports_response;
  296. reports_count = uniqueReports.length;
  297. if (reports_count == 0) {
  298. $('.reports-main-div-search').html('<div class="w-100 pl-3"><h6 class="font-weight-700">All Reports</h6></div><div class="px-3">No Reports Found</div>');
  299. }
  300. else {
  301. if (this.parentArray.length === 1) {
  302. $('.reports-main-div-search').show();
  303. }
  304. }
  305. if (reports_count > 0) {
  306. $('.reports-main-div-search').html('<div class="w-100 pl-3"><h6 class="font-weight-700">All Reports</h6></div>');
  307. }
  308. for (let i = 0; i < reports_count; i++) {
  309. let reportName = uniqueReports[i]['DisplayName'];
  310. let reportid = uniqueReports[i]['ReportId'];
  311. let html = `<div class="col-md-3 col-lg-2 col-sm-4 col-6"><div class="rounded-5 p-2 border border-2 text-truncate"><a class="text-underline text-dark text-truncate font-13" href="javascript:;" onclick="Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAll(${reportid} , '0', 'userdesignedreportviewer_${containerid}_${reportid}_fullscreen');" title="${reportName}"><i class="fa fa-file-text-o font-20 pr-2 font-weight-400"></i>${reportName}</a></div></div>`;
  312. $('.reports-main-div-search').append(html);
  313. }
  314. }
  315. else {
  316. $('.reports-main-div').show();
  317. $('.reports-main-div-search').hide();
  318. uniqueReports = reports_response.filter(checkParent);
  319. function checkParent(res) {
  320. if (res.ReportGroupId == parentid)
  321. return res;
  322. }
  323. reports_count = uniqueReports.length;
  324. if (reports_count == 0) {
  325. $('.reports-main-div').html('');
  326. }
  327. if (reports_count > 0) {
  328. $('.reports-main-div').html('<div class="w-100 pl-3"><h6 class="font-weight-700">Reports</h6></div>');
  329. }
  330. for (let i = 0; i < reports_count; i++) {
  331. let reportName = uniqueReports[i]['DisplayName'];
  332. let reportid = uniqueReports[i]['ReportId'];
  333. let html = `<li class="col-md-3 col-lg-2 col-sm-4 col-6" data-reportName="${reportName}"><div class="rounded-5 p-2 border border-2 text-truncate"><a class="text-underline text-dark text-truncate font-13" href="javascript:;" onclick="Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAll(${reportid} , '0', 'userdesignedreportviewer_${containerid}_${reportid}_fullscreen');" title="${reportName}"><i class="fa fa-file-text-o font-20 pr-2 font-weight-400"></i>${reportName}</a></div></li>`;
  334. $('.reports-main-div').append(html);
  335. }
  336. }
  337. }
  338. loadClickFolder(parentid, reportgroupid, containerid, reportGroupName) {
  339. $(`#${containerid}`).find('.reports-global-search').hide();
  340. $(`#${containerid}`).find('.report_folder_search').val('');
  341. this.loadFolder = [];
  342. this.parentArray.unshift({ id: reportgroupid, folderName: reportGroupName, parentid: parentid });
  343. this.loadReportFolder(reportgroupid, containerid);
  344. $('.back_report').removeClass('hidden');
  345. }
  346. breadcrumb(containerid) {
  347. $('.folders_header').html('');
  348. let html = '';
  349. if (this.loadFolder.length > 0) {
  350. this.parentArray.unshift({ id: this.loadFolder[0].id, folderName: this.loadFolder[0].folderName, parentid: this.loadFolder[0].parentid });
  351. }
  352. for (let i = this.parentArray.length; i > 1; i--) {
  353. let id = this.parentArray[i - 1].id;
  354. let folderName = this.parentArray[i - 2].folderName;
  355. $('.folders_header .breadcrumb-item').removeClass('active');
  356. if (i > 2) {
  357. html += `<li class="breadcrumb-item font-14 font-weight-400 active"><a href="javascript:;" onclick="Unibase.Platform.Analytics.Components.ReportFolder.Instance().breadcrumbClick('${id}','${containerid}')">${folderName}</a></li>`;
  358. }
  359. else {
  360. html += `<li class="breadcrumb-item font-14 font-weight-400 active">${folderName}</li>`;
  361. }
  362. }
  363. $('.folders_header').append(html);
  364. }
  365. breadcrumbClick(clickId, containerid) {
  366. $(`#${containerid}`).find('.reports-global-search').hide();
  367. let endArray;
  368. for (let i = 0; i <= this.parentArray.length - 1; i++) {
  369. let id = this.parentArray[i].id;
  370. if (id == clickId) {
  371. endArray = i;
  372. }
  373. }
  374. let clickedFolder = this.parentArray[endArray - 1];
  375. this.loadFolder = [];
  376. this.loadFolder.unshift({ id: clickedFolder.id, folderName: clickedFolder.folderName, parentid: clickedFolder.parentid });
  377. this.parentArray.splice(0, endArray);
  378. this.noReportsGroup.splice(0, endArray);
  379. if ($('.folder-main-div').html() == '') {
  380. this.allViewableReports.splice(0, endArray - 1);
  381. }
  382. else {
  383. this.allViewableReports.splice(0, endArray);
  384. }
  385. this.loadReportFolder(clickedFolder.id, containerid);
  386. }
  387. loadBackFolder(containerid) {
  388. $(`#${containerid}`).find('.reports-global-search').hide();
  389. $(`#${containerid}`).find('.reports-main-div-search').hide();
  390. if (this.parentArray.length == 0) {
  391. return;
  392. }
  393. const { id } = this.parentArray[1];
  394. let parentArrayLen = this.parentArray.length;
  395. let lastParentId = this.parentArray.shift();
  396. this.noReportsGroup.shift();
  397. if (this.allViewableReports.length > 1) {
  398. if (parentArrayLen == this.allViewableReports.length) {
  399. this.allViewableReports.shift();
  400. }
  401. }
  402. const { parentid } = lastParentId;
  403. this.loadFolder = [];
  404. this.breadcrumb(containerid);
  405. if (this.parentArray.length == 1) {
  406. $('.back_report').addClass('hidden');
  407. }
  408. if (!parentid && parentid != 0) {
  409. return;
  410. }
  411. let res = this.allViewableReports[0];
  412. this.loadReportFolderhtml(res, containerid);
  413. if (id != 0) {
  414. this.loadReporthtml(this.allViewableReports[1], id, containerid);
  415. }
  416. else {
  417. $('.reports-main-div').html('');
  418. }
  419. }
  420. renameFolder(folderName, reportgroupid) {
  421. let parentid = this.parentArray[0].id;
  422. let nextFolder;
  423. if (folderName == undefined) {
  424. let newFolderLen = $('.newfolder').length;
  425. let newFolderNum;
  426. if (newFolderLen == 0) {
  427. newFolderNum = '';
  428. }
  429. else {
  430. newFolderNum = newFolderLen;
  431. }
  432. nextFolder = 'newfolder' + newFolderLen;
  433. folderName = 'New Folder' + newFolderNum;
  434. }
  435. let ModalHtml = `<div class="modal" tabindex="-1" role="dialog" id="renameModal"> <div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Rename</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">&times;</span> </button> </div><div class="modal-body"> <input value="${folderName}"/> </div><div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <button type="button" class="btn btn-primary" id="renamesave" onclick="Unibase.Platform.Analytics.Components.ReportFolder.Instance().saveReportGroup`;
  436. ModalHtml += `(${parentid}, ${reportgroupid}, '${nextFolder}')`;
  437. ModalHtml += `">Save</button> </div></div></div></div>`;
  438. $('#renameModal').remove();
  439. $("#_bizgaze_modal").append(ModalHtml);
  440. $("#renameModal").modal();
  441. $('#renameModal').find('input').select();
  442. }
  443. saveReportGroup(parentid, reportgroupid, nextFolder) {
  444. let folderName = $('#renameModal').find('input').val().toString();
  445. if (reportgroupid == undefined) {
  446. reportgroupid = 0;
  447. }
  448. let isInternal = false;
  449. let groupIndex = 0;
  450. let model = new Unibase.Platform.Analytics.Reports.Requests.ReportGroup();
  451. if (nextFolder != "undefined") {
  452. model.GroupName = folderName;
  453. }
  454. else {
  455. model.GroupName = $('.report_folder.active div').text();
  456. }
  457. model.ReportGroupId = reportgroupid;
  458. model.IsInternalGroup = isInternal;
  459. model.ReportGroupIndex = !parseInt(groupIndex) ? 0 : parseInt(groupIndex);
  460. model.ParentGroupId = parentid;
  461. model.DisplayName = folderName;
  462. Unibase.Platform.Analytics.Managers.ReportManager._instance.saveReportGroup(model).then(function (response) {
  463. let res = JSON.parse(response.result);
  464. if (response.status == Unibase.Data.Status.Error) {
  465. MessageHelper.Instance().showError(response.message, 'divReportGroup_ErrorMessage');
  466. }
  467. else {
  468. MessageHelper.Instance().showSuccess(response.message, '');
  469. if (nextFolder != 'undefined') {
  470. if (_appsettings.active_identity().isAdmin) {
  471. $('.newfolder').contextmenu(function () {
  472. event.preventDefault;
  473. $(this).parents('.folder-main-div').find('a.active').removeClass('active');
  474. $(this).addClass('active');
  475. let reportgroupid = $(this).parent().data('reportgroupid');
  476. let folderName = $(this).find('div').text();
  477. Unibase.Platform.Analytics.Components.ReportFolder.Instance().renameFolder(folderName, reportgroupid);
  478. return false;
  479. });
  480. }
  481. }
  482. else {
  483. $('.folder-main-div').find('a.active').find('div').html(folderName);
  484. }
  485. }
  486. });
  487. if ('#renameModal') {
  488. $("#renameModal").modal('hide');
  489. }
  490. }
  491. static Instance() {
  492. if (this._instance === undefined)
  493. this._instance = new ReportFolder();
  494. return this._instance;
  495. }
  496. }
  497. Components.ReportFolder = ReportFolder;
  498. })(Components = Analytics.Components || (Analytics.Components = {}));
  499. })(Analytics = Platform.Analytics || (Platform.Analytics = {}));
  500. })(Platform = Unibase.Platform || (Unibase.Platform = {}));
  501. })(Unibase || (Unibase = {}));