Merge branch 'Breadcrumb' into pre-prod

This commit is contained in:
Barnabé 2021-10-26 15:19:03 +02:00
commit 6c10b79fdd
40 changed files with 160 additions and 176 deletions

View File

@ -49,6 +49,7 @@ class ApplicationController < ActionController::Base
end
end
set_breadcrumb
end
@ -543,5 +544,26 @@ class ApplicationController < ActionController::Base
@dropdown_title = "Parametrage"
end
def set_breadcrumb
@result = {}
if @qi_menu_active.present?
current_menu = @qi_menus[@qi_menu_active]
current_controller = controller_name.to_sym
@action = action_name.to_sym
@result[:first] = {name: current_menu[:name], link: current_menu[:link]}
if current_menu[:elements][current_controller]
@result[:second] = current_menu[:elements][current_controller]
elsif current_menu[:elements][:p_preferences_products_menu] && current_menu[:elements][:p_preferences_products_menu][:sub_elements][current_controller]
@result[:second] = current_menu[:elements][:p_preferences_products_menu][:sub_elements][current_controller]
else
@result[:second] = nil
end
if @result[:second]
if @result[:first][:name] == @result[:second][:name]
@result[:second] = nil
end
end
end
end
end

View File

@ -0,0 +1,74 @@
# DOC :
# ajouter =breadcrumb dans une vue
# pour personaliser le breadcrumb, il y a plusieurs options :
# passer un ou plusieurs parametre piur overrider l'existant par défaut
# :first_title premier element du breadcrumb
# :first_link premier path du breadcrumb
#
# :second_title second element du breadcrumb
# :second_link second path du breadcrumb
#
# :last_element le tout dernier element du breadcrumb
#
# :record est le nom du record pour un show ou un edit par exemple :record => @p_product.name
#
# :default_crud booléen qui active/neutralise la création du titre "Détail de .." ou "Modification .."
module BreadcrumbHelper
def breadcrumb(opts = {})
default_opts = {
action: @action,
first_title: @result[:first][:name],
first_link: @result[:first][:link],
default_crud: true
}
if @result[:second]
default_opts[:second_title] = @result[:second][:name]
default_opts[:second_link] = @result[:second][:link]
end
options = default_opts.merge opts
capture_haml do
haml_tag :h1 do
unless @result.present?
haml_concat "Erreur dans le BreadcrumbHelper"
else
if options[:record].present? || options[:last_element].present?
haml_concat(link_to options[:first_title], options[:first_link])
if options[:second_title].present? && options[:second_link].present?
haml_tag(:span) { haml_concat(link_to options[:second_title], options[:second_link]) }
elsif options[:second_title].present?
haml_tag(:span) {haml_concat( options[:second_title])}
end
else
if options[:second_title].present?
haml_concat(link_to options[:first_title], options[:first_link])
haml_tag(:span) { haml_concat( options[:second_title]) }
else
haml_concat( options[:first_title])
end
end
if options[:default_crud]
case options[:action]
when :new
haml_tag(:span) {haml_concat("Création #{options[:first_title].singularize.downcase}")}
when :edit
options[:record].present? ? haml_tag(:span) {haml_concat("Modification de : #{options[:record]}")} : haml_tag(:span) {haml_concat("Modification")}
when :index
haml_tag(:span) {haml_concat("Liste")}
when :show
options[:record].present? ? haml_tag(:span) {haml_concat("Détail de : #{options[:record]}")} : haml_tag(:span) {haml_concat("Détail")}
else
haml_tag(:span) {haml_concat(options[:record])} if options[:record].present?
end
end
haml_tag(:span) { haml_concat( options[:last_element]) } if options[:last_element].present?
end
end
end
end
end

View File

@ -13,6 +13,8 @@ class PProductRef < ApplicationRecord
belongs_to :p_product_color
has_many :line_stocks
has_many :p_articles
has_many :p_article_serial_nums, through: :p_articles
accepts_nested_attributes_for :p_article_serial_nums, allow_destroy: true

View File

@ -2,9 +2,7 @@
.qi_header
.right
=link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary btn-ap-add"
%h1
Tableaux de bord achats
= breadcrumb
.qi_search_row

View File

