Added check for updating admin user by typing the url + code formatting.

4.x.x
Menaka Jayawardena 7 years ago
parent 21b0ed284b
commit 54b616985e

@ -19,68 +19,80 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<!-- content --> <!-- content -->
<div id="role-create-form" data-cloud={{isCloud}} class="container col-centered wr-content"> {{#if isAdminRole}}
<div class="wr-form"> <div class="container col-centered wr-content">
<p class="page-sub-title">Edit Role</p> <div class="wr-form">
<p>Please note that * sign represents required fields of data.</p> <p class="page-sub-title">Attention!</p>
<hr/> <hr/>
<div class="row"> <br>This is an prohibited action.
<div class="col-lg-8"> </div>
<div id="role-create-error-msg" class="alert alert-danger hidden" role="alert"> </div>
<i class="icon fw fw-error"></i><span></span> {{else}}
</div> <div id="role-create-form" data-cloud={{isCloud}} class="container">
<label class="wr-input-label">Domain</label> <div class="wr-form">
<div class="wr-input-control"> <p class="page-sub-title">Edit Role</p>
<select id="domain" class="form-control select" disabled> <p>Please note that * sign represents required fields of data.</p>
<option>{{userStore}}</option> <hr/>
</select> <div class="row">
</div> <div class="col-lg-8">
<label class="wr-input-label"> <div id="role-create-error-msg" class="alert alert-danger hidden" role="alert">
Role Name * <i class="icon fw fw-error"></i><span></span>
</label> </div>
<br> <label class="wr-input-label">Domain</label>
<label class="wr-input-label" id="roleNameValidationText"> <div class="wr-input-control">
( {{roleNameHelpText}} ) <select id="domain" class="form-control select" disabled>
</label> <option>{{userStore}}</option>
{{#if isCloud}} </select>
<div id="roleNameField" class="form-group wr-input-control input-group"> </div>
<!--suppress HtmlFormInputWithoutLabel --> <label class="wr-input-label">
<span class="input-group-addon" id="basic-addon1">devicemgt</span> Role Name *
<input aria-describedby="basic-addon1" type="text" id="rolename" </label>
data-regex="{{roleNameJSRegEx}}" <br>
data-errormsg="{{roleNameRegExViolationErrorMsg}}" class="form-control" <label class="wr-input-label" id="roleNameValidationText">
data-currentrole="{{role.roleName}}" ( {{roleNameHelpText}} )
value="{{role.roleName}}"/> </label>
{{#if isCloud}}
{{else}} <div id="roleNameField" class="form-group wr-input-control input-group">
<div id="roleNameField" class="form-group wr-input-control"> <!--suppress HtmlFormInputWithoutLabel -->
<input type="text" id="rolename" data-regex="{{roleNameJSRegEx}}" <span class="input-group-addon" id="basic-addon1">devicemgt</span>
data-errormsg="{{roleNameRegExViolationErrorMsg}}" class="form-control" <input aria-describedby="basic-addon1" type="text" id="rolename"
data-currentrole="{{role.roleName}}" data-regex="{{roleNameJSRegEx}}"
value="{{role.roleName}}"/> data-errormsg="{{roleNameRegExViolationErrorMsg}}" class="form-control"
{{/if}} data-currentrole="{{role.roleName}}"
value="{{role.roleName}}"/>
</div>
{{else}}
<div id="roleNameField" class="form-group wr-input-control">
<input type="text" id="rolename" data-regex="{{roleNameJSRegEx}}"
data-errormsg="{{roleNameRegExViolationErrorMsg}}" class="form-control"
data-currentrole="{{role.roleName}}"
value="{{role.roleName}}"/>
</div>
{{/if}}
<span class=" rolenameError hidden glyphicon glyphicon-remove form-control-feedback"></span> <span class=" rolenameError hidden glyphicon glyphicon-remove form-control-feedback"></span>
<label class="error rolenameEmpty hidden" for="summary">Role name is required & Should be in <label class="error rolenameEmpty hidden" for="summary">Role name is required & Should be in
minimum 3 characters long and do not minimum 3 characters long and do not
include any whitespaces. </label> include any whitespaces. </label>
<br>
<button id="add-role-btn" class="wr-btn">Update Role</button>
<div id="role-created-msg" class="container col-centered wr-content hidden">
<div class="wr-form">
<p class="page-sub-title">Role was updated successfully.</p>
<br>You will be redirected to Roles Listing Page in a moment.
</div>
</div>
<!-- /content -->
<div id="app-context" data-app-context="{{@app.context}}" class="hidden"></div>
</div> </div>
</div> </div>
</div>
<br>
<button id="add-role-btn" class="wr-btn">Update Role</button>
</div>
</div>
<div id="role-created-msg" class="container col-centered wr-content hidden">
<div class="wr-form">
<p class="page-sub-title">Role was updated successfully.</p>
<br>You will be redirected to Roles Listing Page in a moment.
</div> </div>
</div> </div>
<!-- /content --> {{/if}}
<div id="app-context" data-app-context="{{@app.context}}" class="hidden"></div>
</div>
</div> </div>
<!-- /content/body --> </div>
{{#zone "bottomJs"}} <!-- /content/body -->
{{js "js/bottomJs.js"}} {{#zone "bottomJs"}}
{{/zone}} {{js "js/bottomJs.js"}}
{{/zone}}

@ -31,6 +31,8 @@ function onRequest(context) {
var userStore; var userStore;
context.isCloud = deviceMgtProps.isCloud; context.isCloud = deviceMgtProps.isCloud;
var isAdminRole = deviceMgtProps["adminRole"] === roleName;
if (roleName) { if (roleName) {
if (roleName.indexOf("/") > -1) { if (roleName.indexOf("/") > -1) {
userStore = roleName.substr(0, roleName.indexOf("/")); userStore = roleName.substr(0, roleName.indexOf("/"));
@ -41,6 +43,7 @@ function onRequest(context) {
if (response["status"] == "success") { if (response["status"] == "success") {
context["role"] = response["content"]; context["role"] = response["content"];
} }
context["isAdminRole"] = isAdminRole;
context["userStore"] = userStore; context["userStore"] = userStore;
context["roleNameJSRegEx"] = deviceMgtProps["roleValidationConfig"]["roleNameJSRegEx"]; context["roleNameJSRegEx"] = deviceMgtProps["roleValidationConfig"]["roleNameJSRegEx"];
context["roleNameHelpText"] = deviceMgtProps["roleValidationConfig"]["roleNameHelpMsg"]; context["roleNameHelpText"] = deviceMgtProps["roleValidationConfig"]["roleNameHelpMsg"];

Loading…
Cancel
Save