This commit is contained in:
Nicolas Bally 2020-02-25 22:33:47 +01:00
parent 188436aae4
commit f5b030b522
11 changed files with 124 additions and 52 deletions

View File

@ -34,7 +34,7 @@ class Admin::MOdrsController < ApplicationController
@m_odr = MOdr.new(params.require(:m_odr).permit!) @m_odr = MOdr.new(params.require(:m_odr).permit!)
if @m_odr.save if @m_odr.save
redirect_to admin_m_odrs_path
else else
render action: "new" render action: "new"
@ -48,7 +48,7 @@ class Admin::MOdrsController < ApplicationController
if @m_odr.update_attributes(params.require(:m_odr).permit!) if @m_odr.update_attributes(params.require(:m_odr).permit!)
redirect_to admin_m_odrs_path
else else
render action: "edit" render action: "edit"

View File

@ -6,6 +6,17 @@ class MOdr < ApplicationRecord
belongs_to :banner_image_file, :class_name => "ImageFile" belongs_to :banner_image_file, :class_name => "ImageFile"
belongs_to :logo_image_file, :class_name => "ImageFile" belongs_to :logo_image_file, :class_name => "ImageFile"
belongs_to :social_image_file, :class_name => "ImageFile" belongs_to :social_image_file, :class_name => "ImageFile"
belongs_to :footer_image_file, :class_name => "ImageFile"
validates :p_customer, :presence => true
validates :name, :presence => true
validates :slug, :presence => true
validates :start_at, :presence => true
validates :end_at, :presence => true
validates :public_end, :presence => true
end end

View File

@ -1,6 +1,7 @@
=semantic_form_for [:admin, @m_odr], :remote => true do |f| =semantic_form_for [:admin, @m_odr], :remote => false do |f|
.content .qi_row
.qi_pannel.qi_plain.padding
=f.inputs do =f.inputs do
= f.input :p_customer, :label => "Client :" = f.input :p_customer, :label => "Client :"
@ -11,22 +12,41 @@
= f.input :landing_text, :label => "Texte lancement :" = f.input :landing_text, :label => "Texte lancement :"
.row.qi_cancel_margins
.col-sm-4
= f.input :start_at, :label => "Date de début :" , :as => :date = f.input :start_at, :label => "Date de début :" , :as => :date
.col-sm-4
= f.input :end_at, :label => "Date de fin :" , :as => :date = f.input :end_at, :label => "Date de fin :" , :as => :date
.col-sm-4
= f.input :public_end, :label => "Date de fin des envois :" , :as => :date = f.input :public_end, :label => "Date de fin des envois :" , :as => :date
= f.input :address_process, :label => "Récupération de l'adresse postale ?"
= f.input :rib_process, :label => "Récupération d'un RIB ?"
.row.qi_cancel_margins
.col-sm-3
= f.input :address_process, :label => "Récupération de l'adresse postale ?"
.col-sm-3
= f.input :rib_process, :label => "Récupération d'un RIB ?"
.col-sm-3
= f.input :email_needed, :label => "Récupération de l'email ?" = f.input :email_needed, :label => "Récupération de l'email ?"
.col-sm-3
= f.input :tel_needed, :label => "Récupération du tel ?" = f.input :tel_needed, :label => "Récupération du tel ?"
.row.qi_cancel_margins
.col-sm-3
= f.input :logo_image_file_id, :label => "Logo :" , :as => :qi_image_select = f.input :logo_image_file_id, :label => "Logo :" , :as => :qi_image_select
= f.input :logo_image_file_width, :label => "Largeur du logo (px):" = f.input :logo_image_file_width, :label => "Largeur du logo (px):"
= f.input :logo_image_link, :label => "Largeur du logo (px):"
.col-sm-3
= f.input :banner_image_file_id, :label => "Bannière :" , :as => :qi_image_select = f.input :banner_image_file_id, :label => "Bannière :" , :as => :qi_image_select
= f.input :banner_image_file_width, :label => "Largeur de la bannière (px):" = f.input :banner_image_file_width, :label => "Largeur de la bannière (px):"
= f.input :banner_image_link, :label => "Lien du footer :"
.col-sm-3
= f.input :footer_image_file_id, :label => "Footer :" , :as => :qi_image_select
= f.input :footer_image_width, :label => "Largeur du footer (px):"
= f.input :footer_image_link, :label => "Lien du footer :"
.col-sm-3
= f.input :background_image_file_id, :label => "Fond :" , :as => :qi_image_select = f.input :background_image_file_id, :label => "Fond :" , :as => :qi_image_select
=render :partial => "admin/shared/social_form", :locals => {:f => f} =render :partial => "admin/shared/social_form", :locals => {:f => f}
@ -34,6 +54,7 @@
.large_actions
.actions=f.submit "sauvegarder", :class => "btn btn-primary" .actions
=f.submit "sauvegarder", :class => "btn btn-primary"

View File

