From 2055de87d8610b7350f214340c28d4097cd9d4ed Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Thu, 29 Mar 2018 17:31:32 +0200 Subject: [PATCH] suite --- app/assets/stylesheets/plume_print.css.scss | 12 +-- .../admin/plume_articles_controller.rb | 14 ++++ .../admin/plume_cats_controller.rb | 13 +++ .../admin/plume_events_controller.rb | 13 +++ app/models/plume.rb | 10 ++- .../admin/plume_articles/_form.html.haml | 3 + .../plume_articles/_index_block.html.haml | 27 ++++++- .../plume_articles/_plume_article.html.haml | 25 ++++-- .../admin/plume_cats/_index_block.html.haml | 25 ++++++ .../admin/plume_cats/_plume_cat.html.haml | 6 +- app/views/admin/plume_events/_form.html.haml | 3 +- .../admin/plume_events/_index_block.html.haml | 26 +++++- .../admin/plume_events/_plume_event.html.haml | 21 +++-- app/views/admin/plumes/edit.html.haml | 2 +- app/views/public/plumes/print.html.haml | 81 +++++++++++++------ config/routes.rb | 12 ++- ...329134946_add_breakpage_to_plume_events.rb | 6 ++ ...9135016_add_breakpage_to_plume_articles.rb | 5 ++ db/schema.rb | 5 +- 19 files changed, 255 insertions(+), 54 deletions(-) create mode 100644 db/migrate/20180329134946_add_breakpage_to_plume_events.rb create mode 100644 db/migrate/20180329135016_add_breakpage_to_plume_articles.rb diff --git a/app/assets/stylesheets/plume_print.css.scss b/app/assets/stylesheets/plume_print.css.scss index 784159d..3fd1c61 100644 --- a/app/assets/stylesheets/plume_print.css.scss +++ b/app/assets/stylesheets/plume_print.css.scss @@ -65,8 +65,8 @@ text-decoration:none; } .agenda{ background:$beige; - margin:20px -20px; - margin-top:50px; + margin:15px -20px; + margin-top:25px; padding:1px 20px; font-size:1em; page-break-inside: avoid; @@ -295,7 +295,8 @@ html{ .plume_event{ border-bottom:1px dashed $marron; - padding: 10px 0; + padding: 3px 0; + padding-bottom:6px; h2{ color:$vert; @@ -307,7 +308,7 @@ html{ margin: 5px 0; } - margin-bottom:10px; + margin-bottom:3px; } @@ -325,7 +326,8 @@ html{ margin-bottom:10px; .render_block{ padding-bottom:20px; - padding-top:20px; + padding-top:0px; + } } diff --git a/app/controllers/admin/plume_articles_controller.rb b/app/controllers/admin/plume_articles_controller.rb index 72ed2a3..ea2c485 100644 --- a/app/controllers/admin/plume_articles_controller.rb +++ b/app/controllers/admin/plume_articles_controller.rb @@ -10,6 +10,20 @@ class Admin::PlumeArticlesController < ApplicationController before_filter :find_plume_articles + + + def reorder + i = 0 + params[:order].each do |petition_id| + i += 1 + petition = PlumeArticle.find(petition_id) + petition.position = i + petition.save + end + render :inline => "ok" + + end + def index end diff --git a/app/controllers/admin/plume_cats_controller.rb b/app/controllers/admin/plume_cats_controller.rb index 3fb3d49..a2529cd 100644 --- a/app/controllers/admin/plume_cats_controller.rb +++ b/app/controllers/admin/plume_cats_controller.rb @@ -10,6 +10,19 @@ class Admin::PlumeCatsController < ApplicationController before_filter :find_plume_cats + + def reorder + i = 0 + params[:order].each do |petition_id| + i += 1 + petition = PlumeCat.find(petition_id) + petition.position = i + petition.save + end + render :inline => "ok" + + end + def index end diff --git a/app/controllers/admin/plume_events_controller.rb b/app/controllers/admin/plume_events_controller.rb index 3ddf34c..1a5a04d 100644 --- a/app/controllers/admin/plume_events_controller.rb +++ b/app/controllers/admin/plume_events_controller.rb @@ -9,6 +9,19 @@ class Admin::PlumeEventsController < ApplicationController before_filter :find_plume_events + def reorder + i = 0 + params[:order].each do |petition_id| + i += 1 + petition = PlumeEvent.find(petition_id) + petition.position = i + petition.save + end + render :inline => "ok" + + end + + def index end diff --git a/app/models/plume.rb b/app/models/plume.rb index 8484d44..65f5c62 100644 --- a/app/models/plume.rb +++ b/app/models/plume.rb @@ -35,7 +35,15 @@ class Plume < ActiveRecord::Base return cat.plume_articles.first else - return nil + if self.id = 3 + if a = self.plume_articles.where(:id => 25).first + a + else + return nil + end + else + return nil + end end end diff --git a/app/views/admin/plume_articles/_form.html.haml b/app/views/admin/plume_articles/_form.html.haml index eff2f6f..bd489b7 100644 --- a/app/views/admin/plume_articles/_form.html.haml +++ b/app/views/admin/plume_articles/_form.html.haml @@ -1,12 +1,15 @@ = semantic_form_for [:admin,@plume_article], :remote => true do |form| .content = form.inputs do + = form.input :breakpage, :label => "Saut de page ?" = form.input :plume_cat_id, :label => "Catégorie", :collection => @plume_article.plume_cat.plume.plume_cats.order(:position).all, :as => :select, :include_blank => false = form.input :article_type, :label => "Type d'article :", :collection => [["Article pleine page", "page"],["Demi article", "demi"] ], :as => :select, :include_blank => false = form.input :title, :label => "Titre :" = form.input :description, :label => "Description courte :" = form.input :author, :label => "Auteur :" = form.input :image_file_id, :as => :qi_image_select + + diff --git a/app/views/admin/plume_articles/_index_block.html.haml b/app/views/admin/plume_articles/_index_block.html.haml index 877dbf4..4300cff 100644 --- a/app/views/admin/plume_articles/_index_block.html.haml +++ b/app/views/admin/plume_articles/_index_block.html.haml @@ -1,5 +1,30 @@ %table#plume_articles.table - =render @plume_cat.plume_articles + =render @plume_cat.plume_articles.order(:position) + + +:coffeescript + + $('#plume_articles').sortable({ + itemSelector:"tr", + containerSelector :"table", + handle : ".handle", + onDrop: (item, Container, _super) -> + _super(item) + result = [] + + $("#plume_articles").find("tr").each -> + result.push $(this).data("id") + + $.ajax({ + url:"/admin/plume_articles/reorder.js", + type: "POST", + data: { + order : result + } + + }) + }); + \ No newline at end of file diff --git a/app/views/admin/plume_articles/_plume_article.html.haml b/app/views/admin/plume_articles/_plume_article.html.haml index 8d8a02d..5bcad48 100644 --- a/app/views/admin/plume_articles/_plume_article.html.haml +++ b/app/views/admin/plume_articles/_plume_article.html.haml @@ -1,15 +1,21 @@ -%tr#plume_article_row.plume_article_row{:id => plume_article.id} +%tr#plume_article_row.plume_article_row{:id => plume_article.id, :data => {:id => plume_article.id}} - %td=plume_article.title %td - -if plume_article.article_type == "demi" - Demi article + -if plume_article.breakpage + Saut de page -else - Article pleine page + =plume_article.title + %td + -if !plume_article.breakpage + -if plume_article.article_type == "demi" + Demi article + -else + Article pleine page %td - =link_to "voir", public_plume_article_path(plume_article), :target => "plume_article_#{plume_article.id}" + -if !plume_article.breakpage + =link_to "voir", public_plume_article_path(plume_article), :target => "plume_article_#{plume_article.id}" @@ -20,5 +26,8 @@ = link_to i(:"trash-o"), [:admin, plume_article], :confirm => 'Voulez-vous vraiment supprimer cet plume_article ?', :method => :delete, :remote => true = link_to i(:pencil), edit_admin_plume_article_path(plume_article), :style => "padding:0px 0px 0px 0px;", :remote => true - = link_to i(:eye), edit_admin_plume_article_path(plume_article), :style => "padding:0px 0px 0px 0px;" - \ No newline at end of file + -if !plume_article.breakpage + = link_to i(:eye), edit_admin_plume_article_path(plume_article), :style => "padding:0px 0px 0px 0px;" + + %span.handle + =i(:arrows) \ No newline at end of file diff --git a/app/views/admin/plume_cats/_index_block.html.haml b/app/views/admin/plume_cats/_index_block.html.haml index 572572c..e2824a8 100644 --- a/app/views/admin/plume_cats/_index_block.html.haml +++ b/app/views/admin/plume_cats/_index_block.html.haml @@ -2,4 +2,29 @@ %table#plume_cats.table =render @plume.plume_cats.order(:position) + + +:coffeescript + + $('#plume_cats').sortable({ + itemSelector:"tr", + containerSelector :"table", + handle : ".handle", + onDrop: (item, Container, _super) -> + _super(item) + result = [] + + $("#plume_cats").find("tr").each -> + result.push $(this).data("id") + + $.ajax({ + url:"/admin/plume_cats/reorder.js", + type: "POST", + data: { + order : result + } + + }) + }); + \ No newline at end of file diff --git a/app/views/admin/plume_cats/_plume_cat.html.haml b/app/views/admin/plume_cats/_plume_cat.html.haml index a049a56..678f894 100644 --- a/app/views/admin/plume_cats/_plume_cat.html.haml +++ b/app/views/admin/plume_cats/_plume_cat.html.haml @@ -1,4 +1,4 @@ -%tr#plume_cat_row.plume_cat_row{:id => plume_cat.id} +%tr#plume_cat_row.plume_cat_row{:id => plume_cat.id, :data => {:id => plume_cat.id}} %td =plume_cat.title @@ -14,4 +14,6 @@ = link_to i(:pencil), edit_admin_plume_cat_path(plume_cat), :style => "padding:0px 0px 0px 0px;", :remote => true = link_to i(:eye), edit_admin_plume_cat_path(plume_cat), :style => "padding:0px 0px 0px 0px;" - \ No newline at end of file + + %span.handle + =i(:arrows) \ No newline at end of file diff --git a/app/views/admin/plume_events/_form.html.haml b/app/views/admin/plume_events/_form.html.haml index e7c9c89..bfb4994 100644 --- a/app/views/admin/plume_events/_form.html.haml +++ b/app/views/admin/plume_events/_form.html.haml @@ -1,7 +1,8 @@ = semantic_form_for [:admin,@plume_event], :remote => true do |form| .content = form.inputs do - =form.input :plume_id, :collection => Plume.all, :label => "Plume :", :as => :select + = form.input :breakpage, :label => "Saut de page ?" + = form.input :plume_id, :collection => Plume.all, :label => "Plume :", :as => :select = form.input :title, :label => "Titre :" = form.hidden_field :plume_event_id diff --git a/app/views/admin/plume_events/_index_block.html.haml b/app/views/admin/plume_events/_index_block.html.haml index abe63ce..5030999 100644 --- a/app/views/admin/plume_events/_index_block.html.haml +++ b/app/views/admin/plume_events/_index_block.html.haml @@ -1,3 +1,27 @@ %table#plume_events.table.table-hover =render @plume_events - \ No newline at end of file + + +:coffeescript + + $('#plume_events').sortable({ + itemSelector:"tr", + containerSelector :"table", + handle : ".handle", + onDrop: (item, Container, _super) -> + _super(item) + result = [] + + $("#plume_events").find("tr").each -> + result.push $(this).data("id") + + $.ajax({ + url:"/admin/plume_events/reorder.js", + type: "POST", + data: { + order : result + } + + }) + }); + \ No newline at end of file diff --git a/app/views/admin/plume_events/_plume_event.html.haml b/app/views/admin/plume_events/_plume_event.html.haml index 3456e8c..ffb0d83 100644 --- a/app/views/admin/plume_events/_plume_event.html.haml +++ b/app/views/admin/plume_events/_plume_event.html.haml @@ -1,10 +1,17 @@ -%tr#plume_event_row.plume_event_row{:id => plume_event.id} +%tr#plume_event_row.plume_event_row{:id => plume_event.id, :data => {:id => plume_event.id}} - %td{:style => "width:400px"}=raw event_human_date(plume_event) - %td=plume_event.title + %td{:style => "width:400px"} + -if plume_event.breakpage + Saut de page + -else + =raw event_human_date(plume_event) + + %td=plume_event.title if !plume_event.breakpage - %td.actions{:style => "width:200px;text-align:right;"} - = link_to i(:"trash-o"), [:admin, plume_event], :confirm => 'Voulez-vous vraiment supprimer cet événement ?', :method => :delete, :remote => true - = link_to i(:pencil), edit_admin_plume_event_path(plume_event), :remote => true - \ No newline at end of file + %td.actions{:style => "width:200px;text-align:right;"} + = link_to i(:"trash-o"), [:admin, plume_event], :confirm => 'Voulez-vous vraiment supprimer cet événement ?', :method => :delete, :remote => true + = link_to i(:pencil), edit_admin_plume_event_path(plume_event), :remote => true + %span.handle + =i(:arrows) + \ No newline at end of file diff --git a/app/views/admin/plumes/edit.html.haml b/app/views/admin/plumes/edit.html.haml index b1a5ef8..94f0084 100644 --- a/app/views/admin/plumes/edit.html.haml +++ b/app/views/admin/plumes/edit.html.haml @@ -21,7 +21,7 @@ .qi_row .qi_pannel.qi_plain.padding - -@plume_events = @plume.plume_events.order('start_at, stop_at') + -@plume_events = @plume.plume_events.order('position') .right= link_to 'Ajouter un événement', new_admin_plume_event_path(:plume_id => @plume.id), :class => "btn btn-primary", :remote => true %h3 Agenda diff --git a/app/views/public/plumes/print.html.haml b/app/views/public/plumes/print.html.haml index 0348159..c8b81ca 100644 --- a/app/views/public/plumes/print.html.haml +++ b/app/views/public/plumes/print.html.haml @@ -7,7 +7,7 @@ =# wicked_pdf_javascript_include_tag "number_pages" = wicked_pdf_stylesheet_link_tag 'plume_print' - %body{:onload => "number_pages"} + %body{:onload => "number_pages", :style => "text-align:justify;"} .page #plume_header =image_tag "http://lepicvert.org/plume-logo.png", :class => "plume_logo" @@ -18,7 +18,7 @@ .hr - #plume_sub_header + #plume_sub_header{:style => "text-align:left;"} -id = [] -id << @plume.v_une_1.id if @plume.v_une_1 @@ -28,12 +28,13 @@ - -@plume.plume_articles.where(:id => id).each do |article| + -id.each do |id_i| + -article = @plume.plume_articles.where(:id => id_i).first .p_column - + -if article.plume_cat - .plume_cat= article.plume_cat.title - %h2=article.title + .plume_cat{:style => "font-size:18px"}= article.plume_cat.title + %h2{:style => "font-size:17px"}=article.title #couv{:style => "background-image:url('http://lepicvert.org/#{(@plume.image_file.file.url if @plume.image_file)}');"} @@ -107,11 +108,28 @@ .page_inner -@breve_cat.plume_articles.each do |plume_article| - .plume_breve - %h2=plume_article.title + -if plume_article.breakpage + =raw "
" + .page_header{:style => ""} + .right + =image_tag "http://lepicvert.org/plume-header.png" + %span + La Plume + ="N°#{@plume.number}" + .left Brèves + .clear + + =raw "
" + -else + .plume_breve + %h2=plume_article.title - .render_block - =render plume_article.block + .render_block + =render plume_article.block + + -if plume_article.author? + .author + =plume_article.author =image_tag "http://lepicvert.org/adhesion.png", :style => "width:108%;margin-top:50px;margin-left:-4%;max-width:10000%;" @@ -126,21 +144,38 @@ .clear .page_inner -@plume.plume_events.each do |plume_event| - .plume_event - %h2=plume_event.title - .date - =raw event_human_date(plume_event) - .desc - =plume_event.description + -if plume_event.breakpage + =raw "
" + .page_header{:style => ""} + .right + =image_tag "http://lepicvert.org/plume-header.png" + %span + La Plume + ="N°#{@plume.number}" + .left Agenda + .clear + + =raw "
" + -else + .plume_event + %h2=plume_event.title + .date + =raw event_human_date(plume_event) + .desc + =plume_event.description .agenda + %p - Sorties gratuites pour les adhérents et les moins de 18 ans, 3€ pour les personnes extérieures. Inscription obligatoire, sauf mention complémentaire. - %p - Renseignements et inscriptions au 04 76 91 34 33 au plus tard à 17h la veille de la sortie. - %p - Attention : ces dates peuvent être repoussées ou annulées en fonction des conditions météorologiques annoncées. Veillez à vous renseigner au préalable avant chaque activité. D’autres sorties et conférences dont les dates ne sont pas encore fixées peuvent vous être proposées sur www.lepicvert.org. - %p - N’hésitez pas à nous contacter et vous inscrire au 04 76 91 34 33, par mail à contact@lepicvert.asso.fr, ou en consultant notre site www.lepicvert.org + Sorties gratuites pour les adhérents et les moins de 18 ans, 3€ pour les personnes extérieures. Inscription obligatoire, sauf mention complémentaire au 04 76 91 34 33 ou à contact@lepicvert.asso.fr au plus tard à 17h la veille de la sortie. Plus d'infos : www.lepicvert.org + -if false + %p + Sorties gratuites pour les adhérents et les moins de 18 ans, 3€ pour les personnes extérieures. Inscription obligatoire, sauf mention complémentaire. + %p + Renseignements et inscriptions au 04 76 91 34 33 au plus tard à 17h la veille de la sortie. + %p + Attention : ces dates peuvent être repoussées ou annulées en fonction des conditions météorologiques annoncées. Veillez à vous renseigner au préalable avant chaque activité. D’autres sorties et conférences dont les dates ne sont pas encore fixées peuvent vous être proposées sur www.lepicvert.org. + %p + N’hésitez pas à nous contacter et vous inscrire au 04 76 91 34 33, par mail à contact@lepicvert.asso.fr, ou en consultant notre site www.lepicvert.org -if !@pdf diff --git a/config/routes.rb b/config/routes.rb index c5bd290..e9724e7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -94,18 +94,24 @@ Survey::Application.routes.draw do #admin namespace :admin do - resources :plume_events + resources :plume_events do + collection do + post :reorder + end + + + end resources :plume_articles do collection do - get :reorder + post :reorder end end resources :plume_cats do collection do - get :reorder + post :reorder end diff --git a/db/migrate/20180329134946_add_breakpage_to_plume_events.rb b/db/migrate/20180329134946_add_breakpage_to_plume_events.rb new file mode 100644 index 0000000..b7383b1 --- /dev/null +++ b/db/migrate/20180329134946_add_breakpage_to_plume_events.rb @@ -0,0 +1,6 @@ +class AddBreakpageToPlumeEvents < ActiveRecord::Migration + def change + add_column :plume_events, :breakpage, :boolean + add_column :plume_events, :position, :integer + end +end diff --git a/db/migrate/20180329135016_add_breakpage_to_plume_articles.rb b/db/migrate/20180329135016_add_breakpage_to_plume_articles.rb new file mode 100644 index 0000000..5e9c038 --- /dev/null +++ b/db/migrate/20180329135016_add_breakpage_to_plume_articles.rb @@ -0,0 +1,5 @@ +class AddBreakpageToPlumeArticles < ActiveRecord::Migration + def change + add_column :plume_articles, :breakpage, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index 530474e..807f892 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180322155011) do +ActiveRecord::Schema.define(version: 20180329135016) do create_table "admins", force: true do |t| t.string "email", default: "", null: false @@ -681,6 +681,7 @@ ActiveRecord::Schema.define(version: 20180322155011) do t.datetime "created_at" t.datetime "updated_at" t.string "author" + t.boolean "breakpage" end add_index "plume_articles", ["plume_cat_id"], name: "index_plume_articles_on_plume_cat_id", using: :btree @@ -705,6 +706,8 @@ ActiveRecord::Schema.define(version: 20180322155011) do t.boolean "many_days" t.datetime "created_at" t.datetime "updated_at" + t.boolean "breakpage" + t.integer "position" end add_index "plume_events", ["plume_id"], name: "index_plume_events_on_plume_id", using: :btree