This commit is contained in:
Nicolas Bally 2018-10-16 20:34:15 +02:00
parent 18c17a83f1
commit 4953ff7ccb
11 changed files with 130 additions and 87 deletions

View File

@ -1159,3 +1159,9 @@ height: 100%;
} }
} }
.center{
padding:0 20px;
margin:auto;
}

View File

@ -10,9 +10,16 @@ class Public::NeedsController < ApplicationController
before_filter :check_owner, only: [:destroy,:edit,:update] before_filter :check_owner, only: [:destroy,:edit,:update]
def index def index
params[:type] = params[:type] || 1
params[:type] = params[:type].to_i
session[:reseaux_id] = nil if params[:no_reseaux] session[:reseaux_id] = nil if params[:no_reseaux]
# Get only public needs # Get only public needs
@needs = Need.shared @needs = Need.shared
@needs = @needs.where(:need_type => params[:type])
if session[:reseaux_id].to_i > 0 if session[:reseaux_id].to_i > 0
@needs = @needs.where(:reseaux_id => session[:reseaux_id]) @needs = @needs.where(:reseaux_id => session[:reseaux_id])
else else
@ -79,6 +86,8 @@ class Public::NeedsController < ApplicationController
def download_devis def download_devis
@need = Need.find(params[:need_id]) @need = Need.find(params[:need_id])
params[:type] = @need.need_type
if @need.author.id != current_customer.id if @need.author.id != current_customer.id
flash[:error] = "Vous n'êtes pas le propriétaire" flash[:error] = "Vous n'êtes pas le propriétaire"
return redirect_to :back return redirect_to :back
@ -90,6 +99,7 @@ class Public::NeedsController < ApplicationController
def new def new
@need = Need.new() @need = Need.new()
end end
def destroy def destroy
@ -102,10 +112,12 @@ class Public::NeedsController < ApplicationController
def edit def edit
@need = Need.find(params[:id]) @need = Need.find(params[:id])
end end
def show def show
@need = Need.find(params[:id]) @need = Need.find(params[:id])
params[:type] = @need.need_type
@comment = Message.new() @comment = Message.new()
@comments = @need.messages.order(created_at: :desc).page params[:page] @comments = @need.messages.order(created_at: :desc).page params[:page]
end end
@ -122,6 +134,7 @@ class Public::NeedsController < ApplicationController
def create def create
@need = Need.new(need_params) @need = Need.new(need_params)
params[:type] = @need.need_type
@need.reseaux_id = session[:reseaux_id] @need.reseaux_id = session[:reseaux_id]
@need.author = current_customer @need.author = current_customer
@ -151,6 +164,7 @@ class Public::NeedsController < ApplicationController
def wish def wish
@need = Need.find(params[:id]) @need = Need.find(params[:id])
params[:type] = @need.need_type
admins = Admin.where.not(email: nil) admins = Admin.where.not(email: nil)
if (!@need.customers.include?(current_customer)) if (!@need.customers.include?(current_customer))
@need.customers << current_customer @need.customers << current_customer

View File

@ -6,6 +6,7 @@
=f.inputs do =f.inputs do
=f.input :need_type, :label => "Type :", :collection => [["Besoin spécifique", 1],["Centrale d'achat", 2]], :as => :select, :include_blank => false
=f.input :reseaux_id, :label => "Réseau :", :collection => Reseaux.where(:parent_id => nil).all, :as => :select, :include_blank => false =f.input :reseaux_id, :label => "Réseau :", :collection => Reseaux.where(:parent_id => nil).all, :as => :select, :include_blank => false
=f.input :title, :label => "Titre : " =f.input :title, :label => "Titre : "

View File

@ -12,6 +12,7 @@
%br %br
Choissisez le réseaux sur lequel vous souhaitez vous connecter : Choissisez le réseaux sur lequel vous souhaitez vous connecter :
.reseauxes_home .reseauxes_home
-if false
=link_to public_needs_path(:no_reseaux => true), :class => "reseauxes" do =link_to public_needs_path(:no_reseaux => true), :class => "reseauxes" do
.arrow .arrow
=ic :"angle-right" =ic :"angle-right"

