From d9ec20372748c100a0c15493af553c58175c1c1e Mon Sep 17 00:00:00 2001 From: Megala Date: Sun, 16 Oct 2016 13:24:32 +0530 Subject: [PATCH] Fixing EMM-1755 --- .../app/pages/cdmf.page.role.edit/edit.json | 2 +- .../cdmf.page.roles/public/js/role-listing.js | 2 +- .../app/units/cdmf.unit.role.edit/edit.js | 31 ++++++------------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.edit/edit.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.edit/edit.json index 3efeeeb8e2..6959b98af0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.edit/edit.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.edit/edit.json @@ -1,5 +1,5 @@ { "version": "1.0.0", - "uri": "/role/edit/{+any}", + "uri": "/role/edit/", "layout": "cdmf.layout.default" } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js index c934cd1c8a..0f5f905ec3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js @@ -17,7 +17,7 @@ */ var loadRoleBasedActionURL = function (action, rolename) { - var href = $("#ast-container").data("app-context") + "role/" + action + "/" + rolename; + href = $("#ast-container").data("app-context") + "role/" + action + "/?rolename=" + encodeURIComponent(rolename); $(location).attr('href', href); }; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.js index 940867904f..9bca327597 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.js @@ -26,32 +26,19 @@ function onRequest(context) { var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var uri = request.getRequestURI(); - var uriMatcher = new URIMatcher(String(uri)); - var isMatched = uriMatcher.match("/{context}/role/edit/{roleName}") || - uriMatcher.match("/{context}/role/edit/{userStoreName}/{roleName}"); - var matchedElements; - var roleName; + var roleName = request.getParameter("rolename"); var response; var userStore; - if (isMatched) { - if (uriMatcher.match("/{context}/role/edit/{roleName}")) { - matchedElements = uriMatcher.elements(); - roleName = matchedElements["roleName"]; - response = userModule.getRole(roleName); - if (response["status"] == "success") { - context["role"] = response["content"]; - } + if (roleName) { + if (roleName.indexOf("/") > -1) { + userStore = roleName.substr(0, roleName.indexOf("/")); + } else { userStore = "PRIMARY"; - } else if (uriMatcher.match("/{context}/role/edit/{userStoreName}/{roleName}")) { - matchedElements = uriMatcher.elements(); - roleName = matchedElements["roleName"]; - userStore = matchedElements["userStoreName"]; - response = userModule.getRole(userStore + "/" + roleName); - if (response["status"] == "success") { - context["role"] = response["content"]; - } - + } + response = userModule.getRole(roleName); + if (response["status"] == "success") { + context["role"] = response["content"]; } context["userStore"] = userStore; context["roleNameJSRegEx"] = deviceMgtProps["roleValidationConfig"]["roleNameJSRegEx"];