diff --git a/app/assets/javascripts/controllers/admin/trainings.coffee.erb b/app/assets/javascripts/controllers/admin/trainings.coffee.erb index f5d9d7cce..fcd583861 100644 --- a/app/assets/javascripts/controllers/admin/trainings.coffee.erb +++ b/app/assets/javascripts/controllers/admin/trainings.coffee.erb @@ -5,7 +5,7 @@ ## # Controller used in the training creation page (admin) ## -Application.Controllers.controller "NewTrainingController", [ '$scope', ($scope) -> +Application.Controllers.controller "NewTrainingController", [ '$scope', 'machinesPromise', ($scope, machinesPromise) -> @@ -17,6 +17,9 @@ Application.Controllers.controller "NewTrainingController", [ '$scope', ($scope) ## API URL where the form will be posted $scope.actionUrl = '/api/trainings' + ## list of machines + $scope.machines = machinesPromise + ## # For use with 'ng-class', returns the CSS class name for the uploads previews. # The preview may show a placeholder or the content of the file depending on the upload state. @@ -34,7 +37,7 @@ Application.Controllers.controller "NewTrainingController", [ '$scope', ($scope) ## # Controller used in the training edition page (admin) ## -Application.Controllers.controller "EditTrainingController", [ '$scope', '$stateParams', 'trainingPromise', ($scope, $stateParams, trainingPromise) -> +Application.Controllers.controller "EditTrainingController", [ '$scope', '$stateParams', 'trainingPromise', 'machinesPromise', ($scope, $stateParams, trainingPromise, machinesPromise) -> @@ -49,6 +52,9 @@ Application.Controllers.controller "EditTrainingController", [ '$scope', '$state ## Details of the training to edit (id in URL) $scope.training = trainingPromise + ## list of machines + $scope.machines = machinesPromise + ## # For use with 'ng-class', returns the CSS class name for the uploads previews. # The preview may show a placeholder or the content of the file depending on the upload state. diff --git a/app/assets/javascripts/router.coffee.erb b/app/assets/javascripts/router.coffee.erb index 5c9db9555..d3fb4bb84 100644 --- a/app/assets/javascripts/router.coffee.erb +++ b/app/assets/javascripts/router.coffee.erb @@ -530,6 +530,9 @@ angular.module('application.router', ['ui.router']). templateUrl: '<%= asset_path "admin/trainings/new.html" %>' controller: 'NewTrainingController' resolve: + machinesPromise: ['Machine', (Machine)-> + Machine.query().$promise + ] translations: [ 'Translations', (Translations) -> Translations.query(['app.admin.trainings_new', 'app.shared.trainings']).$promise ] @@ -543,6 +546,9 @@ angular.module('application.router', ['ui.router']). trainingPromise: ['Training', '$stateParams', (Training, $stateParams)-> Training.get(id: $stateParams.id).$promise ] + machinesPromise: ['Machine', (Machine)-> + Machine.query().$promise + ] translations: [ 'Translations', (Translations) -> Translations.query('app.shared.trainings').$promise ] diff --git a/app/assets/templates/admin/trainings/_form.html.erb b/app/assets/templates/admin/trainings/_form.html.erb index e47dff573..3c4b6044b 100644 --- a/app/assets/templates/admin/trainings/_form.html.erb +++ b/app/assets/templates/admin/trainings/_form.html.erb @@ -51,6 +51,35 @@ +
+ +
+ + + + + + + + + + +
+
+ +
+ +
+ +
+
+