generate p_spec_type
This commit is contained in:
parent
9db1d17d9a
commit
dfdd443998
76
app/controllers/admin/p_spec_types_controller.rb
Normal file
76
app/controllers/admin/p_spec_types_controller.rb
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# -*- encoding : utf-8 -*-
|
||||||
|
|
||||||
|
class Admin::PSpecTypesController < ApplicationController
|
||||||
|
layout "admin"
|
||||||
|
before_action :auth_admin
|
||||||
|
|
||||||
|
before_action :admin_space
|
||||||
|
|
||||||
|
def admin_space
|
||||||
|
@admin_space = "default"
|
||||||
|
end
|
||||||
|
|
||||||
|
def index
|
||||||
|
@p_spec_types = PSpecType.all
|
||||||
|
|
||||||
|
@p_spec_types = sort_by_sorting(@p_spec_types, "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_types = @p_spec_types.page(page).per(per_page)
|
||||||
|
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
@p_spec_type = PSpecType.find(params[:id])
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@p_spec_type = PSpecType.new
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@p_spec_type = PSpecType.find(params[:id])
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@p_spec_type = PSpecType.new(params.require(:p_spec_type).permit!)
|
||||||
|
|
||||||
|
if @p_spec_type.save
|
||||||
|
|
||||||
|
else
|
||||||
|
render action: "new"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def update
|
||||||
|
@p_spec_type = PSpecType.find(params[:id])
|
||||||
|
|
||||||
|
|
||||||
|
if @p_spec_type.update_attributes(params.require(:p_spec_type).permit!)
|
||||||
|
|
||||||
|
else
|
||||||
|
render action: "edit"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@p_spec_type = PSpecType.find(params[:id])
|
||||||
|
@p_spec_type.destroy
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
2
app/models/p_spec_type.rb
Normal file
2
app/models/p_spec_type.rb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
class PSpecType < ApplicationRecord
|
||||||
|
end
|
12
app/views/admin/p_spec_types/_form.html.haml
Normal file
12
app/views/admin/p_spec_types/_form.html.haml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
=semantic_form_for [:admin, @p_spec_type], :remote => true do |f|
|
||||||
|
|
||||||
|
.content
|
||||||
|
=f.inputs do
|
||||||
|
= f.input :type, :label => f.object.label_for(:type)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.actions=f.submit "sauvegarder", :class => "btn btn-primary"
|
||||||
|
|
16
app/views/admin/p_spec_types/_p_spec_type.html.haml
Normal file
16
app/views/admin/p_spec_types/_p_spec_type.html.haml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
%tr#p_spec_type_row{:id => p_spec_type.id}
|
||||||
|
-tr = {}
|
||||||
|
|
||||||
|
-tr[:actions] = capture do
|
||||||
|
%td.actions
|
||||||
|
= link_to i(:"trash-o"), [:admin, p_spec_type], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
|
||||||
|
= link_to i(:pencil), edit_admin_p_spec_type_path(p_spec_type), :remote => true
|
||||||
|
= link_to i(:eye), admin_p_spec_type_path(p_spec_type), :remote => true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
=render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_spec_type}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
2
app/views/admin/p_spec_types/create.js.erb
Normal file
2
app/views/admin/p_spec_types/create.js.erb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
$('#p_spec_types_rows').prepend("<%= escape_javascript(render(@p_spec_type))%>");
|
||||||
|
close_pane_hover();
|
1
app/views/admin/p_spec_types/destroy.js.erb
Normal file
1
app/views/admin/p_spec_types/destroy.js.erb
Normal file
@ -0,0 +1 @@
|
|||||||
|
$('#p_spec_type_row_<%= @p_spec_type.id %>').remove();
|
1
app/views/admin/p_spec_types/edit.js.erb
Normal file
1
app/views/admin/p_spec_types/edit.js.erb
Normal file
@ -0,0 +1 @@
|
|||||||
|
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
16
app/views/admin/p_spec_types/index.html.haml
Normal file
16
app/views/admin/p_spec_types/index.html.haml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
.qi_header
|
||||||
|
.right= link_to ic(:plus)+' Ajouter', new_admin_p_spec_type_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||||
|
%h1
|
||||||
|
=PSpecType.human rescue ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.qi_search_row
|
||||||
|
=form_tag "", :method => "get", :onsubmit => "" do
|
||||||
|
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_spec_types}
|
||||||
|
|
||||||
|
|
||||||
|
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_spec_types}
|
||||||
|
|
||||||
|
|
||||||
|
|
1
app/views/admin/p_spec_types/new.js.erb
Normal file
1
app/views/admin/p_spec_types/new.js.erb
Normal file
@ -0,0 +1 @@
|
|||||||
|
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
10
app/views/admin/p_spec_types/show.html.haml
Normal file
10
app/views/admin/p_spec_types/show.html.haml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
.qi_header
|
||||||
|
%h1
|
||||||
|
|
||||||
|
%span
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.qi_row
|
||||||
|
.qi_pannel.qi_plain.padding
|
||||||
|
=debug @p_spec_type
|
2
app/views/admin/p_spec_types/update.js.erb
Normal file
2
app/views/admin/p_spec_types/update.js.erb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
$('#p_spec_type_row_<%= @p_spec_type.id %>').replaceWith("<%= escape_javascript(render(@p_spec_type))%>");
|
||||||
|
close_pane_hover();
|
@ -1,5 +1,16 @@
|
|||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
|
|
||||||
|
namespace :admin do
|
||||||
|
resources :p_spec_types do
|
||||||
|
member do
|
||||||
|
|
||||||
|
end
|
||||||
|
collection do
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
namespace :admin do
|
namespace :admin do
|
||||||
resources :p_article_serial_nums do
|
resources :p_article_serial_nums do
|
||||||
member do
|
member do
|
||||||
|
9
db/migrate/20210827074532_create_p_spec_types.rb
Normal file
9
db/migrate/20210827074532_create_p_spec_types.rb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
class CreatePSpecTypes < ActiveRecord::Migration[6.0]
|
||||||
|
def change
|
||||||
|
create_table :p_spec_types do |t|
|
||||||
|
t.string :type
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2021_08_26_145816) do
|
ActiveRecord::Schema.define(version: 2021_08_27_074532) do
|
||||||
|
|
||||||
create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
@ -1978,6 +1978,12 @@ ActiveRecord::Schema.define(version: 2021_08_26_145816) do
|
|||||||
t.index ["p_fournisseur_id"], name: "index_p_ship_bills_on_p_fournisseur_id"
|
t.index ["p_fournisseur_id"], name: "index_p_ship_bills_on_p_fournisseur_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "p_spec_types", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||||
|
t.string "type"
|
||||||
|
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|
|
create_table "p_tank_stocks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||||
t.datetime "ok_at"
|
t.datetime "ok_at"
|
||||||
t.boolean "enabled", default: false
|
t.boolean "enabled", default: false
|
||||||
|
7
test/fixtures/p_spec_types.yml
vendored
Normal file
7
test/fixtures/p_spec_types.yml
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||||
|
|
||||||
|
one:
|
||||||
|
type:
|
||||||
|
|
||||||
|
two:
|
||||||
|
type:
|
7
test/models/p_spec_type_test.rb
Normal file
7
test/models/p_spec_type_test.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class PSpecTypeTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
Reference in New Issue
Block a user