Added edit buttons for User and policy views.

merge-requests/1/head
Menaka Jayawardena 7 years ago
parent 29086834eb
commit 8cac8a3bdc

@ -37,6 +37,14 @@
</li> </li>
{{/zone}} {{/zone}}
{{#zone "navbarActions"}}
{{#if canEdit}}
<li id="policy-edit">
</li>
{{/if}}
{{/zone}}
{{#zone "content"}} {{#zone "content"}}
{{unit "cdmf.unit.device.operation-mod"}} {{unit "cdmf.unit.device.operation-mod"}}
{{unit "cdmf.unit.policy.view"}} {{unit "cdmf.unit.policy.view"}}

@ -17,7 +17,14 @@
*/ */
function onRequest(context) { function onRequest(context) {
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var utility = require("/app/modules/utility.js")["utility"]; var utility = require("/app/modules/utility.js")["utility"];
var deviceType = request.getParameter("type"); var deviceType = request.getParameter("type");
return {"deviceTypePolicyView": utility.getTenantedDeviceUnitName(deviceType, "policy-view")};
var canEdit = false;
if(userModule.isAuthorized("/permission/admin/device-mgt/policy/manage")) {
canEdit = true;
}
return {"deviceTypePolicyView": utility.getTenantedDeviceUnitName(deviceType, "policy-view"), "canEdit": canEdit};
} }

@ -35,6 +35,21 @@
</li> </li>
{{/zone}} {{/zone}}
{{#zone "navbarActions"}}
{{#if canEdit}}
<li>
<a href="{{@app.context}}/user/edit?username={{user.username}}" data-username="{{user.username}}"
data-click-event="edit-form" class="btn padding-reduce-on-grid-view edit-user-link">
<span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-edit fw-stack-1x"></i>
</span>
Edit
</a>
</li>
{{/if}}
{{/zone}}
{{#zone "content"}} {{#zone "content"}}
{{#if canView}} {{#if canView}}
{{#if exists}} {{#if exists}}

@ -48,7 +48,13 @@ function onRequest(context) {
canView = true; canView = true;
} }
var canEdit = false;
if (userModule.isAuthorized("/permission/admin/device-mgt/users/edit")) {
canEdit = true;
}
var isCloud = deviceMgtProps.isCloud; var isCloud = deviceMgtProps.isCloud;
return {"exists": isExsistingUser, "user": user, "userRoles": userRoles, "devices": devices, "canView": canView, "isCloud" : isCloud}; return {"exists": isExsistingUser, "user": user, "userRoles": userRoles, "devices": devices, "canEdit": canEdit,
"canView": canView, "isCloud" : isCloud};
} }

@ -66,6 +66,7 @@ var displayPolicy = function (policyPayloadObj) {
$("#roles-row").addClass("hidden"); $("#roles-row").addClass("hidden");
} }
var policyId = policyPayloadObj["id"];
var deviceType = policy["platform"]; var deviceType = policy["platform"];
var policyOperations = $("#policy-operations"); var policyOperations = $("#policy-operations");
var policyViewTemplateSrc = $(policyOperations).data("template"); var policyViewTemplateSrc = $(policyOperations).data("template");
@ -110,6 +111,23 @@ var displayPolicy = function (policyPayloadObj) {
if (!hasPolicyProfileScript) { if (!hasPolicyProfileScript) {
populateGenericProfileOperations(policyPayloadObj["profile"]["profileFeaturesList"]); populateGenericProfileOperations(policyPayloadObj["profile"]["profileFeaturesList"]);
} }
var policyEditContent =
"<a href=" + context + "/policy/edit?id=" + policyId + "&deviceType=" + deviceType + "\n" +
"data-id=" + policyId +
"data-toggle=\"tooltip\"\n" +
"data-original-title=\"Edit\"\n" +
"data-click-event=\"remove-form\"\n" +
"class=\"btn remove-margin padding-reduce-on-grid-view policy-update-link\">" +
"<span class=\"fw-stack\">" +
"<i class=\"fw fw-circle-outline fw-stack-2x\"></i>" +
"<i class=\"fw fw-edit fw-stack-1x\"></i>" +
"</span>" +
" Edit" +
"</a>";
$("#policy-edit").html(policyEditContent);
}; };
/** /**

Loading…
Cancel
Save