diff --git a/app/controllers/admin/m_odr_product_cats_controller.rb b/app/controllers/admin/m_odr_product_cats_controller.rb new file mode 100644 index 0000000..82a8934 --- /dev/null +++ b/app/controllers/admin/m_odr_product_cats_controller.rb @@ -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 diff --git a/app/models/m_odr_product_cat.rb b/app/models/m_odr_product_cat.rb new file mode 100644 index 0000000..23551eb --- /dev/null +++ b/app/models/m_odr_product_cat.rb @@ -0,0 +1,3 @@ +class MOdrProductCat < ApplicationRecord + belongs_to :m_odr +end diff --git a/app/views/admin/m_odr_product_cats/_form.html.haml b/app/views/admin/m_odr_product_cats/_form.html.haml new file mode 100644 index 0000000..52e86d5 --- /dev/null +++ b/app/views/admin/m_odr_product_cats/_form.html.haml @@ -0,0 +1,7 @@ +.m_odr_product_cat_form.field + + = form.input :name, :label => "Nom :" + + + + =link_to_remove_fields ic(:"trash-o"), form \ No newline at end of file diff --git a/app/views/admin/m_odr_product_cats/_m_odr_product_cat.html.haml b/app/views/admin/m_odr_product_cats/_m_odr_product_cat.html.haml new file mode 100644 index 0000000..620101e --- /dev/null +++ b/app/views/admin/m_odr_product_cats/_m_odr_product_cat.html.haml @@ -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} \ No newline at end of file diff --git a/app/views/admin/m_odr_product_cats/create.js.erb b/app/views/admin/m_odr_product_cats/create.js.erb new file mode 100644 index 0000000..85ff210 --- /dev/null +++ b/app/views/admin/m_odr_product_cats/create.js.erb @@ -0,0 +1,2 @@ +$('#m_odr_product_cats_rows').prepend("<%= escape_javascript(render(@m_odr_product_cat))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/m_odr_product_cats/destroy.js.erb b/app/views/admin/m_odr_product_cats/destroy.js.erb new file mode 100644 index 0000000..c7b9dc1 --- /dev/null +++ b/app/views/admin/m_odr_product_cats/destroy.js.erb @@ -0,0 +1 @@ +$('#m_odr_product_cat_<%= @m_odr_product_cat.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/m_odr_product_cats/edit.js.erb b/app/views/admin/m_odr_product_cats/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/m_odr_product_cats/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/m_odr_product_cats/index.html.haml b/app/views/admin/m_odr_product_cats/index.html.haml new file mode 100644 index 0000000..9a18877 --- /dev/null +++ b/app/views/admin/m_odr_product_cats/index.html.haml @@ -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} diff --git a/app/views/admin/m_odr_product_cats/new.js.erb b/app/views/admin/m_odr_product_cats/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/m_odr_product_cats/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/m_odr_product_cats/show.html.haml b/app/views/admin/m_odr_product_cats/show.html.haml new file mode 100644 index 0000000..91686cb --- /dev/null +++ b/app/views/admin/m_odr_product_cats/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @m_odr_product_cat \ No newline at end of file diff --git a/app/views/admin/m_odr_product_cats/update.js.erb b/app/views/admin/m_odr_product_cats/update.js.erb new file mode 100644 index 0000000..c9801ea --- /dev/null +++ b/app/views/admin/m_odr_product_cats/update.js.erb @@ -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(); \ No newline at end of file diff --git a/app/views/admin/m_odr_reps/show.html.haml b/app/views/admin/m_odr_reps/show.html.haml index de835e0..d0c98a1 100644 --- a/app/views/admin/m_odr_reps/show.html.haml +++ b/app/views/admin/m_odr_reps/show.html.haml @@ -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 diff --git a/app/views/admin/m_odrs/_form.html.haml b/app/views/admin/m_odrs/_form.html.haml index d60addf..ea8d061 100644 --- a/app/views/admin/m_odrs/_form.html.haml +++ b/app/views/admin/m_odrs/_form.html.haml @@ -54,8 +54,42 @@ = f.input :thank_title, :label => "Titre remerciement" = f.input :thank_text, :label => "Texte remerciement" + + + .qi_row + .qi_pannel.qi_plain.padding + %h3 Données récupérées : - =render :partial => "admin/shared/social_form", :locals => {:f => f} + = 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 .qi_pannel.qi_plain.padding @@ -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 : diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 520d419..0cdd237 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -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 diff --git a/db/migrate/20200307102313_create_m_odr_product_cats.rb b/db/migrate/20200307102313_create_m_odr_product_cats.rb new file mode 100644 index 0000000..a96dc58 --- /dev/null +++ b/db/migrate/20200307102313_create_m_odr_product_cats.rb @@ -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 diff --git a/db/migrate/20200307102615_add_m_odr_product_cat_to_m_odr_rep.rb b/db/migrate/20200307102615_add_m_odr_product_cat_to_m_odr_rep.rb new file mode 100644 index 0000000..5a405fb --- /dev/null +++ b/db/migrate/20200307102615_add_m_odr_product_cat_to_m_odr_rep.rb @@ -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 diff --git a/db/migrate/20200307104157_add_prefs_to_m_odrs.rb b/db/migrate/20200307104157_add_prefs_to_m_odrs.rb new file mode 100644 index 0000000..ab76df6 --- /dev/null +++ b/db/migrate/20200307104157_add_prefs_to_m_odrs.rb @@ -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 diff --git a/test/fixtures/m_odr_product_cats.yml b/test/fixtures/m_odr_product_cats.yml new file mode 100644 index 0000000..5ddd779 --- /dev/null +++ b/test/fixtures/m_odr_product_cats.yml @@ -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 diff --git a/test/models/m_odr_product_cat_test.rb b/test/models/m_odr_product_cat_test.rb new file mode 100644 index 0000000..41e34fd --- /dev/null +++ b/test/models/m_odr_product_cat_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class MOdrProductCatTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end