@ -4,8 +4,7 @@
= link_to ic(:minus)+' Sortie de stock', new_admin_stock_movement_path(:movement_type => "deb"), :class => "btn btn-primary bgbd-documents", :remote => true
= link_to ic(:plus)+' Entrée de stock', new_admin_stock_movement_path(:movement_type => "cred"), :class => "btn btn-primary bgbd-documents", :remote => true
%h1
Mouvements de stocks
= breadcrumb

View File

@ -1,7 +1,6 @@
.qi_header
.right= link_to ic(:plus)+' Ajouter', new_admin_p_article_serial_num_path(), :class => "btn btn-primary btn-ap-add", :remote => true
%h1
=PArticleSerialNum.human rescue ""
=breadcrumb

View File

@ -33,7 +33,7 @@
%td.actions
= link_to i(:"trash-o"), [:admin, p_article], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
= link_to i(:pencil), edit_admin_p_article_path(p_article), :remote => true
= link_to i(:eye), admin_p_article_path(p_article), :remote => true
=# link_to i(:eye), admin_p_article_path(p_article), :remote => true

View File

@ -1,7 +1,6 @@
.qi_header
.right= link_to ic(:plus)+' Ajouter', new_admin_p_article_path(), :class => "btn btn-primary btn-ap-add", :remote => true
%h1
=PArticle.human rescue ""
=breadcrumb

View File

@ -1,9 +1,6 @@
.qi_header
.right= link_to 'Ajouter un export', new_admin_p_compta_export_path(), :class => "btn btn-primary", :remote => true
%h1
Stats
%span
Exports comptable
= breadcrumb
@ -30,4 +27,4 @@
%tbody#p_compta_exports_rows
=render @p_compta_exports

View File

@ -1,9 +1,6 @@
.qi_header
.right= link_to 'Ajouter une catégorie', new_admin_p_customer_cat_path(), :class => "btn btn-primary", :remote => true
%h1
Produits
%span
Catégories
=breadcrumb
.qi_row
@ -18,4 +15,4 @@
%tbody#p_customer_cats_rows
=render @p_customer_cats

View File

@ -1,10 +1,5 @@
.qi_header
%h1
Ventes
%span
=link_to "Demandes de commande", admin_p_customer_sheets_path()
%span
Modifier une demande
= breadcrumb

View File

@ -1,10 +1,7 @@
.qi_header
.right
=link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary btn-ap-add"
%h1
Ventes
%span
Demandes de commande
= breadcrumb
.qi_search_row

View File

@ -12,12 +12,7 @@
= link_to i(:pencil), edit_admin_p_customer_sheet_path(@p_customer_sheet), :remote => false
%h1
Ventes
%span
=link_to "Demande de commandes",admin_p_customer_sheets_path
%span
="#{@p_customer_sheet.com_counter}"
= breadcrumb
.qi_row
@ -114,4 +109,4 @@
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents}

View File

@ -1,10 +1,5 @@
.qi_header
%h1
Ventes
%span
=link_to "Clients", admin_p_customers_path
%span
Modifier un client
=breadcrumb record: @p_customer.name
= render 'form'

View File

@ -4,13 +4,13 @@
-if current_admin.has_permission?("customers-c")
.right= link_to ic(:plus)+' Ajouter un client', new_admin_p_customer_path(), :class => "btn btn-primary btn-ap-add", :remote => false
=breadcrumb
-else
.right
=link_to "< Retour aux demandes de commande", admin_p_customer_sheets_path
=link_to "< Retour aux commandes", admin_p_customer_sheets_path
=breadcrumb first_title: "Commandes" , first_link: admin_p_customer_sheets_path ,second_title: "Demande de commande", last_element: 'Selectioner un client', default_crud: false
%h1
Clients

View File

@ -1,10 +1,5 @@
.qi_header
%h1
Ventes
%span
=link_to "Clients", admin_p_customers_path
%span
Créer un nouveau client
=breadcrumb
= render 'form'

View File

@ -3,15 +3,7 @@
= link_to i(:pencil), edit_admin_p_customer_path(@p_customer), :remote => false
%h1
Clients
%span
Détail d'un client
%span
=link_to [:admin, @p_customer] do
=@p_customer.code
=@p_customer.show_name
=breadcrumb record: @p_customer.name
@ -294,4 +286,4 @@

View File

@ -1,10 +1,8 @@
.qi_header
.right
= link_to 'Ajouter un fournisseur', new_admin_p_fournisseur_path(), :class => "btn btn-primary", :remote => true
%h1
Achats
%span
Fournisseurs
=breadcrumb
.qi_row

