calendar: display true times for events after 11:30

fixes CNVS-9270

test plan:
  * open calendar 2 with agenda view enabled
  * create events/assignments/vdd assignments at or near midnight
  * open agenda view
  * confirm that times are not displayed as 11:30 and that events
      are sorted properly
  * open the details popup for an event
  * verify that the correct time is displayed
  * open week view
  * verify that events after 11:30 are positioned as though
      they were starting at 11:30
  * verify that assignments due after 11:30 have their time listed

Change-Id: I506930592bc97e7fcc1df401832f1e77d6f2b3a0
Reviewed-on: https://gerrit.instructure.com/26314
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Matt Fairbourn <mfairbourn@instructure.com>
Reviewed-by: Jon Willesen <jonw@instructure.com>
Product-Review: Braden Anderson <banderson@instructure.com>
This commit is contained in:
Braden Anderson 2013-11-14 13:42:34 -07:00
parent b5b627efa6
commit 5cbcb88ce0
9 changed files with 43 additions and 28 deletions

View File

@ -287,12 +287,16 @@ define [
eventAfterRender: (event, element, view) =>
if event.isDueAtMidnight()
# show the actual time instead of the midnight fudged time
element.find('.fc-event-time').html @calendar.fullCalendar('formatDate', event.startDate(), 'h(:mm)t')
time = element.find('.fc-event-time')
html = time.html()
# the time element also contains the title for calendar events
html = html.replace(/^\d+:\d+/, @calendar.fullCalendar('formatDate', event.startDate(), 'h(:mm)t'))
time.html(html)
if event.eventType.match(/assignment/) && view.name == "agendaWeek"
element.height('') # this fixes it so it can wrap and not be forced onto 1 line
.find('.ui-resizable-handle').remove()
if ENV.CALENDAR.SHOW_AGENDA
if event.eventType.match(/assignment/) && event.isDueAtMidnight()
if event.eventType.match(/assignment/) && event.isDueAtMidnight() && view.name == "month"
element.find('.fc-event-time').empty()
else
if event.eventType.match(/assignment/)

View File

@ -25,26 +25,22 @@ define [
@description = data.description
@start = @parseStartDate()
@end = null # in case it got set by midnight fudging
@originalStartDate = new Date(@start) if @start
super
fullDetailsURL: () ->
@assignment.html_url
startDate: () -> @originalStartDate
parseStartDate: () ->
if @assignment.due_at then $.parseFromISO(@assignment.due_at, 'due_date').time else null
displayTimeString: () ->
if !@assignment.due_at
unless date = @originalStart
return "No Date" # TODO: i18n
date = $.parseFromISO @assignment.due_at, 'due_date'
# TODO: i18n
time_string = "#{date.date_formatted} at #{date.time_string}"
"Due: <time datetime='#{date.time.toISOString()}'>#{time_string}</time>"
time_string = "#{$.dateString(date)} at #{$.timeString(date)}"
"Due: <time datetime='#{date.toISOString()}'>#{time_string}</time>"
readableType: () ->
@readableTypes[@assignmentType()]

View File

@ -33,7 +33,6 @@ define [
@description = @assignment.description
@start = @parseStartDate()
@end = null # in case it got set by midnight fudging
@originalStartDate = new Date(@start) if @start
copyDataFromOverride: (override) ->
@override = override
@ -43,16 +42,13 @@ define [
fullDetailsURL: () ->
@assignment.html_url
startDate: () -> @originalStartDate
parseStartDate: () ->
if @assignment.due_at then $.parseFromISO(@assignment.due_at, 'due_date').time else null
displayTimeString: () ->
if !@start
unless date = @originalStart
return "No Date" # TODO: i18n
date = @start
# TODO: i18n
time_string = "#{$.dateString(date)} at #{$.timeString(date)}"
"Due: <time datetime='#{date.toISOString()}'>#{time_string}</time>"

View File

@ -21,7 +21,6 @@ define [
@id = "calendar_event_#{data.id}" if data.id
@title = data.title || "Untitled"
@start = @parseStartDate()
@originalStartDate = new Date(@start) if @start
@end = @parseEndDate()
@originalEndDate = new Date(@end) if @end
@allDay = data.all_day
@ -41,7 +40,6 @@ define [
super
startDate: () -> @originalStartDate
endDate: () -> @originalEndDate
parseStartDate: () ->

View File

@ -42,7 +42,7 @@ define [
fullDetailsURL: () -> null
startDate: () -> @date
startDate: () -> @originalStart || @date
endDate: () -> @startDate()
possibleContexts: () -> @allPossibleContexts || [ @contextInfo ]
@ -80,9 +80,10 @@ define [
$.ajaxJSON url, method, params, onSuccess, onError
isDueAtMidnight: () ->
@start && (@midnightFudged || (@start.getHours() == 23 && @start.getMinutes() == 59))
@start && (@midnightFudged || (@start.getHours() == 23 && @start.getMinutes() > 30))
copyDataFromObject: (data) ->
@originalStart = new Date(@start) if @start
@midnightFudged = false # clear out cached value because now we have new data
if @isDueAtMidnight()
@midnightFudged = true

View File

@ -116,7 +116,7 @@ define [
events = []
for id, event of contextInfo.events
if !event.start && !start || event.start >= start && event.start <= end
if !event.originalStart && !start || event.originalStart >= start && event.originalStart <= end
events.push event
events
@ -258,7 +258,7 @@ define [
event = commonEventFactory(e, @contexts)
if event && event.object.workflow_state != 'deleted'
requestResult.events.push(event)
requestResult.maxDate = _.max(requestResult.events, (e) -> e.start).start
requestResult.maxDate = _.max(requestResult.events, (e) -> e.originalStart).originalStart
requestResults[key] = requestResult
doneCB = () =>
@ -279,9 +279,9 @@ define [
lastKnownDate = start
for key, requestResult of requestResults
for event in requestResult.events
if !incomplete || event.start < nextPageDate
if !incomplete || event.originalStart < nextPageDate
@addEventToCache event
lastKnownDate = event.start if event.start > lastKnownDate
lastKnownDate = event.originalStart if event.originalStart > lastKnownDate
lastKnownDate = end if !incomplete
for context in contexts

View File

@ -68,7 +68,7 @@ define [
appendEvents: (events) =>
@nextPageDate = events.nextPageDate
@collection.push.apply(@collection, events)
@collection = _.sortBy(@collection, 'start')
@collection = _.sortBy(@collection, 'originalStart')
@render()
loadMore: (e) ->
@ -100,7 +100,7 @@ define [
lastEvent = _.last(@collection)
return if !lastEvent
@trigger('agendaDateRange', @startDate, lastEvent.start)
@trigger('agendaDateRange', @startDate, lastEvent.originalStart)
# Internal: Change a flat array of objects into a sturctured array of
# objects based on the given iterator function. Similar to _.groupBy,
@ -132,7 +132,7 @@ define [
#
# Returns the formatted String
formattedDayString: (event) =>
I18n.l('#date.formats.short_with_weekday', event.start)
I18n.l('#date.formats.short_with_weekday', event.originalStart)
# Internal: change a box of events into an output hash for toJSON
#
@ -142,7 +142,7 @@ define [
eventBoxToHash: (events) =>
now = $.fudgeDateForProfileTimezone(new Date)
event = _.first(events)
start = event.start
start = event.originalStart
isToday =
now.getDate() == start.getDate() &&
now.getMonth() == start.getMonth() &&

View File

@ -23,11 +23,11 @@
<div class="ig-details">
{{#if assignment}}
<b>{{#t "due"}}due{{/t}}</b><span class="screenreader-only">,</span>
{{strftime start "%l:%M%P"}}
{{strftime originalStart "%l:%M%P"}}
{{else}}
{{#unless all_day}}
<span class="screenreader-only">{{#t "starts_at"}}Starts at{{/t}},</span>
{{strftime start "%l:%M%P"}}
{{strftime originalStart "%l:%M%P"}}
{{/unless}}
{{/if}}
</div>

View File

@ -819,6 +819,26 @@ describe "calendar2" do
wait_for_ajaximations
ffj('.ig-row').length.should == 0
end
it "should display midnight assignments at 11:59" do
assignment_model(:course => @course,
:title => "super important",
:due_at => Time.zone.now.beginning_of_day + 1.day - 1.minute)
calendar_events = @teacher.calendar_events_for_calendar.last
calendar_events.title.should == "super important"
@assignment.due_date.should == (Time.zone.now.beginning_of_day + 1.day - 1.minute).to_date
get "/calendar2"
wait_for_ajaximations
f('#agenda').click
wait_for_ajaximations
f('.ig-details').should include_text('11:59')
f('.ig-row').click()
fj('.event-details:visible time').should include_text('11:59')
end
end
end