From b09b941321fe5be73669eebb82e55c7650d41b08 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Wed, 1 Sep 2021 00:54:56 +0200 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20interface=20saisie=20des=20?= =?UTF-8?q?prix=20par=20les=20fournisseurs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Consulter le lien avec le token en navigation privée, épuration de l'affichage, méthodes dédiées... --- .../admin/price_documents_controller.rb | 25 ++- .../admin/price_lines_controller.rb | 2 +- app/helpers/translation_helper.rb | 2 +- app/models/price_line.rb | 6 +- .../admin/price_documents/consult.html.haml | 42 +++-- .../price_documents/consult_edit.html.haml | 38 ++++ .../_form_reponse_fournisseur.html.haml | 22 +-- app/views/admin/price_lines/_form.html.haml | 2 +- .../_form_reponse_fournisseur.html.haml | 2 +- .../admin/price_lines/_price_line.html.haml | 6 +- .../_reponse_pane_hover_form.html.haml | 61 +++++++ app/views/admin/price_lines/edit.js.erb | 2 +- app/views/layouts/admin.html.haml | 166 +++++++++--------- config/routes.rb | 7 +- 14 files changed, 264 insertions(+), 119 deletions(-) create mode 100644 app/views/admin/price_documents/consult_edit.html.haml create mode 100644 app/views/admin/price_lines/_reponse_pane_hover_form.html.haml diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 4a079ad..492ed2c 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -2,7 +2,7 @@ class Admin::PriceDocumentsController < ApplicationController layout "admin" - before_action :auth_admin, :except => :print + before_action :auth_admin, :except => [:print, :consult, :consult_create, :consult_edit, :consult_update] before_action :admin_space, :except => :print @@ -267,6 +267,7 @@ class Admin::PriceDocumentsController < ApplicationController def consult + @consult = true @demande = PriceDocument.where(:f_token => params[:id]).first @@ -284,6 +285,28 @@ class Admin::PriceDocumentsController < ApplicationController end + + def consult_create + @consult = true + + @price_document = PriceDocument.new(params.require(:price_document).permit!) + @price_document.date = Date.today + if @price_document.save + redirect_to consult_edit_admin_price_document_path(:id => @price_document.token) + else + render action: "consult" + + end + + end + + + def consult_edit + @consult = true + + @price_document = PriceDocument.where(:token => params[:id]).first + end + def edit @price_document = PriceDocument.find(params[:id]) diff --git a/app/controllers/admin/price_lines_controller.rb b/app/controllers/admin/price_lines_controller.rb index 18930ce..0874893 100644 --- a/app/controllers/admin/price_lines_controller.rb +++ b/app/controllers/admin/price_lines_controller.rb @@ -2,7 +2,7 @@ class Admin::PriceLinesController < ApplicationController layout "admin" - before_action :auth_admin + before_action :auth_admin, :except => [:edit, :update] before_action :admin_space diff --git a/app/helpers/translation_helper.rb b/app/helpers/translation_helper.rb index 9021c6e..a608c96 100755 --- a/app/helpers/translation_helper.rb +++ b/app/helpers/translation_helper.rb @@ -32,7 +32,7 @@ module TranslationHelper content = capture(&block) if block_given? r = "" - if current_admin.id == 1 + if current_admin and current_admin.id == 1 r += "" r += ic(:"stethoscope") if show_icon diff --git a/app/models/price_line.rb b/app/models/price_line.rb index f02360b..840396a 100644 --- a/app/models/price_line.rb +++ b/app/models/price_line.rb @@ -17,7 +17,10 @@ class PriceLine < ApplicationRecord :ref => {:name => "Ref", :reorder => true}, :title => {:name => "Désignation", :reorder => true}, :qte => {:name => "Qté", :reorder => true}, + :qte_available => {:name => "Qté dispo.", :reorder => true}, + + :ct_u_price_ht => {:name => "Prix de vente", :reorder => true}, :ref_fournisseur => {:name => "Réf. fournisseur", :reorder => true}, :p_product_power_id => {:name => "Chargeur", :reorder => true}, :p_product_zone_id => {:name => "Zone", :reorder => true}, @@ -26,7 +29,8 @@ class PriceLine < ApplicationRecord :ram_unit => {:name => "Ram unité", :reorder => true}, :eu => {:name => "EU ?", :reorder => true}, :fullkit => {:name => "Fullkit ?", :reorder => true}, - :lang_start => {:name => "Démarrage écran langue ?", :reorder => true} + :lang_start => {:name => "Démarrage écran langue ?", :reorder => true}, + :actions => {:name => "Actions"} } diff --git a/app/views/admin/price_documents/consult.html.haml b/app/views/admin/price_documents/consult.html.haml index bc946db..5554f0f 100644 --- a/app/views/admin/price_documents/consult.html.haml +++ b/app/views/admin/price_documents/consult.html.haml @@ -1,15 +1,24 @@ -.qi_header +-if current_admin + .qi_header - %h1 - Consultation fournisseur - %span - =@demande.list_designaton + %h1 + Consultation fournisseur + %span + =@demande.list_designaton .qi_row - =semantic_form_for [:admin, @price_document], :html => {:class => "qi_price_form"}, :remote => false do |f| + %p{:style => "text-align:center;font-size:1.2em;"} + Vous allez pouvoir répondre à une demande de cotation envoyée par Arcom. + %p{:style => "text-align:center;font-size:1.2em;"} + Pour cela, merci de nous indiquer pour quelle société vous répondez à notre demande de chiffrage. + + + + + =semantic_form_for [:admin, @price_document], :url => consult_create_admin_price_documents_path(), :html => {:class => "qi_price_form"}, :remote => false do |f| -@p_customer = @price_document.p_customer =diag do =f.object.errors.messages @@ -22,24 +31,23 @@ =f.hidden_field :price_document_type_id - = f.input :public_fournisseur_name, :label => "Nom entreprise" + %center= f.input :public_fournisseur_name, :label => "Nom de votre société :" + + %p{:style => "text-align:center;font-size:1.2em;"} + Vous pouvez également indiquer votre référence interne : + + =hidden_field_tag :public_edit, params[:public_edit] - = @price_document.price_line_block.block_type - - + .price_line_block_form =f.semantic_fields_for :price_line_block do |f| - =render :partial => "admin/price_line_blocks/form_#{f.object.block_type_slug}", :locals => {:f => f} + %center=render :partial => "admin/price_line_blocks/form_#{f.object.block_type_slug}", :locals => {:f => f} - - - - - .large_actions - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + %center + =f.submit "sauvegarder", :class => "btn btn-primary" diff --git a/app/views/admin/price_documents/consult_edit.html.haml b/app/views/admin/price_documents/consult_edit.html.haml new file mode 100644 index 0000000..a031c76 --- /dev/null +++ b/app/views/admin/price_documents/consult_edit.html.haml @@ -0,0 +1,38 @@ + +.qi_row + .qi_pannel.padding + + %table.table.table-striped + %tr + %td + Numéro réponse + + %td + =@price_document.d_number + %tr + %td + Nom fournisseur saisi + %td + =@price_document.public_fournisseur_name + + + +-params[:search][:per_page] = params[:search][:per_page] || 5000 +-per_page = params[:search][:per_page] +-page = (params[:page] and params[:page] != "") ? params[:page] : 1 + +-@price_lines = @price_document.price_line_block.price_lines + + + + +-@price_lines = sort_by_sorting(@price_lines, "created_at DESC") +-@price_lines = @price_lines.page(page).per(per_page) +%br + + + +.clear +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_lines, :key => "reponses-prix-show"} + + diff --git a/app/views/admin/price_line_blocks/_form_reponse_fournisseur.html.haml b/app/views/admin/price_line_blocks/_form_reponse_fournisseur.html.haml index 06bc0c4..15332b8 100644 --- a/app/views/admin/price_line_blocks/_form_reponse_fournisseur.html.haml +++ b/app/views/admin/price_line_blocks/_form_reponse_fournisseur.html.haml @@ -3,17 +3,19 @@ -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") - .qi_pannel.qi_plain.padding{:style => "margin:20px 0;"} - - = f.input :p_fournisseur_id, :label => "Fournisseur", :collection => PFournisseur.all, :as => :select, :member_label => :name if @price_document.label == "Réponse fournisseur" and current_admin - = f.input :customer_ref, :label => "Référence cotation fournisseur :" - - - .price_lines_form - =f.semantic_fields_for :price_lines do |f| - =render :partial => "admin/price_lines/form_#{f.object.block_type_slug}", :locals => {:form => f} - %p= link_to_add_fields "Ajouter une ligne", f, :price_lines, {:class => "btn btn-primary"} + + = f.input :p_fournisseur_id, :label => "Fournisseur", :collection => PFournisseur.all, :as => :select, :member_label => :name if @price_document.label == "Réponse fournisseur" and current_admin + = f.input :customer_ref, :label => "Votre référence de cotation :" + + + %div{:style => ("display:none" if !current_admin)} + + .price_lines_form + =f.semantic_fields_for :price_lines do |f| + =render :partial => "admin/price_lines/form_#{f.object.block_type_slug}", :locals => {:form => f} + + %p= link_to_add_fields "Ajouter une ligne", f, :price_lines, {:class => "btn btn-primary"} if current_admin \ No newline at end of file diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index 67bd84d..ed95396 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -97,7 +97,7 @@ -else =qi_js_field(form, :price_line, :price_u_ht, :label => "Prix U HT :") - %div{:style => ("display:none;" if !current_admin.has_permission?("customer-sheets-personalised-price"))} + %div{:style => ("display:none;" if !current_admin or !current_admin.has_permission?("customer-sheets-personalised-price"))} = form.input :forced_price, :label => "Prix personnalisé ?", :as => :boolean, :input_html => {:class => "input_price_line_forced_price"} .forced_price_wrapper{:style => ("display:none;" if !form.object.forced_price)}= form.input :ct_u_price_ht, :label => false, :input_html => {:class => "input_price_line_ct_u_price_ht"} diff --git a/app/views/admin/price_lines/_form_reponse_fournisseur.html.haml b/app/views/admin/price_lines/_form_reponse_fournisseur.html.haml index 169acc5..bf511fa 100644 --- a/app/views/admin/price_lines/_form_reponse_fournisseur.html.haml +++ b/app/views/admin/price_lines/_form_reponse_fournisseur.html.haml @@ -33,7 +33,7 @@ = form.input :ram, :label => "Ram" %td - = form.input :ram, :label => "Ram unité" + = form.input :ram_unit, :label => "Ram unité" %td diff --git a/app/views/admin/price_lines/_price_line.html.haml b/app/views/admin/price_lines/_price_line.html.haml index 73c945d..4b7dee4 100644 --- a/app/views/admin/price_lines/_price_line.html.haml +++ b/app/views/admin/price_lines/_price_line.html.haml @@ -1,5 +1,7 @@ -%tr#price_document_row{:id => price_line.id} +%tr#price_line_row{:id => price_line.id} -tr = {} - + -tr[:actions] = capture do + %td + =link_to ic(:pencil), edit_admin_price_line_path(price_line), :remote => true =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => price_line} \ No newline at end of file diff --git a/app/views/admin/price_lines/_reponse_pane_hover_form.html.haml b/app/views/admin/price_lines/_reponse_pane_hover_form.html.haml new file mode 100644 index 0000000..4444417 --- /dev/null +++ b/app/views/admin/price_lines/_reponse_pane_hover_form.html.haml @@ -0,0 +1,61 @@ + + +=semantic_form_for [:admin, @price_line], :remote => true do |form| + + .content + Produit : + =form.object.p_product_ref.cc_name if form.object.p_product_ref + %br + Quantité à satisfaire : + =form.object.qte + + %br + %br + + %table.top_td{:style => "width:100%;"} + %tr + + %td + = form.input :p_product_power_id, :label => "Type de chargeur", :collection => PProductPower.all, :include_blank => false, :as => :select + + %td + = form.input :qte_available, :label => "Qté disponible :", :input_html => {:class => "input_price_line_qte"} + + + %td + = form.input :ct_u_price_ht, :label => "Prix vente" + + %td + = form.input :ready_stock, :label => "Ready stock", :as => :select + + %td + = form.input :ram, :label => "Ram" + + %td + = form.input :ram_unit, :label => "Ram unité" + + + %td + = form.input :eu, :label => "EU ?", :as => :select + + + %td + = form.input :p_product_zone_id, :label => "Zone", :collection => PProductZone.all, :include_blank => true, :as => :select + + + + %td + = form.input :fullkit, :label => "Fullkit", :as => :select + + %td + = form.input :lang_start, :label => "Démarage sur l'écran de langue (starting on screen language)", :as => :select + + + + + + + = form.input :comment, :label => "Commentaire", :input_html => {:style => "height:70px;"} + + .actions= form.submit "Sauvegarder", :class => "btn btn-primary" + diff --git a/app/views/admin/price_lines/edit.js.erb b/app/views/admin/price_lines/edit.js.erb index 6c8f015..30200cb 100644 --- a/app/views/admin/price_lines/edit.js.erb +++ b/app/views/admin/price_lines/edit.js.erb @@ -1 +1 @@ -show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file +show_pane_hover("<%= escape_javascript(render(:partial => "reponse_pane_hover_form"))%>",1200,900); \ No newline at end of file diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 23443a3..3fd69a3 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -30,50 +30,51 @@ =link_to image_tag("/logo-presta.png"), "/", :id => "logo" + -if current_admin - -@qi_menus.each do |k,v| + -@qi_menus.each do |k,v| - :scss - #body_#{k.to_s}{ - #admin_nav{ - //background:$big_color_#{k.to_s} !important; - background-color: #{v[:color].to_s} !important; - } + :scss + #body_#{k.to_s}{ + #admin_nav{ + //background:$big_color_#{k.to_s} !important; + background-color: #{v[:color].to_s} !important; + } - } - #big_cat_#{k.to_s}.active, #big_cat_#{k.to_s}:hover{ - //color:$big_color_#{k.to_s} !important; - //background-color: #{v[:color].to_s} !important; - color:white !important; - border-right:4px solid #{v[:color].to_s}; - } + } + #big_cat_#{k.to_s}.active, #big_cat_#{k.to_s}:hover{ + //color:$big_color_#{k.to_s} !important; + //background-color: #{v[:color].to_s} !important; + color:white !important; + border-right:4px solid #{v[:color].to_s}; + } - #big_cat_#{k.to_s}{ - //color:$big_color_#{k.to_s} !important; - color: rgba(white, 0.5) !important; - border-right:4px solid transparent; - } + #big_cat_#{k.to_s}{ + //color:$big_color_#{k.to_s} !important; + color: rgba(white, 0.5) !important; + border-right:4px solid transparent; + } - .bgbd-#{k.to_s}{ - background-color: #{v[:color].to_s} !important; - border-color: #{v[:color].to_s} !important; - } + .bgbd-#{k.to_s}{ + background-color: #{v[:color].to_s} !important; + border-color: #{v[:color].to_s} !important; + } - .element - =link_to v[:link] do - .cat#big_cat{:id => k.to_s} - =ic v[:icon].to_s.to_sym - =v[:name] + .element + =link_to v[:link] do + .cat#big_cat{:id => k.to_s} + =ic v[:icon].to_s.to_sym + =v[:name] .bottom .element - -if current_admin.has_permission?("admins") + -if current_admin and current_admin.has_permission?("admins") =link_to admin_admins_path do .cat#big_cat_preferences =ic :"cog" @@ -90,92 +91,93 @@ %nav#admin_nav.navbar.navbar-expand-lg.navbar-dark.bg-light %button.navbar-toggler{"aria-controls" => "navbarSupportedContent", "aria-expanded" => "false", "aria-label" => "Toggle navigation", "data-target" => "#navbarSupportedContent", "data-toggle" => "collapse", :type => "button"} %span.navbar-toggler-icon - #navbarSupportedContent.collapse.navbar-collapse - %ul.navbar-nav.mr-auto - -if @qi_menu_active - -qi_menu_active = @qi_menus[@qi_menu_active] + -if current_admin + #navbarSupportedContent.collapse.navbar-collapse + %ul.navbar-nav.mr-auto + -if @qi_menu_active + -qi_menu_active = @qi_menus[@qi_menu_active] - -if qi_menu_active[:elements] - -qi_menu_active[:elements].each do |k,v| - %li.nav-item= link_to v[:name], v[:link], :class => "nav-link "+("active" if (@qi_menu_sub_menu_active and @qi_menu_sub_menu_active == k)).to_s + -if qi_menu_active[:elements] + -qi_menu_active[:elements].each do |k,v| + %li.nav-item= link_to v[:name], v[:link], :class => "nav-link "+("active" if (@qi_menu_sub_menu_active and @qi_menu_sub_menu_active == k)).to_s - %script - =raw '$("#big_cat_'+@qi_menu_active.to_s+'").addClass("active");' + %script + =raw '$("#big_cat_'+@qi_menu_active.to_s+'").addClass("active");' - %form.form-inline.my-2.my-lg-0 - %ul.nav.navbar-nav.navbar-right - %li.nav-item.qi_help_remove{:style => ("display:none" if !session[:qi_helps] )} + %form.form-inline.my-2.my-lg-0 + %ul.nav.navbar-nav.navbar-right + %li.nav-item.qi_help_remove{:style => ("display:none" if !session[:qi_helps] )} - =link_to ic(:"question-circle"), admin_qi_helps_path(), :onclick => '$(".qi_help").hide();$(".qi_help_add").show();$(".qi_help_remove").hide();', :remote => true, :class => "nav-link" + =link_to ic(:"question-circle"), admin_qi_helps_path(), :onclick => '$(".qi_help").hide();$(".qi_help_add").show();$(".qi_help_remove").hide();', :remote => true, :class => "nav-link" - %li.nav-item.qi_help_add{:style => ("display:none" if session[:qi_helps] )} - =link_to ic(:"question-circle-o"), admin_qi_helps_path(:enabled => true), :onclick => '$(".qi_help").show();$(".qi_help_add").hide();$(".qi_help_remove").show();', :remote => true, :class => "nav-link" + %li.nav-item.qi_help_add{:style => ("display:none" if session[:qi_helps] )} + =link_to ic(:"question-circle-o"), admin_qi_helps_path(:enabled => true), :onclick => '$(".qi_help").show();$(".qi_help_add").hide();$(".qi_help_remove").show();', :remote => true, :class => "nav-link" - -if session[:qi_helps] - :scss - .qi_help{ - display:inherit; + -if session[:qi_helps] + :scss + .qi_help{ + display:inherit; + + } + -else + :scss + .qi_help{ + display:none; } - -else - :scss - .qi_help{ - display:none; - - } - %li.nav-item.qi_stat_remove{:style => ("display:none" if !session[:qi_stats] )} + %li.nav-item.qi_stat_remove{:style => ("display:none" if !session[:qi_stats] )} - =link_to raw(""+ic(:"pie-chart")+""), admin_qi_stats_path(), :onclick => '$(".qi_stat, .qi_kpi").show();$(".qi_stat_add").show();$(".qi_stat_remove").hide();', :remote => true, :class => "nav-link" + =link_to raw(""+ic(:"pie-chart")+""), admin_qi_stats_path(), :onclick => '$(".qi_stat, .qi_kpi").show();$(".qi_stat_add").show();$(".qi_stat_remove").hide();', :remote => true, :class => "nav-link" - %li.nav-item.qi_stat_add{:style => ("display:none" if session[:qi_stats] )} - =link_to ic(:"pie-chart"), admin_qi_stats_path(:enabled => true), :onclick => '$(".qi_stat, .qi_kpi").hide();$(".qi_stat_add").hide();$(".qi_stat_remove").show();', :remote => true, :class => "nav-link" + %li.nav-item.qi_stat_add{:style => ("display:none" if session[:qi_stats] )} + =link_to ic(:"pie-chart"), admin_qi_stats_path(:enabled => true), :onclick => '$(".qi_stat, .qi_kpi").hide();$(".qi_stat_add").hide();$(".qi_stat_remove").show();', :remote => true, :class => "nav-link" - -if session[:qi_stats] - :scss - .qi_stat, .qi_kpi{ - display:none; - - } - - -else - :scss - .qi_stat, .qi_kpi{ - display:inherit; + -if session[:qi_stats] + :scss + .qi_stat, .qi_kpi{ + display:none; } + -else + :scss + .qi_stat, .qi_kpi{ + display:inherit; + + } + - %li.nav-item.dropdown - %a#navbarDropdown.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :href => "#", :role => "button"} - =current_admin.firstname - =current_admin.name + %li.nav-item.dropdown + %a#navbarDropdown.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :href => "#", :role => "button"} + =current_admin.firstname + =current_admin.name - .dropdown-menu{"aria-labelledby" => "navbarDropdown"} - = link_to "Gestion des admins", admin_admins_path, :class => "dropdown-item" if current_admin.super_admin - .dropdown-divider - =link_to "Se déconnecter", admin_admin_auth_path(1), method: :delete, :class => "dropdown-item" + .dropdown-menu{"aria-labelledby" => "navbarDropdown"} + = link_to "Gestion des admins", admin_admins_path, :class => "dropdown-item" if current_admin.super_admin + .dropdown-divider + =link_to "Se déconnecter", admin_admin_auth_path(1), method: :delete, :class => "dropdown-item" - -if super_current_admin - %li.nav-item - =link_to ic(:"user-secret"), admin_admins_path, :class => "nav-link" + -if super_current_admin + %li.nav-item + =link_to ic(:"user-secret"), admin_admins_path, :class => "nav-link" - %li.nav-item - =link_to ic(:refresh), "#", :onclick => "location.reload();", :class => "nav-link" + %li.nav-item + =link_to ic(:refresh), "#", :onclick => "location.reload();", :class => "nav-link" diff --git a/config/routes.rb b/config/routes.rb index cdc0dc1..2ec3aac 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -612,10 +612,15 @@ Rails.application.routes.draw do get :consult post :consult_save + post :consult_create + get :consult_edit + put :consult_update + end collection do get :search_to_affect - + post :consult_create + end end end