View File

@ -1,9 +1,6 @@
.qi_header
.right= link_to 'Ajouter un type de paiement', new_admin_p_payment_type_path(), :class => "btn btn-primary", :remote => true
%h1
Paiements
%span
Types de paiement
= breadcrumb
.qi_row
@ -19,4 +16,4 @@
%tbody#p_payment_types_rows
=render @p_payment_types

View File

@ -1,9 +1,6 @@
.qi_header
.right= link_to ic(:plus)+' Ajouter un paiement', new_admin_p_payment_path(), :class => "btn btn-primary btn-ap-add", :remote => true
%h1
Paiements
%span
Liste des paiements
= breadcrumb
.qi_search_row
=form_tag "", :method => "get", :onsubmit => "" do
@ -117,4 +114,4 @@

View File

@ -1,9 +1,6 @@
.qi_header
.right= link_to 'Ajouter une catégorie', new_admin_p_product_cat_path(), :class => "btn btn-primary", :remote => true
%h1
Achats
%span
Catégories produit
=breadcrumb
.qi_row
@ -21,4 +18,4 @@
%tbody#p_product_cats_rows
=render @p_product_cats

View File

@ -1,7 +1,6 @@
.qi_header
.right= link_to ic(:plus)+' Ajouter', new_admin_p_product_color_path(), :class => "btn btn-primary btn-ap-add", :remote => true
%h1
=PProductColor.human
=breadcrumb

View File

@ -1,7 +1,6 @@
.qi_header
.right= link_to ic(:plus)+' Ajouter', new_admin_p_product_power_path(), :class => "btn btn-primary btn-ap-add", :remote => true
%h1
=PProductPower.human rescue ""
= breadcrumb

View File

@ -1,7 +1,6 @@
.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 ""
= breadcrumb

View File

@ -1,10 +1,7 @@
-if !@manager
.qi_header
.right= link_to ic(:plus)+' Ajouter un produit', new_admin_p_product_path(), :class => "btn btn-primary btn-ap-add", :remote => false
%h1
Achats
%span
Références
=breadcrumb
@ -71,4 +68,4 @@
:coffeescript
$(".qi_search_row form").on "submit", ->
$("#p_product_refs_index_wrapper").html('recherche en cours ...')
$("#p_product_refs_index_wrapper").html('recherche en cours ...')

View File

@ -1,15 +1,7 @@
.qi_header
.right
= link_to i(:pencil), edit_admin_p_product_path(@p_product_ref.p_product), :remote => false if @p_product_ref.p_product
%h1
Références produits
%span
Détail d'une référence
%span
=@p_product_ref.p_product.name
="-"
=@p_product_ref.ct_sub_name
=breadcrumb record: @p_product_ref.p_product.name + " - " + @p_product_ref.ct_sub_name
.qi_row
@ -134,6 +126,10 @@
sortis
.clear
-if false
.qi_row
.qi_pannel
%h3 Historique des prix d'achat
-if false
.qi_row

View File

@ -1,7 +1,6 @@
.qi_header
.right= link_to ic(:plus)+' Ajouter', new_admin_p_product_zone_path(), :class => "btn btn-primary btn-ap-add", :remote => true
%h1
=PProductZone.human
= breadcrumb

View File

@ -1,11 +1,5 @@
.qi_header
%h1
Achats
%span
=link_to "Produits", admin_p_products_path()
%span
Modifier un produit
=breadcrumb record: @p_product.code + ' - ' + @p_product.name
= render 'form'

View File

@ -1,9 +1,6 @@
.qi_header
.right= link_to ic(:plus)+' Ajouter un produit', new_admin_p_product_path(), :class => "btn btn-primary btn-ap-add", :remote => false
%h1
Produits & Stocks
%span
Produits
=breadcrumb
.qi_search_row

View File

@ -1,11 +1,5 @@
.qi_header
%h1
Achats
%span
=link_to "Produits", admin_p_products_path()
%span
Ajouter un produit
=breadcrumb

View File

@ -1,7 +1,6 @@
.qi_header
.right= link_to ic(:plus)+' Ajouter', new_admin_p_serial_num_type_path(), :class => "btn btn-primary btn-ap-add", :remote => true
%h1
=PSerialNumType.human rescue ""
= breadcrumb