View File

@ -19,6 +19,7 @@
=i(:"tag") + " " + need.category.name =i(:"tag") + " " + need.category.name
-else -else
Non catégorisé Non catégorisé
-if params[:type].to_i == 1
-if need.verified? -if need.verified?
%span.state.state-info.pull-right %span.state.state-info.pull-right
=need.human_state =need.human_state
@ -46,6 +47,7 @@
%p.description=need.description %p.description=need.description
-if params[:type].to_i == 1
.counters .counters
.item=i(:"hand-paper-o") + " " + need.wishes.length.to_s .item=i(:"hand-paper-o") + " " + need.wishes.length.to_s
.item=i(:"comment-o") + " " + need.messages.length.to_s .item=i(:"comment-o") + " " + need.messages.length.to_s

View File

@ -11,6 +11,7 @@
.row.col-md-3 .row.col-md-3
.white.side-menu .white.side-menu
-if params[:type].to_i == 1
=link_to "Proposer un nouveau besoin", new_public_need_path,style:'display:block', class: 'btn btn-primary' =link_to "Proposer un nouveau besoin", new_public_need_path,style:'display:block', class: 'btn btn-primary'
%br %br
= semantic_form_for :search, :html => {id: :search_form, :method => :get } do |f| = semantic_form_for :search, :html => {id: :search_form, :method => :get } do |f|

View File

@ -1,5 +1,6 @@
.center.white.show-need .center.white.show-need
.top-left-info .top-left-info
-if params[:type].to_i == 1
-if @need.verified? -if @need.verified?
%span.state.state-info.pull-right %span.state.state-info.pull-right
=@need.human_state =@need.human_state
@ -23,6 +24,7 @@
.content .content
%h1= @need.title.upcase %h1= @need.title.upcase
-if params[:type].to_i == 1
-if @need.author -if @need.author
%p.info %p.info
=i(:"clock-o") + " Proposé par " =i(:"clock-o") + " Proposé par "
@ -127,17 +129,17 @@
-if @need.verified? -if @need.verified?
- @wish = @need.wishes.where(need_id: @need.id, customer_id: current_customer.id).first - @wish = @need.wishes.where(need_id: @need.id, customer_id: current_customer.id).first
-if(@wish) -if(@wish)
=link_to i(:"check") + " Intéressé", edit_public_need_wish_path(@need, @wish) , :class => "btn btn-square btn-lg btn-success pull-right" =link_to i(:"check") + " Intéressé - Client", edit_public_need_wish_path(@need, @wish) , :class => "btn btn-square btn-lg btn-success pull-right"
-else -else
=link_to i(:"hand-paper-o") + " Ça m'intéresse !", new_public_need_wish_path(@need) , :class => "btn btn-square btn-lg btn-primary pull-right" =link_to i(:"hand-paper-o") + " Ça m'intéresse ! - Client", new_public_need_wish_path(@need) , :class => "btn btn-square btn-lg btn-primary pull-right"
%br %br
%br %br
%br %br
- @wish_furbish = @need.need_furbish_interests.where(customer_id: current_customer.id).first - @wish_furbish = @need.need_furbish_interests.where(customer_id: current_customer.id).first
-if @wish_furbish -if @wish_furbish
=link_to i(:"check") + " Interessé en tant que fournisseur", public_need_furbish_interest_path(@wish_furbish) , :class => "btn btn-square btn-lg btn-success pull-right", :method => :delete =link_to i(:"check") + " Interessé - Fournisseur", public_need_furbish_interest_path(@wish_furbish) , :class => "btn btn-square btn-lg btn-success pull-right", :method => :delete
-else -else
=link_to i(:"hand-paper-o") + " Ça m'intéresse en tant que fournisseur !", new_public_need_furbish_interest_path(:need_id => @need.id) , :class => "btn btn-square btn-lg btn-primary pull-right" =link_to i(:"hand-paper-o") + " Ça m'intéresse ! - Fournisseur", new_public_need_furbish_interest_path(:need_id => @need.id) , :class => "btn btn-square btn-lg btn-primary pull-right"
-elsif @need.negociating? -elsif @need.negociating?
@ -169,7 +171,9 @@
.clear .clear
%br
-if params[:type].to_i == 1
%hr %hr
%h2= i(:"comments") + " Fil de discussion" %h2= i(:"comments") + " Fil de discussion"
= semantic_form_for [:public, @need, @comment ], :html => {id: :message_form, :method => :post } do |f| = semantic_form_for [:public, @need, @comment ], :html => {id: :message_form, :method => :post } do |f|

