Clean up rating partials
This commit is contained in:
parent
73c5c3c97a
commit
9e10678542
10 changed files with 131 additions and 92 deletions
12
app/views/admin/events/_datatable_row_rating.haml
Normal file
12
app/views/admin/events/_datatable_row_rating.haml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
- if show_votes
|
||||
%div{ data: { toggle: 'tooltip' }, title: rating_tooltip(event, max_rating) }<
|
||||
= rating_stars(event.average_rating, max_rating, avgrate: true)
|
||||
|
||||
.clearfix
|
||||
- if event.voted?(current_user)
|
||||
%span.label.label-success
|
||||
You voted:
|
||||
= rating_fraction(event.user_rating(current_user), max_rating)
|
||||
- else
|
||||
%span.label.label-danger
|
||||
Not rated
|
||||
|
|
@ -168,8 +168,14 @@
|
|||
%b Requirements
|
||||
%td= simple_format(@event.description)
|
||||
|
||||
- if @conference.program && @conference.program.rating && @conference.program.rating > 0
|
||||
= render partial: 'voting'
|
||||
- if @conference.program.rating_enabled?
|
||||
= render 'voting',
|
||||
event: @event,
|
||||
show_votes: @program.show_voting?,
|
||||
max_rating: @program.rating,
|
||||
voting_period: @program.voting_period?,
|
||||
votes: @votes,
|
||||
conference_id: @conference.short_title
|
||||
|
||||
.row
|
||||
= link_to "Comments (#{@comment_count})", '#', id: 'event-comment-link'
|
||||
|
|
|
|||
|
|
@ -1,70 +1,56 @@
|
|||
%table.table#myrating
|
||||
- if @program.show_voting?
|
||||
- if show_votes
|
||||
%tr
|
||||
%td.col-md-2
|
||||
%b Rating
|
||||
%td
|
||||
- if @event.average_rating.to_f > 0
|
||||
#{@event.average_rating}/#{@program.rating}
|
||||
- else
|
||||
Rating: 0/#{@program.rating}
|
||||
|
||||
- @program.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'
|
||||
#{event.average_rating}/#{max_rating}
|
||||
= rating_stars(event.average_rating, max_rating, avgrate: true )
|
||||
%tr
|
||||
%td
|
||||
%b Voters
|
||||
%td
|
||||
= @event.voters.length
|
||||
- if @event.voters.length > 0
|
||||
= votes.length
|
||||
- unless votes.blank?
|
||||
(
|
||||
= @ratings.map {|x| "#{x.name}"}.join ', '
|
||||
= votes.collect(&:name).to_sentence
|
||||
)
|
||||
%tr
|
||||
%td.col-md-2
|
||||
%b Your vote
|
||||
%td
|
||||
- if @program.voting_period?
|
||||
- @program.rating.times do |counter|
|
||||
- if @event.voted?(current_user) && @event.user_rating(current_user) == counter + 1
|
||||
= link_to '', vote_admin_conference_program_event_path(@conference.short_title, @event, rating: counter + 1), remote: true, id: "label#{counter + 1}", class: 'myrating', voted: true
|
||||
- if voting_period
|
||||
- max_rating.times do |counter|
|
||||
- if event.user_rating(current_user) > counter
|
||||
= link_to '',
|
||||
vote_admin_conference_program_event_path(conference_id,
|
||||
event, rating: counter + 1),
|
||||
remote: true,
|
||||
id: "label#{counter + 1}",
|
||||
class: 'rating myrating bright',
|
||||
voted: true
|
||||
- else
|
||||
= link_to '', vote_admin_conference_program_event_path(@conference.short_title, @event, rating: counter + 1), remote: true, id: "label#{counter + 1}", class: 'myrating'
|
||||
%br
|
||||
= link_to '',
|
||||
vote_admin_conference_program_event_path(conference_id,
|
||||
event, rating: counter + 1),
|
||||
remote: true,
|
||||
id: "label#{counter + 1}",
|
||||
class: 'rating myrating'
|
||||
- else
|
||||
- @conference.program.rating.times do |counter|
|
||||
- if @event.voted?(current_user) && @event.user_rating(current_user) == counter + 1
|
||||
= label_tag "label#{counter + 1}", '', class: 'othersrating', voted: true
|
||||
= javascript_tag "$('label[voted=true]').prevAll().andSelf().addClass('bright');"
|
||||
- else
|
||||
= label_tag "label#{counter + 1}", '', class: 'othersrating'
|
||||
(#{voting_open_or_close(@program)})
|
||||
= rating_stars(event.user_rating(current_user), max_rating, voted: true)
|
||||
= (Voting period is closed)
|
||||
|
||||
- if @program.show_voting?
|
||||
- if @ratings.length > 0
|
||||
- @ratings.each do |rate|
|
||||
- unless rate.user_id == current_user.id
|
||||
- if show_votes
|
||||
- unless votes.blank?
|
||||
- votes.each do |vote|
|
||||
- unless vote.user_id == current_user.id
|
||||
%tr
|
||||
%td
|
||||
= rate.name
|
||||
= vote.name
|
||||
%td
|
||||
- @conference.program.rating.times do |counter|
|
||||
= rating_stars(vote, max_rating )
|
||||
|
||||
- if @event.voted?(rate.user) && @event.user_rating(rate.user) == counter + 1
|
||||
= label_tag "label#{counter + 1}", "", class: 'othersrating', voted: true
|
||||
= javascript_tag "$('label[voted=true]').prevAll().andSelf().addClass('bright');"
|
||||
- else
|
||||
= label_tag "label#{counter + 1}", "", class: 'othersrating'
|
||||
:javascript
|
||||
$(function () {
|
||||
var checkedId = $("a[voted='true']").attr('id');
|
||||
$('a[id=' + checkedId + ']').prevAll().andSelf().addClass('bright');
|
||||
});
|
||||
|
||||
$(".myrating").hover(
|
||||
function() { // mouseover
|
||||
$(this).prevAll().andSelf().addClass('glow');
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
- if @program.show_voting?
|
||||
#{event.average_rating}/#{@program.rating}
|
||||
%br
|
||||
#{pluralize(event.voters.length, 'voter')}
|
||||
%br
|
||||
- @program.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'
|
||||
%br
|
||||
|
||||
- if event.voted?(current_user)
|
||||
%span.label.label-success
|
||||
Your rating: #{ event.user_rating(current_user) }
|
||||
- else
|
||||
%span.label.label-danger
|
||||
Not rated
|
||||
|
|
@ -106,8 +106,11 @@
|
|||
= link_to event.title, admin_conference_program_event_path(@conference.short_title, event)
|
||||
|
||||
- if @program.rating_enabled?
|
||||
%td.col-md-1{ 'data-order' => "#{event.average_rating}" }
|
||||
= render partial: 'voting_index', locals: { event: event }
|
||||
%td.col-md-1{ data: { order: event.average_rating } }
|
||||
= render 'datatable_row_rating',
|
||||
event: event,
|
||||
show_votes: @program.show_voting?,
|
||||
max_rating: @program.rating
|
||||
|
||||
- if event.submitter && event.submitter.registrations && event.submitter.registrations.count < 1
|
||||
- bgcolor = '#F7819F'
|
||||
|
|
|
|||
|
|
@ -1 +1,10 @@
|
|||
$('table#myrating').replaceWith("<%= escape_javascript(render :partial => 'voting') %>");
|
||||
$('table#myrating').replaceWith(
|
||||
"<%= escape_javascript(render 'voting', \
|
||||
event: @event, \
|
||||
show_votes: @program.show_voting?, \
|
||||
max_rating: @program.rating, \
|
||||
voting_period: @program.voting_period?, \
|
||||
votes: @votes, \
|
||||
conference_id: @conference.short_title \
|
||||
) %>"
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue