diff --git a/app/assets/javascripts/controllers/admin/groups.coffee.erb b/app/assets/javascripts/controllers/admin/groups.coffee.erb index 24fe12956..1e4cf1d86 100644 --- a/app/assets/javascripts/controllers/admin/groups.coffee.erb +++ b/app/assets/javascripts/controllers/admin/groups.coffee.erb @@ -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')) ] diff --git a/app/assets/javascripts/controllers/admin/members.coffee.erb b/app/assets/javascripts/controllers/admin/members.coffee.erb index 8c29ab523..609f401b8 100644 --- a/app/assets/javascripts/controllers/admin/members.coffee.erb +++ b/app/assets/javascripts/controllers/admin/members.coffee.erb @@ -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)-> diff --git a/app/assets/javascripts/controllers/admin/plans.coffee.erb b/app/assets/javascripts/controllers/admin/plans.coffee.erb index 5848e02c5..0b0a2bb7e 100644 --- a/app/assets/javascripts/controllers/admin/plans.coffee.erb +++ b/app/assets/javascripts/controllers/admin/plans.coffee.erb @@ -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 diff --git a/app/assets/javascripts/controllers/admin/pricing.coffee.erb b/app/assets/javascripts/controllers/admin/pricing.coffee.erb index 5f38a2635..01155be23 100644 --- a/app/assets/javascripts/controllers/admin/pricing.coffee.erb +++ b/app/assets/javascripts/controllers/admin/pricing.coffee.erb @@ -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 diff --git a/app/assets/javascripts/controllers/plans.coffee.erb b/app/assets/javascripts/controllers/plans.coffee.erb index 2e97667ad..27b516d5b 100644 --- a/app/assets/javascripts/controllers/plans.coffee.erb +++ b/app/assets/javascripts/controllers/plans.coffee.erb @@ -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 diff --git a/app/assets/stylesheets/app.layout.scss b/app/assets/stylesheets/app.layout.scss index 0d059df12..538fd9833 100644 --- a/app/assets/stylesheets/app.layout.scss +++ b/app/assets/stylesheets/app.layout.scss @@ -632,7 +632,7 @@ body.container{ & td:first-child:before { font-family: 'fontawesome' !important; - content: '\f023'; + content: '\f070'; position: absolute; left: -4px; } diff --git a/app/assets/templates/admin/pricing/machine_hours.html.erb b/app/assets/templates/admin/pricing/machine_hours.html.erb index 84ecb5e1c..a8eef5c8f 100644 --- a/app/assets/templates/admin/pricing/machine_hours.html.erb +++ b/app/assets/templates/admin/pricing/machine_hours.html.erb @@ -15,7 +15,7 @@ {{ machine.name }} - + {{ findPriceBy(machinesPrices, machine.id, group.id).amount | currency}} diff --git a/app/assets/templates/admin/pricing/spaces.html.erb b/app/assets/templates/admin/pricing/spaces.html.erb index a189ac4c4..549b6e775 100644 --- a/app/assets/templates/admin/pricing/spaces.html.erb +++ b/app/assets/templates/admin/pricing/spaces.html.erb @@ -15,7 +15,7 @@ {{ space.name }} - + {{ findPriceBy(spacesPrices, space.id, group.id).amount | currency}} diff --git a/app/assets/templates/admin/pricing/subscriptions.html.erb b/app/assets/templates/admin/pricing/subscriptions.html.erb index e293319e9..602176e08 100644 --- a/app/assets/templates/admin/pricing/subscriptions.html.erb +++ b/app/assets/templates/admin/pricing/subscriptions.html.erb @@ -34,11 +34,14 @@ - + {{getPlanType(plan.type)}} {{plan.base_name}} {{ plan.interval | planIntervalFilter:plan.interval_count }} - {{getGroupFromId(groups, plan.group_id).name}} + {{group.name}} {{plan.ui_weight}} {{plan.amount | currency}} diff --git a/app/assets/templates/admin/pricing/trainings.html.erb b/app/assets/templates/admin/pricing/trainings.html.erb index 6c6c230fd..4327a783f 100644 --- a/app/assets/templates/admin/pricing/trainings.html.erb +++ b/app/assets/templates/admin/pricing/trainings.html.erb @@ -12,7 +12,7 @@ {{ training.name }} - + {{ findTrainingsPricing(trainingsPricings, training.id, group.id).amount | currency}} diff --git a/app/views/api/groups/_group.json.jbuilder b/app/views/api/groups/_group.json.jbuilder index 5dafd5882..f70cdcb25 100644 --- a/app/views/api/groups/_group.json.jbuilder +++ b/app/views/api/groups/_group.json.jbuilder @@ -1 +1,2 @@ json.extract! group, :id, :slug, :name, :disabled +json.users group.users.count diff --git a/config/locales/app.admin.en.yml b/config/locales/app.admin.en.yml index f6523af8f..1cf5b6ad8 100644 --- a/config/locales/app.admin.en.yml +++ b/config/locales/app.admin.en.yml @@ -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" diff --git a/config/locales/app.admin.fr.yml b/config/locales/app.admin.fr.yml index 8ed3fc105..3b7c5eaa9 100644 --- a/config/locales/app.admin.fr.yml +++ b/config/locales/app.admin.fr.yml @@ -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" diff --git a/config/locales/app.admin.pt.yml b/config/locales/app.admin.pt.yml index 98863cb74..afae56266 100755 --- a/config/locales/app.admin.pt.yml +++ b/config/locales/app.admin.pt.yml @@ -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"