@@ -120,6 +105,7 @@
{{/zone}}
{{#zone "bottomJs"}}
+
{{js "js/role-listing.js"}}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/js/role-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/js/role-listing.js
index c47045e309..1915c07184 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/js/role-listing.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/js/role-listing.js
@@ -21,158 +21,22 @@ var loadRoleBasedActionURL = function (action, rolename) {
$(location).attr('href', href);
};
-var apiBasePath = "/api/device-mgt/v1.0";
-
-/**
- * Following function would execute
- * when a user clicks on the list item
- * initial mode and with out select mode.
- */
-function InitiateViewOption() {
- $(location).attr('href', $(this).data("url"));
-}
-
-/**
- * Sorting function of roles
- * listed on Role Management page in WSO2 Devicemgt Console.
- */
-
-//var loadPaginatedObjects = function (objectGridId, objectGridContainer, objectGridTemplateSrc, serviceURL, callback) {
-// var templateSrc = $(objectGridTemplateSrc).attr("src");
-// $.template(objectGridId, templateSrc, function (template) {
-// invokerUtil.get(serviceURL,
-// function (data) {
-// data = callback(data);
-// if (data.length > 0 && data != null) {
-// $('#ast-container').removeClass('hidden');
-// $('#role-listing-status').hide();
-// for (var i = 0; i < data.viewModel.roles.length; i++) {
-// data.viewModel.roles[i].adminRole = $("#role-table").data("role");
-// }
-// var content = template(data.viewModel);
-// $(objectGridContainer).html(content);
-// if (isInit) {
-// $('#role-grid').datatables_extended_serverside_paging();
-// isInit = false;
-// }
-// $("#dt-select-all").addClass("hidden");
-// $(".icon .text").res_text(0.2);
-// } else {
-// $('#ast-container').addClass('hidden');
-// $('#role-listing-status-msg').text('No roles are available to be displayed.');
-// $('#role-listing-status').show();
-// }
-//
-// //$(objectGridId).datatables_extended();
-// }, function (message) {
-// $('#ast-container').addClass('hidden');
-// $('#role-listing-status-msg').text('Invalid search query. Try again with a valid search ' +
-// 'query');
-// $('#role-listing-status').show();
-// });
-// });
-//};
-
-function loadRoles() {
- var loadingContent = $("#loading-content");
- loadingContent.show();
-
- var dataFilter = function (data) {
- data = JSON.parse(data);
-
- var objects = [];
-
- $(data.roles).each(function( index ) {
- objects.push({name: data.roles[index], DT_RowId : "role-" + data.roles[index]})
- });
-
- var json = {
- "recordsTotal": data.count,
- "recordsFiltered": data.count,
- "data": objects
- };
-
- return JSON.stringify(json);
- };
-
- //noinspection JSUnusedLocalSymbols
- var fnCreatedRow = function (nRow, aData, iDataIndex) {
- $(nRow).attr('data-type', 'selectable');
- };
-
- //noinspection JSUnusedLocalSymbols
- var columns = [
- {
- class: "remove-padding icon-only content-fill",
- data: null,
- defaultContent: '
'
- },
- {
- class: "fade-edge remove-padding-top",
- data: "name",
- defaultContent: ''
- },
- {
- class: "text-right content-fill text-left-on-grid-view no-wrap",
- data: null,
- render: function (data, type, row, meta) {
- return '
' +
- '' +
- '' +
- '' +
- '' +
- '' +
- '' +
- '' +
- '' +
- ' Edit' +
- '' +
- '
' +
- '' +
- '' +
- '' +
- '' +
- '' +
- '' +
- '' +
- '' +
- ' Edit Permission' +
- '' +
- '
' +
- '' +
- '' +
- '' +
- '' +
- ' Remove' +
- '';
- }
+$(function () {
+ var sortableElem = '.wr-sortable';
+ $(sortableElem).sortable({
+ beforeStop: function () {
+ $(this).sortable('toArray');
}
- ];
-
- var options = {
- "placeholder": "Search By Role Name",
- "searchKey" : "filter"
- };
-
- $('#role-grid').datatables_extended_serverside_paging(null, '/api/device-mgt/v1.0/roles', dataFilter, columns, fnCreatedRow, null, options);
-
- loadingContent.hide();
-
-}
+ });
+ $(sortableElem).disableSelection();
+});
+var apiBasePath = "/api/device-mgt/v1.0";
var modalPopup = ".wr-modalpopup";
var modalPopupContainer = modalPopup + " .modalpopup-container";
var modalPopupContent = modalPopup + " .modalpopup-content";
var body = "body";
-var isInit = true;
+$(".icon .text").res_text(0.2);
/*
@@ -199,6 +63,119 @@ function hidePopup() {
$(modalPopup).hide();
}
+/**
+ * Following function would execute
+ * when a user clicks on the list item
+ * initial mode and with out select mode.
+ */
+function InitiateViewOption() {
+ $(location).attr('href', $(this).data("url"));
+}
+
+function loadRoles() {
+ var loadingContent = $("#loading-content");
+ loadingContent.show();
+
+ var dataFilter = function (data) {
+ data = JSON.parse(data);
+
+ var objects = [];
+
+ $(data.roles).each(function( index ) {
+ objects.push(
+ {
+ name: data.roles[index],
+ DT_RowId: "role-" + data.roles[index]
+ }
+ )
+ });
+
+ var json = {
+ "recordsTotal": data.count,
+ "recordsFiltered": data.count,
+ "data": objects
+ };
+
+ return JSON.stringify(json);
+ };
+
+ //noinspection JSUnusedLocalSymbols
+ var fnCreatedRow = function (nRow, aData, iDataIndex) {
+ $(nRow).attr('data-type', 'selectable');
+ };
+
+ //noinspection JSUnusedLocalSymbols
+ var columns = [
+ {
+ class: "remove-padding icon-only content-fill",
+ data: null,
+ defaultContent: "
" +
+ "" +
+ "
"
+ },
+ {
+ class: "fade-edge",
+ data: "name",
+ render: function (name, type, row, meta) {
+ return '
' + name + ' role
';
+ }
+ },
+ {
+ class: "text-right content-fill text-left-on-grid-view no-wrap",
+ data: null,
+ render: function (data, type, row, meta) {
+ return ' ' +
+ '
' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ ' Edit' +
+ '' +
+ '
' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ ' Edit Permission' +
+ '' +
+ '
' +
+ '' +
+ '' +
+ '' +
+ '' +
+ ' Remove' +
+ '';
+ }
+ }
+ ];
+
+ var options = {
+ "placeholder": "Search By Role Name",
+ "searchKey" : "filter"
+ };
+
+ $('#role-grid').datatables_extended_serverside_paging(null, '/api/device-mgt/v1.0/roles', dataFilter, columns, fnCreatedRow, null, options);
+ loadingContent.hide();
+
+}
+
/**
* Following click function would execute
* when a user clicks on "Remove" link
@@ -235,17 +212,6 @@ $("#role-grid").on("click", ".remove-role-link", function () {
});
});
-//$("#search-btn").click(function () {
-// var searchQuery = $("#search-by-name").val();
-// if (searchQuery.trim() != "") {
-// loadRoles(searchQuery);
-// } else {
-// loadRoles();
-// }
-//});
-
$(document).ready(function () {
- $('#role-listing-status').hide();
loadRoles();
- isInit = true;
});
\ No newline at end of file