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.

createdashboard.js 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. var Unibase;
  2. (function (Unibase) {
  3. let Platform;
  4. (function (Platform) {
  5. let Dashboards;
  6. (function (Dashboards) {
  7. let Components;
  8. (function (Components) {
  9. class CreateDashboard extends Platform.Core.BaseComponent {
  10. constructor() {
  11. super();
  12. this.dashboardManager = Dashboards.Managers.DashboardManager.Instance();
  13. }
  14. cssFiles() {
  15. return [];
  16. }
  17. jsFiles() {
  18. return ["platform/dashboards/managers/dashboardmanager.js", "platform/dashboards/requests/dashboards.js", "platform/dashboards/components/dashboardpermissions.js", "platform/portlets/managers/portletmanager.js"];
  19. }
  20. html(id, containerid) {
  21. let html = `<form id="frm_Bizgaze_EditDashboard" method="post" data-validate="parsley" class="w-f bg-white"><div class="header b-b bg-white"><strong id="form_header_name">Create Dashboard</strong><a class="btn btn-xs btn-icon ml-auto"><i class="ti-help-alt"></i></a></div><div class="scrollable"><div id="Unibase_EditDashboardErrorMessages" class="clear"></div><div id="EditDashboard" class="card"><div class="card-header">Details</div><div class="card-body">
  22. <div class="row"><div class="col-lg-12"><div class="floating-label-form-group floating-label-form-group-with-value focus" id="div_DashboardName"><label for="txt_NewDashboardName" id="lbl_Dashboardname">Dashboard Name<span class="text-danger"> *</span></label><div class=""><input type="text" id="Txt_EditDashboardName" class="form-control value-control floating-label-control" data-isdynamic="false" placeholder="Dashboard Name *" data-placeholder="Enter Dashboard Name" data-label="Dashboard Name *" /></div><input type="hidden" id="EditDashboardId" value="0" /></div></div></div><div class="row my-4"><div class="col-lg-6"><div class="floating-label-form-group floating-label-form-group-with-value focus" id="div_DashboardGroup"><label for="ddl_Title" id="lbl_Title">Dashboard Group</label>
  23. <select id="ddl_DashboardGroups" class="form-control" style="font-size:14px"></select>
  24. <label for="Validation" id="lblValidation_DashboardGroup"></label>
  25. </div>
  26. </div>
  27. <div class="col-lg-6">
  28. <div class="floating-label-form-group floating-label-form-group-with-value focus" id="div_Dashboardindex">
  29. <label for="lbl_EditDashboardIndex" id="lbl_Dashboardindex">Index Number</label>
  30. <div class="input-group">
  31. <input type="number" id="Txt_EditDashboardIndex" min="0" onkeypress="return event.charCode != 45 && event.charCode!=101" class="form-control value-control floating-label-control" data-isdynamic="false" placeholder="Dashboard Index" data-placeholder="Enter Dashboard Index" data-label="Dashboard Index" />
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="row"><div class="col-lg-6 d-flex justify-content-between align-items-center"><span>Pin Common Filters</span><label class="switch mb-0" for="pinCmnFiltersChk"><input type="checkbox" class="pin-cmn-filters-chk" id="pinCmnFiltersChk"><span></span></label></div>
  37. <div class="col-sm-6 m-b hidden">
  38. <label>Select Lobs</label>
  39. <input type="hidden" id="hfLobs" />
  40. <select multiple="multiple" id="txtLobs" style="width:100%" class="txtLobs"></select></div></div>
  41. </div>
  42. </div>
  43. <div class="card">
  44. <div class="card-header">
  45. <span>Permissions</span>
  46. </div>
  47. <div class="card-body">
  48. <div id="divBizgaze_DashboardPermissions_MessagesPlaceholder" class="clear m-b-sm">
  49. </div>
  50. <div class="row">
  51. <div class="col-sm-12">
  52. <strong>Is Trackable ?</strong>
  53. <a href="javascript:;">
  54. <label class="switch pull-right">
  55. <input id="Ch_IsTrackable" type="checkbox" data-group="Viewable">
  56. <span class="slider round"></span>
  57. </label>
  58. </a>
  59. </div>
  60. </div>
  61. <div class="row">
  62. <div class="col-sm-12">
  63. <strong>Everyone can view?</strong>
  64. <a href="javascript:;">
  65. <label class="switch pull-right">
  66. <input id="chkIsDashboardViewable" type="checkbox" data-group="Viewable" checked>
  67. <span class="slider round"></span>
  68. </label>
  69. </a>
  70. </div>
  71. </div>
  72. <div class="row hidden mb-4" id="div_DashboardViewRoles">
  73. <div class="col-sm-12 m-b">
  74. <label>Roles that <strong>can</strong> view</label>
  75. <input type="hidden" id="hfDashboardViewRoles" />
  76. <select type="text" id="txtDashboardViewRoles" style="width:100%" value="" multiple="multiple"></select>
  77. </div>
  78. </div>
  79. <div class="row" id="div_DashboardExcludeViewRoles">
  80. <div class="col-sm-12 m-b">
  81. <label>Roles that <strong>can't</strong> view</label>
  82. <input type="hidden" id="hfDashboardExcludeViewRoles" />
  83. <select type="text" id="txtDashboardExcludeViewRoles" style="width:100%" value="" multiple="multiple"></select>
  84. </div>
  85. </div>
  86. <div class="row" id="divWPStages">
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. <div class="footer bg-white b-t">
  92. <a href="javascript:;" id="btn_CloseDashboard" class="pull-left btn btn-light btn-sm mr-auto">Close</a>
  93. <a href="javascript:;" id="btn_SaveDashboard" class="pull-right btn btn-sm btn-primary">Save</a>
  94. </div>
  95. </form>`;
  96. return html;
  97. }
  98. load(id, containerid, callback) {
  99. var instance = this;
  100. instance.loadDashboardGroups();
  101. $('#chkIsDashboardViewable').change(function () {
  102. var viewable = $("#chkIsDashboardViewable").prop('checked');
  103. if (viewable) {
  104. $('#div_DashboardViewRoles').addClass("hidden");
  105. $('#div_DashboardExcludeViewRoles').removeClass("hidden");
  106. }
  107. else {
  108. $('#div_DashboardExcludeViewRoles').removeClass("hidden");
  109. $('#div_DashboardViewRoles').removeClass("hidden");
  110. }
  111. });
  112. let IncludeRoles = [];
  113. let ExcludeRoles = [];
  114. $('#txtDashboardViewRoles').on("select2:select", function (e) {
  115. var result = e.params.data;
  116. if (Number(result.id) != 0) {
  117. var roleId = result.id;
  118. IncludeRoles.push(roleId);
  119. $(ExcludeRoles).each(function (i, value) {
  120. if (value == roleId) {
  121. var index = ExcludeRoles.indexOf(value);
  122. if (index > -1) {
  123. ExcludeRoles.splice(index, 1);
  124. }
  125. ExcludeRoles.splice(value, 1);
  126. jQuery("#txtDashboardExcludeViewRoles").val(ExcludeRoles).trigger('change');
  127. return false;
  128. }
  129. });
  130. }
  131. });
  132. $('#txtDashboardViewRoles').on("select2:unselect", function (e) {
  133. var result = e.params.data;
  134. if (Number(result.id) != 0) {
  135. var roleId = Number(result.id);
  136. IncludeRoles.pop(roleId);
  137. }
  138. });
  139. $('#txtDashboardExcludeViewRoles').on("select2:select", function (e) {
  140. var result = e.params.data;
  141. if (Number(result.id) != 0) {
  142. var roleId = result.id;
  143. ExcludeRoles.push(roleId);
  144. $(IncludeRoles).each(function (i, value) {
  145. if (value == roleId) {
  146. var index = IncludeRoles.indexOf(value);
  147. if (index > -1) {
  148. IncludeRoles.splice(index, 1);
  149. }
  150. jQuery("#txtDashboardViewRoles").val(IncludeRoles).trigger('change');
  151. return false;
  152. }
  153. });
  154. }
  155. });
  156. $('#txtDashboardExcludeViewRoles').on("select2:unselect", function (e) {
  157. var result = e.params.data;
  158. if (Number(result.id) != 0) {
  159. var roleId = result.id;
  160. ExcludeRoles.pop(roleId);
  161. }
  162. });
  163. $("#btn_SaveDashboard").click(function () {
  164. if ($("#Txt_EditDashboardName").val() == '') {
  165. MessageHelper.Instance().showError("Dashboard Name is required", 'Unibase_EditDashboardErrorMessages');
  166. return false;
  167. }
  168. let reqObj = new Unibase.Platform.Dashboards.Requests.Dashboard();
  169. reqObj.DashboardName = String($("#Txt_EditDashboardName").val());
  170. reqObj.DashboardIndex = Number($("#Txt_EditDashboardIndex").val());
  171. reqObj.DashboardGroupId = Number($("#ddl_DashboardGroups").val());
  172. reqObj.ViewRoles = IncludeRoles;
  173. reqObj.ExcludeRoles = ExcludeRoles;
  174. reqObj.IsTrackable = $("#Ch_IsTrackable").is(":checked");
  175. reqObj.ViewAllStages = true;
  176. reqObj.PinCommonFilters = $("#pinCmnFiltersChk").is(':checked');
  177. instance.dashboardManager.saveDashboard(reqObj).then(function (response) {
  178. if (response.errors == null) {
  179. instance.navigationHelper.closePopUp();
  180. MessageHelper.Instance().showSuccess('Dashboard Saved Successfully', '');
  181. Unibase.Platform.Dashboards.Components.ManageDashboard.Instance().loadDashboardGroups();
  182. }
  183. else
  184. MessageHelper.Instance().showError(response.errors[0], 'Unibase_EditDashboardErrorMessages');
  185. });
  186. });
  187. $("#btn_CloseDashboard").click(function () {
  188. instance.navigationHelper.closePopUp();
  189. });
  190. var _Permissions_ViewRoles = [];
  191. var ExcludeViewRoles = [];
  192. var Ids = [];
  193. var ExludedIds = [];
  194. var ViewRoleElementId = "txtDashboardViewRoles";
  195. var ExcludeRoleElementId = "txtDashboardExcludeViewRoles";
  196. Unibase.Platform.Dashboards.Components.DashboardPermissions.Instance().select2dashboardbinding(0, false, _Permissions_ViewRoles, ExcludeViewRoles, Ids, ExludedIds, ViewRoleElementId, ExcludeRoleElementId);
  197. }
  198. loadDashboardGroups() {
  199. var instance = this;
  200. instance.dashboardManager.getDashboardGroups().then(function (response) {
  201. var indexhtml = "";
  202. let html = "";
  203. for (var i = 0; i < response.result.length; i++) {
  204. html += '<option value="' + response.result[i].DashboardGroupId + '">' + response.result[i].DashboardGroupName + '</option>';
  205. indexhtml += '<input type="hidden" class="portletscount_' + response.result[i].DashboardGroupId + '" value = "' + response.result[i].PortletCount + '">';
  206. }
  207. var selectOpt = '<option value="0">No Group</option>';
  208. $('#ddl_DashboardGroups').html(selectOpt + html).append(indexhtml);
  209. $('#ddl_DashboardGroups').change(function () {
  210. var portletscount = 0;
  211. var groupid = Number($('#ddl_DashboardGroups').val());
  212. portletscount = Number($('.portletscount_' + groupid + '').val());
  213. $('#Txt_EditDashboardIndex').val(portletscount);
  214. if (groupid != 0) {
  215. $('#Txt_EditDashboardIndex').attr('disabled', 'true');
  216. }
  217. });
  218. });
  219. }
  220. static Instance() {
  221. return new CreateDashboard();
  222. }
  223. }
  224. Components.CreateDashboard = CreateDashboard;
  225. })(Components = Dashboards.Components || (Dashboards.Components = {}));
  226. })(Dashboards = Platform.Dashboards || (Platform.Dashboards = {}));
  227. })(Platform = Unibase.Platform || (Unibase.Platform = {}));
  228. })(Unibase || (Unibase = {}));