1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00

add missing fields in training form

This commit is contained in:
Sylvain 2016-06-22 11:25:48 +02:00
parent ca73e83f7e
commit 7deefd0e57
8 changed files with 49 additions and 8 deletions

View File

@ -5,7 +5,7 @@
## ##
# Controller used in the training creation page (admin) # 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 ## API URL where the form will be posted
$scope.actionUrl = '/api/trainings' $scope.actionUrl = '/api/trainings'
## list of machines
$scope.machines = machinesPromise
## ##
# For use with 'ng-class', returns the CSS class name for the uploads previews. # 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. # 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) # 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) ## Details of the training to edit (id in URL)
$scope.training = trainingPromise $scope.training = trainingPromise
## list of machines
$scope.machines = machinesPromise
## ##
# For use with 'ng-class', returns the CSS class name for the uploads previews. # 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. # The preview may show a placeholder or the content of the file depending on the upload state.

View File

@ -530,6 +530,9 @@ angular.module('application.router', ['ui.router']).
templateUrl: '<%= asset_path "admin/trainings/new.html" %>' templateUrl: '<%= asset_path "admin/trainings/new.html" %>'
controller: 'NewTrainingController' controller: 'NewTrainingController'
resolve: resolve:
machinesPromise: ['Machine', (Machine)->
Machine.query().$promise
]
translations: [ 'Translations', (Translations) -> translations: [ 'Translations', (Translations) ->
Translations.query(['app.admin.trainings_new', 'app.shared.trainings']).$promise 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)-> trainingPromise: ['Training', '$stateParams', (Training, $stateParams)->
Training.get(id: $stateParams.id).$promise Training.get(id: $stateParams.id).$promise
] ]
machinesPromise: ['Machine', (Machine)->
Machine.query().$promise
]
translations: [ 'Translations', (Translations) -> translations: [ 'Translations', (Translations) ->
Translations.query('app.shared.trainings').$promise Translations.query('app.shared.trainings').$promise
] ]

View File

@ -51,6 +51,35 @@
</div> </div>
</div> </div>
<div class="form-group m-b-lg" ng-class="{'has-error': trainingForm['training[machine_ids]'].$dirty && trainingForm['training[machine_ids]'].$invalid}">
<label for="name" class="col-sm-2 control-label">{{ 'associated_machines' | translate }}</label>
<div class="col-sm-4">
<input type="hidden"
value="{{training.machine_ids}}"
name="training[machine_ids][]">
<ui-select multiple ng-model="training.machine_ids" name="training[machine_ids][]" class="form-control">
<ui-select-match>
<span ng-bind="$item.name"></span>
<input type="hidden" name="training[machine_ids][]" value="{{$item.id}}" />
</ui-select-match>
<ui-select-choices repeat="m.id as m in (machines | filter: $select.search)">
<span ng-bind-html="m.name | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
</div>
</div>
<div class="form-group m-b-lg" ng-class="{'has-error': trainingForm['training[nb_total_places]'].$dirty && trainingForm['training[nb_total_places]'].$invalid}">
<label for="name" class="col-sm-2 control-label">{{ 'number_of_tickets' | translate }}</label>
<div class="col-sm-4">
<input ng-model="training.nb_total_places"
type="number"
name="training[nb_total_places]"
class="form-control"
id="training_nb_total_places">
</div>
</div>
</div> <!-- ./panel-body --> </div> <!-- ./panel-body -->
<div class="panel-footer no-padder"> <div class="panel-footer no-padder">

View File

@ -4,7 +4,7 @@
<div class="row no-gutter"> <div class="row no-gutter">
<div class="col-xs-2 col-sm-2 col-md-1"> <div class="col-xs-2 col-sm-2 col-md-1">
<section class="heading-btn"> <section class="heading-btn">
<a ng-click="cancel()"><i class="fa fa-long-arrow-left"></i></a> <a ng-click="backPrevLocation($event)"><i class="fa fa-long-arrow-left"></i></a>
</section> </section>
</div> </div>
<div class="col-xs-10 col-sm-10 col-md-8 b-l b-r-md"> <div class="col-xs-10 col-sm-10 col-md-8 b-l b-r-md">
@ -15,7 +15,7 @@
<div class="col-xs-12 col-sm-12 col-md-3 b-t hide-b-md"> <div class="col-xs-12 col-sm-12 col-md-3 b-t hide-b-md">
<section class="heading-actions wrapper"> <section class="heading-actions wrapper">
<div class="btn btn-lg btn-block btn-default rounded m-t-xs" ng-click="cancel()" translate>{{ 'cancel' }}</div> <div class="btn btn-lg btn-block btn-default rounded m-t-xs" ng-click="backPrevLocation($event)" translate>{{ 'cancel' }}</div>
</section> </section>
</div> </div>
</div> </div>

View File

@ -46,8 +46,6 @@ en:
trainings: trainings:
# track and monitor the trainings # track and monitor the trainings
associated_machines: "Associated machines"
number_of_tickets: "Number of tickets"
training: "Training" training: "Training"
year_NUMBER: "Year {{NUMBER}}" # angular interpolation year_NUMBER: "Year {{NUMBER}}" # angular interpolation
month_of_NAME: "Month of {{NAME}}" # angular interpolation month_of_NAME: "Month of {{NAME}}" # angular interpolation

View File

@ -46,8 +46,6 @@ fr:
trainings: trainings:
# suivre et surveiller les formations # suivre et surveiller les formations
associated_machines: "Machines associées"
number_of_tickets: "Nombre de places"
training: "Formation" training: "Formation"
year_NUMBER: "Année {{NUMBER}}" # angular interpolation year_NUMBER: "Année {{NUMBER}}" # angular interpolation
month_of_NAME: "Mois de {{NAME}}" # angular interpolation month_of_NAME: "Mois de {{NAME}}" # angular interpolation

View File

@ -215,6 +215,8 @@ en:
# training edition form # training edition form
add_a_new_training: "Add a new training" add_a_new_training: "Add a new training"
validate_your_training: "Validate your training" validate_your_training: "Validate your training"
associated_machines: "Associated machines"
number_of_tickets: "Number of tickets"
user_admin: user_admin:
# partial form to edit/create an user (admin view) # partial form to edit/create an user (admin view)

View File

@ -215,6 +215,8 @@ fr:
# formulaire d'édition d'une formation # formulaire d'édition d'une formation
add_a_new_training: "Ajouter une nouvelle formation" add_a_new_training: "Ajouter une nouvelle formation"
validate_your_training: "Valider votre formation" validate_your_training: "Valider votre formation"
associated_machines: "Machines associées"
number_of_tickets: "Nombre de places"
user_admin: user_admin:
# formulaire partiel d'édition/création utilisateur (vue admin) # formulaire partiel d'édition/création utilisateur (vue admin)