View File

@ -6,11 +6,18 @@
-if !@my_reseauxes -if !@my_reseauxes
-if current_customer.account_validated? -if current_customer.account_validated?
%li=link_to ic(:home)+" Accueil", public_my_reseauxes_path, :class => "btn" %li=link_to ic(:home)+" Accueil", public_my_reseauxes_path, :class => "btn"
-if false
-if !@reseaux -if !@reseaux
%li=link_to ic(:"youtube-play")+" Présentation Négos","", :class => "btn negos-video" %li=link_to ic(:"youtube-play")+" Présentation Négos","", :class => "btn negos-video"
-if current_customer.account_validated? -if current_customer.account_validated?
%li=link_to ic(:star)+" Besoins", public_needs_path, :class => "btn" %li=link_to ic(:star)+" Besoins", public_needs_path, :class => "btn"
- unread_message = ContactMessage.where(contact_id: current_customer.id, read_by_customer: false).count - unread_message = ContactMessage.where(contact_id: current_customer.id, read_by_customer: false).count
%li=link_to ic(:comment)+" Nous contacter" + (unread_message > 0 ? " (#{unread_message})" : ""), public_contact_messages_path, :class => "btn" %li=link_to ic(:comment)+" Nous contacter" + (unread_message > 0 ? " (#{unread_message})" : ""), public_contact_messages_path, :class => "btn"
%li=link_to ic(:user)+" Mon compte", public_my_account_path, :class => "btn" %li=link_to ic(:user)+" Mon compte", public_my_account_path, :class => "btn"

View File

@ -3,10 +3,11 @@
.center .center
-if current_customer.account_validated? -if current_customer.account_validated?
=link_to "Besoins", public_needs_path, :class => ("active" if @needs) =link_to "Besoins spécifiques", public_needs_path(:type => 1), :class => ("active" if @needs and params[:type].to_i == 1)
=link_to "Centrale d'achat", public_needs_path(:type => 2), :class => ("active" if @needs and params[:type].to_i == 2)
-if session[:reseaux_id].to_i > 0 -if session[:reseaux_id].to_i > 0
=link_to "Offres", public_reseaux_products_path(:reseaux_id => session[:reseaux_id].to_i), :class => ("active" if @products or @product) =link_to "Offres exclusives", public_reseaux_products_path(:reseaux_id => session[:reseaux_id].to_i), :class => ("active" if @products or @product)
.clear .clear

View File

@ -0,0 +1,5 @@
class AddNeedTypeToNeeds < ActiveRecord::Migration
def change
add_column :needs, :need_type, :integer, :default => 1
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180921093741) do ActiveRecord::Schema.define(version: 20181016180809) do
create_table "abonnements", force: :cascade do |t| create_table "abonnements", force: :cascade do |t|
t.integer "abonnement_type_id", limit: 4 t.integer "abonnement_type_id", limit: 4
@ -579,6 +579,7 @@ ActiveRecord::Schema.define(version: 20180921093741) do
t.integer "referent_negos_id", limit: 4 t.integer "referent_negos_id", limit: 4
t.integer "referent_technique_id", limit: 4 t.integer "referent_technique_id", limit: 4
t.integer "reseaux_id", limit: 4 t.integer "reseaux_id", limit: 4
t.integer "need_type", limit: 4, default: 1
end end
add_index "needs", ["author_id"], name: "index_needs_on_author_id", using: :btree add_index "needs", ["author_id"], name: "index_needs_on_author_id", using: :btree