diff --git a/app/assets/javascripts/osem-schedule.js b/app/assets/javascripts/osem-schedule.js index 41136871..683735af 100644 --- a/app/assets/javascripts/osem-schedule.js +++ b/app/assets/javascripts/osem-schedule.js @@ -134,9 +134,6 @@ function starClicked(e){ } var params = { favourite_user_id: $(e.target).data('user') }; - if($(e.target).hasClass('fa-star-o')){ - params['add'] = true; - } $.ajax({ url: $(e.target).data('url'), diff --git a/app/assets/stylesheets/osem-schedule.css.scss b/app/assets/stylesheets/osem-schedule.css.scss index c5b872f1..3cab9cb7 100644 --- a/app/assets/stylesheets/osem-schedule.css.scss +++ b/app/assets/stylesheets/osem-schedule.css.scss @@ -127,7 +127,7 @@ a.unstyled-link { .program-dropdown, .schedule-dropdown{ margin-left: 20%; margin-right: 20%; - margin-top: 40px; + margin-top: 10px; margin-bottom: 20px; } @@ -234,20 +234,6 @@ td.no-padding{ cursor: pointer; } -.program-dropdown{ - margin-left: 20%; - margin-right: 20%; - margin-top: 40px; -} - -.program-dropdown > button{ - width: 100%; -} - -.program-dropdown > .dropdown-menu{ - width: 100%; -} - .no-events-day{ color: #D8D8D8 !important; } @@ -263,10 +249,6 @@ td.no-padding{ font-size: 7px; } -#star{ - margin-top: 8px; -} - #star-events{ margin-right: 5px; vertical-align: text-top; diff --git a/app/controllers/schedules_controller.rb b/app/controllers/schedules_controller.rb index 0b135328..8d6e37a1 100644 --- a/app/controllers/schedules_controller.rb +++ b/app/controllers/schedules_controller.rb @@ -1,6 +1,7 @@ class SchedulesController < ApplicationController protect_from_forgery with: :null_session before_action :respond_to_options + before_action :favourites load_and_authorize_resource :conference, find_by: :short_title load_resource :program, through: :conference, singleton: true, except: :index @@ -29,13 +30,16 @@ class SchedulesController < ApplicationController @dates = @conference.start_date..@conference.end_date @events_schedules = @program.selected_event_schedules + @events_schedules = @events_schedules.select{ |e| e.event.favourite_users.exists?(current_user.id) } if @events_schedules && current_user && @favourites @events_schedules = [] unless @events_schedules + @favourites = params[:favourites] == 'true' @unscheduled_events = if @program.selected_schedule @program.events.confirmed - @program.selected_schedule.events else @program.events.confirmed end + @unscheduled_events = @unscheduled_events.select{ |e| e.favourite_users.exists?(current_user.id) } if current_user && @favourites day = @conference.current_conference_day @tag = day.strftime('%Y-%m-%d') if day @@ -43,6 +47,10 @@ class SchedulesController < ApplicationController private + def favourites + @favourites = params[:favourites] == 'true' + end + def respond_to_options respond_to do |format| format.html { head :ok } diff --git a/app/views/schedules/_carousel.html.haml b/app/views/schedules/_carousel.html.haml index 5c5acc29..0bbab166 100644 --- a/app/views/schedules/_carousel.html.haml +++ b/app/views/schedules/_carousel.html.haml @@ -30,6 +30,7 @@ .room.elipsis.break-words{ style: "-webkit-line-clamp: #{ room_lines(@rooms) }; height: #{ room_height(@rooms) }px;" } = room.name - event_schedules = room.event_schedules.select{ |e| (e.schedule_id == @conference.program.selected_schedule.id) && (e.end_time > start_time) && (e.start_time <= (start_time + hrs_per_slide.hour)) } + - event_schedules = event_schedules.select{ |e| e.event.favourite_users.exists?(current_user.id) } if current_user && @favourites - (1..intervals).each do |i| - if span > 1 - span -= 1 diff --git a/app/views/schedules/_schedule_item.html.haml b/app/views/schedules/_schedule_item.html.haml index 74aeb64c..027cfcc4 100644 --- a/app/views/schedules/_schedule_item.html.haml +++ b/app/views/schedules/_schedule_item.html.haml @@ -7,15 +7,14 @@ = canceled_replacement_event_label(event, event_schedule, 'schedule-label') + - if current_user + = link_to('#', onClick: 'starClicked();') do + %span#star{ class: "fa fa-lg #{ event.favourite_users.exists?(current_user.id) ? 'fa-star' : 'fa-star-o' }", | + "aria-hidden" =>"true", | + "data-url" => conference_program_proposal_path(@conference.short_title, event.id), | + "data-user" => current_user.id } = event.title - - if current_user - = link_to('#', onClick: 'starClicked();') do - %span#star{ class: "fa fa-lg #{ event.favourite_users.exists?(current_user.id) ? 'fa-star' : 'fa-star-o' }", | - "aria-hidden" =>"true", | - "data-url" => conference_program_proposal_path(@conference.short_title, event.id), | - "data-user" => current_user.id } - - if speaker = event.speakers.first = image_tag speaker.gravatar_url, :class => "img-circle pull-right speaker-pic", | :alt => speaker.name, | diff --git a/app/views/schedules/_schedule_tabs.html.haml b/app/views/schedules/_schedule_tabs.html.haml index 0317f8bc..30dd5ab7 100644 --- a/app/views/schedules/_schedule_tabs.html.haml +++ b/app/views/schedules/_schedule_tabs.html.haml @@ -2,6 +2,6 @@ / Nav tabs %ul.nav.nav-tabs{ role: "tablist" } %li{ class: "schedule #{ 'active' if active == 'schedule' }", role: "presentation" } - = link_to('Schedule', conference_schedule_path(@conference.short_title)) + = link_to('Schedule', conference_schedule_path(@conference.short_title, favourites: @favourites)) %li{ class: "program #{ 'active' if active == 'program' }", role: "presentation" } - = link_to('All events', events_conference_schedule_path(@conference.short_title)) + = link_to('All events', events_conference_schedule_path(@conference.short_title, favourites: @favourites)) diff --git a/app/views/schedules/events.html.haml b/app/views/schedules/events.html.haml index 8680d3c3..b63cb184 100644 --- a/app/views/schedules/events.html.haml +++ b/app/views/schedules/events.html.haml @@ -5,6 +5,13 @@ %h1.text-center Program for = @conference.title + - if current_user + .row + .col-md-12.text-center + = button_to (@favourites ? 'All events' : 'Only favourites events'), + events_conference_schedule_path(@conference.short_title), + params: { favourites: !@favourites }, + method: :get, class: 'btn btn-success' .dropdown.program-dropdown %button{ type: "button", class: "btn btn-default dropdown-toggle", 'data-toggle' => "dropdown" } Dates diff --git a/app/views/schedules/show.html.haml b/app/views/schedules/show.html.haml index bd0f9976..d73a9107 100644 --- a/app/views/schedules/show.html.haml +++ b/app/views/schedules/show.html.haml @@ -5,6 +5,13 @@ %h1.text-center Schedule for = @conference.title + - if current_user + .row + .col-md-12.text-center + = button_to (@favourites ? 'All events' : 'Only favourites events'), + conference_schedule_path(@conference.short_title), + params: { favourites: !@favourites }, + method: :get, class: 'btn btn-success' .dropdown.schedule-dropdown %button{ type: "button", class: "btn btn-default dropdown-toggle", 'data-toggle' => "dropdown" } = @day