Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agenda and My Schedule #56

Merged
merged 42 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
32a8c9d
View WIP
LuigiR0jas Jul 22, 2024
f39ce51
Merge branch 'main' into 23-events-index-agenda
LuigiR0jas Jul 23, 2024
bc66d28
Date filters initial implementation
LuigiR0jas Jul 24, 2024
234c913
Merge branch 'main' into 23-events-index-agenda
LuigiR0jas Jul 26, 2024
52cda5a
Merge branch 'main' into 23-events-index-agenda
LuigiR0jas Jul 30, 2024
d6f56c5
Merge branch 'main' into 23-events-index-agenda
LuigiR0jas Jul 30, 2024
e419ca0
Merge branch 'main' into 23-events-index-agenda
LuigiR0jas Aug 5, 2024
1de9162
Rename events to sessions
LuigiR0jas Aug 5, 2024
1316cbb
Add event to schedule
LuigiR0jas Aug 5, 2024
e443067
Design adjustments
LuigiR0jas Aug 6, 2024
62ddc70
Fix missing translation
LuigiR0jas Aug 6, 2024
1ecfc98
Remove attendees from session
LuigiR0jas Aug 6, 2024
3cf9dd6
Merge branch 'main' into 23-events-index-agenda
LuigiR0jas Aug 7, 2024
4977ebe
Agenda date pills based on session dates
andresag4 Aug 7, 2024
3d85c43
Update user sign inspecs
andresag4 Aug 7, 2024
4239a02
Add schedule
LuigiR0jas Aug 7, 2024
97ce96d
Merge branch '23-events-index-agenda' of https://github.com/TelosLabs…
LuigiR0jas Aug 7, 2024
d415a8b
Merge branch 'main' into 23-events-index-agenda
LuigiR0jas Aug 7, 2024
93bce45
Refactor
LuigiR0jas Aug 7, 2024
f058a6a
Merge branch '23-events-index-agenda' of https://github.com/TelosLabs…
LuigiR0jas Aug 7, 2024
730f9db
Merge fixes and layout improvements
LuigiR0jas Aug 7, 2024
6e4c6d1
Update sessions and schedule views
LuigiR0jas Aug 9, 2024
0b1d8f6
Merge branch 'main' into 23-events-index-agenda
LuigiR0jas Aug 12, 2024
4657d41
Refactor sessions and schedule
LuigiR0jas Aug 13, 2024
de68420
Rename resource, add empty states
LuigiR0jas Aug 14, 2024
64ea7d3
Review changes
LuigiR0jas Aug 14, 2024
0f479c0
Merge branch 'main' into 23-events-index-agenda
LuigiR0jas Aug 14, 2024
c9939eb
Add small changes
LuigiR0jas Aug 14, 2024
cb22750
Add filters partial
LuigiR0jas Aug 14, 2024
c473a53
Fix filter params
LuigiR0jas Aug 14, 2024
04e270f
fix icon path
LuigiR0jas Aug 14, 2024
dd44037
Merge branch 'main' into 23-events-index-agenda
LuigiR0jas Aug 14, 2024
61d1705
Fix layout from merge changes
LuigiR0jas Aug 14, 2024
a95cf43
Standard fix
LuigiR0jas Aug 14, 2024
c732034
Update app/views/sessions/_card.html.erb
LuigiR0jas Aug 14, 2024
f2a0302
Update app/controllers/attendees_controller.rb
LuigiR0jas Aug 14, 2024
c7b0817
Update app/controllers/sessions_controller.rb
LuigiR0jas Aug 14, 2024
f8af06d
Merge branch 'main' into 23-events-index-agenda
LuigiR0jas Aug 15, 2024
0f1da15
Changes from review
LuigiR0jas Aug 15, 2024
6fae572
Remove unnecessary flash messages
LuigiR0jas Aug 15, 2024
c23e45b
Fix bottom padding
LuigiR0jas Aug 15, 2024
6e6c5b6
Improvements
Sergio-e Aug 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/assets/images/icons/bookmark-full.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/images/icons/bookmark-outline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/images/icons/bookmark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions app/assets/images/icons/calendar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions app/assets/images/icons/clock.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions app/assets/images/icons/filters.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/assets/images/icons/location-pin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions app/assets/images/icons/location.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/placeholder.png
LuigiR0jas marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion app/assets/stylesheets/application.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions app/assets/stylesheets/application.tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,14 @@ div.field_with_errors > input {
focus:bg-white focus:text-black focus:placeholder-gray
focus:border-white focus:ring-white mb-2
}

