1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00

[ongoing] prevent disable group with users + [ongoing] hide disabled groups

This commit is contained in:
Sylvain 2017-10-05 17:54:44 +02:00
parent fb092afc8c
commit 189665e53b
14 changed files with 27 additions and 16 deletions

View File

@ -77,11 +77,14 @@ Application.Controllers.controller "GroupsController", ["$scope", 'groupsPromise
##
$scope.toggleDisableGroup = (index) ->
group = $scope.groups[index]
Group.update {id: group.id}, { group: { disabled: !group.disabled } }, (response) ->
$scope.groups[index] = response
growl.success(_t('group_form.group_successfully_enabled_disabled', { STATUS: response.disabled }, 'messageformat'))
, (error) ->
growl.error(_t('group_form.unable_to_enable_disable_group', { STATUS: !group.disabled }, 'messageformat'))
if (!group.disabled && group.users > 0)
growl.error(_t('group_form.unable_to_disable_group_with_users', { USERS: group.users }, 'messageformat'))
else
Group.update {id: group.id}, { group: { disabled: !group.disabled } }, (response) ->
$scope.groups[index] = response
growl.success(_t('group_form.group_successfully_enabled_disabled', { STATUS: response.disabled }, 'messageformat'))
, (error) ->
growl.error(_t('group_form.unable_to_enable_disable_group', { STATUS: !group.disabled }, 'messageformat'))
]

View File

@ -25,7 +25,7 @@ class MembersController
## Retrieve the profiles groups (eg. students ...)
Group.query (groups) ->
$scope.groups = groups.filter (g) -> g.slug != 'admins'
$scope.groups = groups.filter (g) -> g.slug != 'admins' && !g.disabled
## Retrieve the list the available trainings
Training.query().$promise.then (data)->

View File

@ -13,7 +13,7 @@ class PlanController
## groups list
$scope.groups = groups.filter (g) -> g.slug != 'admins'
$scope.groups = groups.filter (g) -> g.slug != 'admins' && !g.disabled
## users with role 'partner', notifiables for a partner plan
$scope.partners = partners.users

View File

