From 48898840d3796df76c918ff1723a9cf8521bc64c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 27 Sep 2021 11:20:37 +0200 Subject: [PATCH 1/9] set breadcrump helper --- app/controllers/application_controller.rb | 11 +++++++ app/helpers/breadcrumb_helper.rb | 35 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 app/helpers/breadcrumb_helper.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ce02913..76cf36c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -49,6 +49,7 @@ class ApplicationController < ActionController::Base end end + set_breadcrumb end @@ -539,5 +540,15 @@ 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 + @result[:first] = {name: current_menu[:name], link: current_menu[:link]} + @result[:second] = current_menu[:elements][current_controller] + @title = @result[:first][:name].to_s + '/' + @result[:second][:name].to_s + end + end end diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb new file mode 100644 index 0000000..84b4c0b --- /dev/null +++ b/app/helpers/breadcrumb_helper.rb @@ -0,0 +1,35 @@ +module BreadcrumbHelper + def breadcrumb(*custom_last_item) + if custom_last_item.present? + first_title_length = @result[:first][:name].to_s.length + 1 + @title.slice!(0, first_title_length) + @title << "/" + custom_last_item[0] + end + if @result.present? + capture_haml do + haml_tag :h1 do + haml_concat(link_to @result[:first][:name], @result[:first][:link]) + haml_tag :span do + haml_concat(link_to @result[:second][:name], @result[:second][:link]) + if custom_last_item.present? + haml_tag :span do + haml_concat(custom_last_item[0]) + end + end + end + end + end + else + capture_haml do + haml_tag :h1 do + haml_concat "Erreur dans le BreadcrumbHelper" + end + end + end + end + + def breadcrumb_title + @result[:first][:name] + "/" + result[:second][:name] + end + +end From 5d1d1ee1631d2712c57a4fc70beb178a4508251f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 27 Sep 2021 16:56:10 +0200 Subject: [PATCH 2/9] refacto breadcrump --- app/controllers/application_controller.rb | 6 ++- app/helpers/breadcrumb_helper.rb | 50 ++++++++++----------- app/views/admin/p_customers/index.html.haml | 3 +- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 76cf36c..517c5a8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -545,9 +545,13 @@ class ApplicationController < ActionController::Base 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]} @result[:second] = current_menu[:elements][current_controller] - @title = @result[:first][:name].to_s + '/' + @result[:second][:name].to_s + if @result[:first][:name] == @result[:second][:name] + @result[:second] = nil + end end end end diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb index 84b4c0b..84bac8c 100644 --- a/app/helpers/breadcrumb_helper.rb +++ b/app/helpers/breadcrumb_helper.rb @@ -1,35 +1,31 @@ module BreadcrumbHelper - def breadcrumb(*custom_last_item) - if custom_last_item.present? - first_title_length = @result[:first][:name].to_s.length + 1 - @title.slice!(0, first_title_length) - @title << "/" + custom_last_item[0] - end - if @result.present? - capture_haml do - haml_tag :h1 do - haml_concat(link_to @result[:first][:name], @result[:first][:link]) - haml_tag :span do - haml_concat(link_to @result[:second][:name], @result[:second][:link]) - if custom_last_item.present? - haml_tag :span do - haml_concat(custom_last_item[0]) - end + def breadcrumb(options = {}) + options = {action: @action}.merge options + + capture_haml do + haml_tag :h1 do + unless @result.present? + haml_concat "Erreur dans le BreadcrumbHelper" + else + if options[:custom_last_item].present? + haml_concat(link_to @result[:first][:name], @result[:first][:link]) + haml_tag(:span) { haml_concat(link_to @result[:second][:name], @result[:second][:link]) } if @result[:second].present? + case options[:action] + when :new + haml_tag(:span) {haml_concat("Création #{@result[:first][:name].singularize.downcase}")} + when :edit + haml_tag(:span) {haml_concat('Modification')} + when :index + haml_tag(:span) {haml_concat('Liste')} end + + haml_tag(:span) {haml_concat(options[:custom_last_item])} + else + @result[:second].present? ? haml_concat(link_to @result[:first][:name], @result[:first][:link]) : haml_concat( @result[:first][:name]) + haml_tag(:span) { haml_concat( @result[:second][:name]) } if @result[:second].present? end end end - else - capture_haml do - haml_tag :h1 do - haml_concat "Erreur dans le BreadcrumbHelper" - end - end end end - - def breadcrumb_title - @result[:first][:name] + "/" + result[:second][:name] - end - end diff --git a/app/views/admin/p_customers/index.html.haml b/app/views/admin/p_customers/index.html.haml index c7ddc07..8c34c18 100644 --- a/app/views/admin/p_customers/index.html.haml +++ b/app/views/admin/p_customers/index.html.haml @@ -9,7 +9,8 @@ =link_to "< Retour aux demandes de commande", admin_p_customer_sheets_path %h1 - Clients + =breadcrumb + =hello From 57c3da9789a56e0b81b481f548610d47532e47c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 27 Sep 2021 16:56:42 +0200 Subject: [PATCH 3/9] wip p_ ustomer breadcrumb --- app/views/admin/p_customer_cats/index.html.haml | 7 ++----- app/views/admin/p_customers/edit.html.haml | 1 + app/views/admin/p_customers/index.html.haml | 6 ++---- app/views/admin/p_customers/new.html.haml | 7 +------ app/views/admin/p_customers/show.html.haml | 13 +++---------- 5 files changed, 9 insertions(+), 25 deletions(-) diff --git a/app/views/admin/p_customer_cats/index.html.haml b/app/views/admin/p_customer_cats/index.html.haml index a447feb..ae53751 100644 --- a/app/views/admin/p_customer_cats/index.html.haml +++ b/app/views/admin/p_customer_cats/index.html.haml @@ -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 - \ No newline at end of file + diff --git a/app/views/admin/p_customers/edit.html.haml b/app/views/admin/p_customers/edit.html.haml index 4f29362..0981487 100644 --- a/app/views/admin/p_customers/edit.html.haml +++ b/app/views/admin/p_customers/edit.html.haml @@ -1,4 +1,5 @@ .qi_header + =breadcrumb("Modifier un client") %h1 Ventes %span diff --git a/app/views/admin/p_customers/index.html.haml b/app/views/admin/p_customers/index.html.haml index 8c34c18..6d34ced 100644 --- a/app/views/admin/p_customers/index.html.haml +++ b/app/views/admin/p_customers/index.html.haml @@ -7,11 +7,9 @@ -else .right =link_to "< Retour aux demandes de commande", admin_p_customer_sheets_path + =breadcrumb - %h1 - =breadcrumb - =hello - + diff --git a/app/views/admin/p_customers/new.html.haml b/app/views/admin/p_customers/new.html.haml index a3ca07d..99210cb 100644 --- a/app/views/admin/p_customers/new.html.haml +++ b/app/views/admin/p_customers/new.html.haml @@ -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' diff --git a/app/views/admin/p_customers/show.html.haml b/app/views/admin/p_customers/show.html.haml index deab7df..6eedb53 100644 --- a/app/views/admin/p_customers/show.html.haml +++ b/app/views/admin/p_customers/show.html.haml @@ -3,15 +3,8 @@ = 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("Détail client / #{@p_customer.code} - #{@p_customer.show_name}") + @@ -294,4 +287,4 @@ - \ No newline at end of file + From af1de12b1eeeefcc87c4b678946003b66d82bbb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 27 Sep 2021 19:09:05 +0200 Subject: [PATCH 4/9] Upgrade breadcrumb --- app/controllers/application_controller.rb | 10 +++- app/helpers/breadcrumb_helper.rb | 69 ++++++++++++++++++----- 2 files changed, 64 insertions(+), 15 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 517c5a8..c7db3bf 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -548,10 +548,16 @@ class ApplicationController < ActionController::Base @action = action_name.to_sym @result[:first] = {name: current_menu[:name], link: current_menu[:link]} - @result[:second] = current_menu[:elements][current_controller] - if @result[:first][:name] == @result[:second][:name] + if current_menu[:elements][current_controller] + @result[:second] = current_menu[: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 diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb index 84bac8c..2cce85a 100644 --- a/app/helpers/breadcrumb_helper.rb +++ b/app/helpers/breadcrumb_helper.rb @@ -1,29 +1,72 @@ +# 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(options = {}) - options = {action: @action}.merge options + 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[:custom_last_item].present? - haml_concat(link_to @result[:first][:name], @result[:first][:link]) - haml_tag(:span) { haml_concat(link_to @result[:second][:name], @result[:second][:link]) } if @result[:second].present? + 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_title]) } + 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 #{@result[:first][:name].singularize.downcase}")} + haml_tag(:span) {haml_concat("Création #{options[:first_title].singularize.downcase}")} when :edit - haml_tag(:span) {haml_concat('Modification')} + haml_tag(:span) {haml_concat("Modification #{options[:record]}")} when :index - haml_tag(:span) {haml_concat('Liste')} + 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 - - haml_tag(:span) {haml_concat(options[:custom_last_item])} - else - @result[:second].present? ? haml_concat(link_to @result[:first][:name], @result[:first][:link]) : haml_concat( @result[:first][:name]) - haml_tag(:span) { haml_concat( @result[:second][:name]) } if @result[:second].present? end + haml_tag(:span) { haml_concat( options[:last_element]) } if options[:last_element].present? end end end From 48e81e45249713d81558dac5e4c5782d74305dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 27 Sep 2021 19:14:39 +0200 Subject: [PATCH 5/9] WIP deploy breadcrumb on views --- app/views/admin/p_customers/edit.html.haml | 8 +------- app/views/admin/p_customers/show.html.haml | 3 +-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/app/views/admin/p_customers/edit.html.haml b/app/views/admin/p_customers/edit.html.haml index 0981487..22d6097 100644 --- a/app/views/admin/p_customers/edit.html.haml +++ b/app/views/admin/p_customers/edit.html.haml @@ -1,11 +1,5 @@ .qi_header - =breadcrumb("Modifier un client") - %h1 - Ventes - %span - =link_to "Clients", admin_p_customers_path - %span - Modifier un client + =breadcrumb(record: @p_customer.name) = render 'form' diff --git a/app/views/admin/p_customers/show.html.haml b/app/views/admin/p_customers/show.html.haml index 6eedb53..6a5e837 100644 --- a/app/views/admin/p_customers/show.html.haml +++ b/app/views/admin/p_customers/show.html.haml @@ -3,8 +3,7 @@ = link_to i(:pencil), edit_admin_p_customer_path(@p_customer), :remote => false - =breadcrumb("Détail client / #{@p_customer.code} - #{@p_customer.show_name}") - + =breadcrumb(record: "#{@p_customer.code} - #{@p_customer.show_name}") From f1ed7e4ff5d6849897238d326e6aa1f8f1d9dd6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 28 Sep 2021 11:22:49 +0200 Subject: [PATCH 6/9] add sub_sub_menu to breadcrumb --- app/controllers/application_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c7db3bf..3a67bd5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -546,10 +546,11 @@ class ApplicationController < ActionController::Base 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 From 973182221e611e85ef6ae500cdc480a377245e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 28 Sep 2021 11:23:02 +0200 Subject: [PATCH 7/9] bugfix breadcrumn --- app/helpers/breadcrumb_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb index 2cce85a..2e2800d 100644 --- a/app/helpers/breadcrumb_helper.rb +++ b/app/helpers/breadcrumb_helper.rb @@ -40,7 +40,7 @@ module BreadcrumbHelper 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_title]) } + 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 @@ -57,11 +57,11 @@ module BreadcrumbHelper when :new haml_tag(:span) {haml_concat("Création #{options[:first_title].singularize.downcase}")} when :edit - haml_tag(:span) {haml_concat("Modification #{options[:record]}")} + 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")} + 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 From 4d3ccfd221fefced0843ce0afad5c13fc4198789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 28 Sep 2021 12:29:38 +0200 Subject: [PATCH 8/9] add breadcrumb to views --- app/views/admin/buy_lists/index.html.haml | 4 +- app/views/admin/line_stocks/index.html.haml | 3 +- .../p_article_serial_nums/index.html.haml | 3 +- .../admin/p_articles/_p_article.html.haml | 2 +- app/views/admin/p_articles/index.html.haml | 3 +- .../admin/p_compta_exports/index.html.haml | 7 +- .../admin/p_customer_sheets/edit.html.haml | 7 +- .../admin/p_customer_sheets/index.html.haml | 5 +- .../admin/p_customer_sheets/show.html.haml | 9 +- app/views/admin/p_customers/edit.html.haml | 2 +- app/views/admin/p_customers/index.html.haml | 5 +- app/views/admin/p_customers/show.html.haml | 2 +- .../admin/p_fournisseurs/index.html.haml | 7 +- .../admin/p_payment_types/index.html.haml | 7 +- app/views/admin/p_payments/index.html.haml | 7 +- .../admin/p_product_cats/index.html.haml | 7 +- .../admin/p_product_colors/index.html.haml | 3 +- .../admin/p_product_powers/index.html.haml | 3 +- .../admin/p_product_ref_specs/index.html.haml | 3 +- .../admin/p_product_refs/index.html.haml | 7 +- app/views/admin/p_product_refs/show.html.haml | 130 +++++++++--------- .../admin/p_product_zones/index.html.haml | 3 +- app/views/admin/p_products/edit.html.haml | 8 +- app/views/admin/p_products/index.html.haml | 5 +- app/views/admin/p_products/new.html.haml | 8 +- .../admin/p_serial_num_types/index.html.haml | 3 +- app/views/admin/p_spec_types/index.html.haml | 3 +- app/views/admin/p_spec_values/index.html.haml | 3 +- .../analyse_reponses.html.haml | 8 +- .../admin/price_documents/edit.html.haml | 11 +- .../admin/price_documents/index.html.haml | 19 +-- .../admin/price_documents/show.html.haml | 10 +- app/views/admin/s_brands/index.html.haml | 7 +- .../admin/stock_movements/index.html.haml | 2 +- .../admin/stock_movements/show.html.haml | 7 +- 35 files changed, 114 insertions(+), 209 deletions(-) diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index de9fbbb..b5b831a 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -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 diff --git a/app/views/admin/line_stocks/index.html.haml b/app/views/admin/line_stocks/index.html.haml index 0658b45..7360c8e 100644 --- a/app/views/admin/line_stocks/index.html.haml +++ b/app/views/admin/line_stocks/index.html.haml @@ -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 diff --git a/app/views/admin/p_article_serial_nums/index.html.haml b/app/views/admin/p_article_serial_nums/index.html.haml index 0c3ea96..e5f732a 100644 --- a/app/views/admin/p_article_serial_nums/index.html.haml +++ b/app/views/admin/p_article_serial_nums/index.html.haml @@ -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 diff --git a/app/views/admin/p_articles/_p_article.html.haml b/app/views/admin/p_articles/_p_article.html.haml index 32497fc..c713ea0 100644 --- a/app/views/admin/p_articles/_p_article.html.haml +++ b/app/views/admin/p_articles/_p_article.html.haml @@ -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 diff --git a/app/views/admin/p_articles/index.html.haml b/app/views/admin/p_articles/index.html.haml index 0064c5c..cfe9452 100644 --- a/app/views/admin/p_articles/index.html.haml +++ b/app/views/admin/p_articles/index.html.haml @@ -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 diff --git a/app/views/admin/p_compta_exports/index.html.haml b/app/views/admin/p_compta_exports/index.html.haml index 381dcf9..0371115 100644 --- a/app/views/admin/p_compta_exports/index.html.haml +++ b/app/views/admin/p_compta_exports/index.html.haml @@ -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 - \ No newline at end of file + diff --git a/app/views/admin/p_customer_sheets/edit.html.haml b/app/views/admin/p_customer_sheets/edit.html.haml index 604e1fa..0f8df99 100644 --- a/app/views/admin/p_customer_sheets/edit.html.haml +++ b/app/views/admin/p_customer_sheets/edit.html.haml @@ -1,10 +1,5 @@ .qi_header - %h1 - Ventes - %span - =link_to "Demandes de commande", admin_p_customer_sheets_path() - %span - Modifier une demande + = breadcrumb diff --git a/app/views/admin/p_customer_sheets/index.html.haml b/app/views/admin/p_customer_sheets/index.html.haml index f61d281..b0db10f 100644 --- a/app/views/admin/p_customer_sheets/index.html.haml +++ b/app/views/admin/p_customer_sheets/index.html.haml @@ -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 diff --git a/app/views/admin/p_customer_sheets/show.html.haml b/app/views/admin/p_customer_sheets/show.html.haml index 57031b4..1b37292 100644 --- a/app/views/admin/p_customer_sheets/show.html.haml +++ b/app/views/admin/p_customer_sheets/show.html.haml @@ -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} - \ No newline at end of file + diff --git a/app/views/admin/p_customers/edit.html.haml b/app/views/admin/p_customers/edit.html.haml index 22d6097..d2c283d 100644 --- a/app/views/admin/p_customers/edit.html.haml +++ b/app/views/admin/p_customers/edit.html.haml @@ -1,5 +1,5 @@ .qi_header - =breadcrumb(record: @p_customer.name) + =breadcrumb record: @p_customer.name = render 'form' diff --git a/app/views/admin/p_customers/index.html.haml b/app/views/admin/p_customers/index.html.haml index 6d34ced..ea441a2 100644 --- a/app/views/admin/p_customers/index.html.haml +++ b/app/views/admin/p_customers/index.html.haml @@ -4,10 +4,11 @@ -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 - =breadcrumb + =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 diff --git a/app/views/admin/p_customers/show.html.haml b/app/views/admin/p_customers/show.html.haml index 6a5e837..ea0dbf2 100644 --- a/app/views/admin/p_customers/show.html.haml +++ b/app/views/admin/p_customers/show.html.haml @@ -3,7 +3,7 @@ = link_to i(:pencil), edit_admin_p_customer_path(@p_customer), :remote => false - =breadcrumb(record: "#{@p_customer.code} - #{@p_customer.show_name}") + =breadcrumb record: @p_customer.name diff --git a/app/views/admin/p_fournisseurs/index.html.haml b/app/views/admin/p_fournisseurs/index.html.haml index f77d543..ef18615 100644 --- a/app/views/admin/p_fournisseurs/index.html.haml +++ b/app/views/admin/p_fournisseurs/index.html.haml @@ -2,10 +2,7 @@ .right = link_to 'Ajouter un fournisseur', new_admin_p_fournisseur_path(), :class => "btn btn-primary", :remote => true - %h1 - Achats - %span - Fournisseurs + =breadcrumb .qi_row @@ -28,4 +25,4 @@ %tbody#p_fournisseurs_rows =render @p_fournisseurs - \ No newline at end of file + diff --git a/app/views/admin/p_payment_types/index.html.haml b/app/views/admin/p_payment_types/index.html.haml index 08213cf..f9e4779 100644 --- a/app/views/admin/p_payment_types/index.html.haml +++ b/app/views/admin/p_payment_types/index.html.haml @@ -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 - \ No newline at end of file + diff --git a/app/views/admin/p_payments/index.html.haml b/app/views/admin/p_payments/index.html.haml index 9d5500c..f586b10 100644 --- a/app/views/admin/p_payments/index.html.haml +++ b/app/views/admin/p_payments/index.html.haml @@ -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 @@ - \ No newline at end of file + diff --git a/app/views/admin/p_product_cats/index.html.haml b/app/views/admin/p_product_cats/index.html.haml index 4df21f9..3ab0b4e 100644 --- a/app/views/admin/p_product_cats/index.html.haml +++ b/app/views/admin/p_product_cats/index.html.haml @@ -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 - \ No newline at end of file + diff --git a/app/views/admin/p_product_colors/index.html.haml b/app/views/admin/p_product_colors/index.html.haml index 4da1f8e..68a3daa 100644 --- a/app/views/admin/p_product_colors/index.html.haml +++ b/app/views/admin/p_product_colors/index.html.haml @@ -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 diff --git a/app/views/admin/p_product_powers/index.html.haml b/app/views/admin/p_product_powers/index.html.haml index 5a129d6..14211e1 100644 --- a/app/views/admin/p_product_powers/index.html.haml +++ b/app/views/admin/p_product_powers/index.html.haml @@ -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 diff --git a/app/views/admin/p_product_ref_specs/index.html.haml b/app/views/admin/p_product_ref_specs/index.html.haml index f486839..043b6c0 100644 --- a/app/views/admin/p_product_ref_specs/index.html.haml +++ b/app/views/admin/p_product_ref_specs/index.html.haml @@ -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 diff --git a/app/views/admin/p_product_refs/index.html.haml b/app/views/admin/p_product_refs/index.html.haml index 3a3aeaf..df20346 100644 --- a/app/views/admin/p_product_refs/index.html.haml +++ b/app/views/admin/p_product_refs/index.html.haml @@ -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 @@ -57,4 +54,4 @@ :coffeescript $(".qi_search_row form").on "submit", -> - $("#p_product_refs_index_wrapper").html('recherche en cours ...') \ No newline at end of file + $("#p_product_refs_index_wrapper").html('recherche en cours ...') diff --git a/app/views/admin/p_product_refs/show.html.haml b/app/views/admin/p_product_refs/show.html.haml index 309a88d..800f758 100644 --- a/app/views/admin/p_product_refs/show.html.haml +++ b/app/views/admin/p_product_refs/show.html.haml @@ -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 @@ -20,9 +12,10 @@ %td Produit %td=@p_product_ref.p_product.name #link_to @p_product_ref.p_product.name, [:admin, @p_product_ref.p_product] - %tr - %td Actif ? - %td=@p_product_ref.enabled ? "Oui" : "Non" + -if false + %tr + %td Actif ? + %td=@p_product_ref.enabled ? "Oui" : "Non" %tr @@ -45,30 +38,31 @@ %td Unité de vente (archive) : %td= @p_product_ref.uv - %tr - %td Conditionnement de référence : - %td - -if @p_product_ref.p_product and @p_product_ref.p_product.p_product_conditioning - = @p_product_ref.p_product.p_product_conditioning.name + -if false + %tr + %td Conditionnement de référence : + %td + -if @p_product_ref.p_product and @p_product_ref.p_product.p_product_conditioning + = @p_product_ref.p_product.p_product_conditioning.name + + %tr + %td Conditionnement : + %td + -if @p_product_ref.p_product_conditioning + = @p_product_ref.p_product_conditioning.name - %tr - %td Conditionnement : - %td - -if @p_product_ref.p_product_conditioning - = @p_product_ref.p_product_conditioning.name + %tr + %td Quantité par rapport au conditionnement de référence : + %td + = @p_product_ref.conditioning_ref_qte - %tr - %td Quantité par rapport au conditionnement de référence : - %td - = @p_product_ref.conditioning_ref_qte - - %tr - %td Prix de vente à l'unité de référence - %td - =number_to_currency( @p_product_ref.ct_price_ht / @p_product_ref.conditioning_ref_qte, :precision => 3) if @p_product_ref.ct_price_ht? and @p_product_ref.conditioning_ref_qte? - ="/" - = @p_product_ref.p_product.p_product_conditioning.name if @p_product_ref.p_product.p_product_conditioning + %tr + %td Prix de vente à l'unité de référence + %td + =number_to_currency( @p_product_ref.ct_price_ht / @p_product_ref.conditioning_ref_qte, :precision => 3) if @p_product_ref.ct_price_ht? and @p_product_ref.conditioning_ref_qte? + ="/" + = @p_product_ref.p_product.p_product_conditioning.name if @p_product_ref.p_product.p_product_conditioning -if @p_product_ref @@ -132,41 +126,41 @@ sortis .clear +-if false + .qi_row + .qi_pannel + %h3 Historique des prix d'achat -.qi_row - .qi_pannel - %h3 Historique des prix d'achat - - %table.table.table-striped.table-hover.table-bordered - %tr - %th - Date - %th Fournisseur - %th Document - %th Total - %th Qté - %th P.U. - - -price_line_achats = PriceLine.joins(:price_lineable).joins(:price_line_block).where(:cc_block_type => "Facture achat").where(:p_product_ref_id => @p_product_ref.id).order("price_documents.date DESC").each do |price_line| - + %table.table.table-striped.table-hover.table-bordered %tr - %td - =l price_line.price_line_block.price_lineable.date, :format => :date + %th + Date + %th Fournisseur + %th Document + %th Total + %th Qté + %th P.U. + + -price_line_achats = PriceLine.joins(:price_lineable).joins(:price_line_block).where(:cc_block_type => "Facture achat").where(:p_product_ref_id => @p_product_ref.id).order("price_documents.date DESC").each do |price_line| + + %tr + %td + =l price_line.price_line_block.price_lineable.date, :format => :date + + %td + =link_to price_line.price_lineable.p_fournisseur.show_name, [:admin, price_line.price_lineable.p_fournisseur] if price_line.price_lineable.p_fournisseur + + %td + =link_to price_line.price_lineable.d_number, [:admin, price_line.price_lineable] + + %td + =number_to_currency price_line.tot_amount_ht + + + %td + =price_line.qte + + %td + =number_to_currency price_line.price_u_ht - %td - =link_to price_line.price_lineable.p_fournisseur.show_name, [:admin, price_line.price_lineable.p_fournisseur] if price_line.price_lineable.p_fournisseur - - %td - =link_to price_line.price_lineable.d_number, [:admin, price_line.price_lineable] - - %td - =number_to_currency price_line.tot_amount_ht - - - %td - =price_line.qte - - %td - =number_to_currency price_line.price_u_ht - - \ No newline at end of file + diff --git a/app/views/admin/p_product_zones/index.html.haml b/app/views/admin/p_product_zones/index.html.haml index cf5e70a..8651c8d 100644 --- a/app/views/admin/p_product_zones/index.html.haml +++ b/app/views/admin/p_product_zones/index.html.haml @@ -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 diff --git a/app/views/admin/p_products/edit.html.haml b/app/views/admin/p_products/edit.html.haml index e0d5b2b..a70a9dc 100644 --- a/app/views/admin/p_products/edit.html.haml +++ b/app/views/admin/p_products/edit.html.haml @@ -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' diff --git a/app/views/admin/p_products/index.html.haml b/app/views/admin/p_products/index.html.haml index ec874e5..3ff55ee 100644 --- a/app/views/admin/p_products/index.html.haml +++ b/app/views/admin/p_products/index.html.haml @@ -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 diff --git a/app/views/admin/p_products/new.html.haml b/app/views/admin/p_products/new.html.haml index c9ff653..45f9916 100644 --- a/app/views/admin/p_products/new.html.haml +++ b/app/views/admin/p_products/new.html.haml @@ -1,11 +1,5 @@ .qi_header - %h1 - Achats - %span - =link_to "Produits", admin_p_products_path() - - %span - Ajouter un produit + =breadcrumb diff --git a/app/views/admin/p_serial_num_types/index.html.haml b/app/views/admin/p_serial_num_types/index.html.haml index 80034b4..456211f 100644 --- a/app/views/admin/p_serial_num_types/index.html.haml +++ b/app/views/admin/p_serial_num_types/index.html.haml @@ -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 diff --git a/app/views/admin/p_spec_types/index.html.haml b/app/views/admin/p_spec_types/index.html.haml index 46d02ec..fb1e681 100644 --- a/app/views/admin/p_spec_types/index.html.haml +++ b/app/views/admin/p_spec_types/index.html.haml @@ -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 diff --git a/app/views/admin/p_spec_values/index.html.haml b/app/views/admin/p_spec_values/index.html.haml index 8f34bd1..d629379 100644 --- a/app/views/admin/p_spec_values/index.html.haml +++ b/app/views/admin/p_spec_values/index.html.haml @@ -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 diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml index 8627aca..3766d31 100644 --- a/app/views/admin/price_documents/analyse_reponses.html.haml +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -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| diff --git a/app/views/admin/price_documents/edit.html.haml b/app/views/admin/price_documents/edit.html.haml index f652735..2193d72 100644 --- a/app/views/admin/price_documents/edit.html.haml +++ b/app/views/admin/price_documents/edit.html.haml @@ -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" diff --git a/app/views/admin/price_documents/index.html.haml b/app/views/admin/price_documents/index.html.haml index 014b9eb..ca45910 100644 --- a/app/views/admin/price_documents/index.html.haml +++ b/app/views/admin/price_documents/index.html.haml @@ -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 diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml index 1f7bc6a..c474220 100644 --- a/app/views/admin/price_documents/show.html.haml +++ b/app/views/admin/price_documents/show.html.haml @@ -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 diff --git a/app/views/admin/s_brands/index.html.haml b/app/views/admin/s_brands/index.html.haml index 164cd26..d74bcd7 100644 --- a/app/views/admin/s_brands/index.html.haml +++ b/app/views/admin/s_brands/index.html.haml @@ -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 - \ No newline at end of file + diff --git a/app/views/admin/stock_movements/index.html.haml b/app/views/admin/stock_movements/index.html.haml index 3dec3e9..6d44fd9 100644 --- a/app/views/admin/stock_movements/index.html.haml +++ b/app/views/admin/stock_movements/index.html.haml @@ -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 diff --git a/app/views/admin/stock_movements/show.html.haml b/app/views/admin/stock_movements/show.html.haml index d8210be..0c8b675 100644 --- a/app/views/admin/stock_movements/show.html.haml +++ b/app/views/admin/stock_movements/show.html.haml @@ -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}" + From 05c832eb5291abcb6203512ca22c9efc21c0cc23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 28 Sep 2021 12:29:55 +0200 Subject: [PATCH 9/9] bugfix p_product_refs --- app/models/p_product_ref.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index 9a7fccf..8e08f51 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -10,6 +10,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