Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
138 changes: 138 additions & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,14 @@ hr {
color: #1F6B45;
}

.item-badge--presenting {
background-color: #FEF9C3;
color: #8A6500;
border: 1px solid #E0C97A;
padding: 0.0625rem 0.4375rem;
font-weight: 600;
}

.item-badge--private {
background-color: transparent;
color: #525C66;
Expand Down Expand Up @@ -3053,6 +3061,136 @@ hr {
.pdf-page--notary { page-break-before: always; }
}


/* ---------- Lightning talk slots --------------------------- */

.lightning-slots {
margin-top: 0.75rem;
border-top: 1px dashed #e6e8eb;
padding-top: 0.5rem;
}

.lightning-slots__summary {
font-size: 0.875rem;
color: #525C66;
cursor: pointer;
list-style: none;
padding: 0.375rem 0;
display: flex;
align-items: center;
gap: 0.5rem;
}

.lightning-slots__summary::-webkit-details-marker { display: none; }

.lightning-slots__count { color: #525C66; }

.lightning-slots__toggle {
margin-left: auto;
display: inline-flex;
align-items: center;
gap: 0.375rem;
color: #C41C1C;
font-weight: 500;
}

.lightning-slots__chevron {
display: inline-block;
width: 0;
height: 0;
border-top: 4px solid transparent;
border-bottom: 4px solid transparent;
border-left: 6px solid #C41C1C;
transition: transform 0.15s ease;
}

.lightning-slots[open] .lightning-slots__chevron {
transform: rotate(90deg);
}

.lightning-slots__toggle-label { text-decoration: underline; }
.lightning-slots__toggle-label--open { display: none; }
.lightning-slots[open] .lightning-slots__toggle-label--closed { display: none; }
.lightning-slots[open] .lightning-slots__toggle-label--open { display: inline; }

.lightning-slots__list {
list-style: none;
padding: 0.5rem 0 0 0;
margin: 0;
display: flex;
flex-direction: column;
gap: 0.375rem;
}

.lightning-slot {
display: flex;
flex-wrap: wrap;
align-items: baseline;
gap: 0.5rem;
padding: 0.375rem 0.5rem;
border-radius: 0.375rem;
background-color: #FAFAF6;
font-size: 0.875rem;
line-height: 1.4;
}

.lightning-slot--open { color: #8a8f96; font-style: italic; }

.lightning-slot__position { font-weight: 600; min-width: 1.75rem; color: #525C66; }
.lightning-slot__time { color: #1F6B45; font-variant-numeric: tabular-nums; min-width: 4.5rem; }
.lightning-slot__speaker { font-weight: 500; color: #1f242a; }
.lightning-slot__talk-title { font-style: italic; color: #1f242a; }
.lightning-slot__talk-description { color: #525C66; flex-basis: 100%; padding-left: 6.5rem; }
.lightning-slot__slides { color: #C41C1C; text-decoration: underline; }
.lightning-slot__edit { color: #C41C1C; font-size: 0.8125rem; margin-left: auto; }
.lightning-slot__open-label { color: #8a8f96; }

.schedule-item__action--lightning {
display: flex;
flex-direction: column;
align-items: stretch;
gap: 0.375rem;
min-width: 130px;
}

.schedule-item__action--lightning > form,
.schedule-item__action--lightning > .add-btn,
.schedule-item__action--lightning > form > .add-btn {
width: 100%;
}

/* ---------- Admin speakers list (drag-to-reorder) ---------- */

.speakers-list {
list-style: none;
padding: 0;
margin: 0 0 1rem 0;
display: flex;
flex-direction: column;
gap: 0.375rem;
}

.speakers-list__item {
display: grid;
grid-template-columns: auto 2.5rem 5rem 1fr 2fr auto;
gap: 0.75rem;
align-items: center;
padding: 0.5rem 0.75rem;
background-color: #FAFAF6;
border: 1px solid #e6e8eb;
border-radius: 0.375rem;
cursor: grab;
}

.speakers-list__item.is-dragging { opacity: 0.4; }
.speakers-list__handle { color: #c8cdd1; cursor: grab; user-select: none; }
.speakers-list__position { font-weight: 600; color: #525C66; }
.speakers-list__time { color: #1F6B45; font-variant-numeric: tabular-nums; }
.speakers-list__name { font-weight: 500; color: #1f242a; }
.speakers-list__title { color: #525C66; font-size: 0.9375rem; }

.btn-small { padding: 0.25rem 0.625rem; font-size: 0.8125rem; }

/* ---------- Meal-spot transport form: hide passenger seats unless driving --- */
/* Uses :has() to react to the radio's checked state — no JS needed. */
.transport-fields .seats-field {
Expand Down
93 changes: 93 additions & 0 deletions app/controllers/admin/lightning_talk_signups_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
module Admin
class LightningTalkSignupsController < AdminController
before_action :load_schedule_item
before_action :set_signup, only: %i[update destroy]

def index
respond_to do |format|
format.html { redirect_to admin_lightning_talks_path }
format.pdf {
send_data LightningTalksPdf.new(@schedule_item).render,
filename: pdf_filename,
type: "application/pdf",
disposition: "attachment"
}
end
end

def create
user = User.find(params[:user_id])
LightningTalkSignup.claim_next_slot!(user: user, schedule_item: @schedule_item)
redirect_back fallback_location: admin_lightning_talks_path,
notice: "Speaker added."
rescue LightningTalkSignup::SlotsFull
redirect_back fallback_location: admin_lightning_talks_path,
alert: "All speaking slots are full."
end

def update
if @signup.update(signup_params)
redirect_back fallback_location: admin_lightning_talks_path,
notice: "Talk details updated."
else
redirect_back fallback_location: admin_lightning_talks_path,
alert: @signup.errors.full_messages.to_sentence
end
end

def destroy
removed_position = @signup.position
LightningTalkSignup.transaction do
@signup.destroy!
@schedule_item.lightning_talk_signups
.where("position > ?", removed_position)
.order(:position)
.each { |s| s.update_columns(position: s.position - 1) }
end
redirect_back fallback_location: admin_lightning_talks_path,
notice: "Speaker removed."
end

def reorder
ids = Array(params[:signup_ids]).map(&:to_i)
LightningTalkSignup.transaction do
signups = @schedule_item.lightning_talk_signups.where(id: ids).index_by(&:id)
# Two-pass renumber to avoid colliding with the unique [schedule_item_id, position] index.
signups.each_value { |s| s.update_columns(position: s.position + LightningTalkSignup::MAX_SPEAKERS) }
ids.each_with_index do |id, index|
signups[id]&.update_columns(position: index + 1)
end
end

respond_to do |format|
format.json { head :no_content }
format.turbo_stream {
signups = @schedule_item.lightning_talk_signups.includes(:user).ordered
render turbo_stream: turbo_stream.replace(
"lightning-speakers-list",
partial: "admin/lightning_talk_signups/speakers_list",
locals: { signups: signups, schedule_item: @schedule_item }
)
}
end
end

private

def load_schedule_item
@schedule_item = ScheduleItem.find(params[:schedule_item_id])
end

def set_signup
@signup = @schedule_item.lightning_talk_signups.find(params[:id])
end

def signup_params
params.require(:lightning_talk_signup).permit(:talk_title, :talk_description, :slides_url)
end

def pdf_filename
"lightning-talks-#{@schedule_item.day}-#{@schedule_item.id}.pdf"
end
end
end
7 changes: 7 additions & 0 deletions app/controllers/admin/lightning_talks_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Admin
class LightningTalksController < AdminController
def index
@schedule_item = ScheduleItem.lightning.ordered.first
end
end
end
49 changes: 49 additions & 0 deletions app/controllers/lightning_talk_signups_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
class LightningTalkSignupsController < ApplicationController
before_action :load_schedule_item

def create
@signup = LightningTalkSignup.claim_next_slot!(
user: current_user,
schedule_item: @schedule_item
)
respond_to do |format|
format.turbo_stream {
render turbo_stream: turbo_stream.replace(
helpers.dom_id(@schedule_item),
partial: "schedule/session_item",
locals: { item: @schedule_item, planned: true }
)
}
format.html { redirect_back fallback_location: schedule_path, notice: "You're signed up to give a lightning talk." }
end
rescue LightningTalkSignup::SlotsFull
redirect_back fallback_location: schedule_path, alert: "All speaking slots are full."
end

def edit
@signup = current_signup
end

def update
@signup = current_signup
if @signup.update(signup_params)
redirect_to schedule_path(anchor: helpers.dom_id(@schedule_item)), notice: "Talk details saved."
else
render :edit, status: :unprocessable_content
end
end

private

def load_schedule_item
@schedule_item = ScheduleItem.find(params[:schedule_item_id])
end

def current_signup
current_user.lightning_talk_signups.find_by!(schedule_item_id: @schedule_item.id)
end

def signup_params
params.require(:lightning_talk_signup).permit(:talk_title, :talk_description, :slides_url)
end
end
1 change: 1 addition & 0 deletions app/controllers/plan_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def index
.sort_by { |pi| [ ScheduleItem::DAY_META.keys.index(pi.schedule_item.day) || 99, pi.schedule_item.sort_time.to_i ] }
.group_by { |pi| pi.schedule_item.day }

@speaking_ids = current_user.lightning_talk_signups.pluck(:schedule_item_id).to_set
# @travel = MOCK_TRAVEL
end
end
2 changes: 2 additions & 0 deletions app/helpers/admin/lightning_talk_signups_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module Admin::LightningTalkSignupsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/admin/lightning_talks_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module Admin::LightningTalksHelper
end
2 changes: 2 additions & 0 deletions app/helpers/lightning_talk_signups_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module LightningTalkSignupsHelper
end
63 changes: 63 additions & 0 deletions app/javascript/controllers/sortable_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { Controller } from "@hotwired/stimulus"

// Drag-to-reorder. Each child <li> needs draggable="true" and data-id="...".
// On drop, PATCHes the new ordered ids array to data-sortable-url-value.
export default class extends Controller {
static values = { url: String }

connect() {
this.draggedItem = null
this.element.addEventListener("dragstart", this.onDragStart)
this.element.addEventListener("dragover", this.onDragOver)
this.element.addEventListener("drop", this.onDrop)
this.element.addEventListener("dragend", this.onDragEnd)
}

disconnect() {
this.element.removeEventListener("dragstart", this.onDragStart)
this.element.removeEventListener("dragover", this.onDragOver)
this.element.removeEventListener("drop", this.onDrop)
this.element.removeEventListener("dragend", this.onDragEnd)
}

onDragStart = (e) => {
const li = e.target.closest("[data-id]")
if (!li) return
this.draggedItem = li
li.classList.add("is-dragging")
e.dataTransfer.effectAllowed = "move"
}

onDragOver = (e) => {
e.preventDefault()
const target = e.target.closest("[data-id]")
if (!target || target === this.draggedItem) return
const rect = target.getBoundingClientRect()
const before = (e.clientY - rect.top) < rect.height / 2
target.parentNode.insertBefore(this.draggedItem, before ? target : target.nextSibling)
}

onDrop = (e) => { e.preventDefault() }

onDragEnd = () => {
if (this.draggedItem) this.draggedItem.classList.remove("is-dragging")
this.draggedItem = null
this.persist()
}

persist() {
const ids = Array.from(this.element.querySelectorAll("[data-id]")).map(el => el.dataset.id)
const csrf = document.querySelector('meta[name="csrf-token"]')?.content
fetch(this.urlValue, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
"X-CSRF-Token": csrf,
"Accept": "text/vnd.turbo-stream.html"
},
body: JSON.stringify({ signup_ids: ids })
})
.then(r => r.text())
.then(html => window.Turbo?.renderStreamMessage(html))
}
}
Loading
Loading