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

prevent from removing the last category

This commit is contained in:
Sylvain 2016-06-30 09:51:06 +02:00
parent 5374d8d0a6
commit bb6295c487
3 changed files with 7 additions and 2 deletions

View File

@ -129,8 +129,8 @@ class EventsController
##
# Controller used in the events listing page (admin view)
##
Application.Controllers.controller "AdminEventsController", ["$scope", "$state", 'dialogs','Event', 'Category', 'EventTheme', 'AgeRange', 'eventsPromise', 'categoriesPromise', 'themesPromise', 'ageRangesPromise', '_t'
, ($scope, $state, dialogs, Event, Category, EventTheme, AgeRange, eventsPromise, categoriesPromise, themesPromise, ageRangesPromise, _t) ->
Application.Controllers.controller "AdminEventsController", ["$scope", "$state", 'dialogs', 'growl', 'Event', 'Category', 'EventTheme', 'AgeRange', 'eventsPromise', 'categoriesPromise', 'themesPromise', 'ageRangesPromise', '_t'
, ($scope, $state, dialogs, growl, Event, Category, EventTheme, AgeRange, eventsPromise, categoriesPromise, themesPromise, ageRangesPromise, _t) ->
@ -191,6 +191,9 @@ Application.Controllers.controller "AdminEventsController", ["$scope", "$state",
# @param index {number} element index in the $scope[model] array
##
$scope.removeElement = (model, index) ->
if model == 'category' and getModel(model)[1].length == 1
growl.error(_t('at_least_one_category_is_required_unable_to_delete_the_last_one'))
return false
dialogs.confirm
resolve:
object: ->

View File

@ -85,6 +85,7 @@ en:
age_ranges: "Age ranges"
add_a_range: "Add a range"
do_you_really_want_to_delete_this_ELEMENT_used_NUMBER_times: "Do you really want to delete this {ELEMENT, select, category{category} theme{theme} age_range{age range} other{element}}? {NUMBER, plural, =0{It is not currently associated with any events} one{Currently, it is associated with only one event} other{Currently, it is associated with {NUMBER} events}}." # messageFormat interpolation
at_least_one_category_is_required_unable_to_delete_the_last_one: "At least one category is required. Unable to delete the last one."
events_new:
# add a new event

View File

@ -85,6 +85,7 @@ fr:
age_ranges: "Tranches d'âge"
add_a_range: "Ajouter une tranche"
do_you_really_want_to_delete_this_ELEMENT_used_NUMBER_times: "Voulez-vous vraiment supprimer cette {ELEMENT, select, category{catégorie} theme{thématique} age_range{tranche d'âge} other{élément}} ? {NUMBER, plural, =0{Elle n'est actuellement associée à aucun évènement} one{Elle est actuellement associée à un seul évènement} other{Elle est actuellement associée à {NUMBER} évènements}}." # messageFormat interpolation
at_least_one_category_is_required_unable_to_delete_the_last_one: "Au moins une catégorie est requise. Impossible de supprimer la dernière."
events_new:
# ajouter un nouveau atelier/stage