add p_fournisseur_ref
This commit is contained in:
parent
0209a981d4
commit
9de88372a1
76
app/controllers/admin/p_fournisseur_refs_controller.rb
Normal file
76
app/controllers/admin/p_fournisseur_refs_controller.rb
Normal file
@ -0,0 +1,76 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
|
||||
class Admin::PFournisseurRefsController < ApplicationController
|
||||
layout "admin"
|
||||
before_action :auth_admin
|
||||
|
||||
before_action :admin_space
|
||||
|
||||
def admin_space
|
||||
@admin_space = "default"
|
||||
end
|
||||
|
||||
def index
|
||||
@p_fournisseur_refs = PFournisseurRef.all
|
||||
|
||||
@p_fournisseur_refs = sort_by_sorting(@p_fournisseur_refs, "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_fournisseur_refs = @p_fournisseur_refs.page(page).per(per_page)
|
||||
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@p_fournisseur_ref = PFournisseurRef.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
@p_fournisseur_ref = PFournisseurRef.new
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
@p_fournisseur_ref = PFournisseurRef.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
@p_fournisseur_ref = PFournisseurRef.new(params.require(:p_fournisseur_ref).permit!)
|
||||
|
||||
if @p_fournisseur_ref.save
|
||||
|
||||
else
|
||||
render action: "new"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def update
|
||||
@p_fournisseur_ref = PFournisseurRef.find(params[:id])
|
||||
|
||||
|
||||
if @p_fournisseur_ref.update_attributes(params.require(:p_fournisseur_ref).permit!)
|
||||
|
||||
else
|
||||
render action: "edit"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
@p_fournisseur_ref = PFournisseurRef.find(params[:id])
|
||||
@p_fournisseur_ref.destroy
|
||||
|
||||
end
|
||||
end
|
4
app/models/p_fournisseur_ref.rb
Normal file
4
app/models/p_fournisseur_ref.rb
Normal file
@ -0,0 +1,4 @@
|
||||
class PFournisseurRef < ApplicationRecord
|
||||
belongs_to :p_product_ref
|
||||
belongs_to :p_fournisseur
|
||||
end
|
14
app/views/admin/p_fournisseur_refs/_form.html.haml
Normal file
14
app/views/admin/p_fournisseur_refs/_form.html.haml
Normal file
@ -0,0 +1,14 @@
|
||||
=semantic_form_for [:admin, @p_fournisseur_ref], :remote => true do |f|
|
||||
|
||||
.content
|
||||
=f.inputs do
|
||||
= f.input :ref, :label => f.object.label_for(:ref)
|
||||
= f.input :p_product_ref, :label => f.object.label_for(:p_product_ref)
|
||||
= f.input :p_fournisseur, :label => f.object.label_for(:p_fournisseur)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.actions=f.submit "sauvegarder", :class => "btn btn-primary"
|
||||
|
@ -0,0 +1,16 @@
|
||||
%tr#p_fournisseur_ref_row{:id => p_fournisseur_ref.id}
|
||||
-tr = {}
|
||||
|
||||
-tr[:actions] = capture do
|
||||
%td.actions
|
||||
= link_to i(:"trash-o"), [:admin, p_fournisseur_ref], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
|
||||
= link_to i(:pencil), edit_admin_p_fournisseur_ref_path(p_fournisseur_ref), :remote => true
|
||||
= link_to i(:eye), admin_p_fournisseur_ref_path(p_fournisseur_ref), :remote => true
|
||||
|
||||
|
||||
|
||||
=render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_fournisseur_ref}
|
||||
|
||||
|
||||
|
||||
|
2
app/views/admin/p_fournisseur_refs/create.js.erb
Normal file
2
app/views/admin/p_fournisseur_refs/create.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
$('#p_fournisseur_refs_rows').prepend("<%= escape_javascript(render(@p_fournisseur_ref))%>");
|
||||
close_pane_hover();
|
1
app/views/admin/p_fournisseur_refs/destroy.js.erb
Normal file
1
app/views/admin/p_fournisseur_refs/destroy.js.erb
Normal file
@ -0,0 +1 @@
|
||||
$('#p_fournisseur_ref_row_<%= @p_fournisseur_ref.id %>').remove();
|
1
app/views/admin/p_fournisseur_refs/edit.js.erb
Normal file
1
app/views/admin/p_fournisseur_refs/edit.js.erb
Normal file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
16
app/views/admin/p_fournisseur_refs/index.html.haml
Normal file
16
app/views/admin/p_fournisseur_refs/index.html.haml
Normal file
@ -0,0 +1,16 @@
|
||||
.qi_header
|
||||
.right= link_to ic(:plus)+' Ajouter', new_admin_p_fournisseur_ref_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||
%h1
|
||||
=PFournisseurRef.human rescue ""
|
||||
|
||||
|
||||
|
||||
.qi_search_row
|
||||
=form_tag "", :method => "get", :onsubmit => "" do
|
||||
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_fournisseur_refs}
|
||||
|
||||
|
||||
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_fournisseur_refs}
|
||||
|
||||
|
||||
|
1
app/views/admin/p_fournisseur_refs/new.js.erb
Normal file
1
app/views/admin/p_fournisseur_refs/new.js.erb
Normal file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
10
app/views/admin/p_fournisseur_refs/show.html.haml
Normal file
10
app/views/admin/p_fournisseur_refs/show.html.haml
Normal file
@ -0,0 +1,10 @@
|
||||
.qi_header
|
||||
%h1
|
||||
|
||||
%span
|
||||
|
||||
|
||||
|
||||
.qi_row
|
||||
.qi_pannel.qi_plain.padding
|
||||
=debug @p_fournisseur_ref
|
2
app/views/admin/p_fournisseur_refs/update.js.erb
Normal file
2
app/views/admin/p_fournisseur_refs/update.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
$('#p_fournisseur_ref_row_<%= @p_fournisseur_ref.id %>').replaceWith("<%= escape_javascript(render(@p_fournisseur_ref))%>");
|
||||
close_pane_hover();
|
@ -1,5 +1,16 @@
|
||||
Rails.application.routes.draw do
|
||||
|
||||
namespace :admin do
|
||||
resources :p_fournisseur_refs do
|
||||
member do
|
||||
|
||||
end
|
||||
collection do
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace :admin do
|
||||
resources :price_line_resp_selects do
|
||||
member do
|
||||
|
11
db/migrate/20211005134955_create_p_fournisseur_refs.rb
Normal file
11
db/migrate/20211005134955_create_p_fournisseur_refs.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class CreatePFournisseurRefs < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
create_table :p_fournisseur_refs do |t|
|
||||
t.string :ref
|
||||
t.references :p_product_ref, foreign_key: true
|
||||
t.references :p_fournisseur, foreign_key: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
14
db/schema.rb
14
db/schema.rb
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2021_10_04_161753) do
|
||||
ActiveRecord::Schema.define(version: 2021_10_05_134955) do
|
||||
|
||||
create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
t.string "name"
|
||||
@ -1451,6 +1451,16 @@ ActiveRecord::Schema.define(version: 2021_10_04_161753) do
|
||||
t.index ["p_fournisseur_id"], name: "index_p_fournisseur_orders_on_p_fournisseur_id"
|
||||
end
|
||||
|
||||
create_table "p_fournisseur_refs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
t.string "ref"
|
||||
t.bigint "p_product_ref_id"
|
||||
t.bigint "p_fournisseur_id"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.index ["p_fournisseur_id"], name: "index_p_fournisseur_refs_on_p_fournisseur_id"
|
||||
t.index ["p_product_ref_id"], name: "index_p_fournisseur_refs_on_p_product_ref_id"
|
||||
end
|
||||
|
||||
create_table "p_fournisseurs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.string "code"
|
||||
@ -3158,6 +3168,8 @@ ActiveRecord::Schema.define(version: 2021_10_04_161753) do
|
||||
add_foreign_key "p_customer_product_prices", "p_customers"
|
||||
add_foreign_key "p_customer_product_prices", "p_product_refs"
|
||||
add_foreign_key "p_customer_ribs", "p_customers"
|
||||
add_foreign_key "p_fournisseur_refs", "p_fournisseurs"
|
||||
add_foreign_key "p_fournisseur_refs", "p_product_refs"
|
||||
add_foreign_key "p_product_aromes", "p_aromes"
|
||||
add_foreign_key "p_product_aromes", "p_products"
|
||||
add_foreign_key "p_product_images", "image_files"
|
||||
|
11
test/fixtures/p_fournisseur_refs.yml
vendored
Normal file
11
test/fixtures/p_fournisseur_refs.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
ref: MyString
|
||||
p_product_ref: one
|
||||
p_fournisseur: one
|
||||
|
||||
two:
|
||||
ref: MyString
|
||||
p_product_ref: two
|
||||
p_fournisseur: two
|
7
test/models/p_fournisseur_ref_test.rb
Normal file
7
test/models/p_fournisseur_ref_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class PFournisseurRefTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Reference in New Issue
Block a user