g qis sorecop_taxes
This commit is contained in:
parent
a9a5e22251
commit
91dc7a8631
76
app/controllers/admin/sorecop_taxes_controller.rb
Normal file
76
app/controllers/admin/sorecop_taxes_controller.rb
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# -*- encoding : utf-8 -*-
|
||||||
|
|
||||||
|
class Admin::SorecopTaxesController < ApplicationController
|
||||||
|
layout "admin"
|
||||||
|
before_action :auth_admin
|
||||||
|
|
||||||
|
before_action :admin_space
|
||||||
|
|
||||||
|
def admin_space
|
||||||
|
@admin_space = "default"
|
||||||
|
end
|
||||||
|
|
||||||
|
def index
|
||||||
|
@sorecop_taxes = SorecopTax.all
|
||||||
|
|
||||||
|
@sorecop_taxes = sort_by_sorting(@sorecop_taxes, "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
|
||||||
|
@sorecop_taxes = @sorecop_taxes.page(page).per(per_page)
|
||||||
|
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
@sorecop_tax = SorecopTax.find(params[:id])
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@sorecop_tax = SorecopTax.new
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@sorecop_tax = SorecopTax.find(params[:id])
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@sorecop_tax = SorecopTax.new(params.require(:sorecop_tax).permit!)
|
||||||
|
|
||||||
|
if @sorecop_tax.save
|
||||||
|
|
||||||
|
else
|
||||||
|
render action: "new"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def update
|
||||||
|
@sorecop_tax = SorecopTax.find(params[:id])
|
||||||
|
|
||||||
|
|
||||||
|
if @sorecop_tax.update_attributes(params.require(:sorecop_tax).permit!)
|
||||||
|
|
||||||
|
else
|
||||||
|
render action: "edit"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@sorecop_tax = SorecopTax.find(params[:id])
|
||||||
|
@sorecop_tax.destroy
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
3
app/models/sorecop_tax.rb
Normal file
3
app/models/sorecop_tax.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
class SorecopTax < ApplicationRecord
|
||||||
|
belongs_to :sorecop_cat_id
|
||||||
|
end
|
16
app/views/admin/sorecop_taxes/_form.html.haml
Normal file
16
app/views/admin/sorecop_taxes/_form.html.haml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
=semantic_form_for [:admin, @sorecop_tax], :remote => true do |f|
|
||||||
|
|
||||||
|
.content
|
||||||
|
=f.inputs do
|
||||||
|
= f.input :critere_min, :label => f.object.label_for(:critere_min)
|
||||||
|
= f.input :critere_max, :label => f.object.label_for(:critere_max)
|
||||||
|
= f.input :title, :label => f.object.label_for(:title)
|
||||||
|
= f.input :fixed_price, :label => f.object.label_for(:fixed_price)
|
||||||
|
= f.input :sorecop_cat_id, :label => f.object.label_for(:sorecop_cat_id)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.actions=f.submit "sauvegarder", :class => "btn btn-primary"
|
||||||
|
|
16
app/views/admin/sorecop_taxes/_sorecop_tax.html.haml
Normal file
16
app/views/admin/sorecop_taxes/_sorecop_tax.html.haml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
%tr#sorecop_tax_row{:id => sorecop_tax.id}
|
||||||
|
-tr = {}
|
||||||
|
|
||||||
|
-tr[:actions] = capture do
|
||||||
|
%td.actions
|
||||||
|
= link_to i(:"trash-o"), [:admin, sorecop_tax], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
|
||||||
|
= link_to i(:pencil), edit_admin_sorecop_tax_path(sorecop_tax), :remote => true
|
||||||
|
= link_to i(:eye), admin_sorecop_tax_path(sorecop_tax), :remote => true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
=render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => sorecop_tax}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
2
app/views/admin/sorecop_taxes/create.js.erb
Normal file
2
app/views/admin/sorecop_taxes/create.js.erb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
$('#sorecop_taxes_rows').prepend("<%= escape_javascript(render(@sorecop_tax))%>");
|
||||||
|
close_pane_hover();
|
1
app/views/admin/sorecop_taxes/destroy.js.erb
Normal file
1
app/views/admin/sorecop_taxes/destroy.js.erb
Normal file
@ -0,0 +1 @@
|
|||||||
|
$('#sorecop_tax_row_<%= @sorecop_tax.id %>').remove();
|
1
app/views/admin/sorecop_taxes/edit.js.erb
Normal file
1
app/views/admin/sorecop_taxes/edit.js.erb
Normal file
@ -0,0 +1 @@
|
|||||||
|
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
16
app/views/admin/sorecop_taxes/index.html.haml
Normal file
16
app/views/admin/sorecop_taxes/index.html.haml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
.qi_header
|
||||||
|
.right= link_to ic(:plus)+' Ajouter', new_admin_sorecop_tax_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||||
|
%h1
|
||||||
|
=SorecopTax.human rescue ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.qi_search_row
|
||||||
|
=form_tag "", :method => "get", :onsubmit => "" do
|
||||||
|
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @sorecop_taxes}
|
||||||
|
|
||||||
|
|
||||||
|
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @sorecop_taxes}
|
||||||
|
|
||||||
|
|
||||||
|
|
1
app/views/admin/sorecop_taxes/new.js.erb
Normal file
1
app/views/admin/sorecop_taxes/new.js.erb
Normal file
@ -0,0 +1 @@
|
|||||||
|
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
10
app/views/admin/sorecop_taxes/show.html.haml
Normal file
10
app/views/admin/sorecop_taxes/show.html.haml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
.qi_header
|
||||||
|
%h1
|
||||||
|
|
||||||
|
%span
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.qi_row
|
||||||
|
.qi_pannel.qi_plain.padding
|
||||||
|
=debug @sorecop_tax
|
2
app/views/admin/sorecop_taxes/update.js.erb
Normal file
2
app/views/admin/sorecop_taxes/update.js.erb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
$('#sorecop_tax_row_<%= @sorecop_tax.id %>').replaceWith("<%= escape_javascript(render(@sorecop_tax))%>");
|
||||||
|
close_pane_hover();
|
@ -1,5 +1,16 @@
|
|||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
|
|
||||||
|
namespace :admin do
|
||||||
|
resources :sorecop_taxes do
|
||||||
|
member do
|
||||||
|
|
||||||
|
end
|
||||||
|
collection do
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
namespace :admin do
|
namespace :admin do
|
||||||
resources :sorecop_cats do
|
resources :sorecop_cats do
|
||||||
member do
|
member do
|
||||||
|
13
db/migrate/20210923165046_create_sorecop_taxes.rb
Normal file
13
db/migrate/20210923165046_create_sorecop_taxes.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
class CreateSorecopTaxes < ActiveRecord::Migration[6.0]
|
||||||
|
def change
|
||||||
|
create_table :sorecop_taxes do |t|
|
||||||
|
t.decimal :critere_min
|
||||||
|
t.decimal :critere_max
|
||||||
|
t.string :title
|
||||||
|
t.boolean :fixed_price
|
||||||
|
t.references :sorecop_cat_id, foreign_key: true
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
15
test/fixtures/sorecop_taxes.yml
vendored
Normal file
15
test/fixtures/sorecop_taxes.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||||
|
|
||||||
|
one:
|
||||||
|
critere_min: 9.99
|
||||||
|
critere_max: 9.99
|
||||||
|
title: MyString
|
||||||
|
fixed_price: false
|
||||||
|
sorecop_cat_id: one
|
||||||
|
|
||||||
|
two:
|
||||||
|
critere_min: 9.99
|
||||||
|
critere_max: 9.99
|
||||||
|
title: MyString
|
||||||
|
fixed_price: false
|
||||||
|
sorecop_cat_id: two
|
7
test/models/sorecop_tax_test.rb
Normal file
7
test/models/sorecop_tax_test.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class SorecopTaxTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
Reference in New Issue
Block a user