1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

[bug taiga#20] group change not propagated (partial fix)

This commit is contained in:
Sylvain 2016-04-11 19:26:40 +02:00
parent 4b6f3c5ea7
commit 563266f160
3 changed files with 19 additions and 18 deletions

View File

@ -79,6 +79,7 @@ Application.Controllers.controller "EditProfileController", ["$scope", "$rootSco
$scope.selectGroup = ->
Member.update {id: $scope.user.id}, {user: {group_id: $scope.userGroup}}, (user) ->
$scope.user = user
$rootScope.currentUser = user
$scope.group.change = false
growl.success(_t('your_group_has_been_successfully_changed'))
, (err) ->

View File

@ -1,7 +1,7 @@
'use strict'
Application.Controllers.controller "PlansIndexController", ["$scope", "$state", '$uibModal', 'Auth', 'dialogs', 'growl', 'plansPromise', 'groupsPromise', 'Subscription', 'Member', 'subscriptionExplicationsPromise', '_t'
, ($scope, $state, $uibModal, Auth, dialogs, growl, plansPromise, groupsPromise, Subscription, Member, subscriptionExplicationsPromise, _t) ->
Application.Controllers.controller "PlansIndexController", ["$scope", "$rootScope", "$state", '$uibModal', 'Auth', 'dialogs', 'growl', 'plansPromise', 'groupsPromise', 'Subscription', 'Member', 'subscriptionExplicationsPromise', '_t'
, ($scope, $rootScope, $state, $uibModal, Auth, dialogs, growl, plansPromise, groupsPromise, Subscription, Member, subscriptionExplicationsPromise, _t) ->
@ -11,10 +11,10 @@ Application.Controllers.controller "PlansIndexController", ["$scope", "$state",
$scope.groups = groupsPromise
## default : do not show the group changing form
$scope.changeGroup = false
## group ID of the current/selected user
$scope.userGroup = null
$scope.group =
change: false
id: null
## list of plans, classified by group
$scope.plansClassifiedByGroup = []
@ -45,8 +45,8 @@ Application.Controllers.controller "PlansIndexController", ["$scope", "$state",
$scope.updateMember = ->
$scope.selectedPlan = null
$scope.paidPlan = null
$scope.userGroup = $scope.ctrl.member.group_id
$scope.changeGroup = false
$scope.group.id = $scope.ctrl.member.group_id
$scope.group.change = false
@ -77,24 +77,24 @@ Application.Controllers.controller "PlansIndexController", ["$scope", "$state",
##
# Return the group object, identified by the ID set in $scope.userGroup
# Return the group object, identified by the ID set in $scope.group.id
##
$scope.getUserGroup = ->
for group in $scope.groups
if group.id == $scope.userGroup
if group.id == $scope.group.id
return group
##
# Change the group of the current/selected user to the one set in $scope.userGroup
# Change the group of the current/selected user to the one set in $scope.group.id
##
$scope.selectGroup = ->
Member.update {id: $scope.ctrl.member.id}, {user: {group_id: $scope.userGroup}}, (user) ->
Member.update {id: $scope.ctrl.member.id}, {user: {group_id: $scope.group.id}}, (user) ->
$scope.ctrl.member = user
$scope.changeGroup = false
$scope.group.change = false
if $scope.currentUser.role isnt 'admin'
$scope.currentUser = user
$rootScope.currentUser = user
growl.success(_t('your_group_was_successfully_changed'))
else
growl.success(_t('the_user_s_group_was_successfully_changed'))
@ -128,7 +128,7 @@ Application.Controllers.controller "PlansIndexController", ["$scope", "$state",
if $scope.currentUser.role isnt 'admin'
$scope.ctrl.member = $scope.currentUser
$scope.paidPlan = $scope.currentUser.subscribed_plan
$scope.userGroup = $scope.currentUser.group_id
$scope.group.id = $scope.currentUser.group_id
else
Member.query {requested_attributes:'[subscription]'}, (members) ->
membersNoPlan = []

View File

@ -91,19 +91,19 @@
<h3 ng-show="currentUser.role === 'admin'" translate translate-values="{GENDER:getGender(currentUser)}" translate-interpolation="messageformat">{{ 'his_group' }}</h3>
</div>
<div class="widget-content no-bg auto wrapper">
<div ng-show="!changeGroup">
<div ng-show="!group.change">
<div class="well well-warning">
<strong>{{getUserGroup().name}}</strong>
</div>
<button class="btn btn-default m-t"
ng-click="changeGroup = !changeGroup"
ng-click="group.change = !group.change"
ng-show="(!selectedPlan && ctrl.member && !ctrl.member.subscribed_plan && ctrl.member.subscription) || (!paidPlan)"
translate
translate-values="{ROLE:currentUser.role}"
translate-interpolation="messageformat">{{ 'he_wants_to_change_group' }}</button>
</div>
<div ng-show="changeGroup">
<select class="form-control" ng-options="g.id as g.name for g in groups" ng-model="userGroup"></select>
<div ng-show="group.change">
<select class="form-control" ng-options="g.id as g.name for g in groups" ng-model="group.id"></select>
<button class="btn btn-success m-t"
ng-click="selectGroup()"
translate