diff --git a/app/assets/javascripts/controllers/admin/members.js.erb b/app/assets/javascripts/controllers/admin/members.js.erb index d3a7318a3..b7478619d 100644 --- a/app/assets/javascripts/controllers/admin/members.js.erb +++ b/app/assets/javascripts/controllers/admin/members.js.erb @@ -1075,7 +1075,8 @@ Application.Controllers.controller('NewAdminController', ['$state', '$scope', 'A /** * Controller used in the manager's creation page (admin view) */ -Application.Controllers.controller('NewManagerController', ['$state', '$scope', 'User', 'growl', '_t', function ($state, $scope, User, growl, _t) { +Application.Controllers.controller('NewManagerController', ['$state', '$scope', 'User', 'groupsPromise', 'tagsPromise', 'growl', '_t', + function ($state, $scope, User, groupsPromise, tagsPromise, growl, _t) { // default admin profile $scope.manager = { statistic_profile_attributes: { @@ -1094,6 +1095,12 @@ Application.Controllers.controller('NewManagerController', ['$state', '$scope', } }; + // list of all groups + $scope.groups = groupsPromise; + + // list of all tags + $scope.tags = tagsPromise; + /** * Shows the birth day datepicker * @param $event {Object} jQuery event object @@ -1112,7 +1119,7 @@ Application.Controllers.controller('NewManagerController', ['$state', '$scope', return $state.go('app.admin.members'); } , function (error) { - growl.error(_t('app.admin.admins_new.failed_to_create_admin') + JSON.stringify(error.data ? error.data : error)); + growl.error(_t('app.admin.admins_new.failed_to_create_manager') + JSON.stringify(error.data ? error.data : error)); console.error(error); } ); diff --git a/app/assets/javascripts/router.js.erb b/app/assets/javascripts/router.js.erb index 1bed35283..2ae49b5c7 100644 --- a/app/assets/javascripts/router.js.erb +++ b/app/assets/javascripts/router.js.erb @@ -938,6 +938,10 @@ angular.module('application.router', ['ui.router']) templateUrl: '<%= asset_path "admin/managers/new.html" %>', controller: 'NewManagerController' } + }, + resolve: { + groupsPromise: ['Group', function (Group) { return Group.query().$promise; }], + tagsPromise: ['Tag', function (Tag) { return Tag.query().$promise; }] } }) diff --git a/app/assets/templates/admin/members/managers.html.erb b/app/assets/templates/admin/members/managers.html.erb index 64e1028f0..26d76b686 100644 --- a/app/assets/templates/admin/members/managers.html.erb +++ b/app/assets/templates/admin/members/managers.html.erb @@ -12,23 +12,26 @@
{{ 'app.admin.members.surname' | translate }} | +{{ 'app.admin.members.surname' | translate }} | -{{ 'app.admin.members.first_name' | translate }} | +{{ 'app.admin.members.first_name' | translate }} | {{ 'app.admin.members.email' | translate }} | -{{ 'app.admin.members.phone' | translate }} | +{{ 'app.admin.members.phone' | translate }} | |
---|---|---|---|---|---|---|---|
{{ manager.profile_attributes.last_name }} | -{{ manager.profile_attributes.first_name }} | +{{ manager.last_name }} | +{{ manager.first_name }} | {{ manager.email }} | -{{ manager.profile_attributes.phone }} | +{{ manager.phone }} |
+
diff --git a/app/assets/templates/shared/_manager_form.html b/app/assets/templates/shared/_manager_form.html
index a929ffe35..b78763907 100644
--- a/app/assets/templates/shared/_manager_form.html
+++ b/app/assets/templates/shared/_manager_form.html
@@ -22,7 +22,7 @@
-
-
-
-
-
-
-
-
-
-
- {{ 'app.shared.user_admin.group_is_required' }}
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+ {{ 'app.shared.user_admin.group_is_required' }}
+
+
+
diff --git a/app/controllers/api/users_controller.rb b/app/controllers/api/users_controller.rb
index 9a8a4ead7..7d77ff160 100644
--- a/app/controllers/api/users_controller.rb
+++ b/app/controllers/api/users_controller.rb
@@ -15,9 +15,9 @@ class API::UsersController < API::ApiController
def create
authorize User
- res = if params[:user]
+ res = if !params[:user].empty?
UserService.create_partner(partner_params)
- elsif params[:manager]
+ elsif !params[:manager].empty?
UserService.create_manager(manager_params)
else
nil
diff --git a/app/services/user_service.rb b/app/services/user_service.rb
index ee44514f2..77f40c6cf 100644
--- a/app/services/user_service.rb
+++ b/app/services/user_service.rb
@@ -59,7 +59,7 @@ class UserService
saved = manager.save
if saved
manager.send_confirmation_instructions
- manager.add_role(:admin)
+ manager.add_role(:manager)
manager.remove_role(:member)
UsersMailer.delay.notify_user_account_created(manager, generated_password)
end
diff --git a/app/views/api/users/index.json.jbuilder b/app/views/api/users/index.json.jbuilder
index 1050df34d..d2d409391 100644
--- a/app/views/api/users/index.json.jbuilder
+++ b/app/views/api/users/index.json.jbuilder
@@ -2,6 +2,7 @@
json.users @users do |user|
json.extract! user, :id, :email, :first_name, :last_name
+ json.phone user.profile.phone
json.name user.profile.full_name
json.resource user.roles.last.resource
end
+
+
+
+
+
+
+ |