@@ -24,15 +23,6 @@
{{organization.uid}} |
{{organization.created_at | date: 'dd/MM/yyyy'}} |
-
-
-
- {{ userRoles.keyFromRole(organization.role) | translate }}
-
-
-
-
- |
diff --git a/src/app/components/mnoe-users-list/mno-users-list.coffee b/src/app/components/mnoe-users-list/mno-users-list.coffee
index a84c9995..3be089d1 100644
--- a/src/app/components/mnoe-users-list/mno-users-list.coffee
+++ b/src/app/components/mnoe-users-list/mno-users-list.coffee
@@ -11,7 +11,7 @@
# Variables initialization
scope.users =
search: ''
- sortAttr: 'created_at'
+ sortAttr: 'created_at.desc'
nbItems: 10
page: 1
pageChangedCb: (nbItems, page) ->
@@ -79,7 +79,7 @@
fetchUsers(scope.users.nbItems, 0, scope.users.sortAttr)
# Fetch users
- fetchUsers = (limit, offset, sort = 'surname') ->
+ fetchUsers = (limit, offset, sort = 'created_at.desc') ->
scope.users.loading = true
MnoeCurrentUser.getUser().then( ->
params = if MnoeAdminConfig.isAccountManagerEnabled()
diff --git a/src/app/views/user/user.controller.coffee b/src/app/views/user/user.controller.coffee
index f01daf7f..9014518f 100644
--- a/src/app/views/user/user.controller.coffee
+++ b/src/app/views/user/user.controller.coffee
@@ -1,6 +1,8 @@
-@App.controller 'UserController', ($stateParams, MnoeUsers) ->
+@App.controller 'UserController', ($stateParams, MnoeUsers, UserRoles, $translate, toastr, MnoErrorsHandler) ->
'ngInject'
vm = this
+ vm.user = {}
+ vm.orgSearchParams = { 'where[users.id]': $stateParams.userId }
# Get the user
MnoeUsers.get($stateParams.userId).then(
@@ -10,5 +12,73 @@
phone = vm.user.phone
if phone && countryCode
vm.user.phone = '+' + countryCode + phone
+
+ # These bindings are so that we can add additional fields with functionality to the organization table.
+ vm.orgTableBindings = {
+ userRoles: UserRoles
+ user: vm.user
+
+ editRole: (organization) ->
+ # Keep track of old roles when editing organization's roles.
+ organization.beforeEditRole = organization.role
+ organization.editMode = true
+
+ exitEditRole: (organization) ->
+ organization.role = organization.beforeEditRole
+ organization.editMode = false
+
+ updateUserRole: (organization, user) ->
+ user.isUpdatingRole = true
+ # The role must be set on the user for #updateUserRole.
+ user.role = organization.role
+
+ MnoeUsers.updateUserRole(organization, user).then(
+ () ->
+ $translate(UserRoles.keyFromRole(user.role)).then((tls) ->
+ toastr.success('mnoe_admin_panel.dashboard.users.widget.local_list.role_update_success', {extraData: {user: "#{user.email}", role: tls}})
+ )
+ (error) ->
+ organization.role = organization.beforeEditRole
+ toastr.error('mnoe_admin_panel.dashboard.users.widget.local_list.role_update_error')
+ MnoErrorsHandler.processServerError(error)
+ ).finally(() ->
+ # So that the organization/user reverts back to non-editing view.
+ organization.beforeEditRole = null
+ organization.isUpdatingRole = false
+ organization.editMode = false
+ )
+ }
)
+
+ $translate('mnoe_admin_panel.dashboard.organization.widget.local_list.search_organizations.table.role')
+ .then((translation) ->
+ vm.orgTableFields= [
+ {
+ header: translation
+ style: {
+ width: '130px'
+ }
+ skip_natural: false
+ render: (organization, bindings) ->
+ template: "
+