Merge efdb2cd63b into 4b6895f31d
This commit is contained in:
commit
e06a47820c
16 changed files with 118 additions and 25 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
|
// ADMIN SCHEDULE
|
||||||
|
|
||||||
var url; // Should be initialize in Schedule.initialize
|
var url; // Should be initialize in Schedule.initialize
|
||||||
var schedule_id; // Should be initialize in Schedule.initialize
|
var schedule_id; // Should be initialize in Schedule.initialize
|
||||||
|
|
||||||
|
|
@ -114,6 +116,31 @@ $(document).ready( function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// PUBLIC SCHEDULE
|
||||||
|
|
||||||
|
function starClicked(e){
|
||||||
|
// stops the click from propagating
|
||||||
|
if (!e) var e = window.event;
|
||||||
|
e.preventDefault();
|
||||||
|
e.cancelBubble = true;
|
||||||
|
if (e.stopPropagation) e.stopPropagation();
|
||||||
|
|
||||||
|
var callback = function(data) {
|
||||||
|
$(e.target).toggleClass('fa-star fa-star-o');
|
||||||
|
}
|
||||||
|
|
||||||
|
var params = { favourite_user_id: $(e.target).data('user') };
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: $(e.target).data('url'),
|
||||||
|
type: 'PATCH',
|
||||||
|
data: params,
|
||||||
|
success: callback,
|
||||||
|
dataType : 'json'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function eventClicked(e, element){
|
function eventClicked(e, element){
|
||||||
var url = $(element).data('url');
|
var url = $(element).data('url');
|
||||||
if(e.ctrlKey)
|
if(e.ctrlKey)
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ a.unstyled-link {
|
||||||
.program-dropdown, .schedule-dropdown{
|
.program-dropdown, .schedule-dropdown{
|
||||||
margin-left: 20%;
|
margin-left: 20%;
|
||||||
margin-right: 20%;
|
margin-right: 20%;
|
||||||
margin-top: 40px;
|
margin-top: 10px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -221,20 +221,6 @@ td.no-padding{
|
||||||
cursor: pointer;
|
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{
|
.no-events-day{
|
||||||
color: #D8D8D8 !important;
|
color: #D8D8D8 !important;
|
||||||
}
|
}
|
||||||
|
|
@ -254,6 +240,15 @@ td.no-padding{
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#star{
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#star-events{
|
||||||
|
margin-right: 5px;
|
||||||
|
vertical-align: text-top;
|
||||||
|
}
|
||||||
|
|
||||||
/* Small devices (tablets, 768px and up) */
|
/* Small devices (tablets, 768px and up) */
|
||||||
@media (min-width: 768px) {
|
@media (min-width: 768px) {
|
||||||
.room, .event-title{
|
.room, .event-title{
|
||||||
|
|
|
||||||
|
|
@ -81,11 +81,22 @@ class ProposalsController < ApplicationController
|
||||||
redirect_to conference_program_proposals_path(conference_id: @conference.short_title),
|
redirect_to conference_program_proposals_path(conference_id: @conference.short_title),
|
||||||
notice: 'Proposal was successfully updated.'
|
notice: 'Proposal was successfully updated.'
|
||||||
else
|
else
|
||||||
flash.now[:error] = "Could not update proposal: #{@event.errors.full_messages.join(', ')}"
|
flash[:error] = "Could not update proposal: #{@event.errors.full_messages.join(', ')}"
|
||||||
render action: 'edit'
|
render action: 'edit'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def toggle_favorite
|
||||||
|
user = User.find(params[:favourite_user_id])
|
||||||
|
users = @event.favourite_users
|
||||||
|
if users.include? user
|
||||||
|
@event.favourite_users.delete(user)
|
||||||
|
else
|
||||||
|
@event.favourite_users << user
|
||||||
|
end
|
||||||
|
render json: {}
|
||||||
|
end
|
||||||
|
|
||||||
def withdraw
|
def withdraw
|
||||||
authorize! :update, @event
|
authorize! :update, @event
|
||||||
@url = conference_program_proposal_path(@conference.short_title, params[:id])
|
@url = conference_program_proposal_path(@conference.short_title, params[:id])
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
class SchedulesController < ApplicationController
|
class SchedulesController < ApplicationController
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
before_action :respond_to_options
|
before_action :respond_to_options
|
||||||
|
before_action :favourites
|
||||||
load_resource :conference, find_by: :short_title
|
load_resource :conference, find_by: :short_title
|
||||||
load_resource :program, through: :conference, singleton: true, except: :index
|
load_resource :program, through: :conference, singleton: true, except: :index
|
||||||
before_action :load_withdrawn_event_schedules, only: [:show, :events]
|
before_action :load_withdrawn_event_schedules, only: [:show, :events]
|
||||||
|
|
@ -58,9 +59,17 @@ class SchedulesController < ApplicationController
|
||||||
@events_schedules = @program.selected_event_schedules(
|
@events_schedules = @program.selected_event_schedules(
|
||||||
includes: [:room, { event: %i[track event_type speakers submitter] }]
|
includes: [:room, { event: %i[track event_type speakers submitter] }]
|
||||||
)
|
)
|
||||||
@events_schedules = [] unless @events_schedules
|
|
||||||
|
|
||||||
@unscheduled_events = @program.events.confirmed - @events_schedules.map(&:event)
|
@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 - @events_schedules.map(&:event)
|
||||||
|
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
|
day = @conference.current_conference_day
|
||||||
@tag = day.strftime('%Y-%m-%d') if day
|
@tag = day.strftime('%Y-%m-%d') if day
|
||||||
|
|
@ -72,6 +81,10 @@ class SchedulesController < ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def favourites
|
||||||
|
@favourites = params[:favourites] == 'true'
|
||||||
|
end
|
||||||
|
|
||||||
def respond_to_options
|
def respond_to_options
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { head :ok }
|
format.html { head :ok }
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,10 @@ class Ability
|
||||||
event.users.include?(user)
|
event.users.include?(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
can :toggle_favorite, Event do |event|
|
||||||
|
event.scheduled?
|
||||||
|
end
|
||||||
|
|
||||||
# can manage the commercials of their own events
|
# can manage the commercials of their own events
|
||||||
can :manage, Commercial, commercialable_type: 'Event', commercialable_id: user.events.pluck(:id)
|
can :manage, Commercial, commercialable_type: 'Event', commercialable_id: user.events.pluck(:id)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,12 @@ class Event < ApplicationRecord
|
||||||
belongs_to :difficulty_level
|
belongs_to :difficulty_level
|
||||||
belongs_to :program
|
belongs_to :program
|
||||||
|
|
||||||
|
has_and_belongs_to_many :favourite_users, class_name: 'User'
|
||||||
|
|
||||||
accepts_nested_attributes_for :event_users, allow_destroy: true
|
accepts_nested_attributes_for :event_users, allow_destroy: true
|
||||||
accepts_nested_attributes_for :speakers, allow_destroy: true
|
accepts_nested_attributes_for :speakers, allow_destroy: true
|
||||||
accepts_nested_attributes_for :users
|
accepts_nested_attributes_for :users
|
||||||
|
accepts_nested_attributes_for :favourite_users
|
||||||
|
|
||||||
before_create :generate_guid
|
before_create :generate_guid
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,8 @@ class User < ApplicationRecord
|
||||||
has_many :booths, through: :booth_requests
|
has_many :booths, through: :booth_requests
|
||||||
has_many :survey_replies
|
has_many :survey_replies
|
||||||
has_many :survey_submissions
|
has_many :survey_submissions
|
||||||
|
has_and_belongs_to_many :favourite_events, class_name: 'Event'
|
||||||
|
|
||||||
accepts_nested_attributes_for :roles
|
accepts_nested_attributes_for :roles
|
||||||
|
|
||||||
scope :admin, -> { where(is_admin: true) }
|
scope :admin, -> { where(is_admin: true) }
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,10 @@
|
||||||
%td.room{ style: "height: #{ td_height(@rooms) }px;" }
|
%td.room{ style: "height: #{ td_height(@rooms) }px;" }
|
||||||
.room.elipsis.break-words{ style: "-webkit-line-clamp: #{ room_lines(@rooms) }; height: #{ room_height(@rooms) }px;" }
|
.room.elipsis.break-words{ style: "-webkit-line-clamp: #{ room_lines(@rooms) }; height: #{ room_height(@rooms) }px;" }
|
||||||
= room.name
|
= room.name
|
||||||
|
|
||||||
- event_schedules = (@event_schedules_by_room_id[room.id] || []).select{ |e| (e.end_time > start_time) && (e.start_time <= (start_time + hrs_per_slide.hour)) }
|
- event_schedules = (@event_schedules_by_room_id[room.id] || []).select{ |e| (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
|
||||||
|
|
||||||
- interval_count.times do |offset|
|
- interval_count.times do |offset|
|
||||||
- if span > 1
|
- if span > 1
|
||||||
- span -= 1
|
- span -= 1
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,15 @@
|
||||||
= image_tag speaker.gravatar_url, :class => "img-circle pull-right all-speaker-pic", |
|
= image_tag speaker.gravatar_url, :class => "img-circle pull-right all-speaker-pic", |
|
||||||
:alt => speaker.name, |
|
:alt => speaker.name, |
|
||||||
:title => speaker.name |
|
:title => speaker.name |
|
||||||
|
|
||||||
%p
|
%p
|
||||||
= canceled_replacement_event_label(event, event_schedule)
|
= canceled_replacement_event_label(event, event_schedule)
|
||||||
= replacement_event_notice(event_schedule)
|
= replacement_event_notice(event_schedule)
|
||||||
|
- if current_user
|
||||||
|
= link_to('#', onClick: 'starClicked();') do
|
||||||
|
%span#star-events{ class: "fa fa-lg #{ event.favourite_users.exists?(current_user.id) ? 'fa-star' : 'fa-star-o' }", |
|
||||||
|
"aria-hidden" => "true", |
|
||||||
|
"data-url" => toggle_favorite_conference_program_proposal_path(@conference.short_title, event.id), |
|
||||||
|
"data-user" => current_user.id }
|
||||||
%span.h3
|
%span.h3
|
||||||
= event.title
|
= event.title
|
||||||
%br
|
%br
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,18 @@
|
||||||
%td.event{ width: "#{ width * span }%" , |
|
%td.event{ width: "#{ width * span }%" , |
|
||||||
colspan: span, |
|
colspan: span, |
|
||||||
role: "button" }
|
role: "button" }
|
||||||
%a.unstyled-link{href: url_for(conference_program_proposal_path(@conference.short_title, event.id))}
|
%div{ onClick: 'eventClicked(event, this);', "data-url" => "#{url_for(conference_program_proposal_path(@conference.short_title, event.id))}" }
|
||||||
%div{ class: "elipsis break-words event-title", |
|
%div{ class: "elipsis break-words event-title", |
|
||||||
style: "-webkit-line-clamp: #{ event_lines(@rooms) }; height: #{ event_height(@rooms) }px;"} |
|
style: "-webkit-line-clamp: #{ event_lines(@rooms) }; height: #{ event_height(@rooms) }px;"} |
|
||||||
|
|
||||||
= canceled_replacement_event_label(event, event_schedule, 'schedule-label')
|
= 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" => toggle_favorite_conference_program_proposal_path(@conference.short_title, event.id), |
|
||||||
|
"data-user" => current_user.id }
|
||||||
= event.title
|
= event.title
|
||||||
|
|
||||||
- event.speakers_ordered.each do |speaker|
|
- event.speakers_ordered.each do |speaker|
|
||||||
|
|
@ -14,4 +20,3 @@
|
||||||
:alt => speaker.name, |
|
:alt => speaker.name, |
|
||||||
:title => speaker.name, |
|
:title => speaker.name, |
|
||||||
:style => "height: #{ speaker_height(@rooms) }px; width: #{ speaker_width(@rooms) }px;"
|
:style => "height: #{ speaker_height(@rooms) }px; width: #{ speaker_width(@rooms) }px;"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,6 @@
|
||||||
/ Nav tabs
|
/ Nav tabs
|
||||||
%ul.nav.nav-tabs{ role: "tablist" }
|
%ul.nav.nav-tabs{ role: "tablist" }
|
||||||
%li{ class: "schedule #{ 'active' if active == 'schedule' }", role: "presentation" }
|
%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" }
|
%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))
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,13 @@
|
||||||
%h1.text-center
|
%h1.text-center
|
||||||
Program for
|
Program for
|
||||||
= @conference.title
|
= @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
|
.dropdown.program-dropdown
|
||||||
%button{ type: "button", class: "btn btn-default dropdown-toggle", 'data-toggle' => "dropdown" }
|
%button{ type: "button", class: "btn btn-default dropdown-toggle", 'data-toggle' => "dropdown" }
|
||||||
Dates
|
Dates
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,13 @@
|
||||||
%h1.text-center
|
%h1.text-center
|
||||||
Schedule for
|
Schedule for
|
||||||
= @conference.title
|
= @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
|
.dropdown.schedule-dropdown
|
||||||
%button{ type: "button", class: "btn btn-default dropdown-toggle", 'data-toggle' => "dropdown" }
|
%button{ type: "button", class: "btn btn-default dropdown-toggle", 'data-toggle' => "dropdown" }
|
||||||
= @day
|
= @day
|
||||||
|
|
|
||||||
|
|
@ -166,6 +166,7 @@ Osem::Application.routes.draw do
|
||||||
patch '/withdraw' => 'proposals#withdraw'
|
patch '/withdraw' => 'proposals#withdraw'
|
||||||
patch '/confirm' => 'proposals#confirm'
|
patch '/confirm' => 'proposals#confirm'
|
||||||
patch '/restart' => 'proposals#restart'
|
patch '/restart' => 'proposals#restart'
|
||||||
|
patch :toggle_favorite
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :tracks, except: :destroy do
|
resources :tracks, except: :destroy do
|
||||||
|
|
|
||||||
8
db/migrate/20160811143427_create_events_users.rb
Normal file
8
db/migrate/20160811143427_create_events_users.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
class CreateEventsUsers < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :events_users, id: false do |t|
|
||||||
|
t.references :event
|
||||||
|
t.references :user
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -263,6 +263,11 @@ ActiveRecord::Schema[7.0].define(version: 2024_11_21_114727) do
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "events_users", id: false, force: :cascade do |t|
|
||||||
|
t.integer "event_id"
|
||||||
|
t.integer "user_id"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "lodgings", force: :cascade do |t|
|
create_table "lodgings", force: :cascade do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.text "description"
|
t.text "description"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue