diff --git a/app/assets/javascripts/controllers/main_nav.coffee.erb b/app/assets/javascripts/controllers/main_nav.coffee.erb index 8b9a49217..77d98d350 100644 --- a/app/assets/javascripts/controllers/main_nav.coffee.erb +++ b/app/assets/javascripts/controllers/main_nav.coffee.erb @@ -19,7 +19,7 @@ Application.Controllers.controller "MainNavController", ["$scope", "$location", linkIcon: 'calendar' } { - state: 'app.logged.trainings_reserve' + state: 'app.public.trainings_list' linkText: 'trainings_registrations' linkIcon: 'graduation-cap' } diff --git a/app/assets/javascripts/controllers/trainings.coffee.erb b/app/assets/javascripts/controllers/trainings.coffee.erb index 03be4e08c..afd0f07b5 100644 --- a/app/assets/javascripts/controllers/trainings.coffee.erb +++ b/app/assets/javascripts/controllers/trainings.coffee.erb @@ -1,5 +1,15 @@ 'use strict' +Application.Controllers.controller "TrainingsController", ['$scope', '$state', 'trainingsPromise', ($scope, $state, trainingsPromise) -> + $scope.trainings = trainingsPromise + + $scope.reserveTraining = (training, event) -> + $state.go('app.logged.trainings_reserve') + + $scope.showTraining = (training) -> + $state.go('app.logged.trainings_reserve') +] + ## # 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 d3fb4bb84..1d83ec30b 100644 --- a/app/assets/javascripts/router.coffee.erb +++ b/app/assets/javascripts/router.coffee.erb @@ -364,6 +364,19 @@ angular.module('application.router', ['ui.router']). ] # trainings + .state 'app.public.trainings_list', + url: '/trainings' + views: + 'main@': + templateUrl: '<%= asset_path "trainings/index.html" %>' + controller: 'TrainingsController' + resolve: + trainingsPromise: ['Training', (Training)-> + Training.query().$promise + ] + translations: [ 'Translations', (Translations) -> + Translations.query(['app.public.trainings_list']).$promise + ] .state 'app.logged.trainings_reserve', url: '/trainings/reserve' views: diff --git a/app/assets/templates/trainings/index.html.erb b/app/assets/templates/trainings/index.html.erb new file mode 100644 index 000000000..4766a9f20 --- /dev/null +++ b/app/assets/templates/trainings/index.html.erb @@ -0,0 +1,59 @@ +
+
+
+
+ +
+
+
+
+

{{ 'the_trainings' }}

+
+
+ +
+
+ + +
+ +
+ +
+ + +
+
+ +
+
+
+
+

{{training.name}}

+

{{training.description | humanize : 140 }}

+
+ +
+ + +
+
+ + + +
diff --git a/app/views/api/trainings/index.json.jbuilder b/app/views/api/trainings/index.json.jbuilder index 72ff1ff85..a951597ee 100644 --- a/app/views/api/trainings/index.json.jbuilder +++ b/app/views/api/trainings/index.json.jbuilder @@ -1,8 +1,8 @@ +user_is_admin = (current_user and current_user.is_admin?) + json.array!(@trainings) do |training| - json.id training.id - json.name training.name - json.description training.description - json.machine_ids training.machine_ids + json.extract! training, :id, :name, :description, :machine_ids, :nb_total_places + json.training_image training.training_image.attachment.large.url if training.training_image json.availabilities training.availabilities do |a| json.id a.id json.start_at a.start_at.iso8601 @@ -13,7 +13,6 @@ json.array!(@trainings) do |training| json.is_valid slot.reservation.user.trainings.include?(training) end end if attribute_requested?(@requested_attributes, 'availabilities') - json.nb_total_places training.nb_total_places - json.plan_ids training.plan_ids if current_user and current_user.is_admin? + json.plan_ids training.plan_ids if user_is_admin end diff --git a/config/locales/app.public.en.yml b/config/locales/app.public.en.yml index 45fa4bf55..b2fc2f298 100644 --- a/config/locales/app.public.en.yml +++ b/config/locales/app.public.en.yml @@ -160,7 +160,6 @@ en: # list of machines the_fablab_s_machines: "The FabLab's machines" add_a_machine: "Add a machine" - book: "Book" _or_the_: " or the " machines_show: diff --git a/config/locales/app.public.fr.yml b/config/locales/app.public.fr.yml index a0e16b2dd..f6ed68ede 100644 --- a/config/locales/app.public.fr.yml +++ b/config/locales/app.public.fr.yml @@ -160,7 +160,6 @@ fr: # liste des machines the_fablab_s_machines: "Les machines du FabLab" add_a_machine: "Ajouter une machine" - book: "Réserver" _or_the_: " ou la " machines_show: @@ -172,6 +171,11 @@ fr: unauthorized_operation: "Opération non autorisée" the_machine_cant_be_deleted_because_it_is_already_reserved_by_some_users: "La machine ne peut pas être supprimée car elle a déjà été réservée par des utilisateurs." + + trainings_list: + # liste des formations + the_trainings: "Les formations" + plans: # page récapitulative des abonnements subcriptions: "Les abonnements" diff --git a/config/locales/app.shared.en.yml b/config/locales/app.shared.en.yml index 325f1e45b..6863478d8 100644 --- a/config/locales/app.shared.en.yml +++ b/config/locales/app.shared.en.yml @@ -88,6 +88,7 @@ en: _for_your_changes_to_take_effect: "for your changes to take effect." illustration: "Illustration" add_an_illustration: "Add an illustration." + book: "Book" messages: you_will_lose_any_unsaved_modification_if_you_quit_this_page: "You will lose any unsaved modification if you quit this page" diff --git a/config/locales/app.shared.fr.yml b/config/locales/app.shared.fr.yml index 329d7d3ed..91740a082 100644 --- a/config/locales/app.shared.fr.yml +++ b/config/locales/app.shared.fr.yml @@ -88,6 +88,7 @@ fr: _for_your_changes_to_take_effect: "pour que les modifications soient prises en compte." illustration: "Visuel" add_an_illustration: "Ajouter un visuel" + book: "Réserver" messages: you_will_lose_any_unsaved_modification_if_you_quit_this_page: "Vous perdrez les modifications non enregistrées si vous quittez cette page"