From f5b030b52280be6d33e66ffb9bd979d98d33ebc9 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Tue, 25 Feb 2020 22:33:47 +0100 Subject: [PATCH] suite --- app/controllers/admin/m_odrs_controller.rb | 4 +- app/models/m_odr.rb | 11 +++ app/views/admin/m_odrs/_form.html.haml | 73 ++++++++++++------- app/views/admin/m_odrs/_m_odr.html.haml | 17 +++-- app/views/admin/m_odrs/edit.html.haml | 8 ++ app/views/admin/m_odrs/index.html.haml | 27 ++++--- app/views/admin/m_odrs/new.html.haml | 8 ++ app/views/public/m_odrs/show.html.haml | 9 ++- config/routes.rb | 2 +- .../20200225205920_add_footer_to_m_odrs.rb | 10 +++ db/schema.rb | 7 +- 11 files changed, 124 insertions(+), 52 deletions(-) create mode 100644 app/views/admin/m_odrs/edit.html.haml create mode 100644 app/views/admin/m_odrs/new.html.haml create mode 100644 db/migrate/20200225205920_add_footer_to_m_odrs.rb diff --git a/app/controllers/admin/m_odrs_controller.rb b/app/controllers/admin/m_odrs_controller.rb index a637c73..e07b513 100644 --- a/app/controllers/admin/m_odrs_controller.rb +++ b/app/controllers/admin/m_odrs_controller.rb @@ -34,7 +34,7 @@ class Admin::MOdrsController < ApplicationController @m_odr = MOdr.new(params.require(:m_odr).permit!) if @m_odr.save - + redirect_to admin_m_odrs_path else render action: "new" @@ -48,7 +48,7 @@ class Admin::MOdrsController < ApplicationController if @m_odr.update_attributes(params.require(:m_odr).permit!) - + redirect_to admin_m_odrs_path else render action: "edit" diff --git a/app/models/m_odr.rb b/app/models/m_odr.rb index 4104f11..14e680e 100644 --- a/app/models/m_odr.rb +++ b/app/models/m_odr.rb @@ -6,6 +6,17 @@ class MOdr < ApplicationRecord belongs_to :banner_image_file, :class_name => "ImageFile" belongs_to :logo_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 diff --git a/app/views/admin/m_odrs/_form.html.haml b/app/views/admin/m_odrs/_form.html.haml index 3eed63a..933a753 100644 --- a/app/views/admin/m_odrs/_form.html.haml +++ b/app/views/admin/m_odrs/_form.html.haml @@ -1,39 +1,60 @@ -=semantic_form_for [:admin, @m_odr], :remote => true do |f| +=semantic_form_for [:admin, @m_odr], :remote => false do |f| - .content - =f.inputs do - = f.input :p_customer, :label => "Client :" + .qi_row + .qi_pannel.qi_plain.padding + =f.inputs do + = f.input :p_customer, :label => "Client :" - = f.input :name, :label => "Nom de l'ODR :" - = f.input :slug, :label => "Permalien :" - = f.input :description, :label => "Description :" , :as => :text + = f.input :name, :label => "Nom de l'ODR :" + = f.input :slug, :label => "Permalien :" + = f.input :description, :label => "Description :" , :as => :text - = f.input :landing_text, :label => "Texte lancement :" + = f.input :landing_text, :label => "Texte lancement :" - = f.input :start_at, :label => "Date de début :" , :as => :date - = f.input :end_at, :label => "Date de fin :" , :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 ?" - - = f.input :email_needed, :label => "Récupération de l'email ?" - = f.input :tel_needed, :label => "Récupération du tel ?" + .row.qi_cancel_margins + .col-sm-4 + = f.input :start_at, :label => "Date de début :" , :as => :date + .col-sm-4 + = 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 + + .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 ?" + .col-sm-3 + = f.input :tel_needed, :label => "Récupération du tel ?" - = f.input :logo_image_file_id, :label => "Logo :" , :as => :qi_image_select - = f.input :logo_image_file_width, :label => "Largeur du logo (px):" + .row.qi_cancel_margins + .col-sm-3 + = 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_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_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 :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 :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} - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + .large_actions + .actions + =f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/m_odrs/_m_odr.html.haml b/app/views/admin/m_odrs/_m_odr.html.haml index 968430d..dc5c31f 100644 --- a/app/views/admin/m_odrs/_m_odr.html.haml +++ b/app/views/admin/m_odrs/_m_odr.html.haml @@ -1,18 +1,21 @@ %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 + =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.start_at %td= m_odr.end_at %td= m_odr.public_end - %td= m_odr.address_process - %td= m_odr.rib_process - %td= m_odr.description - %td= m_odr.email_needed - %td= m_odr.tel_needed - %td= m_odr.p_customer_id + %td= "oui" if m_odr.address_process + %td= "oui" if m_odr.rib_process + %td= "oui" if m_odr.email_needed + %td= "oui" if m_odr.tel_needed + %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(: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 diff --git a/app/views/admin/m_odrs/edit.html.haml b/app/views/admin/m_odrs/edit.html.haml new file mode 100644 index 0000000..c972322 --- /dev/null +++ b/app/views/admin/m_odrs/edit.html.haml @@ -0,0 +1,8 @@ +.qi_header + %h1 + ODR + %span + Créer une ODR + += render 'form' + diff --git a/app/views/admin/m_odrs/index.html.haml b/app/views/admin/m_odrs/index.html.haml index 094b588..24b5dc6 100644 --- a/app/views/admin/m_odrs/index.html.haml +++ b/app/views/admin/m_odrs/index.html.haml @@ -1,8 +1,7 @@ .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 - - %span + ODR @@ -10,17 +9,17 @@ .qi_pannel.qi_plain.padding %table.table %tr - %th name - %th slug - %th start_at - %th end_at - %th public_end - %th address_process - %th rib_process - %th description - %th email_needed - %th tel_needed - %th p_customer_id + %th Client + %th Nom + %th Lien + %th Date de début + %th Date de fin + %th Fin de réception + %th Adresse ? + %th Rib ? + %th Email ? + %th Tel ? + %th.actions diff --git a/app/views/admin/m_odrs/new.html.haml b/app/views/admin/m_odrs/new.html.haml new file mode 100644 index 0000000..c972322 --- /dev/null +++ b/app/views/admin/m_odrs/new.html.haml @@ -0,0 +1,8 @@ +.qi_header + %h1 + ODR + %span + Créer une ODR + += render 'form' + diff --git a/app/views/public/m_odrs/show.html.haml b/app/views/public/m_odrs/show.html.haml index ce7812d..2053177 100644 --- a/app/views/public/m_odrs/show.html.haml +++ b/app/views/public/m_odrs/show.html.haml @@ -69,4 +69,11 @@ -if false %p{:style => "font-weight:bold;font-size:2em;text-transform:uppercase;font-family:'Helvetica Neue', Helvetica, sans-serif;"} - jours avant l'ouverture \ No newline at end of file + 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;": "")) \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index d06a3eb..bf34177 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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" diff --git a/db/migrate/20200225205920_add_footer_to_m_odrs.rb b/db/migrate/20200225205920_add_footer_to_m_odrs.rb new file mode 100644 index 0000000..8ed7e80 --- /dev/null +++ b/db/migrate/20200225205920_add_footer_to_m_odrs.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index fadbbd3..48c3ae6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # 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| 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.string "landing_text" 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" end