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

hide machines list in edition of training if machines module is disabled

This commit is contained in:
Du Peng 2022-05-12 12:51:52 +02:00
parent 88dc91bcaf
commit 4d9da0c5f9
3 changed files with 13 additions and 7 deletions

View File

@ -81,8 +81,8 @@ class TrainingsController {
/**
* Controller used in the training creation page (admin)
*/
Application.Controllers.controller('NewTrainingController', ['$scope', '$state', 'machinesPromise', 'CSRF',
function ($scope, $state, machinesPromise, CSRF) {
Application.Controllers.controller('NewTrainingController', ['$scope', '$state', 'machinesPromise', 'settingsPromise', 'CSRF',
function ($scope, $state, machinesPromise, settingsPromise, CSRF) {
/* PUBLIC SCOPE */
// Form action on the following URL
@ -94,6 +94,8 @@ Application.Controllers.controller('NewTrainingController', ['$scope', '$state',
// list of machines
$scope.machines = machinesPromise;
$scope.enableMachinesModule = settingsPromise.machines_module === 'true';
/* PRIVATE SCOPE */
/**
@ -114,8 +116,8 @@ Application.Controllers.controller('NewTrainingController', ['$scope', '$state',
/**
* Controller used in the training edition page (admin)
*/
Application.Controllers.controller('EditTrainingController', ['$scope', '$state', '$transition$', 'trainingPromise', 'machinesPromise', 'CSRF',
function ($scope, $state, $transition$, trainingPromise, machinesPromise, CSRF) {
Application.Controllers.controller('EditTrainingController', ['$scope', '$state', '$transition$', 'trainingPromise', 'machinesPromise', 'settingsPromise', 'CSRF',
function ($scope, $state, $transition$, trainingPromise, machinesPromise, settingsPromise, CSRF) {
/* PUBLIC SCOPE */
// Form action on the following URL
@ -130,6 +132,8 @@ Application.Controllers.controller('EditTrainingController', ['$scope', '$state'
// list of machines
$scope.machines = machinesPromise;
$scope.enableMachinesModule = settingsPromise.machines_module === 'true';
/* PRIVATE SCOPE */
/**

View File

@ -683,7 +683,8 @@ angular.module('application.router', ['ui.router'])
}
},
resolve: {
machinesPromise: ['Machine', function (Machine) { return Machine.query().$promise; }]
machinesPromise: ['Machine', function (Machine) { return Machine.query().$promise; }],
settingsPromise: ['Setting', function (Setting) { return Setting.query({ names: "['machines_module']" }).$promise; }]
}
})
.state('app.admin.trainings_edit', {
@ -697,7 +698,8 @@ angular.module('application.router', ['ui.router'])
},
resolve: {
trainingPromise: ['Training', '$transition$', function (Training, $transition$) { return Training.get({ id: $transition$.params().id }).$promise; }],
machinesPromise: ['Machine', function (Machine) { return Machine.query().$promise; }]
machinesPromise: ['Machine', function (Machine) { return Machine.query().$promise; }],
settingsPromise: ['Setting', function (Setting) { return Setting.query({ names: "['machines_module']" }).$promise; }]
}
})
// events

View File

@ -65,7 +65,7 @@
</div>
</div>
<div class="form-group m-b-lg" ng-class="{'has-error': trainingForm['training[machine_ids]'].$dirty && trainingForm['training[machine_ids]'].$invalid}">
<div ng-if="enableMachinesModule" class="form-group m-b-lg" ng-class="{'has-error': trainingForm['training[machine_ids]'].$dirty && trainingForm['training[machine_ids]'].$invalid}">
<label for="training_machines" class="col-sm-2 control-label">{{ 'app.shared.trainings.associated_machines' | translate }}</label>
<div class="col-sm-4">
<ui-select multiple ng-model="training.machine_ids" class="form-control" id="training_machines">