diff --git a/app/assets/javascripts/controllers/admin/trainings.coffee.erb b/app/assets/javascripts/controllers/admin/trainings.coffee.erb index 42288420f..1e69b333d 100644 --- a/app/assets/javascripts/controllers/admin/trainings.coffee.erb +++ b/app/assets/javascripts/controllers/admin/trainings.coffee.erb @@ -139,9 +139,9 @@ Application.Controllers.controller "EditTrainingController", [ '$scope', '$state ## -# Controller used in the public listing page, allowing logged users to see the list of trainings +# Controller used in the trainings management page, allowing admins users to see and manage the list of trainings and reservations. ## -Application.Controllers.controller "TrainingsController", ["$scope", "$state", "$uibModal", 'Training', 'trainingsPromise', 'machinesPromise', '_t', 'growl', 'dialogs' +Application.Controllers.controller "TrainingsAdminController", ["$scope", "$state", "$uibModal", 'Training', 'trainingsPromise', 'machinesPromise', '_t', 'growl', 'dialogs' , ($scope, $state, $uibModal, Training, trainingsPromise, machinesPromise, _t, growl, dialogs) -> diff --git a/app/assets/javascripts/controllers/trainings.coffee.erb b/app/assets/javascripts/controllers/trainings.coffee.erb index afd0f07b5..4dfbeb11d 100644 --- a/app/assets/javascripts/controllers/trainings.coffee.erb +++ b/app/assets/javascripts/controllers/trainings.coffee.erb @@ -1,15 +1,44 @@ 'use strict' +## +# Public listing of the trainings +## Application.Controllers.controller "TrainingsController", ['$scope', '$state', 'trainingsPromise', ($scope, $state, trainingsPromise) -> + + ## List of trainings $scope.trainings = trainingsPromise + ## + # Callback for the 'reserve' button + ## $scope.reserveTraining = (training, event) -> - $state.go('app.logged.trainings_reserve') + $state.go('app.logged.trainings_reserve', {id: training.id}) + ## + # Callback for the 'show' button + ## $scope.showTraining = (training) -> - $state.go('app.logged.trainings_reserve') + $state.go('app.public.training_show', {id: training.id}) ] + + +## +# Public view of a specific training +## +Application.Controllers.controller "ShowTrainingController", ['$scope', '$state', 'trainingPromise', ($scope, $state, trainingPromise) -> + + ## Current training + $scope.training = trainingPromise + + ## + # Callback for the 'reserve' button + ## + $scope.reserveTraining = (training, event) -> + $state.go('app.logged.trainings_reserve', {id: training.id}) +] + + ## # Controller used in the training reservation agenda page. # This controller is very similar to the machine reservation controller with one major difference: here, ONLY ONE diff --git a/app/assets/javascripts/router.coffee.erb b/app/assets/javascripts/router.coffee.erb index 1d83ec30b..a707fc77a 100644 --- a/app/assets/javascripts/router.coffee.erb +++ b/app/assets/javascripts/router.coffee.erb @@ -377,6 +377,19 @@ angular.module('application.router', ['ui.router']). translations: [ 'Translations', (Translations) -> Translations.query(['app.public.trainings_list']).$promise ] + .state 'app.public.training_show', + url: '/trainings/:id' + views: + 'main@': + templateUrl: '<%= asset_path "trainings/show.html" %>' + controller: 'ShowTrainingController' + resolve: + trainingPromise: ['Training', '$stateParams', (Training, $stateParams)-> + Training.get({id: $stateParams.id}).$promise + ] + translations: [ 'Translations', (Translations) -> + Translations.query(['app.public.training_show']).$promise + ] .state 'app.logged.trainings_reserve', url: '/trainings/reserve' views: @@ -525,7 +538,7 @@ angular.module('application.router', ['ui.router']). views: 'main@': templateUrl: '<%= asset_path "admin/trainings/index.html" %>' - controller: 'TrainingsController' + controller: 'TrainingsAdminController' resolve: trainingsPromise: ['Training', (Training)-> Training.query().$promise diff --git a/app/assets/templates/trainings/show.html.erb b/app/assets/templates/trainings/show.html.erb new file mode 100644 index 000000000..217f3f8b2 --- /dev/null +++ b/app/assets/templates/trainings/show.html.erb @@ -0,0 +1,42 @@ +
diff --git a/config/locales/app.public.en.yml b/config/locales/app.public.en.yml index b2fc2f298..d089dbc24 100644 --- a/config/locales/app.public.en.yml +++ b/config/locales/app.public.en.yml @@ -171,6 +171,14 @@ en: unauthorized_operation: "Unauthoried operation" the_machine_cant_be_deleted_because_it_is_already_reserved_by_some_users: "The machine can't be deleted because it's already reserved by some users." + trainings_list: + # list of trainings + the_trainings: "The trainings" + + training_show: + # details of a training + book_this_training: "Book this training" + plans: # summary of the subscriptions subcriptions: "Subscriptions" diff --git a/config/locales/app.public.fr.yml b/config/locales/app.public.fr.yml index f6ed68ede..c438413c7 100644 --- a/config/locales/app.public.fr.yml +++ b/config/locales/app.public.fr.yml @@ -176,6 +176,11 @@ fr: # liste des formations the_trainings: "Les formations" + training_show: + # détails d'une formation + book_this_training: "Réserver cette formation" + + plans: # page récapitulative des abonnements subcriptions: "Les abonnements"