@ -1,18 +1,21 @@
%tr#m_odr_row{:id => m_odr.id} %tr#m_odr_row{:id => m_odr.id}
%td= m_odr.p_customer.show_name if m_odr.p_customer
%td= m_odr.name %td= m_odr.name
%td
=link_to public_m_odr_path(m_odr.slug), public_m_odr_path(m_odr.slug), :target => "_blank"
%td= m_odr.slug %td= m_odr.slug
%td= m_odr.start_at %td= m_odr.start_at
%td= m_odr.end_at %td= m_odr.end_at
%td= m_odr.public_end %td= m_odr.public_end
%td= m_odr.address_process %td= "oui" if m_odr.address_process
%td= m_odr.rib_process %td= "oui" if m_odr.rib_process
%td= m_odr.description %td= "oui" if m_odr.email_needed
%td= m_odr.email_needed %td= "oui" if m_odr.tel_needed
%td= m_odr.tel_needed
%td= m_odr.p_customer_id
%td.actions %td.actions
= link_to i(:"trash-o"), [:admin, m_odr], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true = link_to i(:"trash-o"), [:admin, m_odr], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
= link_to i(:pencil), edit_admin_m_odr_path(m_odr), :remote => true = link_to i(:pencil), edit_admin_m_odr_path(m_odr), :remote => false
= link_to i(:eye), admin_m_odr_path(m_odr), :remote => true = link_to i(:eye), admin_m_odr_path(m_odr), :remote => true

View File

@ -0,0 +1,8 @@
.qi_header
%h1
ODR
%span
Créer une ODR
= render 'form'

View File

@ -1,8 +1,7 @@
.qi_header .qi_header
.right= link_to 'Ajouter ', new_admin_m_odr_path(), :class => "btn btn-primary", :remote => true .right= link_to 'Ajouter ', new_admin_m_odr_path(), :class => "btn btn-primary", :remote => false
%h1 %h1
ODR
%span
@ -10,17 +9,17 @@
.qi_pannel.qi_plain.padding .qi_pannel.qi_plain.padding
%table.table %table.table
%tr %tr
%th name %th Client
%th slug %th Nom
%th start_at %th Lien
%th end_at %th Date de début
%th public_end %th Date de fin
%th address_process %th Fin de réception
%th rib_process %th Adresse ?
%th description %th Rib ?
%th email_needed %th Email ?
%th tel_needed %th Tel ?
%th p_customer_id
%th.actions %th.actions

View File

@ -0,0 +1,8 @@
.qi_header
%h1
ODR
%span
Créer une ODR
= render 'form'

View File

@ -70,3 +70,10 @@
-if false -if false
%p{:style => "font-weight:bold;font-size:2em;text-transform:uppercase;font-family:'Helvetica Neue', Helvetica, sans-serif;"} %p{:style => "font-weight:bold;font-size:2em;text-transform:uppercase;font-family:'Helvetica Neue', Helvetica, sans-serif;"}
jours avant l'ouverture jours avant l'ouverture
-if @m_odr.footer_image_file
-if @m_odr.footer_image_link?
=link_to image_tag(@m_odr.footer_image_file.file.url, :class => "odr_banner", :style => (@m_odr.footer_image_width? ? "max-width:#{@m_odr.footer_image_width}px;margin:auto;": "")), @m_odr.footer_image_link, :target => "_blank"
-else
=image_tag(@m_odr.footer_image_file.file.url, :class => "odr_banner", :style => (@m_odr.footer_image_width? ? "max-width:#{@m_odr.footer_image_width}px;margin:auto;": ""))

View File

@ -660,7 +660,7 @@ Rails.application.routes.draw do
get ':slug.html', to: 'public/m_odrs#show' get ':slug.html', to: 'public/m_odrs#show', :as => :public_m_odr
root "admin/admin_auths#index" root "admin/admin_auths#index"

View File

@ -0,0 +1,10 @@
class AddFooterToMOdrs < ActiveRecord::Migration[6.0]
def change
add_column :m_odrs, :footer_image_file_id, :integer
add_column :m_odrs, :footer_image_width, :integer
add_column :m_odrs, :footer_image_link, :string
add_column :m_odrs, :banner_image_link, :string
add_column :m_odrs, :logo_image_link, :string
end
end

View File

@ -10,7 +10,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: 2020_02_25_090129) do ActiveRecord::Schema.define(version: 2020_02_25_205920) do
create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.string "name" t.string "name"
@ -537,6 +537,11 @@ ActiveRecord::Schema.define(version: 2020_02_25_090129) do
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
t.string "landing_text" t.string "landing_text"
t.integer "show_count", default: 0 t.integer "show_count", default: 0
t.integer "footer_image_file_id"
t.integer "footer_image_width"
t.string "footer_image_link"
t.string "banner_image_link"
t.string "logo_image_link"
t.index ["p_customer_id"], name: "index_m_odrs_on_p_customer_id" t.index ["p_customer_id"], name: "index_m_odrs_on_p_customer_id"
end end