@ -19,6 +19,7 @@ Application.Controllers.controller "EditPricingController", ["$scope", "$state",
## List of groups (eg. normal, student ...)
$scope.groups = groups.filter (g) -> g.slug != 'admins'
$scope.enabledGroups = groups.filter (g) -> g.slug != 'admins' && !g.disabled
## Associate free machine hours with subscriptions
$scope.machineCredits = machineCreditsPromise

View File

@ -8,7 +8,7 @@ Application.Controllers.controller "PlansIndexController", ["$scope", "$rootScop
### PUBLIC SCOPE ###
## list of groups
$scope.groups = groupsPromise.filter (g) -> g.slug != 'admins'
$scope.groups = groupsPromise.filter (g) -> g.slug != 'admins' & !g.disabled
## default : do not show the group changing form
## group ID of the current/selected user

View File

@ -632,7 +632,7 @@ body.container{
& td:first-child:before {
font-family: 'fontawesome' !important;
content: '\f023';
content: '\f070';
position: absolute;
left: -4px;
}

View File

@ -15,7 +15,7 @@
<td>
{{ machine.name }}
</td>
<td ng-repeat="group in groups">
<td ng-repeat="group in enabledGroups">
<span editable-number="findPriceBy(machinesPrices, machine.id, group.id).amount"
onbeforesave="updatePrice($data, findPriceBy(machinesPrices, machine.id, group.id))">
{{ findPriceBy(machinesPrices, machine.id, group.id).amount | currency}}

View File

@ -15,7 +15,7 @@
<td>
{{ space.name }}
</td>
<td ng-repeat="group in groups">
<td ng-repeat="group in enabledGroups">
<span editable-number="findPriceBy(spacesPrices, space.id, group.id).amount"
onbeforesave="updatePrice($data, findPriceBy(spacesPrices, space.id, group.id))">
{{ findPriceBy(spacesPrices, space.id, group.id).amount | currency}}

View File

@ -34,11 +34,14 @@
</tr>
</thead>
<tbody>
<tr ng-repeat="plan in plans | filterDisabled:planFiltering | orderBy:orderPlans" ng-class="{'disabled-line' : plan.disabled && planFiltering === 'all'}">
<tr ng-repeat="plan in plans | filterDisabled:planFiltering | orderBy:orderPlans"
ng-class="{'disabled-line' : plan.disabled && planFiltering === 'all'}"
ng-init="group = getGroupFromId(groups, plan.group_id)"
ng-hide="group.disabled">
<td>{{getPlanType(plan.type)}}</td>
<td>{{plan.base_name}}</td>
<td>{{ plan.interval | planIntervalFilter:plan.interval_count }}</td>
<td>{{getGroupFromId(groups, plan.group_id).name}}</td>
<td>{{group.name}}</td>
<td class="hidden-xs">{{plan.ui_weight}}</td>
<td>{{plan.amount | currency}}</td>
<td><button type="button" class="btn btn-default" ui-sref="app.admin.plans.edit({id:plan.id})"><i class="fa fa-pencil-square-o"></i></button> <button type="button" class="btn btn-danger" ng-click="deletePlan(plans, plan.id)"><i class="fa fa-trash"></i></button></td>

View File

@ -12,7 +12,7 @@
<td>
{{ training.name }}
</td>
<td ng-repeat="group in groups">
<td ng-repeat="group in enabledGroups">
<span editable-number="findTrainingsPricing(trainingsPricings, training.id, group.id).amount"
onbeforesave="updateTrainingsPricing($data, findTrainingsPricing(trainingsPricings, training.id, group.id))">
{{ findTrainingsPricing(trainingsPricings, training.id, group.id).amount | currency}}

View File

@ -1 +1,2 @@
json.extract! group, :id, :slug, :name, :disabled
json.users group.users.count

View File

@ -430,6 +430,7 @@ en:
unable_to_delete_group_because_some_users_and_or_groups_are_still_linked_to_it: "Unable to delete group because some users and/or groups are still linked to it."
group_successfully_enabled_disabled: "Group successfully {STATUS, select, true{disabled} other{enabled}}." # messageFormat interpolation
unable_to_enable_disable_group: "Unable to {STATUS, select, true{disable} other{enable}} group." # messageFormat interpolation
unable_to_disable_group_with_users: "Unable to disable group because it still contains {USERS} active {USERS, plural, =1{user} other{users}}." # messageFormat interpolation
status_enabled: "Enabled"
status_disabled: "Disabled"
status_all: "All"

View File

@ -430,6 +430,7 @@ fr:
unable_to_delete_group_because_some_users_and_or_groups_are_still_linked_to_it: "Le groupe n'a pas pu être supprimé car des utilisateurs et/ou des abonnements sont toujours associés à ce dernier."
group_successfully_enabled_disabled: "Le groupe a bien été {STATUS, select, true{désactivé} other{activé}}." # messageFormat interpolation
unable_to_enable_disable_group: "Impossible {STATUS, select, true{de désactiver} other{d'activer}} le groupe." # messageFormat interpolation
unable_to_disable_group_with_users: "Impossible de désactiver le groupe car il contient encore {USERS} {USERS, plural, =0{personne} =1{utilisateur actif} other{utilisateurs actifs}}." # messageFormat interpolation
status_enabled: "Activés"
status_disabled: "Désactivés"
status_all: "Tous"

View File

@ -434,8 +434,9 @@ pt:
an_error_occurred_when_saving_the_new_group: "Um erro ocorreu ao salvar novo grupo."
group_successfully_deleted: "Grupo excluido com sucesso."
unable_to_delete_group_because_some_users_and_or_groups_are_still_linked_to_it: "Não é possível excluir o grupo porque alguns usuários e / ou grupos ainda estão vinculados a ele."
group_successfully_enabled_disabled: "Group successfully {STATUS, select, true{disabled} other{enabled}}." # messageFormat interpolation
unable_to_enable_disable_group: "Unable to {STATUS, select, true{disable} other{enable}} group." # messageFormat interpolation
group_successfully_enabled_disabled: "Group successfully {STATUS, select, true{disabled} other{enabled}}." # messageFormat interpolation TODO
unable_to_enable_disable_group: "Unable to {STATUS, select, true{disable} other{enable}} group." # messageFormat interpolation TODO
unable_to_disable_group_with_users: "Unable to disable group because it still contains {USERS} active {USERS, plural, =1{user} other{users}}." # messageFormat interpolation TODO
status_enabled: "Ativos"
status_disabled: "Desabilitados"
status_all: "Todos"