From 70f30fcb1fe2754c1d9934541dc0f2cb25e4ce93 Mon Sep 17 00:00:00 2001 From: Ana Date: Sun, 12 Jun 2016 21:37:16 +0200 Subject: [PATCH] Dropdown with date tags in all events Dropdown with date tags in all events of the schedule --- app/assets/stylesheets/osem-schedule.css.scss | 18 +++++++++++++ app/models/program.rb | 11 ++++++++ app/views/conference/_all_events.html.erb | 26 +++++++++++++++++++ app/views/conference/schedule.html.erb | 20 ++++++++++++-- 4 files changed, 73 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/osem-schedule.css.scss b/app/assets/stylesheets/osem-schedule.css.scss index 587cde8d..206a0c70 100644 --- a/app/assets/stylesheets/osem-schedule.css.scss +++ b/app/assets/stylesheets/osem-schedule.css.scss @@ -184,6 +184,24 @@ td.no-padding{ display: inline-block; } +.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; +} + /* Small devices (tablets, 768px and up) */ @media (min-width: 768px) { .room, .event-title{ diff --git a/app/models/program.rb b/app/models/program.rb index be8f56a9..ffbb5ef0 100644 --- a/app/models/program.rb +++ b/app/models/program.rb @@ -91,6 +91,17 @@ class Program < ActiveRecord::Base self.languages.split(',').map {|l| ISO_639.find(l).english_name} if self.languages.present? end + ## + # Checks if there is any event in the program that starts in the given date + # + # ====Returns + # * +True+ -> If there is any event for the given date + # * +False+ -> If there is not any event for the given date + def any_event_for_this_date?(date) + parsed_date = DateTime.parse("#{date} 00:00").utc + events.where(start_time: parsed_date..(parsed_date + 1)).any? + end + private ## diff --git a/app/views/conference/_all_events.html.erb b/app/views/conference/_all_events.html.erb index 6d7ac5e1..59175100 100644 --- a/app/views/conference/_all_events.html.erb +++ b/app/views/conference/_all_events.html.erb @@ -1,4 +1,24 @@

Program for <%= @conference.title %>

+ +
@@ -46,3 +66,9 @@
<% end %> + +<%= javascript_tag do %> +$('.program-selector').on('click', function(e) { + $('.li-dropdown-program').removeClass('active'); +}); +<% end %> diff --git a/app/views/conference/schedule.html.erb b/app/views/conference/schedule.html.erb index f39b0cc2..14079862 100644 --- a/app/views/conference/schedule.html.erb +++ b/app/views/conference/schedule.html.erb @@ -3,10 +3,10 @@
@@ -25,3 +25,19 @@ <%= render 'all_events' %> <% end %>
+ +<%= javascript_tag do %> +// We set the program tab to active if the url tag starts by 'program-' +$( document ).ready(function() { + if(window.location.hash.substring(1).startsWith('program-')){ + schedule = $('.schedule'); + schedule.removeClass('active'); + schedule.find('a').attr("aria-expanded", "false"); + $('#schedule').removeClass('active'); + program = $('.program'); + program.addClass('active'); + program.find('a').attr("aria-expanded", "true"); + $('#program').addClass('active'); + } +}); +<% end %>