diff --git a/app/controllers/admin/p_product_ref_specs_controller.rb b/app/controllers/admin/p_product_ref_specs_controller.rb new file mode 100644 index 0000000..7522ebb --- /dev/null +++ b/app/controllers/admin/p_product_ref_specs_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::PProductRefSpecsController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @p_product_ref_specs = PProductRefSpec.all + + @p_product_ref_specs = sort_by_sorting(@p_product_ref_specs, "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_product_ref_specs = @p_product_ref_specs.page(page).per(per_page) + + } + end + end + + def show + @p_product_ref_spec = PProductRefSpec.find(params[:id]) + + end + + def new + @p_product_ref_spec = PProductRefSpec.new + + end + + def edit + @p_product_ref_spec = PProductRefSpec.find(params[:id]) + + end + + def create + @p_product_ref_spec = PProductRefSpec.new(params.require(:p_product_ref_spec).permit!) + + if @p_product_ref_spec.save + + else + render action: "new" + + end + + end + + + def update + @p_product_ref_spec = PProductRefSpec.find(params[:id]) + + + if @p_product_ref_spec.update_attributes(params.require(:p_product_ref_spec).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @p_product_ref_spec = PProductRefSpec.find(params[:id]) + @p_product_ref_spec.destroy + + end +end diff --git a/app/models/p_product_ref_spec.rb b/app/models/p_product_ref_spec.rb new file mode 100644 index 0000000..3b80fce --- /dev/null +++ b/app/models/p_product_ref_spec.rb @@ -0,0 +1,5 @@ +class PProductRefSpec < ApplicationRecord + belongs_to :p_product_ref + belongs_to :p_spec_type + belongs_to :p_spec_value +end diff --git a/app/views/admin/p_product_ref_specs/_form.html.haml b/app/views/admin/p_product_ref_specs/_form.html.haml new file mode 100644 index 0000000..8fd4851 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/_form.html.haml @@ -0,0 +1,14 @@ +=semantic_form_for [:admin, @p_product_ref_spec], :remote => true do |f| + + .content + =f.inputs do + = f.input :p_product_ref, :label => f.object.label_for(:p_product_ref) + = f.input :p_spec_type, :label => f.object.label_for(:p_spec_type) + = f.input :p_spec_value, :label => f.object.label_for(:p_spec_value) + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/p_product_ref_specs/_p_product_ref_spec.html.haml b/app/views/admin/p_product_ref_specs/_p_product_ref_spec.html.haml new file mode 100644 index 0000000..e91add0 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/_p_product_ref_spec.html.haml @@ -0,0 +1,16 @@ +%tr#p_product_ref_spec_row{:id => p_product_ref_spec.id} + -tr = {} + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, p_product_ref_spec], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_product_ref_spec_path(p_product_ref_spec), :remote => true + = link_to i(:eye), admin_p_product_ref_spec_path(p_product_ref_spec), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_product_ref_spec} + + + + \ No newline at end of file diff --git a/app/views/admin/p_product_ref_specs/create.js.erb b/app/views/admin/p_product_ref_specs/create.js.erb new file mode 100644 index 0000000..d7a17bc --- /dev/null +++ b/app/views/admin/p_product_ref_specs/create.js.erb @@ -0,0 +1,2 @@ +$('#p_product_ref_specs_rows').prepend("<%= escape_javascript(render(@p_product_ref_spec))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_product_ref_specs/destroy.js.erb b/app/views/admin/p_product_ref_specs/destroy.js.erb new file mode 100644 index 0000000..5e87c5d --- /dev/null +++ b/app/views/admin/p_product_ref_specs/destroy.js.erb @@ -0,0 +1 @@ +$('#p_product_ref_spec_row_<%= @p_product_ref_spec.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_product_ref_specs/edit.js.erb b/app/views/admin/p_product_ref_specs/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/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_product_ref_specs/index.html.haml b/app/views/admin/p_product_ref_specs/index.html.haml new file mode 100644 index 0000000..f486839 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/index.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_p_product_ref_spec_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PProductRefSpec.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_product_ref_specs} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_product_ref_specs} + + + diff --git a/app/views/admin/p_product_ref_specs/new.js.erb b/app/views/admin/p_product_ref_specs/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/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_product_ref_specs/show.html.haml b/app/views/admin/p_product_ref_specs/show.html.haml new file mode 100644 index 0000000..e56e759 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_product_ref_spec \ No newline at end of file diff --git a/app/views/admin/p_product_ref_specs/update.js.erb b/app/views/admin/p_product_ref_specs/update.js.erb new file mode 100644 index 0000000..ccaba69 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/update.js.erb @@ -0,0 +1,2 @@ +$('#p_product_ref_spec_row_<%= @p_product_ref_spec.id %>').replaceWith("<%= escape_javascript(render(@p_product_ref_spec))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index b1d1e69..a585b05 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,16 @@ Rails.application.routes.draw do + namespace :admin do + resources :p_product_ref_specs do + member do + + end + collection do + + end + end + end + namespace :admin do resources :p_spec_values do member do diff --git a/db/migrate/20210827074812_create_p_product_ref_specs.rb b/db/migrate/20210827074812_create_p_product_ref_specs.rb new file mode 100644 index 0000000..0731732 --- /dev/null +++ b/db/migrate/20210827074812_create_p_product_ref_specs.rb @@ -0,0 +1,11 @@ +class CreatePProductRefSpecs < ActiveRecord::Migration[6.0] + def change + create_table :p_product_ref_specs do |t| + t.references :p_product_ref, foreign_key: true + t.references :p_spec_type, foreign_key: true + t.references :p_spec_value, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index a09865a..7edf151 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_08_27_074615) do +ActiveRecord::Schema.define(version: 2021_08_27_074812) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1745,6 +1745,17 @@ ActiveRecord::Schema.define(version: 2021_08_27_074615) do t.index ["p_product_ref_id"], name: "index_p_product_ref_price_histories_on_p_product_ref_id" end + create_table "p_product_ref_specs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + t.bigint "p_product_ref_id" + t.bigint "p_spec_type_id" + t.bigint "p_spec_value_id" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["p_product_ref_id"], name: "index_p_product_ref_specs_on_p_product_ref_id" + t.index ["p_spec_type_id"], name: "index_p_product_ref_specs_on_p_spec_type_id" + t.index ["p_spec_value_id"], name: "index_p_product_ref_specs_on_p_spec_value_id" + end + create_table "p_product_refs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "ref" t.integer "p_product_id" @@ -3126,6 +3137,9 @@ ActiveRecord::Schema.define(version: 2021_08_27_074615) do add_foreign_key "p_product_prices", "p_price_cats" add_foreign_key "p_product_prices", "p_product_refs" add_foreign_key "p_product_ref_price_histories", "p_product_refs" + add_foreign_key "p_product_ref_specs", "p_product_refs" + add_foreign_key "p_product_ref_specs", "p_spec_types" + add_foreign_key "p_product_ref_specs", "p_spec_values" add_foreign_key "p_product_utilisations", "p_products" add_foreign_key "p_product_utilisations", "p_utilisations" add_foreign_key "partition_lines", "partitions" diff --git a/test/fixtures/p_product_ref_specs.yml b/test/fixtures/p_product_ref_specs.yml new file mode 100644 index 0000000..e22eda8 --- /dev/null +++ b/test/fixtures/p_product_ref_specs.yml @@ -0,0 +1,11 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + p_product_ref: one + p_spec_type: one + p_spec_value: one + +two: + p_product_ref: two + p_spec_type: two + p_spec_value: two diff --git a/test/models/p_product_ref_spec_test.rb b/test/models/p_product_ref_spec_test.rb new file mode 100644 index 0000000..59dbd78 --- /dev/null +++ b/test/models/p_product_ref_spec_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PProductRefSpecTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end