View File

@ -1,7 +1,6 @@
.qi_header
.right= link_to ic(:plus)+' Ajouter', new_admin_p_spec_type_path(), :class => "btn btn-primary btn-ap-add", :remote => true
%h1
=PSpecType.human rescue ""
= breadcrumb

View File

@ -1,7 +1,6 @@
.qi_header
.right= link_to ic(:plus)+' Ajouter', new_admin_p_spec_value_path(), :class => "btn btn-primary btn-ap-add", :remote => true
%h1
=PSpecValue.human rescue ""
= breadcrumb

View File

@ -1,11 +1,5 @@
.qi_header
%h1
Achats
%span
Analyse des réponces à la demande de prix n°
= link_to @price_document.d_number, admin_price_document_path(@price_document)
\-
= @price_document.list_designaton
=breadcrumb second_title: "Demande de prix #{@price_document.d_number} - #{@price_document.list_designaton}", second_link: admin_price_document_path(@price_document) , last_element: "Analyse de des réponses"
-unmatched_fournisseur = 0
=semantic_form_for [:admin, @price_document],url: analyse_reponses_save_admin_price_document_path, method: :post, :html => {:class => "qi_price_form"}, :remote => false do |form|

View File

@ -1,13 +1,6 @@
.qi_header
%h1
Documents comptables
%span
Modifier un document
%span
=@price_document.label
="-"
=@price_document.d_number
=breadcrumb second_title: @price_document.label, second_link: admin_price_documents_path(:price_document_type_id => @price_document.price_document_type_id), record: @price_document.d_number
.qi_row=render :partial => "form"

View File

@ -1,21 +1,16 @@
.qi_header
.right
-if false # params[:price_document_type_id].to_s == "5"
=link_to ic(:plus)+" Ajouter un avoir", new_admin_price_document_path, :class => "btn btn-primary bgbd-ventes"
-elsif params[:price_document_type_id].to_i == 6
-if params[:price_document_type_id].to_i == 6 # Facture Achat
= link_to 'Ajouter une facture achat', new_admin_price_document_path(:document_type => "Facture d'achat"), :class => "btn btn-primary bgbd-documents", :remote => false
-elsif params[:price_document_type_id].to_i == 7
-elsif params[:price_document_type_id].to_i == 4 # Commande Achat
= link_to 'Ajouter une commande achat', new_admin_price_document_path(:document_type => "Commande achat"), :class => "btn btn-primary bgbd-documents", :remote => false
-elsif params[:price_document_type_id].to_i == 7
-else
=link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary bgbd-ventes"
%h1
Documents
%span
Liste
-if params[:price_document_type_id]
=breadcrumb second_title: PriceDocumentType.find(params[:price_document_type_id]).label
.qi_search_row

View File

@ -13,16 +13,8 @@
= link_to i(:download), print_admin_price_document_path(@price_document.token), :remote => false, :target => "_blank" if !PriceLineBlock::PURCHASE_BLOCKS.include?(@price_document.block_type)
%h1
Documents
=breadcrumb second_title: @price_document.label, second_link: admin_price_documents_path(:price_document_type_id => @price_document.price_document_type_id), record: @price_document.d_number
%span
=@price_document.price_document_type.label
%span
="##{@price_document.id}"
%span
=@price_document.d_number
.qi_row

View File

@ -1,9 +1,6 @@
.qi_header
.right= link_to 'Ajouter une marque', new_admin_s_brand_path(), :class => "btn btn-primary", :remote => true
%h1
Marques
%span
Liste
=breadcrumb
.qi_row
@ -18,4 +15,4 @@
%tbody#s_brands_rows
=render @s_brands

View File

@ -3,7 +3,7 @@
= link_to ic(:minus)+' Sortie de stock', new_admin_stock_movement_path(:movement_type => "deb"), :class => "btn btn-primary bgbd-documents", :remote => true
= link_to ic(:plus)+' Entrée de stock', new_admin_stock_movement_path(:movement_type => "cred"), :class => "btn btn-primary bgbd-documents", :remote => true
%h1 Mouvements de stock manuels
= breadcrumb

View File

@ -1,9 +1,6 @@
.qi_header
%h1
Mouvements de stock manuels
%span
Détail du mouvement
="##{@stock_movement.id}"
= breadcrumb record: "mouvement ##{@stock_movement.id}"