This commit is contained in:
Nicolas Bally 2020-03-08 12:41:55 +01:00
parent 29b3d883f3
commit 492e15481a
19 changed files with 231 additions and 3 deletions

View File

@ -0,0 +1,74 @@
# -*- encoding : utf-8 -*-
class Admin::MOdrProductCatsController < ApplicationController
layout "admin"
before_action :auth_admin
before_action :admin_space
def admin_space
@admin_space = "default"
end
def index
@m_odr_product_cats = MOdrProductCat.all
@m_odr_product_cats = sort_by_sorting(@m_odr_product_cats, "created_at DESC")
params[:search][:per_page] = params[:search][:per_page] || 50
per_page = params[:search][:per_page]
page = (params[:page] and params[:page] != "") ? params[:page] : 1
@m_odr_product_cats = @m_odr_product_cats.page(page).per(per_page)
end
def show
@m_odr_product_cat = MOdrProductCat.find(params[:id])
end
def new
@m_odr_product_cat = MOdrProductCat.new
end
def edit
@m_odr_product_cat = MOdrProductCat.find(params[:id])
end
def create
@m_odr_product_cat = MOdrProductCat.new(params.require(:m_odr_product_cat).permit!)
if @m_odr_product_cat.save
else
render action: "new"
end
end
def update
@m_odr_product_cat = MOdrProductCat.find(params[:id])
if @m_odr_product_cat.update_attributes(params.require(:m_odr_product_cat).permit!)
else
render action: "edit"
end
end
def destroy
@m_odr_product_cat = MOdrProductCat.find(params[:id])
@m_odr_product_cat.destroy
end
end

View File

@ -0,0 +1,3 @@
class MOdrProductCat < ApplicationRecord
belongs_to :m_odr
end

View File

@ -0,0 +1,7 @@
.m_odr_product_cat_form.field
= form.input :name, :label => "Nom :"
=link_to_remove_fields ic(:"trash-o"), form

View File

@ -0,0 +1,13 @@
%tr#m_odr_product_cat_row{:id => m_odr_product_cat.id}
-tr = {}
-tr[:actions] = capture do
%td.actions
= link_to i(:"trash-o"), [:admin, m_odr_product_cat], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
= link_to i(:pencil), edit_admin_m_odr_product_cat_path(m_odr_product_cat), :remote => true
= link_to i(:eye), admin_m_odr_product_cat_path(m_odr_product_cat), :remote => true
=render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => m_odr_product_cat}

View File

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

View File

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

View File

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

View File

@ -0,0 +1,20 @@
.qi_header
.right= link_to 'Ajouter ', new_admin_m_odr_product_cat_path(), :class => "btn btn-primary", :remote => true
%h1
%span
.qi_search_row
=form_tag "", :method => "get", :onsubmit => "" do
-params[:search] =params[:search] || {}
%table
%tr
%td
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @m_odr_product_cats}
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @m_odr_product_cats}

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

View File

@ -0,0 +1,2 @@
$('#m_odr_product_cat_row_<%= @m_odr_product_cat.id %>').replaceWith("<%= escape_javascript(render(@m_odr_product_cat))%>");
close_pane_hover();

View File

@ -141,7 +141,7 @@
-if @m_odr_rep.state == "Refusée"
.red Offre refusée :
-[["achat-hors-delais", "Achat hors délais"],["facture-illisible", "Facture illisible"],["pneus-non-porteurs-de-l-offre", "Pneus invalides"]].each do |key|
-[["achat-hors-delais", "Achat hors délais"],["facture-illisible", "Facture illisible"],["pneus-non-porteurs-de-l-offre", "Pneus invalides"],["dossier-deja-enregistre", "Dossier déjà enregistré"]].each do |key|
%br
=link_to " Envoyer un mail de notification : #{key[1]}", send_mail_admin_m_odr_rep_path(@m_odr_rep, :slug => key[0]), :remote => false

View File

@ -55,6 +55,40 @@
= f.input :thank_text, :label => "Texte remerciement"
.qi_row
.qi_pannel.qi_plain.padding
%h3 Données récupérées :
= f.input :address_process, :label => "Adresse postale ?"
= f.input :address_needed, :label => "Obligatoire ?"
= f.input :rib_process, :label => "RIB ?"
= f.input :rib_needed, :label => " Obligatoire ?"
= f.input :email_process, :label => "Email ?"
= f.input :email_needed, :label => "Obligatoire ?"
= f.input :tel_process, :label => "Tel ?"
= f.input :tel_needed, :label => "Obligatoire ?"
= f.input :confirm_case_needed, :label => "Case de confirmation obligatoire ?"
.qi_row
.qi_pannel.qi_plain.padding
= f.input :placeholder, :label => "Afficher les libellés ?"
= f.input :name_label, :label => "Label nom :"
= f.input :firstname_label, :label => "Label prénom :"
= f.input :confirm_case_label, :label => "Label case de confirmation :"
= f.input :product_cat_label, :label => "Label catégorie produit :"
= f.input :product_label, :label => "Label produit :"
= f.input :qte_label, :label => "Label quantité :"
= f.input :place_label, :label => "Label lieu de vente :"
.qi_row
.qi_pannel.qi_plain.padding
=render :partial => "admin/shared/social_form", :locals => {:f => f}
.qi_row
@ -87,6 +121,18 @@
%p= link_to_add_fields ic(:plus)+" Ajouter ue marque", f, :m_odr_brands
.qi_row
.qi_pannel.qi_plain.padding
Catégories produits :
%hr
.m_odr_product_cats_form
=f.semantic_fields_for :m_odr_product_cats do |form|
=render :partial => "admin/m_odr_product_cats/form", :locals => {:form => form}
%p= link_to_add_fields ic(:plus)+" Ajouter une catégorie", f, :m_odr_product_cats
.qi_row
.qi_pannel.qi_plain.padding
Produits concernés :

View File

@ -69,7 +69,7 @@
=link_to admin_file_tunels_path do
.cat#big_cat_tournees
=ic :"lock"
Tunels fichier sécurisés
Tunnels fichier sécurisés
-if false

View File

@ -0,0 +1,10 @@
class CreateMOdrProductCats < ActiveRecord::Migration[6.0]
def change
create_table :m_odr_product_cats do |t|
t.references :m_odr, foreign_key: true
t.string :name
t.timestamps
end
end
end

View File

@ -0,0 +1,5 @@
class AddMOdrProductCatToMOdrRep < ActiveRecord::Migration[6.0]
def change
add_reference :m_odr_reps, :m_odr_product_cat, foreign_key: true
end
end

View File

@ -0,0 +1,17 @@
class AddPrefsToMOdrs < ActiveRecord::Migration[6.0]
def change
add_column :m_odrs, :name_label, :string
add_column :m_odrs, :firstname_label, :string
add_column :m_odrs, :placeholder, :boolean, :default => false
add_column :m_odrs, :email_process, :boolean, :default => true
add_column :m_odrs, :tel_process, :boolean, :default => true
add_column :m_odrs, :rib_needed, :boolean, :default => true
add_column :m_odrs, :address_needed, :boolean, :default => true
add_column :m_odrs, :confirm_case_needed, :boolean, :default => false
add_column :m_odrs, :confirm_case_label, :string, :default => false
add_column :m_odrs, :product_cat_label, :string
add_column :m_odrs, :product_label, :string
add_column :m_odrs, :qte_label, :string
add_column :m_odrs, :place_label, :string
end
end

9
test/fixtures/m_odr_product_cats.yml vendored Normal file
View File

@ -0,0 +1,9 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
m_odr: one
name: MyString
two:
m_odr: two
name: MyString

View File

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