generate p_product_ref_spec

This commit is contained in:
Barnabé 2021-08-27 09:48:30 +02:00
parent 374c92b9a4
commit b1df8ad4c5
16 changed files with 199 additions and 1 deletions

View File

@ -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

View File

@ -0,0 +1,5 @@
class PProductRefSpec < ApplicationRecord
belongs_to :p_product_ref
belongs_to :p_spec_type
belongs_to :p_spec_value
end

View File

@ -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"

View File

@ -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}

View File

@ -0,0 +1,2 @@
$('#p_product_ref_specs_rows').prepend("<%= escape_javascript(render(@p_product_ref_spec))%>");
close_pane_hover();

View File

@ -0,0 +1 @@
$('#p_product_ref_spec_row_<%= @p_product_ref_spec.id %>').remove();

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);

View File

@ -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}

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);

View File

@ -0,0 +1,10 @@
.qi_header
%h1
%span
.qi_row
.qi_pannel.qi_plain.padding
=debug @p_product_ref_spec

View File

@ -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();

View File

@ -1,5 +1,16 @@
Rails.application.routes.draw do 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 namespace :admin do
resources :p_spec_values do resources :p_spec_values do
member do member do

View File

@ -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

View File

@ -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_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| create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.string "name" 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" t.index ["p_product_ref_id"], name: "index_p_product_ref_price_histories_on_p_product_ref_id"
end 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| create_table "p_product_refs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.string "ref" t.string "ref"
t.integer "p_product_id" 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_price_cats"
add_foreign_key "p_product_prices", "p_product_refs" 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_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_products"
add_foreign_key "p_product_utilisations", "p_utilisations" add_foreign_key "p_product_utilisations", "p_utilisations"
add_foreign_key "partition_lines", "partitions" add_foreign_key "partition_lines", "partitions"

11
test/fixtures/p_product_ref_specs.yml vendored Normal file
View File

@ -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

View File

@ -0,0 +1,7 @@
require 'test_helper'
class PProductRefSpecTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end