Add tableActions component
Creating a separate table actions component to allow
row action customizations like disabling certain
actions and rendering different icons.
Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com>
Change-Id: I85e96045af27701f5ecc4af9bf824e248abccbf5
diff --git a/app/users/controllers/user-accounts-controller.js b/app/users/controllers/user-accounts-controller.js
index 3d63d69..b5ed1a5 100644
--- a/app/users/controllers/user-accounts-controller.js
+++ b/app/users/controllers/user-accounts-controller.js
@@ -19,16 +19,24 @@
$scope.tableModel = {};
$scope.tableModel.data = [];
- $scope.tableModel.header = ['Username', 'Privilege', 'Account status']
- $scope.tableModel.actions = ['Edit', 'Delete'];
+ $scope.tableModel.header = ['Username', 'Privilege', 'Account status'];
/**
* Data table mapper
* @param {*} user
+ * @returns user
*/
function mapTableData(user) {
- let accountStatus =
+ const accountStatus =
user.Locked ? 'Locked' : user.Enabled ? 'Enabled' : 'Disabled';
+ const editAction = {type: 'Edit', enabled: true, file: 'icon-edit.svg'};
+ const deleteAction = {
+ type: 'Delete',
+ enabled: user.UserName === 'root' ? false : true,
+ file: 'icon-trashcan.svg'
+ };
+
+ user.actions = [editAction, deleteAction];
user.uiData = [user.UserName, user.RoleId, accountStatus];
return user;
}