From 25e0b989d298b8aa55ee924b22b986f1ef44ef3b Mon Sep 17 00:00:00 2001 From: megala21 Date: Thu, 18 May 2017 14:17:03 +0530 Subject: [PATCH 1/2] Fixing issues in group sharing --- .../cdmf.page.groups/public/js/listing.js | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js index 1fc2eec829..b88f52b8dc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js @@ -112,7 +112,7 @@ function toTitleCase(str) { }); } -function htmlspecialchars(text) { +function htmlspecialchars(text){ return jQuery('
').text(text).html(); } @@ -402,17 +402,17 @@ function attachEvents() { var shareGroupNewRoleFromSelectionLink = $("a#share-group-new-role-from-selection"); shareGroupNewRoleFromSelectionLink.click(function () { - var roles = []; - $('.modal .roleCheckBoxes').each( - function () { - if ($(this).is(':checked')) { - roles.push($(this).data('role-name')); - } - } - ); - addNewRole(roles); - // $(modalPopupContent).html($('#share-group-w3-modal-content').html()); - // createNewRole(roles); + var roles = $("#roles").val(); + if (roles && roles.length >= 2) { + addNewRole(roles); + } else { + var errorMsgWrapper = "#notification-error-msg"; + var errorMsg = "#notification-error-msg span"; + $(errorMsg).text("To create a new role with the combination of roles, at least two roles should be" + + " selected."); + $(errorMsgWrapper).removeClass("hidden"); + + } }); }); @@ -534,8 +534,8 @@ function listAllRoles(groupId) { html += ''; $("#rolesListing").html(html); markAlreadySavedUsersRoles(groupId); - $("select.select2[multiple=multiple]").select2({ - tags: false + $("select.select2[multiple=multiple]").select2({tags: false}).on("select2:select", function () { + $("#notification-error-msg").addClass("hidden"); }); } else { $("#rolesListing").html("No roles available"); @@ -633,9 +633,6 @@ function displayErrors(jqXHR) { }); } else { $(modalPopupContent).html($('#group-unexpected-error-content').html()); - if (jqXHR.responseText) { - $('#unexp-error-msg').html(jqXHR.responseText.replace(new RegExp("\"", 'g'), "")); - } $("a#group-unexpected-error-link").click(function () { hidePopup(); }); From f41a692bf319e6f69eae87639bc7dbf7bf6f377f Mon Sep 17 00:00:00 2001 From: megala21 Date: Thu, 18 May 2017 14:21:24 +0530 Subject: [PATCH 2/2] Reformatting code --- .../app/pages/cdmf.page.groups/public/js/listing.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js index b88f52b8dc..716d6f6917 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js @@ -112,7 +112,7 @@ function toTitleCase(str) { }); } -function htmlspecialchars(text){ +function htmlspecialchars(text) { return jQuery('
').text(text).html(); } @@ -411,7 +411,6 @@ function attachEvents() { $(errorMsg).text("To create a new role with the combination of roles, at least two roles should be" + " selected."); $(errorMsgWrapper).removeClass("hidden"); - } }); }); @@ -633,6 +632,9 @@ function displayErrors(jqXHR) { }); } else { $(modalPopupContent).html($('#group-unexpected-error-content').html()); + if (jqXHR.responseText) { + $('#unexp-error-msg').html(jqXHR.responseText.replace(new RegExp("\"", 'g'), "")); + } $("a#group-unexpected-error-link").click(function () { hidePopup(); });