/* Hide scrollbar for Chrome, Safari and Opera */
.no-scrollbar::-webkit-scrollbar {
display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.no-scrollbar {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
5 changes: 4 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ class ApplicationController < ActionController::Base

default_form_builder ApplicationFormBuilder

helper_method :current_profile
helper_method :current_profile, :current_conference

private

def current_profile = current_user&.profile

# TODO: Must change after implementing multi-conference support
def current_conference = Conference.last
LuigiR0jas marked this conversation as resolved.
Show resolved Hide resolved
end
33 changes: 33 additions & 0 deletions app/controllers/schedules_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class SchedulesController < ApplicationController
def index
@sessions = Session.includes(:location, :speakers, :tags)
@sessions = @sessions.from_user(current_user)
LuigiR0jas marked this conversation as resolved.
Show resolved Hide resolved
@sessions = @sessions.on_date(params[:on_date].to_date) if params[:on_date].present?
end

def update
@session = Session.find(params[:id])

@session.attendees.include?(current_user) ? remove_user_from_session : add_user_to_session

redirect_to schedules_path(on_date: params[:on_date])
end

private

def remove_user_from_session
if @session.attendees.delete(current_user)
flash[:notice] = I18n.t("controllers.sessions.remove_user.notice")
else
flash[:alert] = I18n.t("controllers.sessions.remove_user.alert")
end
end

def add_user_to_session
if @session.attendees.push(current_user)
flash[:notice] = I18n.t("controllers.sessions.add_user.notice")
else
flash[:alert] = I18n.t("controllers.sessions.add_user.alert")
end
end
end
28 changes: 28 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
class SessionsController < ApplicationController
def index
@sessions = Session.includes(:location, :speakers, :tags)
@sessions = @sessions.on_date(params[:on_date].to_date) if params[:on_date].present?
end

def show
@session = Session.find(params[:id])
@speaker = @session.speakers.first
end

def update
@session = Session.find(params[:id])

@session.attendees.include?(current_user) ? remove_user_from_session : add_user_to_session

redirect_to sessions_path(on_date: params[:on_date])
end

private

def remove_user_from_session
if @session.attendees.delete(current_user)
flash[:notice] = I18n.t("controllers.sessions.remove_user.notice")
else
flash[:alert] = I18n.t("controllers.sessions.remove_user.alert")
end
end

def add_user_to_session
if @session.attendees.push(current_user)
flash[:notice] = I18n.t("controllers.sessions.add_user.notice")
else
flash[:alert] = I18n.t("controllers.sessions.add_user.alert")
end
end
end
6 changes: 3 additions & 3 deletions app/controllers/user_sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ def create

if @user
login @user
redirect_to root_path, notice: t("controllers.sessions.create.notice")
redirect_to root_path
else
redirect_to new_user_session_path, alert: t("controllers.sessions.create.alert")
LuigiR0jas marked this conversation as resolved.
Show resolved Hide resolved
redirect_to new_user_session_path
end
end

def destroy
logout
redirect_to root_path, notice: t("controllers.sessions.destroy.notice")
redirect_to root_path
end

private
Expand Down
7 changes: 7 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
module ApplicationHelper
def session_pill_class(session_date = nil)
if request.params[:on_date] == session_date.to_s || (session_date.blank? && request.params[:on_date].blank?)
"bg-red text-white"
else
"bg-white text-red"
end
end
end
6 changes: 6 additions & 0 deletions app/models/conference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ class Conference < ApplicationRecord
def self.ransackable_attributes(_auth_object = nil)
%w[name]
end

def session_dates
LuigiR0jas marked this conversation as resolved.
Show resolved Hide resolved
Rails.cache.fetch("conference_#{id}_session_dates") do
sessions.distinct.pluck(Arel.sql("date(starts_at)")).map(&:to_date)
end
end
end
11 changes: 11 additions & 0 deletions app/models/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,18 @@ class Session < ApplicationRecord

validates_datetime :ends_at, after: :starts_at

scope :on_date, ->(date) { where(starts_at: date.all_day) }
LuigiR0jas marked this conversation as resolved.
Show resolved Hide resolved
scope :from_user, ->(user) { joins(:attendees).where(attendees: {id: user.id}) }
LuigiR0jas marked this conversation as resolved.
Show resolved Hide resolved

after_commit :invalidate_cache

def self.ransackable_attributes(_auth_object = nil)
%w[title]
end

private

def invalidate_cache
LuigiR0jas marked this conversation as resolved.
Show resolved Hide resolved
Rails.cache.delete("conference_#{conference_id}_session_dates")
end
end
2 changes: 1 addition & 1 deletion app/models/speaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Speaker < ApplicationRecord

has_and_belongs_to_many :sessions

[:name, :bio, :job_title, :github_url, :twitter_url, :linkedin_url].each do |attr|
[:name, :bio, :job_title, :github_url, :twitter_url, :linkedin_url, :image].each do |attr|
delegate attr, "#{attr}=", to: :profile, allow_nil: true
end

Expand Down
8 changes: 4 additions & 4 deletions app/views/layouts/_bottom_navbar.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<div class="sticky bottom-0 flex flex-row items-center justify-center gap-8 bg-white py-1 border-t border-b border-gray-7 text-[11px]">
<a href="<%= sessions_path %>" class="<%= nav_text_class_for [sessions_path] %> flex flex-col items-center">
<%= inline_svg_tag "calendar.svg", class: nav_icon_class_for([sessions_path]) %>
<a href="<%= sessions_path %>" class="<%= nav_text_class_for [sessions_path, root_path] %> flex flex-col items-center">
<%= inline_svg_tag "calendar.svg", class: nav_icon_class_for([sessions_path, root_path]) %>
Agenda
</a>
<a href="<%= root_path %>" class="<%= nav_text_class_for [root_path] %> flex flex-col items-center justify-center">
<%= inline_svg_tag "clock.svg", class: nav_icon_class_for([root_path]) %>
<a href="<%= schedules_path %>" class="<%= nav_text_class_for [schedules_path] %> flex flex-col items-center justify-center">
<%= inline_svg_tag "clock.svg", class: nav_icon_class_for([schedules_path]) %>
My Schedule
</a>
<a href="<%= profile_path(current_profile&.uuid) %>" class="<%= nav_text_class_for [profile_path(current_profile&.uuid), edit_profile_path(current_profile&.uuid)] %> flex flex-col items-center justify-center">
Expand Down
3 changes: 3 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<head>
<title>RailsWorld</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-refresh-scroll" content="preserve">
<meta name="turbo-refresh-method" content="morph">

<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/profiles/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</div>
<% else %>
<div class="w-[120px] h-[120px] rounded-full bg-slate-300 p-5 flex flex-row items-center justify-center">
<%= image_tag url_for("user_avatar.svg") %>
<%= image_tag url_for("icons/user_avatar.svg") %>
</div>
<% end %>
<div class="flex flex-col items-start ml-5">
Expand Down
28 changes: 28 additions & 0 deletions app/views/schedules/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<div class="flex flex-col items-center bg-gray-light">
<div class="flex flex-col items-center w-full max-w-screen-md px-5 py-10">
<div class="flex w-full mb-4">
<h1 class="text-4xl italic font-black text-gray-800">My Schedule</h1>
</div>

<div class="flex justify-between w-full mb-6">
<div class="flex items-center gap-2 overflow-x-scroll no-scrollbar">
<%= link_to 'All dates', sessions_path, class: "flex min-w-fit items-center justify-center px-4 py-2 rounded-full font-medium #{session_pill_class}" %>
<% current_conference.session_dates.each do |session_date| %>
<%= link_to session_date.strftime("%a, %d"),
sessions_path(on_date: session_date),
class: "flex min-w-fit items-center justify-center px-4 py-2 font-medium rounded-full #{session_pill_class(session_date)}" %>
<% end %>
</div>

<div class="flex items-center justify-center ml-3 p-2 bg-white rounded-full min-w-[40px] min-h-[40px]">
<%= inline_svg_tag("icons/filters.svg", size: "18") %>
</div>
</div>

<div class="flex flex-col w-full h-full">
<% @sessions.each do |session| %>
<%= render partial:'sessions/card', locals: { session: session, speaker: session.speakers.first} %>
<% end %>
</div>
</div>
</div>
Loading