-
-{{#zone "bottomJs"}}
- {{js "js/bottomJs.js"}}
-{{/zone}}
+
+ {{#zone "bottomJs"}}
+ {{js "js/bottomJs.js"}}
+ {{/zone}}
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 9bca327597c..d5c363ef1fa 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
@@ -29,6 +29,7 @@ function onRequest(context) {
var roleName = request.getParameter("rolename");
var response;
var userStore;
+ context.isCloud = deviceMgtProps.isCloud;
if (roleName) {
if (roleName.indexOf("/") > -1) {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js
index 7dae9199692..6ae0e8016f9 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js
@@ -83,18 +83,18 @@ clearInline["role-name"] = function () {
*/
validateInline["role-name"] = function () {
var rolenameinput = $("input#rolename");
- if (inputIsValid( rolenameinput.data("regex"), rolenameinput.val())) {
+ if (inputIsValid(rolenameinput.data("regex"), rolenameinput.val())) {
disableInlineError("roleNameField", "rolenameEmpty", "rolenameError");
} else {
enableInlineError("roleNameField", "rolenameEmpty", "rolenameError");
}
};
-function formatRepo (user) {
+function formatRepo(user) {
if (user.loading) {
return user.text
}
- if (!user.username){
+ if (!user.username) {
return;
}
var markup = '
' +
@@ -102,7 +102,7 @@ function formatRepo (user) {
'
' +
'
' + user.username + '
';
if (user.firstname) {
- markup += '
' + user.firstname + '
';
+ markup += '
' + user.firstname + '
';
}
if (user.emailAddress) {
markup += '
' + user.emailAddress + '
';
@@ -111,14 +111,14 @@ function formatRepo (user) {
return markup;
}
-function formatRepoSelection (user) {
+function formatRepoSelection(user) {
return user.username || user.text;
}
$(document).ready(function () {
var appContext = $("#app-context").data("app-context");
$("#users").select2({
- multiple:true,
+ multiple: true,
tags: false,
ajax: {
url: appContext + "/api/invoker/execute/",
@@ -148,23 +148,29 @@ $(document).ready(function () {
},
cache: true
},
- escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
+ escapeMarkup: function (markup) {
+ return markup;
+ }, // let our custom formatter work
minimumInputLength: 1,
templateResult: formatRepo, // omitted for brevity, see the source of this page
templateSelection: formatRepoSelection // omitted for brevity, see the source of this page
});
-
/**
* Following click function would execute
* when a user clicks on "Add Role" button
* on Add Role page in WSO2 MDM Console.
*/
- $("button#add-role-btn").click(function() {
+ $("button#add-role-btn").click(function () {
+ var isCloud = $("#role-create-form").data("cloud");
var rolenameInput = $("input#rolename");
var roleName = rolenameInput.val();
var currentRoleName = $("input#rolename").data("currentrole");
+ if (isCloud) {
+
+ currentRoleName = "devicemgt" + currentRoleName;
+ }
var domain = $("#domain").val();
var errorMsgWrapper = "#role-create-error-msg";
var errorMsg = "#role-create-error-msg span";
@@ -182,12 +188,17 @@ $(document).ready(function () {
$(errorMsgWrapper).removeClass("hidden");
} else {
var addRoleFormData = {};
- addRoleFormData.roleName = roleName;
+ if (isCloud) {
+ addRoleFormData.roleName = "devicemgt" + roleName;
+ } else {
+ addRoleFormData.roleName = roleName;
+ }
var addRoleAPI = apiBasePath + "/roles/" + encodeURIComponent(currentRoleName);
- if (domain != "PRIMARY"){
+ if (domain != "PRIMARY") {
addRoleFormData.roleName = domain + "/" + roleName;
addRoleAPI = addRoleAPI + "?user-store=" + encodeURIComponent(domain);
}
+
invokerUtil.put(
addRoleAPI,
addRoleFormData,
@@ -201,6 +212,7 @@ $(document).ready(function () {
$("#role-created-msg").removeClass("hidden");
}
}, function (data) {
+
var payload = JSON.parse(data.responseText);
$(errorMsg).text(payload.message);
$(errorMsgWrapper).removeClass("hidden");
@@ -209,11 +221,11 @@ $(document).ready(function () {
}
});
- $("#rolename").focus(function() {
+ $("#rolename").focus(function () {
clearInline["role-name"]();
});
- $("#rolename").blur(function() {
+ $("#rolename").blur(function () {
validateInline["role-name"]();
});