From 52543589e4e884e9a302aaf72ea327c1c9dd8ab3 Mon Sep 17 00:00:00 2001 From: Stella Date: Sun, 23 Feb 2014 14:56:09 +0200 Subject: [PATCH 1/3] voting visual changes --- app/assets/javascripts/osem.js | 5 ----- app/assets/stylesheets/osem.css | 2 +- app/controllers/admin/events_controller.rb | 12 +++++++--- app/views/admin/events/_proposal.html.haml | 12 +++++----- app/views/admin/events/_voting.html.haml | 26 ++++++++++++++++++++-- app/views/admin/events/index.html.haml | 6 ++--- app/views/admin/events/vote.js.erb | 2 +- 7 files changed, 44 insertions(+), 21 deletions(-) diff --git a/app/assets/javascripts/osem.js b/app/assets/javascripts/osem.js index dbae93ac..21dd66c8 100644 --- a/app/assets/javascripts/osem.js +++ b/app/assets/javascripts/osem.js @@ -60,11 +60,6 @@ $(function() { $(".comment-reply").hide(); $(".user-details-popover").popover(); $("#comments-div").hide(); - - $("#votes-link").click(function(){ - $("#votes-div").toggle(); - return false; - }); }); function word_count(text, divId, maxcount) { diff --git a/app/assets/stylesheets/osem.css b/app/assets/stylesheets/osem.css index 81531f5e..d4da287f 100644 --- a/app/assets/stylesheets/osem.css +++ b/app/assets/stylesheets/osem.css @@ -14,7 +14,7 @@ background: url(../assets/star.png) 0 0; width: 26px; height: 26px; - display: block; + display: inline-block; } .myrating, .othersrating { background: url(../assets/star.png) 0 0; diff --git a/app/controllers/admin/events_controller.rb b/app/controllers/admin/events_controller.rb index 5c486b50..9199128e 100644 --- a/app/controllers/admin/events_controller.rb +++ b/app/controllers/admin/events_controller.rb @@ -1,5 +1,6 @@ class Admin::EventsController < ApplicationController before_filter :verify_organizer + # FIXME: The timezome should only be applied on output, otherwise # you get lost in timezone conversions... # around_filter :set_timezone_for_this_request @@ -122,16 +123,21 @@ class Admin::EventsController < ApplicationController end def vote - event = Event.find(params[:id]) + @event = Event.find(params[:id]) + @ratings = @event.votes.includes(:person) if votes = current_user.person.votes.find_by_event_id(params[:id]) votes.update_attributes(:rating => params[:rating]) else - @myvote = event.votes.build + @myvote = @event.votes.build @myvote.person = current_user.person @myvote.rating = params[:rating] @myvote.save end - redirect_to admin_conference_event_path(@conference.short_title, event) + + respond_to do |format| + format.html { redirect_to admin_conference_event_path(@conference.short_title, @event)} + format.js + end end end diff --git a/app/views/admin/events/_proposal.html.haml b/app/views/admin/events/_proposal.html.haml index 1e931836..986450ba 100644 --- a/app/views/admin/events/_proposal.html.haml +++ b/app/views/admin/events/_proposal.html.haml @@ -13,7 +13,7 @@ .span12 %table.table %tr - %td + %td{:style => "width:20%"} %b Type %td .dropdown @@ -113,6 +113,10 @@ %td %b Description %td= simple_format(@event.description) + + - if @conference.call_for_papers.rating > 0 + = render :partial => "voting" + - if @event.event_attachments.size > 0 %table.table %thead @@ -142,11 +146,7 @@ %td = link_to "Delete", conference_proposal_event_attachment_path(@conference.short_title, @event.id, a.id), :method => :delete, :confirm => "Are you sure you want to delete this attachment? It's permanant!" -- if @conference.call_for_papers.rating > 0 - .row-fluid - = link_to "Votes (#{@event.voters.length})", "#", :id => "votes-link" - #votes-div - = render :partial => 'voting' + .row-fluid = link_to "Comments (#{@comment_count})", "#", :id => "event-comment-link" #comments-div diff --git a/app/views/admin/events/_voting.html.haml b/app/views/admin/events/_voting.html.haml index 11ed1eed..8353bbc4 100644 --- a/app/views/admin/events/_voting.html.haml +++ b/app/views/admin/events/_voting.html.haml @@ -1,7 +1,29 @@ -%table#myeventratings{:style=>"width: 20%"} +%table.table#myrating %tr + %td{:style => "width:20%"} + %b Rating %td - %b Your vote: + - if @event.average_rating.to_f > 0 + #{@event.average_rating}/#{@conference.call_for_papers.rating} + - else + Rating: (0/#{@conference.call_for_papers.rating}) + + - @conference.call_for_papers.rating.times do |counter| + - if @event.average_rating.to_f.round == counter+1 + = label_tag "label_rating", "", :class => "avgrating", :avgrate => true + = javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');" + - else + = label_tag "label_rating", "", :class => "avgrating" + %tr + %td + %b Voters + %td + = @event.voters.length + ( + = @ratings.map {|x| "#{x.first_name} #{x.last_name}"}.join ', ' + ) + %tr + %td Your vote %td - @conference.call_for_papers.rating.times do |counter| - voted = @event.voted?(@event, current_user.person) diff --git a/app/views/admin/events/index.html.haml b/app/views/admin/events/index.html.haml index e5fd2047..ae537b13 100644 --- a/app/views/admin/events/index.html.haml +++ b/app/views/admin/events/index.html.haml @@ -31,12 +31,12 @@ = event.id %td =link_to event.title, admin_conference_event_path(@conference.short_title, event) - %td + %td{:style => "width:96px"} - if @conference.call_for_papers.rating != 0 - if event.average_rating.to_f > 0 - Rating: (#{event.average_rating}/#{@conference.call_for_papers.rating}) + Rating: #{event.average_rating}/#{@conference.call_for_papers.rating} - else - Rating: (0/#{@conference.call_for_papers.rating}) + Rating: 0/#{@conference.call_for_papers.rating} %br - @conference.call_for_papers.rating.times do |counter| diff --git a/app/views/admin/events/vote.js.erb b/app/views/admin/events/vote.js.erb index 38ffd622..dc677901 100644 --- a/app/views/admin/events/vote.js.erb +++ b/app/views/admin/events/vote.js.erb @@ -1 +1 @@ -$('table#myeventratings').replaceWith("<%= escape_javascript(render :partial => 'voting') %>"); \ No newline at end of file +$('table#myrating').replaceWith("<%= escape_javascript(render :partial => 'voting') %>"); \ No newline at end of file From 0dbd513c8a887f0b44d4806b28eeaba720a67066 Mon Sep 17 00:00:00 2001 From: Stella Date: Sun, 23 Feb 2014 15:03:21 +0200 Subject: [PATCH 2/3] Add no of voters in events index --- app/views/admin/events/index.html.haml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/admin/events/index.html.haml b/app/views/admin/events/index.html.haml index ae537b13..cba87136 100644 --- a/app/views/admin/events/index.html.haml +++ b/app/views/admin/events/index.html.haml @@ -35,6 +35,8 @@ - if @conference.call_for_papers.rating != 0 - if event.average_rating.to_f > 0 Rating: #{event.average_rating}/#{@conference.call_for_papers.rating} + %br + Voters: #{event.voters.length} - else Rating: 0/#{@conference.call_for_papers.rating} %br From 68c119b4436ad183d6a994c7d5cc0338717f988f Mon Sep 17 00:00:00 2001 From: Stella Date: Sun, 2 Mar 2014 10:36:22 +0200 Subject: [PATCH 3/3] fixed table width, no td in index if no voting options --- app/views/admin/events/_proposal.html.haml | 9 +++---- app/views/admin/events/_voting.html.haml | 14 +++++----- app/views/admin/events/index.html.haml | 30 +++++++++++----------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/app/views/admin/events/_proposal.html.haml b/app/views/admin/events/_proposal.html.haml index 986450ba..35396a13 100644 --- a/app/views/admin/events/_proposal.html.haml +++ b/app/views/admin/events/_proposal.html.haml @@ -5,15 +5,14 @@ %br %span.muted = @event.subtitle - .span2 = link_to "Edit", edit_admin_conference_event_path(@conference.short_title, @event), :class => "btn btn-mini btn-primary" - + .row-fluid .span12 %table.table %tr - %td{:style => "width:20%"} + %td{:style => "width:15%"} %b Type %td .dropdown @@ -114,8 +113,8 @@ %b Description %td= simple_format(@event.description) - - if @conference.call_for_papers.rating > 0 - = render :partial => "voting" + - if @conference.call_for_papers.rating > 0 + = render :partial => "voting" - if @event.event_attachments.size > 0 %table.table diff --git a/app/views/admin/events/_voting.html.haml b/app/views/admin/events/_voting.html.haml index 8353bbc4..b7af6aaf 100644 --- a/app/views/admin/events/_voting.html.haml +++ b/app/views/admin/events/_voting.html.haml @@ -1,12 +1,12 @@ %table.table#myrating %tr - %td{:style => "width:20%"} + %td{:style => "width:15%"} %b Rating %td - if @event.average_rating.to_f > 0 #{@event.average_rating}/#{@conference.call_for_papers.rating} - else - Rating: (0/#{@conference.call_for_papers.rating}) + Rating: 0/#{@conference.call_for_papers.rating} - @conference.call_for_papers.rating.times do |counter| - if @event.average_rating.to_f.round == counter+1 @@ -19,11 +19,13 @@ %b Voters %td = @event.voters.length - ( - = @ratings.map {|x| "#{x.first_name} #{x.last_name}"}.join ', ' - ) + - if @event.voters.length > 0 + ( + = @ratings.map {|x| "#{x.first_name} #{x.last_name}"}.join ', ' + ) %tr - %td Your vote + %td + %b Your vote %td - @conference.call_for_papers.rating.times do |counter| - voted = @event.voted?(@event, current_user.person) diff --git a/app/views/admin/events/index.html.haml b/app/views/admin/events/index.html.haml index cba87136..33b2709d 100644 --- a/app/views/admin/events/index.html.haml +++ b/app/views/admin/events/index.html.haml @@ -13,8 +13,9 @@ %b ID %th %b Title - %th - %b Rating + - if @conference.call_for_papers.rating != 0 + %th + %b Rating %th %b Submitter %th @@ -31,25 +32,24 @@ = event.id %td =link_to event.title, admin_conference_event_path(@conference.short_title, event) - %td{:style => "width:96px"} - - if @conference.call_for_papers.rating != 0 + + - if @conference.call_for_papers.rating != 0 + %td{:style => "width:96px"} - if event.average_rating.to_f > 0 - Rating: #{event.average_rating}/#{@conference.call_for_papers.rating} + %b #{event.average_rating}/#{@conference.call_for_papers.rating} %br - Voters: #{event.voters.length} + #{pluralize(event.voters.length, 'voter')} + %br + - @conference.call_for_papers.rating.times do |counter| + - if event.average_rating.to_f.round == counter+1 + = label_tag "label_rating", "", :class => "avgrating", :avgrate => true + = javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');" + - else + = label_tag "label_rating", "", :class => "avgrating" - else Rating: 0/#{@conference.call_for_papers.rating} %br - - @conference.call_for_papers.rating.times do |counter| - - if event.average_rating.to_f.round == counter+1 - = label_tag "label_rating", "", :class => "avgrating", :avgrate => true - = javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');" - - else - = label_tag "label_rating", "", :class => "avgrating" - - else - = link_to "(enable voting)", admin_conference_cfp_info_path(@conference.short_title) - - if event.submitter.registrations.count < 1 - bgcolor="#F7819F" - else