mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
inteface to add/remove/edit managers
This commit is contained in:
parent
91165d0432
commit
e1a8646e5f
@ -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);
|
||||
}
|
||||
);
|
||||
|
@ -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; }]
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -12,23 +12,26 @@
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:15%"><a href="" ng-click="setOrderManager('profile_attributes.last_name')">{{ 'app.admin.members.surname' | translate }} <i class="fa fa-arrows-v" ng-class="{'fa fa-sort-alpha-asc': orderAdmin =='profile_attributes.last_name', 'fa fa-sort-alpha-desc': orderAdmin =='-profile_attributes.last_name', 'fa fa-arrows-v': orderAdmin }"></i></a></th>
|
||||
<th style="width:15%"><a href="" ng-click="setOrderManager('last_name')">{{ 'app.admin.members.surname' | translate }} <i class="fa fa-arrows-v" ng-class="{'fa fa-sort-alpha-asc': orderAdmin =='last_name', 'fa fa-sort-alpha-desc': orderAdmin =='-last_name', 'fa fa-arrows-v': orderAdmin }"></i></a></th>
|
||||
|
||||
<th style="width:15%"><a href="" ng-click="setOrderManager('profile_attributes.first_name')">{{ 'app.admin.members.first_name' | translate }} <i class="fa fa-arrows-v" ng-class="{'fa fa-sort-alpha-asc': orderAdmin =='profile_attributes.first_name', 'fa fa-sort-alpha-desc': orderAdmin =='-profile_attributes.first_name', 'fa fa-arrows-v': orderAdmin }"></i></a></th>
|
||||
<th style="width:15%"><a href="" ng-click="setOrderManager('first_name')">{{ 'app.admin.members.first_name' | translate }} <i class="fa fa-arrows-v" ng-class="{'fa fa-sort-alpha-asc': orderAdmin =='first_name', 'fa fa-sort-alpha-desc': orderAdmin =='-first_name', 'fa fa-arrows-v': orderAdmin }"></i></a></th>
|
||||
|
||||
<th style="width:15%"><a href="" ng-click="setOrderManager('email')">{{ 'app.admin.members.email' | translate }} <i class="fa fa-arrows-v" ng-class="{'fa fa-sort-alpha-asc': orderAdmin =='email', 'fa fa-sort-alpha-desc': orderAdmin =='-email', 'fa fa-arrows-v': orderAdmin }"></i></a></th>
|
||||
|
||||
<th style="width:10%"><a href="" ng-click="setOrderManager('profile_attributes.phone')">{{ 'app.admin.members.phone' | translate }} <i class="fa fa-arrows-v" ng-class="{'fa fa-sort-numeric-asc': orderAdmin =='profile_attributes.phone', 'fa fa-sort-numeric-desc': orderAdmin =='-profile_attributes.phone', 'fa fa-arrows-v': orderAdmin }"></i></a></th>
|
||||
<th style="width:10%"><a href="" ng-click="setOrderManager('phone')">{{ 'app.admin.members.phone' | translate }} <i class="fa fa-arrows-v" ng-class="{'fa fa-sort-numeric-asc': orderAdmin =='profile_attributes.phone', 'fa fa-sort-numeric-desc': orderAdmin =='-profile_attributes.phone', 'fa fa-arrows-v': orderAdmin }"></i></a></th>
|
||||
<th style="width:10%"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="manager in managers | filter:searchFilter | orderBy: orderManager">
|
||||
<td class="text-c">{{ manager.profile_attributes.last_name }}</td>
|
||||
<td class="text-c">{{ manager.profile_attributes.first_name }}</td>
|
||||
<td class="text-c">{{ manager.last_name }}</td>
|
||||
<td class="text-c">{{ manager.first_name }}</td>
|
||||
<td>{{ manager.email }}</td>
|
||||
<td>{{ manager.profile_attributes.phone }}</td>
|
||||
<td>{{ manager.phone }}</td>
|
||||
<td>
|
||||
<button class="btn btn-default edit-member" ui-sref="app.admin.members_edit({id: manager.id})">
|
||||
<i class="fa fa-edit"></i>
|
||||
</button>
|
||||
<button class="btn btn-danger" ng-if="manager.id != currentUser.id" ng-click="destroyManager(managers, manager)">
|
||||
<i class="fa fa-trash-o"></i>
|
||||
</button>
|
||||
|
@ -22,7 +22,7 @@
|
||||
<div class="form-group" ng-class="{'has-error': managerForm['manager[username]'].$dirty && managerForm['manager[username]'].$invalid}">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="fa fa-user"></i> <span class="exponent"><i class="fa fa-asterisk" aria-hidden="true"></i></span></span>
|
||||
<input ng-model="admin.username"
|
||||
<input ng-model="manager.username"
|
||||
type="text" name="manager[username]"
|
||||
class="form-control"
|
||||
id="user_username"
|
||||
@ -63,7 +63,7 @@
|
||||
<div class="form-group" ng-class="{'has-error': managerForm['manager[email]'].$dirty && managerForm['manager[email]'].$invalid}">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="fa fa-envelope"></i> <span class="exponent"><i class="fa fa-asterisk" aria-hidden="true"></i></span></span>
|
||||
<input ng-model="admin.email"
|
||||
<input ng-model="manager.email"
|
||||
type="email"
|
||||
name="manager[email]"
|
||||
class="form-control"
|
||||
@ -118,36 +118,40 @@
|
||||
placeholder="{{ 'app.admin.manager_new.phone_number' | translate }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" ng-class="{'has-error': managerForm['manager[group_id]'].$dirty && managerForm['manager[group_id]'].$invalid}">
|
||||
<label for="manager_group_id" class="col-sm-3 control-label">
|
||||
<span translate>{{ 'app.shared.user_admin.group' }}</span>
|
||||
<span class="exponent"><i class="fa fa-asterisk" aria-hidden="true"></i></span>
|
||||
</label>
|
||||
<div class="col-sm-9">
|
||||
<select ng-model="manager.group_id" class="form-control" name="manager[group_id]" id="manager_group_id"
|
||||
ng-options="g.id as g.name for g in groups" required>
|
||||
</select>
|
||||
<input type="hidden" name="manager[group_id]" ng-value="manager.group_id" />
|
||||
<span class="help-block" ng-show="managerForm['manager[group_id]'].$dirty && managerForm['manager[group_id]'].$error.required" translate>{{ 'app.shared.user_admin.group_is_required' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" translate>{{ 'app.shared.user_admin.tags' }}</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="hidden" name="manager[tag_ids][]" value="" />
|
||||
<ui-select multiple ng-model="manager.tag_ids" name="user[tag_ids][]" class="form-control">
|
||||
<ui-select-match>
|
||||
<span ng-bind="$item.name"></span>
|
||||
<input type="hidden" name="manager[tag_ids][]" value="{{$item.id}}" />
|
||||
</ui-select-match>
|
||||
<ui-select-choices repeat="t.id as t in (tags | filter: $select.search)">
|
||||
<span ng-bind-html="t.name | highlight: $select.search"></span>
|
||||
</ui-select-choices>
|
||||
</ui-select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="form-group" ng-class="{'has-error': managerForm['manager[group_id]'].$dirty && managerForm['manager[group_id]'].$invalid}">
|
||||
<label for="manager_group_id" class="col-sm-3 control-label">
|
||||
<span translate>{{ 'app.shared.user_admin.group' }}</span>
|
||||
<span class="exponent"><i class="fa fa-asterisk" aria-hidden="true"></i></span>
|
||||
</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-model="manager.group_id" class="form-control" name="manager[group_id]" id="manager_group_id"
|
||||
ng-options="g.id as g.name for g in groups" required>
|
||||
</select>
|
||||
<input type="hidden" name="manager[group_id]" ng-value="manager.group_id" />
|
||||
<span class="help-block" ng-show="managerForm['manager[group_id]'].$dirty && managerForm['manager[group_id]'].$error.required" translate>{{ 'app.shared.user_admin.group_is_required' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" translate>{{ 'app.shared.user_admin.tags' }}</label>
|
||||
<div class="col-sm-6 nopadding">
|
||||
<input type="hidden" name="manager[tag_ids][]" value="" />
|
||||
<ui-select multiple ng-model="manager.tag_ids" name="user[tag_ids][]" class="form-control">
|
||||
<ui-select-match>
|
||||
<span ng-bind="$item.name"></span>
|
||||
<input type="hidden" name="manager[tag_ids][]" value="{{$item.id}}" />
|
||||
</ui-select-match>
|
||||
<ui-select-choices repeat="t.id as t in (tags | filter: $select.search)">
|
||||
<span ng-bind-html="t.name | highlight: $select.search"></span>
|
||||
</ui-select-choices>
|
||||
</ui-select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user