generate p_spec_value
This commit is contained in:
parent
dfdd443998
commit
374c92b9a4
76
app/controllers/admin/p_spec_values_controller.rb
Normal file
76
app/controllers/admin/p_spec_values_controller.rb
Normal file
@ -0,0 +1,76 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
|
||||
class Admin::PSpecValuesController < ApplicationController
|
||||
layout "admin"
|
||||
before_action :auth_admin
|
||||
|
||||
before_action :admin_space
|
||||
|
||||
def admin_space
|
||||
@admin_space = "default"
|
||||
end
|
||||
|
||||
def index
|
||||
@p_spec_values = PSpecValue.all
|
||||
|
||||
@p_spec_values = sort_by_sorting(@p_spec_values, "id DESC")
|
||||
respond_to do |format|
|
||||
format.html{
|
||||
|
||||
params[:search][:per_page] = params[:search][:per_page] || 100
|
||||
per_page = params[:search][:per_page]
|
||||
page = (params[:page] and params[:page] != "") ? params[:page] : 1
|
||||
@p_spec_values = @p_spec_values.page(page).per(per_page)
|
||||
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@p_spec_value = PSpecValue.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
@p_spec_value = PSpecValue.new
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
@p_spec_value = PSpecValue.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
@p_spec_value = PSpecValue.new(params.require(:p_spec_value).permit!)
|
||||
|
||||
if @p_spec_value.save
|
||||
|
||||
else
|
||||
render action: "new"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def update
|
||||
@p_spec_value = PSpecValue.find(params[:id])
|
||||
|
||||
|
||||
if @p_spec_value.update_attributes(params.require(:p_spec_value).permit!)
|
||||
|
||||
else
|
||||
render action: "edit"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
@p_spec_value = PSpecValue.find(params[:id])
|
||||
@p_spec_value.destroy
|
||||
|
||||
end
|
||||
end
|
2
app/models/p_spec_value.rb
Normal file
2
app/models/p_spec_value.rb
Normal file
@ -0,0 +1,2 @@
|
||||
class PSpecValue < ApplicationRecord
|
||||
end
|
13
app/views/admin/p_spec_values/_form.html.haml
Normal file
13
app/views/admin/p_spec_values/_form.html.haml
Normal file
@ -0,0 +1,13 @@
|
||||
=semantic_form_for [:admin, @p_spec_value], :remote => true do |f|
|
||||
|
||||
.content
|
||||
=f.inputs do
|
||||
= f.input :value, :label => f.object.label_for(:value)
|
||||
= f.input :unit, :label => f.object.label_for(:unit)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.actions=f.submit "sauvegarder", :class => "btn btn-primary"
|
||||
|
16
app/views/admin/p_spec_values/_p_spec_value.html.haml
Normal file
16
app/views/admin/p_spec_values/_p_spec_value.html.haml
Normal file
@ -0,0 +1,16 @@
|
||||
%tr#p_spec_value_row{:id => p_spec_value.id}
|
||||
-tr = {}
|
||||
|
||||
-tr[:actions] = capture do
|
||||
%td.actions
|
||||
= link_to i(:"trash-o"), [:admin, p_spec_value], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
|
||||
= link_to i(:pencil), edit_admin_p_spec_value_path(p_spec_value), :remote => true
|
||||
= link_to i(:eye), admin_p_spec_value_path(p_spec_value), :remote => true
|
||||
|
||||
|
||||
|
||||
=render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_spec_value}
|
||||
|
||||
|
||||
|
||||
|
2
app/views/admin/p_spec_values/create.js.erb
Normal file
2
app/views/admin/p_spec_values/create.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
$('#p_spec_values_rows').prepend("<%= escape_javascript(render(@p_spec_value))%>");
|
||||
close_pane_hover();
|
1
app/views/admin/p_spec_values/destroy.js.erb
Normal file
1
app/views/admin/p_spec_values/destroy.js.erb
Normal file
@ -0,0 +1 @@
|
||||
$('#p_spec_value_row_<%= @p_spec_value.id %>').remove();
|
1
app/views/admin/p_spec_values/edit.js.erb
Normal file
1
app/views/admin/p_spec_values/edit.js.erb
Normal file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
16
app/views/admin/p_spec_values/index.html.haml
Normal file
16
app/views/admin/p_spec_values/index.html.haml
Normal file
@ -0,0 +1,16 @@
|
||||
.qi_header
|
||||
.right= link_to ic(:plus)+' Ajouter', new_admin_p_spec_value_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||
%h1
|
||||
=PSpecValue.human rescue ""
|
||||
|
||||
|
||||
|
||||
.qi_search_row
|
||||
=form_tag "", :method => "get", :onsubmit => "" do
|
||||
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_spec_values}
|
||||
|
||||
|
||||
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_spec_values}
|
||||
|
||||
|
||||
|
1
app/views/admin/p_spec_values/new.js.erb
Normal file
1
app/views/admin/p_spec_values/new.js.erb
Normal file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
10
app/views/admin/p_spec_values/show.html.haml
Normal file
10
app/views/admin/p_spec_values/show.html.haml
Normal file
@ -0,0 +1,10 @@
|
||||
.qi_header
|
||||
%h1
|
||||
|
||||
%span
|
||||
|
||||
|
||||
|
||||
.qi_row
|
||||
.qi_pannel.qi_plain.padding
|
||||
=debug @p_spec_value
|
2
app/views/admin/p_spec_values/update.js.erb
Normal file
2
app/views/admin/p_spec_values/update.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
$('#p_spec_value_row_<%= @p_spec_value.id %>').replaceWith("<%= escape_javascript(render(@p_spec_value))%>");
|
||||
close_pane_hover();
|
@ -1,5 +1,16 @@
|
||||
Rails.application.routes.draw do
|
||||
|
||||
namespace :admin do
|
||||
resources :p_spec_values do
|
||||
member do
|
||||
|
||||
end
|
||||
collection do
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace :admin do
|
||||
resources :p_spec_types do
|
||||
member do
|
||||
|
10
db/migrate/20210827074615_create_p_spec_values.rb
Normal file
10
db/migrate/20210827074615_create_p_spec_values.rb
Normal file
@ -0,0 +1,10 @@
|
||||
class CreatePSpecValues < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
create_table :p_spec_values do |t|
|
||||
t.string :value
|
||||
t.string :unit
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2021_08_27_074532) do
|
||||
ActiveRecord::Schema.define(version: 2021_08_27_074615) do
|
||||
|
||||
create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
t.string "name"
|
||||
@ -1984,6 +1984,13 @@ ActiveRecord::Schema.define(version: 2021_08_27_074532) do
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
end
|
||||
|
||||
create_table "p_spec_values", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
t.string "value"
|
||||
t.string "unit"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
end
|
||||
|
||||
create_table "p_tank_stocks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
t.datetime "ok_at"
|
||||
t.boolean "enabled", default: false
|
||||
|
9
test/fixtures/p_spec_values.yml
vendored
Normal file
9
test/fixtures/p_spec_values.yml
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
value: MyString
|
||||
unit: MyString
|
||||
|
||||
two:
|
||||
value: MyString
|
||||
unit: MyString
|
7
test/models/p_spec_value_test.rb
Normal file
7
test/models/p_spec_value_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class PSpecValueTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Reference in New Issue
Block a user