diff --git a/app/controllers/admin/p_fournisseur_refs_controller.rb b/app/controllers/admin/p_fournisseur_refs_controller.rb new file mode 100644 index 0000000..31e86bc --- /dev/null +++ b/app/controllers/admin/p_fournisseur_refs_controller.rb @@ -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 diff --git a/app/models/p_fournisseur_ref.rb b/app/models/p_fournisseur_ref.rb new file mode 100644 index 0000000..5c8fa6c --- /dev/null +++ b/app/models/p_fournisseur_ref.rb @@ -0,0 +1,4 @@ +class PFournisseurRef < ApplicationRecord + belongs_to :p_product_ref + belongs_to :p_fournisseur +end diff --git a/app/views/admin/p_fournisseur_refs/_form.html.haml b/app/views/admin/p_fournisseur_refs/_form.html.haml new file mode 100644 index 0000000..0fdf241 --- /dev/null +++ b/app/views/admin/p_fournisseur_refs/_form.html.haml @@ -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" + \ No newline at end of file diff --git a/app/views/admin/p_fournisseur_refs/_p_fournisseur_ref.html.haml b/app/views/admin/p_fournisseur_refs/_p_fournisseur_ref.html.haml new file mode 100644 index 0000000..b9969b4 --- /dev/null +++ b/app/views/admin/p_fournisseur_refs/_p_fournisseur_ref.html.haml @@ -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} + + + + \ No newline at end of file diff --git a/app/views/admin/p_fournisseur_refs/create.js.erb b/app/views/admin/p_fournisseur_refs/create.js.erb new file mode 100644 index 0000000..a57e725 --- /dev/null +++ b/app/views/admin/p_fournisseur_refs/create.js.erb @@ -0,0 +1,2 @@ +$('#p_fournisseur_refs_rows').prepend("<%= escape_javascript(render(@p_fournisseur_ref))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_fournisseur_refs/destroy.js.erb b/app/views/admin/p_fournisseur_refs/destroy.js.erb new file mode 100644 index 0000000..72148c9 --- /dev/null +++ b/app/views/admin/p_fournisseur_refs/destroy.js.erb @@ -0,0 +1 @@ +$('#p_fournisseur_ref_row_<%= @p_fournisseur_ref.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_fournisseur_refs/edit.js.erb b/app/views/admin/p_fournisseur_refs/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_fournisseur_refs/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_fournisseur_refs/index.html.haml b/app/views/admin/p_fournisseur_refs/index.html.haml new file mode 100644 index 0000000..bcead3b --- /dev/null +++ b/app/views/admin/p_fournisseur_refs/index.html.haml @@ -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} + + + diff --git a/app/views/admin/p_fournisseur_refs/new.js.erb b/app/views/admin/p_fournisseur_refs/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_fournisseur_refs/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_fournisseur_refs/show.html.haml b/app/views/admin/p_fournisseur_refs/show.html.haml new file mode 100644 index 0000000..213e4c6 --- /dev/null +++ b/app/views/admin/p_fournisseur_refs/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_fournisseur_ref \ No newline at end of file diff --git a/app/views/admin/p_fournisseur_refs/update.js.erb b/app/views/admin/p_fournisseur_refs/update.js.erb new file mode 100644 index 0000000..b135464 --- /dev/null +++ b/app/views/admin/p_fournisseur_refs/update.js.erb @@ -0,0 +1,2 @@ +$('#p_fournisseur_ref_row_<%= @p_fournisseur_ref.id %>').replaceWith("<%= escape_javascript(render(@p_fournisseur_ref))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 355ebde..d3a9d8a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/db/migrate/20211005134955_create_p_fournisseur_refs.rb b/db/migrate/20211005134955_create_p_fournisseur_refs.rb new file mode 100644 index 0000000..dc65fc0 --- /dev/null +++ b/db/migrate/20211005134955_create_p_fournisseur_refs.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index dc64e8d..15f694f 100644 --- a/db/schema.rb +++ b/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" diff --git a/test/fixtures/p_fournisseur_refs.yml b/test/fixtures/p_fournisseur_refs.yml new file mode 100644 index 0000000..0e0af5e --- /dev/null +++ b/test/fixtures/p_fournisseur_refs.yml @@ -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 diff --git a/test/models/p_fournisseur_ref_test.rb b/test/models/p_fournisseur_ref_test.rb new file mode 100644 index 0000000..c6087ea --- /dev/null +++ b/test/models/p_fournisseur_ref_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PFournisseurRefTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end