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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. var Unibase;
  2. (function (Unibase) {
  3. let Platform;
  4. (function (Platform) {
  5. let Permissions;
  6. (function (Permissions) {
  7. let Components;
  8. (function (Components) {
  9. class EditRole extends Platform.Core.BaseComponent {
  10. constructor() {
  11. super();
  12. this.InstalledAppId = 0;
  13. }
  14. cssFiles() {
  15. return ['libs/jquery-ui-slider-pips/jquery-ui-slider-pips.css', 'libs/jquery-ui-slider-pips/Custom-slider-ui-pips.css'];
  16. }
  17. jsFiles() {
  18. return ['platform/permission/components/editrole.js', 'platform/permission/requests/role.js', '/platform/apps/components/stages/stages.js', 'platform/permission/components/permissions.js', '/platform/apps/managers/stagemanager.js', '/platform/apps/components/stages/stagepermissions.js', '/platform/filters/components/filter.js', '/platform/filters/managers/filtermanager.js', 'platform/permission/managers/permissionmanager.js', 'platform/permission/requests/approlesetting.js', '/platform/permission/infos/role.js', "platform/forms/components/formviewer/formviewer.js", 'libs/parsley/parsley.min.js', 'platform/permission/managers/permissionmanager.js', 'platform/core/infos/status.js'];
  19. }
  20. html(id, containerid) {
  21. var instance = this;
  22. var appid = instance.appSettings.InstalledAppId;
  23. instance.InstalledAppId = instance.appSettings.InstalledAppId;
  24. let html = ``;
  25. html += `<form id="form_Roles" default="" button="btnSaveDesignation" data-validate="parsley" data-isdynamic="false">
  26. <input type="hidden" id="hf_RoleId" value="" />
  27. <div class="b-b bg-white header">
  28. <strong class="text-dark Title" id="newRole">New Role</strong>
  29. <strong class="text-dark hidden Title" id="editRole">Edit Role</strong>
  30. <div class="btn-group ml-auto">
  31. <a class="btn btn-sm"><i class="ti-help-alt" title="help"></i></a>
  32. </div>
  33. </div>
  34. <div class="simple-scroll-bar scrollable" id="divroleheight">
  35. <div class="clear" id="divRoleError">
  36. </div>
  37. <div class="card">
  38. <div id="div_rolemessage" class="clear"></div>
  39. <div class="card-body">
  40. <div class="row">
  41. <div class="col-sm-12">
  42. <div class="" id="div_rolename">
  43. <label for="lblName">Role Name<span class="text-danger"> *</span></label>
  44. <input id="txtRoleName" class="form-control value-control required floating-label-control pl-1" data-isdefault="true" data-required="true" data-validatemsg data-val-required="The RoleName field is required." placeholder="RoleName" type="text" value="" data-label="Role Name *" data-placeholder="Administrator">
  45. </div>
  46. </div>
  47. </div>
  48. <div class="row">
  49. <div class="col-sm-12">
  50. <div class="" id="div_roleDescription">
  51. <label for="lblDescription">Description</label>
  52. <input id="txtDescription" class="form-control value-control floating-label-control pl-1" name="Description" data-isdefault="true" data-required="true" data-regularexp data-validatemsg placeholder="Short description about the role" type="text" value="" data-label="Description" data-placeholder="Short description about the role">
  53. </div>
  54. <br />
  55. </div>
  56. </div>
  57. <div class="row">
  58. <div class="col-sm-6">
  59. <label for="lblLobCategory" class="mt-15">
  60. Is
  61. Public ?
  62. </label>
  63. <input type="hidden" id="hfIsPublic" value="false" />
  64. <div class="btn-group btn-group-justified mt-10" data-toggle="buttons">
  65. <label class="btn btn-sm btn-isPublic btn-default active" onclick="Unibase.Platform.Permissions.Components.EditRole.Instance().ispublicChange(false)">
  66. <input name="options" id="option2" type="radio">
  67. <i class="fa fa-check text-active"></i>No
  68. </label>
  69. <label class="btn btn-sm btn-default btn-isPublictrue " onclick=" Unibase.Platform.Permissions.Components.EditRole.Instance().ispublicChange(true)">
  70. <input name="options" id="option1" type="radio">
  71. <i class="fa fa-check text-active"></i> Yes
  72. </label>
  73. </div>
  74. </div>
  75. <div class="col-sm-6">
  76. <label class="mt-15">Auto Assignment</label>
  77. <input type="hidden" id="hfAutoAssignment" value="false" />
  78. <div class="btn-group btn-group-justified mt-10" data-toggle="buttons">
  79. <label class="btn btn-sm btn-default btn-isAutoAssignment active" onclick=" Unibase.Platform.Permissions.Components.EditRole.Instance().isAutoAssignmentChange(false)">
  80. <input name="options" id="option2" type="radio">
  81. <i class="fa fa-check text-active"></i>No
  82. </label>
  83. <label class="btn btn-sm btn-default btn-isAutoAssignmentTrue " onclick=" Unibase.Platform.Permissions.Components.EditRole.Instance().isAutoAssignmentChange(true)">
  84. <input name="options" id="option1" type="radio">
  85. <i class="fa fa-check text-active"></i>Yes
  86. </label>
  87. </div>
  88. </div>
  89. </div>
  90. <div class="row">
  91. <div class="col-sm-6">
  92. <div class=" floating-label-form-group floating-label-form-group-with-value" id="div_InternalRole">
  93. <label for="lblInternalRole">Internal Role <span class="text-danger"> *</span></label>
  94. <select id="select_InternalRole" class="form-control value-control required floating-label-control" placeholder="Select Internal Role" data-required="true"></select>
  95. </div>
  96. <br />
  97. </div>
  98. </div>
  99. </div>
  100. </div>
  101. </div>
  102. <div class="bg-white footer b-t">
  103. <a href="javascript:;" id="btn_Close" class="btn btn-light btn-sm mr-auto btn-close">Close</a>
  104. <a href="javascript:;" id="btn_SaveRole" class="pull-right btn btn-sm btn-primary">Save</a>
  105. </div>
  106. </form>`;
  107. return html;
  108. }
  109. load(id, containerid, callback) {
  110. var roleid = id;
  111. var instance = this;
  112. instance.InstalledAppId = instance.appSettings.InstalledAppId;
  113. $("#btn_rolesClose").click(function () {
  114. $('#' + containerid).modal('hide');
  115. $('#' + containerid).remove();
  116. });
  117. $("#btn_SaveRole").click(function () {
  118. let rolecontrolid = "form_Roles";
  119. let result = Unibase.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation(rolecontrolid);
  120. if (result == false) {
  121. MessageHelper.Instance().showError("Mandatory fields are missing", "div_rolemessage");
  122. return false;
  123. }
  124. else {
  125. instance.SaveRole(containerid, roleid, instance.InstalledAppId);
  126. }
  127. });
  128. $('#btnAddNewStage_' + containerid).click(function () {
  129. Unibase.Platform.Apps.Components.Stages.Instance().AddStage(0);
  130. });
  131. $("#btn_Close").click(function () {
  132. $('#' + containerid).modal('hide');
  133. $('#' + containerid).remove();
  134. });
  135. instance.roledata(id);
  136. }
  137. roledata(roleid) {
  138. var instance = this;
  139. $("#divroleheight").height($(window).outerHeight() - 144);
  140. Permissions.Managers.PermissionManager.Instance().getInternalRoles().then(function (response) {
  141. for (var i = 0; i < response.result.length; i++) {
  142. $('#select_InternalRole').append('<option value="' + response.result[i].Value + '">' + response.result[i].SelectText + '</option>');
  143. }
  144. if (roleid != 0) {
  145. Unibase.Platform.Permissions.Managers.PermissionManager.Instance().getRole(roleid).then(function (response) {
  146. var role = response.result;
  147. var status1 = '';
  148. var status2 = '';
  149. if (role.IsPublic == true) {
  150. status1 = 'active';
  151. status2 = '';
  152. }
  153. else {
  154. status1 = '';
  155. status2 = 'active';
  156. }
  157. var assign1 = '';
  158. var assign2 = '';
  159. if (role.AutoAssignment == true) {
  160. assign1 = 'active';
  161. assign2 = '';
  162. }
  163. else {
  164. assign1 = '';
  165. assign2 = 'active';
  166. }
  167. $("#txtRoleName").val(role.RoleName);
  168. $("#txtDescription").val(role.Description);
  169. $("#hf_RoleId").val(role.RoleId);
  170. $(".btn-isPublic").removeClass('active').addClass(status2);
  171. $(".btn-isPublictrue").addClass(status1);
  172. $(".btn-isAutoAssignment").removeClass('active').addClass(assign2);
  173. $(".btn-isAutoAssignmentTrue").addClass(assign1);
  174. $("#editRole").removeClass('hidden');
  175. $("#newRole").addClass('hidden');
  176. $("#hfIsPublic").val(String(role.IsPublic));
  177. $("#hfAutoAssignment").val(String(role.AutoAssignment));
  178. $('#select_InternalRole').val(role.InternalRoleId);
  179. });
  180. }
  181. });
  182. }
  183. editRole(roleid, installedappid) {
  184. var appinstalledid = installedappid;
  185. var instance = Unibase.Platform.Permissions.Components.EditRole.Instance();
  186. instance.appSettings.InstalledAppId = Number(appinstalledid);
  187. this.navigationHelper.popup(roleid, '', instance, null, Platform.Helpers.Size.DockLeft);
  188. }
  189. ispublicChange(status) {
  190. $('#hfIsPublic').val(status);
  191. }
  192. isAutoAssignmentChange(status) {
  193. $('#hfAutoAssignment').val(status);
  194. }
  195. SaveRole(containerid, roleid, InstalledAppId) {
  196. if (roleid == 0) {
  197. $('#hf_RoleId').val(0);
  198. }
  199. if ($('#hfIsPublic').val() == '') {
  200. $('#hfIsPublic').val("false");
  201. }
  202. if ($('#hfAutoAssignment').val() == '') {
  203. $('#hfAutoAssignment').val("false");
  204. }
  205. if (Number($('#select_InternalRole').val()) == 0) {
  206. MessageHelper.Instance().showError("Please Select InternalRole", "divRoleError");
  207. return false;
  208. }
  209. let reqObj = new Permissions.Requests.Role();
  210. reqObj.RoleId = Number(roleid);
  211. reqObj.RoleName = String($('#txtRoleName').val());
  212. reqObj.Description = String($('#txtDescription').val());
  213. reqObj.IsPublic = Boolean($('#hfIsPublic').val());
  214. reqObj.AutoAssignment = Boolean($('#hfAutoAssignment').val());
  215. reqObj.InternalRoleId = Number($('#select_InternalRole').val());
  216. Permissions.Managers.PermissionManager.Instance().saveRole(reqObj).then(function (response) {
  217. if (response.status == Unibase.Data.Status.Error) {
  218. MessageHelper.Instance().showError(response.message, "divRoleError");
  219. }
  220. else {
  221. MessageHelper.Instance().showSuccess(response.message, "divRoleError");
  222. $('#' + containerid).modal('hide');
  223. $('#' + containerid).remove();
  224. }
  225. Unibase.Platform.Permissions.Components.Permission.Instance().loadRoles(InstalledAppId, "");
  226. });
  227. }
  228. static Instance() {
  229. if (this.instance === undefined) {
  230. this.instance = new EditRole();
  231. }
  232. return this.instance;
  233. }
  234. }
  235. Components.EditRole = EditRole;
  236. })(Components = Permissions.Components || (Permissions.Components = {}));
  237. })(Permissions = Platform.Permissions || (Platform.Permissions = {}));
  238. })(Platform = Unibase.Platform || (Unibase.Platform = {}));
  239. })(Unibase || (Unibase = {}));