mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-29 18:52:22 +01:00
ability to disable machine
This commit is contained in:
parent
5ce6d4486e
commit
c67360771a
@ -112,7 +112,7 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="training[public_page]" class="control-label col-sm-2" translate>
|
||||
<label for="training[disabled]" class="control-label col-sm-2" translate>
|
||||
{{ 'trainings_form.disable_training' }}
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
|
@ -15,21 +15,21 @@
|
||||
<uib-alert ng-repeat="alert in alerts" type="{{alert.type}}" close="closeAlert($index)">{{alert.msg}}</uib-alert>
|
||||
|
||||
<div class="form-group m-b-lg" ng-class="{'has-error': machineForm['machine[name]'].$dirty && machineForm['machine[name]'].$invalid}">
|
||||
<label for="name" class="col-sm-2 control-label">{{ 'name' | translate }} *</label>
|
||||
<label for="name" class="col-sm-2 control-label">{{ 'machine_form.name' | translate }} *</label>
|
||||
<div class="col-sm-4">
|
||||
<input ng-model="machine.name"
|
||||
type="text"
|
||||
name="machine[name]"
|
||||
class="form-control"
|
||||
id="machine_name"
|
||||
placeholder="{{'name' | translate}}"
|
||||
placeholder="{{'machine_form.name' | translate}}"
|
||||
required>
|
||||
<span class="help-block" ng-show="machineForm['machine[name]'].$dirty && machineForm['machine[name]'].$error.required" translate>{{ 'name_is_required' }}</span>
|
||||
<span class="help-block" ng-show="machineForm['machine[name]'].$dirty && machineForm['machine[name]'].$error.required" translate>{{ 'machine_form.name_is_required' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group m-b-lg">
|
||||
<label for="machine_image" class="col-sm-2 control-label">{{ 'illustration' | translate }} *</label>
|
||||
<label for="machine_image" class="col-sm-2 control-label">{{ 'machine_form.illustration' | translate }} *</label>
|
||||
<div class="col-sm-10">
|
||||
<div class="fileinput" data-provides="fileinput" ng-class="fileinputClass(machine.machine_image)">
|
||||
<div class="fileinput-new thumbnail" style="width: 334px; height: 250px;">
|
||||
@ -40,7 +40,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<span class="btn btn-default btn-file">
|
||||
<span class="fileinput-new">{{ 'add_an_illustration' | translate }} <i class="fa fa-upload fa-fw"></i></span>
|
||||
<span class="fileinput-new">{{ 'machine_form.add_an_illustration' | translate }} <i class="fa fa-upload fa-fw"></i></span>
|
||||
<span class="fileinput-exists" translate>{{ 'change' }}</span>
|
||||
<input type="file"
|
||||
ng-model="machine.machine_image"
|
||||
@ -57,7 +57,7 @@
|
||||
|
||||
|
||||
<div class="form-group m-b-xl" ng-class="{'has-error': machineForm['machine[description]'].$dirty && machineForm['machine[description]'].$invalid}">
|
||||
<label for="description" class="col-sm-2 control-label">{{ 'description' | translate }} *</label>
|
||||
<label for="description" class="col-sm-2 control-label">{{ 'machine_form.description' | translate }} *</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="hidden"
|
||||
name="machine[description]"
|
||||
@ -69,12 +69,12 @@
|
||||
name="machine[description]"
|
||||
required>
|
||||
</summernote>
|
||||
<span class="help-block" ng-show="machineForm['machine[description]'].$dirty && machineForm['machine[description]'].$error.required" translate>{{ 'description_is_required' }}</span>
|
||||
<span class="help-block" ng-show="machineForm['machine[description]'].$dirty && machineForm['machine[description]'].$error.required" translate>{{ 'machine_form.description_is_required' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group m-b-xl" ng-class="{'has-error': machineForm['machine[spec]'].$dirty && machineForm['machine[spec]'].$invalid}">
|
||||
<label for="spec" class="col-sm-2 control-label">{{ 'technical_specifications' | translate }} *</label>
|
||||
<label for="spec" class="col-sm-2 control-label">{{ 'machine_form.technical_specifications' | translate }} *</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="hidden"
|
||||
name="machine[spec]"
|
||||
@ -86,12 +86,12 @@
|
||||
name="machine[spec]"
|
||||
required>
|
||||
</summernote>
|
||||
<span class="help-block" ng-show="machineForm['machine[spec]'].$dirty && machineForm['machine[spec]'].$error.required" translate>{{ 'technical_specifications_are_required' }}</span>
|
||||
<span class="help-block" ng-show="machineForm['machine[spec]'].$dirty && machineForm['machine[spec]'].$error.required" translate>{{ 'machine_form.technical_specifications_are_required' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group m-b-xl">
|
||||
<label class="col-sm-2 control-label" translate>{{ 'attached_files_(pdf)' }}</label>
|
||||
<label class="col-sm-2 control-label" translate>{{ 'machine_form.attached_files_(pdf)' }}</label>
|
||||
<div class="col-sm-10">
|
||||
<div ng-repeat="file in machine.machine_files_attributes" ng-show="!file._destroy">
|
||||
<input type="hidden" ng-model="file.id" name="machine[machine_files_attributes][][id]" ng-value="file.id" />
|
||||
@ -101,13 +101,30 @@
|
||||
<div class="form-control" data-trigger="fileinput">
|
||||
<i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename">{{file.attachment}}</span>
|
||||
</div>
|
||||
<span class="input-group-addon btn btn-default btn-file"><span class="fileinput-new" translate>{{ 'attach_a_file' }}</span>
|
||||
<span class="input-group-addon btn btn-default btn-file"><span class="fileinput-new" translate>{{ 'machine_form.attach_a_file' }}</span>
|
||||
<span class="fileinput-exists" translate>{{ 'change' }}</span><input type="file" name="machine[machine_files_attributes][][attachment]" accept=".pdf"></span>
|
||||
<a class="input-group-addon btn btn-danger fileinput-exists" data-dismiss="fileinput" ng-click="deleteFile(file)"><i class="fa fa-trash-o"></i></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<a class="btn btn-default" ng-click="addFile()" role="button"> {{ 'add_an_attachment' | translate }} <i class="fa fa-file-o fa-fw"></i></a>
|
||||
<a class="btn btn-default" ng-click="addFile()" role="button"> {{ 'machine_form.add_an_attachment' | translate }} <i class="fa fa-file-o fa-fw"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="machine[disabled]" class="control-label col-sm-2" translate>
|
||||
{{ 'machine_form.disable_machine' }}
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<input bs-switch
|
||||
ng-model="machine.disabled"
|
||||
name="machine[disabled]"
|
||||
type="checkbox"
|
||||
class="form-control"
|
||||
switch-on-text="{{ 'yes' | translate }}"
|
||||
switch-off-text="{{ 'no' | translate }}"
|
||||
switch-animate="true"/>
|
||||
<input type="hidden" name="machine[disabled]" value="{{machine.disabled}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -115,7 +132,7 @@
|
||||
|
||||
<div class="panel-footer no-padder">
|
||||
<input type="submit"
|
||||
value="{{ 'validate_your_machine' | translate }}"
|
||||
value="{{ 'machine_form.validate_your_machine' | translate }}"
|
||||
class="r-b btn-valid btn btn-warning btn-block p-lg btn-lg text-u-c"
|
||||
ng-disabled="machineForm.$invalid"/>
|
||||
</div>
|
||||
|
@ -42,7 +42,7 @@ class API::MachinesController < API::ApiController
|
||||
end
|
||||
|
||||
def machine_params
|
||||
params.require(:machine).permit(:name, :description, :spec, :plan_ids, plan_ids: [], machine_image_attributes: [:attachment],
|
||||
params.require(:machine).permit(:name, :description, :spec, :disabled, :plan_ids, plan_ids: [], machine_image_attributes: [:attachment],
|
||||
machine_files_attributes: [:id, :attachment, :_destroy])
|
||||
end
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
json.array!(@machines) do |machine|
|
||||
json.extract! machine, :id, :name, :description, :spec, :slug
|
||||
json.extract! machine, :id, :name, :description, :spec, :slug, :disabled
|
||||
json.url machine_url(machine, format: :json)
|
||||
json.machine_image machine.machine_image.attachment.medium.url if machine.machine_image
|
||||
end
|
||||
|
@ -1,4 +1,4 @@
|
||||
json.extract! @machine, :id, :name, :description, :spec, :created_at, :updated_at, :slug
|
||||
json.extract! @machine, :id, :name, :description, :spec, :disabled, :created_at, :updated_at, :slug
|
||||
json.machine_image @machine.machine_image.attachment.large.url if @machine.machine_image
|
||||
json.machine_files_attributes @machine.machine_files do |f|
|
||||
json.id f.id
|
||||
|
@ -144,11 +144,20 @@ fr:
|
||||
|
||||
machine:
|
||||
# formulaire d'édition d'une machine
|
||||
technical_specifications_are_required: "Les caractéristiques techniques sont requises."
|
||||
attached_files_(pdf): "Pièces jointes (pdf)"
|
||||
attach_a_file: "Joindre un fichier"
|
||||
add_an_attachment: "Ajouter une pièce jointe"
|
||||
validate_your_machine: "Valider votre machine"
|
||||
machine_form:
|
||||
name: "Nom"
|
||||
name_is_required: "Le nom est requis."
|
||||
illustration: "Visuel"
|
||||
add_an_illustration: "Ajouter un visuel"
|
||||
description: "Description"
|
||||
description_is_required: "La description est requise."
|
||||
technical_specifications: "Caractéristiques techniques"
|
||||
technical_specifications_are_required: "Les caractéristiques techniques sont requises."
|
||||
attached_files_(pdf): "Pièces jointes (pdf)"
|
||||
attach_a_file: "Joindre un fichier"
|
||||
add_an_attachment: "Ajouter une pièce jointe"
|
||||
disable_machine: "Désactiver la machine"
|
||||
validate_your_machine: "Valider votre machine"
|
||||
|
||||
plan_subscribe:
|
||||
# cadre de souscription à un abonnement
|
||||
|
5
db/migrate/20171011100640_add_disabled_to_machine.rb
Normal file
5
db/migrate/20171011100640_add_disabled_to_machine.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddDisabledToMachine < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :machines, :disabled, :boolean
|
||||
end
|
||||
end
|
@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20171010143708) do
|
||||
ActiveRecord::Schema.define(version: 20171011100640) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@ -271,6 +271,7 @@ ActiveRecord::Schema.define(version: 20171010143708) do
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "slug", limit: 255
|
||||
t.boolean "disabled"
|
||||
end
|
||||
|
||||
add_index "machines", ["slug"], name: "index_machines_on_slug", unique: true, using: :btree
|
||||
|
Loading…
x
Reference in New Issue
Block a user