Fix for EMM-1575

revert-70aa11f8
kamidu 8 years ago
parent 75df243a33
commit 0ab9db2afd

@ -103,12 +103,12 @@
<label class=" hidden error email-invalid" for="summary">Invalid Email <label class=" hidden error email-invalid" for="summary">Invalid Email
Address.</label> Address.</label>
</div> </div>
{{#if canViewRoles}}
<label class="wr-input-label" <label class="wr-input-label"
title="Optional field that can have 0-to-many roles for the user"> title="Optional field that can have 0-to-many roles for the user">
User Roles User Roles
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span> <span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</label> </label>
{{#if canViewRoles}}
<div class="wr-input-control"> <div class="wr-input-control">
<select id="roles" class="form-control select2" multiple="multiple"> <select id="roles" class="form-control select2" multiple="multiple">
{{#each roles}} {{#each roles}}

@ -179,6 +179,7 @@ $("#userStore").change(
$("select option:selected").each(function () { $("select option:selected").each(function () {
str += $(this).text() + ""; str += $(this).text() + "";
}); });
if ($("#roles").length > 0) {
var getRolesAPI = deviceMgtAPIsBasePath + "/roles?user-store=" + str + "&limit=100"; var getRolesAPI = deviceMgtAPIsBasePath + "/roles?user-store=" + str + "&limit=100";
invokerUtil.get( invokerUtil.get(
@ -200,6 +201,8 @@ $("#userStore").change(
} }
); );
}
}).change(); }).change();
$(document).ready(function () { $(document).ready(function () {
@ -224,7 +227,10 @@ $(document).ready(function () {
var firstname = firstnameInput.val(); var firstname = firstnameInput.val();
var lastname = lastnameInput.val(); var lastname = lastnameInput.val();
var emailAddress = $("input#emailAddress").val(); var emailAddress = $("input#emailAddress").val();
var roles = $("select#roles").val(); var roles ;
if ($("#roles").length > 0) {
roles = $("select#roles").val();
}
var errorMsgWrapper = "#user-create-error-msg"; var errorMsgWrapper = "#user-create-error-msg";
var errorMsg = "#user-create-error-msg span"; var errorMsg = "#user-create-error-msg span";
if (!username) { if (!username) {
@ -272,7 +278,9 @@ $(document).ready(function () {
$("input#firstname").val(""); $("input#firstname").val("");
$("input#lastname").val(""); $("input#lastname").val("");
$("input#email").val(""); $("input#email").val("");
if ($("#roles").length > 0) {
$("select#roles").select2("val", ""); $("select#roles").select2("val", "");
}
// Refreshing with success message // Refreshing with success message
$("#user-create-form").addClass("hidden"); $("#user-create-form").addClass("hidden");
$("#user-created-msg").removeClass("hidden"); $("#user-created-msg").removeClass("hidden");

@ -36,7 +36,7 @@
{{/zone}} {{/zone}}
{{#zone "content"}} {{#zone "content"}}
{{#if canManage}} {{#if canManage}}
<!-- content/body --> <!-- content/body -->
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
@ -51,7 +51,8 @@
<div id="user-create-error-msg" class="alert alert-danger hidden" role="alert"> <div id="user-create-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span> <i class="icon fw fw-error"></i><span></span>
</div> </div>
<label class="wr-input-label" title="Select the domain of the user store from the drop-down given below. The domain of the default user store is PRIMARY"> <label class="wr-input-label"
title="Select the domain of the user store from the drop-down given below. The domain of the default user store is PRIMARY">
User Store Domain User Store Domain
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span> <span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</label> </label>
@ -94,8 +95,10 @@
<span class="glyphicon glyphicon-remove form-control-feedback hidden emailError"></span> <span class="glyphicon glyphicon-remove form-control-feedback hidden emailError"></span>
<label class=" hidden error email-required" for="summary">This field is <label class=" hidden error email-required" for="summary">This field is
required.</label> required.</label>
<label class=" hidden error email-invalid" for="summary">Invalid Email Address.</label> <label class=" hidden error email-invalid" for="summary">Invalid Email
Address.</label>
</div> </div>
{{#if canViewRoles}}
<label class="wr-input-label" <label class="wr-input-label"
title="Optional field that can have 0-to-many roles for the user"> title="Optional field that can have 0-to-many roles for the user">
User Roles User Roles
@ -109,6 +112,7 @@
{{/each}} {{/each}}
</select> </select>
</div> </div>
{{/if}}
</div> </div>
</div> </div>
<br> <br>
@ -137,14 +141,14 @@
</div> </div>
</div> </div>
<!-- /content/body --> <!-- /content/body -->
{{else}} {{else}}
<h1 class="page-sub-title"> <h1 class="page-sub-title">
Permission Denied Permission Denied
</h1> </h1>
<br> <br>
You not authorized to enter User Management Section. You not authorized to enter User Management Section.
<br> <br>
{{/if}} {{/if}}
{{/zone}} {{/zone}}

@ -63,6 +63,9 @@ function onRequest() {
if (userModule.isAuthorized("/permission/admin/device-mgt/users/manage")) { if (userModule.isAuthorized("/permission/admin/device-mgt/users/manage")) {
page.canManage = true; page.canManage = true;
} }
if (userModule.isAuthorized("/permission/admin/device-mgt/roles/view")) {
page.canViewRoles = true;
}
page["usernameJSRegEx"] = devicemgtProps["userValidationConfig"]["usernameJSRegEx"]; page["usernameJSRegEx"] = devicemgtProps["userValidationConfig"]["usernameJSRegEx"];
page["usernameRegExViolationErrorMsg"] = devicemgtProps["userValidationConfig"]["usernameRegExViolationErrorMsg"]; page["usernameRegExViolationErrorMsg"] = devicemgtProps["userValidationConfig"]["usernameRegExViolationErrorMsg"];

@ -75,7 +75,7 @@ var disableInlineError = function (inputField, errorMsg, errorSign) {
*/ */
validateInline["user-name"] = function () { validateInline["user-name"] = function () {
var usernameinput = $("input#username"); var usernameinput = $("input#username");
if (inputIsValid( usernameinput.data("regex"), usernameinput.val())) { if (inputIsValid(usernameinput.data("regex"), usernameinput.val())) {
disableInlineError("usernameInputField", "usernameEmpty", "usernameError"); disableInlineError("usernameInputField", "usernameEmpty", "usernameError");
} else { } else {
enableInlineError("usernameInputField", "usernameEmpty", "usernameError"); enableInlineError("usernameInputField", "usernameEmpty", "usernameError");
@ -113,12 +113,12 @@ validateInline["last-name"] = function () {
validateInline["emailAddress"] = function () { validateInline["emailAddress"] = function () {
var email = $("#emailAddress").val(); var email = $("#emailAddress").val();
if (!email) { if (!email) {
enableInlineError("emailField", "email-required" , "emailError"); enableInlineError("emailField", "email-required", "emailError");
} else if (emailIsValid(email)) { } else if (emailIsValid(email)) {
disableInlineError("emailField", "email-required" , "emailError"); disableInlineError("emailField", "email-required", "emailError");
disableInlineError("emailField", "email-invalid" , "emailError"); disableInlineError("emailField", "email-invalid", "emailError");
} else { } else {
enableInlineError("emailField", "email-invalid" , "emailError"); enableInlineError("emailField", "email-invalid", "emailError");
} }
}; };
@ -148,8 +148,8 @@ clearInline["last-name"] = function () {
* clear Validation messages when gain focus to the field. * clear Validation messages when gain focus to the field.
*/ */
clearInline["emailAddress"] = function () { clearInline["emailAddress"] = function () {
disableInlineError("emailField", "email-required" , "emailError"); disableInlineError("emailField", "email-required", "emailError");
disableInlineError("emailField", "email-invalid" , "emailError"); disableInlineError("emailField", "email-invalid", "emailError");
}; };
/** /**
@ -168,11 +168,16 @@ $(document).ready(function () {
$("select.select2[multiple=multiple]").select2({ $("select.select2[multiple=multiple]").select2({
tags: false tags: false
}); });
var roleList = $("#roles").attr("selectedVals").trim().replace(/ /g, ""); var roleList, roleArr;
if ($("#roles").length > 0) {
roleList = $("#roles").attr("selectedVals").trim().replace(/ /g, "");
roleList = roleList.replace(/(\r\n|\n|\r)/gm, ""); roleList = roleList.replace(/(\r\n|\n|\r)/gm, "");
var roleArr = roleList.split(","); roleArr = roleList.split(",");
$("#roles").val(roleArr).trigger("change"); }
if ($("#roles").length > 0) {
$("#roles").val(roleArr).trigger("change");
}
/** /**
* Following click function would execute * Following click function would execute
* when a user clicks on "Add User" button * when a user clicks on "Add User" button
@ -188,7 +193,10 @@ $(document).ready(function () {
var firstname = firstnameInput.val(); var firstname = firstnameInput.val();
var lastname = lastnameInput.val(); var lastname = lastnameInput.val();
var emailAddress = $("input#emailAddress").val(); var emailAddress = $("input#emailAddress").val();
var roles;
if ($("#roles").length > 0) {
var roles = $("select#roles").val(); var roles = $("select#roles").val();
}
var errorMsgWrapper = "#user-create-error-msg"; var errorMsgWrapper = "#user-create-error-msg";
var errorMsg = "#user-create-error-msg span"; var errorMsg = "#user-create-error-msg span";
if (!username) { if (!username) {
@ -255,27 +263,27 @@ $(document).ready(function () {
} }
}); });
$("#emailAddress").focus(function() { $("#emailAddress").focus(function () {
clearInline["emailAddress"](); clearInline["emailAddress"]();
}); });
$("#emailAddress").blur(function() { $("#emailAddress").blur(function () {
validateInline["emailAddress"](); validateInline["emailAddress"]();
}); });
$("#lastname").focus(function() { $("#lastname").focus(function () {
clearInline["last-name"](); clearInline["last-name"]();
}); });
$("#lastname").blur(function() { $("#lastname").blur(function () {
validateInline["last-name"](); validateInline["last-name"]();
}); });
$("#firstname").focus(function() { $("#firstname").focus(function () {
clearInline["first-name"](); clearInline["first-name"]();
}); });
$("#firstname").blur(function() { $("#firstname").blur(function () {
validateInline["first-name"](); validateInline["first-name"]();
}); });
}); });
Loading…
Cancel
Save