On calendar1, open a syllabus event in dialog. Closes #9398
Testing Steps: ========== * Create an event on the calendar (preferably not for the current month). * Ensure you are setup to use Calendar1 (can change from Cal2 with button) * Visit the course syllabus and find the event listed there. * Click the event in syllabus * Verify that calendar opens to the proper month and the dialog with event information opens and is displayed. Change-Id: Ib6d3eee1a863eccfebd42a2788c51e7af4b4689a Reviewed-on: https://gerrit.instructure.com/13182 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Jon Jensen <jon@instructure.com>
This commit is contained in:
parent
72f298bf46
commit
2fe698524a
|
@ -30,7 +30,12 @@ class CalendarsController < ApplicationController
|
|||
return redirect_to(calendar_url_for([@context]))
|
||||
end
|
||||
get_all_pertinent_contexts(true) # passing true has it return groups too.
|
||||
build_calendar_dates
|
||||
if params[:event_id]
|
||||
event = CalendarEvent.find_by_id(params[:event_id])
|
||||
event = nil if event && event.start_at.nil?
|
||||
@active_event_id = event.id if event
|
||||
end
|
||||
build_calendar_dates(event)
|
||||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
|
@ -149,7 +154,7 @@ class CalendarsController < ApplicationController
|
|||
end
|
||||
protected :calendar_events_for_request_format
|
||||
|
||||
def build_calendar_dates
|
||||
def build_calendar_dates(event_to_focus)
|
||||
@today = Time.zone.today
|
||||
|
||||
if params[:start_day] && params[:end_day]
|
||||
|
@ -165,10 +170,16 @@ class CalendarsController < ApplicationController
|
|||
end
|
||||
@current = Date.new(y = @year, m = @month, d = 1)
|
||||
else
|
||||
@month = params[:month].to_i
|
||||
@month = !@month || @month == 0 ? @today.month : @month
|
||||
@year = params[:year].to_i
|
||||
@year = !@year || @year == 0 ? @today.year : @year
|
||||
if event_to_focus
|
||||
use_start = event_to_focus.start_at.in_time_zone
|
||||
@month = use_start.month
|
||||
@year = use_start.year
|
||||
else
|
||||
@month = params[:month].to_i
|
||||
@month = !@month || @month == 0 ? @today.month : @month
|
||||
@year = params[:year].to_i
|
||||
@year = !@year || @year == 0 ? @today.year : @year
|
||||
end
|
||||
|
||||
@first_day = Date.parse(params[:start_day]) if params[:start_day]
|
||||
@last_day = Date.parse(params[:end_day]) if params[:end_day]
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<%
|
||||
js_env :CALENDAR => { :ACTIVE_EVENT => @active_event_id }
|
||||
js_bundle :calendar
|
||||
jammit_css :calendar
|
||||
@body_classes << "full-width"
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
define([
|
||||
'INST' /* INST */,
|
||||
'ENV',
|
||||
'i18n!calendars',
|
||||
'jquery' /* $ */,
|
||||
'compiled/userSettings',
|
||||
|
@ -38,9 +39,10 @@ define([
|
|||
'jqueryui/resizable' /* /\.resizable/ */,
|
||||
'jqueryui/sortable' /* /\.sortable/ */,
|
||||
'jqueryui/tabs' /* /\.tabs/ */
|
||||
], function(INST, I18n, $, userSettings, calendarMonths) {
|
||||
], function(INST, ENV, I18n, $, userSettings, calendarMonths) {
|
||||
|
||||
window.calendar = {
|
||||
activateEventId: ENV.CALENDAR.ACTIVE_EVENT,
|
||||
viewItem: function(context_string, item_id, item_type) {
|
||||
},
|
||||
showingUndatedEvents: false,
|
||||
|
@ -624,6 +626,15 @@ define([
|
|||
if($("#" + groupId).length > 0) {
|
||||
$event.showIf($("#" + groupId).attr('checked'));
|
||||
}
|
||||
|
||||
// After loading the data, if have an event to activate and the event was just updated, show it.
|
||||
if (event.id == calendar.activateEventId && calendar.activateEventId) {
|
||||
$day = $event.parents(".calendar_day");
|
||||
// Remove the ID from being automatically activated on the next data refresh
|
||||
calendar.activateEventId = null;
|
||||
showEvent($event, $day);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
function refreshCalendarData(cache) {
|
||||
|
|
|
@ -211,5 +211,18 @@ describe "calendar" do
|
|||
ff('.mini_calendar_day .day_number')[10].click
|
||||
keep_trying_until { f('.calendar_month .month_name').text.should == f('.mini-cal-month-and-year .month_name').text }
|
||||
end
|
||||
|
||||
it "should open an event dialog on calendar from URL" do
|
||||
event_title = 'Test Event 123'
|
||||
start_time = 3.months.ago
|
||||
end_time = start_time + 1.hour
|
||||
calendar_event_model(:title => event_title, :start_at => start_time, :end_at => end_time)
|
||||
|
||||
get "/calendar?event_id=#{@event.id}&include_contexts=course_#{@course.id}"
|
||||
wait_for_ajax_requests
|
||||
|
||||
keep_trying_until { fj(".ui-dialog").should be_displayed } #using fj to bypass selenium cache
|
||||
fj(".ui-dialog .title").text.should == event_title
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue