Run prettier on app/coffeescripts/ from calendar to collections
This was achieved by turning the prettier rule on in .eslintrc.js then running: ./node_modules/eslint app/cofeescripts/<folder_name>/**/*.js on each folder from the start directory to the end directory listed above. Test Plan: - Automated tests pass refs COREFE-347 flag = none Change-Id: I2dd0ade9bab95e026f2b4bf39bfec494f0a6be7e Reviewed-on: https://gerrit.instructure.com/212253 Tested-by: Jenkins Reviewed-by: Ryan Shaw <ryan@instructure.com> QA-Review: Ryan Shaw <ryan@instructure.com> Product-Review: Ryan Shaw <ryan@instructure.com>
This commit is contained in:
parent
c1df717492
commit
3c606cbcc2
|
@ -31,17 +31,17 @@ import fcUtil from '../util/fcUtil'
|
|||
import userSettings from '../userSettings'
|
||||
import colorSlicer from 'color-slicer'
|
||||
import calendarAppTemplate from 'jst/calendar/calendarApp'
|
||||
import commonEventFactory from '../calendar/commonEventFactory'
|
||||
import ShowEventDetailsDialog from '../calendar/ShowEventDetailsDialog'
|
||||
import EditEventDetailsDialog from '../calendar/EditEventDetailsDialog'
|
||||
import Scheduler from '../calendar/Scheduler'
|
||||
import commonEventFactory from './commonEventFactory'
|
||||
import ShowEventDetailsDialog from './ShowEventDetailsDialog'
|
||||
import EditEventDetailsDialog from './EditEventDetailsDialog'
|
||||
import Scheduler from './Scheduler'
|
||||
import CalendarNavigator from '../views/calendar/CalendarNavigator'
|
||||
import AgendaView from '../views/calendar/AgendaView'
|
||||
import calendarDefaults from '../calendar/CalendarDefaults'
|
||||
import calendarDefaults from './CalendarDefaults'
|
||||
import ContextColorer from '../contextColorer'
|
||||
import deparam from '../util/deparam'
|
||||
import htmlEscape from 'str/htmlEscape'
|
||||
import calendarEventFilter from '../calendar/CalendarEventFilter'
|
||||
import calendarEventFilter from './CalendarEventFilter'
|
||||
import schedulerActions from 'jsx/calendar/scheduler/actions'
|
||||
import 'fullcalendar'
|
||||
import 'fullcalendar/dist/lang-all'
|
||||
|
@ -259,13 +259,13 @@ export default class Calendar {
|
|||
// This is used to set a custom time format for regions who use 24 hours time.
|
||||
// We return null in the non 24 time case so that we can allow the fullcallendar npm package
|
||||
// to set whatever time format calendar events should be
|
||||
eventTimeFormat () {
|
||||
return I18n.lookup('time.formats.tiny_on_the_hour') === "%k:%M" ? "HH:mm" : null
|
||||
eventTimeFormat() {
|
||||
return I18n.lookup('time.formats.tiny_on_the_hour') === '%k:%M' ? 'HH:mm' : null
|
||||
}
|
||||
|
||||
today = () => {
|
||||
return this.gotoDate(fcUtil.now())
|
||||
};
|
||||
}
|
||||
|
||||
// FullCalendar callbacks
|
||||
getEvents = (start, end, timezone, donecb, datacb) => {
|
||||
|
@ -274,16 +274,25 @@ export default class Calendar {
|
|||
|
||||
const _donecb = events => {
|
||||
if (this.displayAppointmentEvents) {
|
||||
return this.dataSource.getEventsForAppointmentGroup(this.displayAppointmentEvents, aEvents => {
|
||||
// Make sure any events in the current appointment group get marked -
|
||||
// order is important here, as some events in aEvents may also appear in
|
||||
// events. So clear events first, then mark aEvents. Our de-duping algorithm
|
||||
// will keep the duplicates at the end of the list first.
|
||||
events.forEach(event => event.removeClass('current-appointment-group'))
|
||||
aEvents.forEach(event => event.addClass('current-appointment-group'))
|
||||
this.gettingEvents = false
|
||||
donecb(calendarEventFilter(this.displayAppointmentEvents, events.concat(aEvents), this.schedulerState))
|
||||
})
|
||||
return this.dataSource.getEventsForAppointmentGroup(
|
||||
this.displayAppointmentEvents,
|
||||
aEvents => {
|
||||
// Make sure any events in the current appointment group get marked -
|
||||
// order is important here, as some events in aEvents may also appear in
|
||||
// events. So clear events first, then mark aEvents. Our de-duping algorithm
|
||||
// will keep the duplicates at the end of the list first.
|
||||
events.forEach(event => event.removeClass('current-appointment-group'))
|
||||
aEvents.forEach(event => event.addClass('current-appointment-group'))
|
||||
this.gettingEvents = false
|
||||
donecb(
|
||||
calendarEventFilter(
|
||||
this.displayAppointmentEvents,
|
||||
events.concat(aEvents),
|
||||
this.schedulerState
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
} else {
|
||||
this.gettingEvents = false
|
||||
if (datacb) {
|
||||
|
@ -295,11 +304,12 @@ export default class Calendar {
|
|||
}
|
||||
|
||||
let _datacb
|
||||
if (datacb) _datacb = events => datacb(calendarEventFilter(this.displayAppointmentEvents, events, this.schedulerState))
|
||||
if (datacb)
|
||||
_datacb = events =>
|
||||
datacb(calendarEventFilter(this.displayAppointmentEvents, events, this.schedulerState))
|
||||
|
||||
return this.dataSource.getEvents(start, end, contexts, _donecb, _datacb)
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// Close all event details popup on the page and have them cleaned up.
|
||||
closeEventPopups() {
|
||||
|
@ -315,7 +325,7 @@ export default class Calendar {
|
|||
windowResize = view => {
|
||||
this.closeEventPopups()
|
||||
this.drawNowLine()
|
||||
};
|
||||
}
|
||||
|
||||
eventRender = (event, element, view) => {
|
||||
const $element = $(element)
|
||||
|
@ -335,7 +345,9 @@ export default class Calendar {
|
|||
|
||||
const screenReaderTitleHint = event.eventType.match(/assignment/)
|
||||
? I18n.t('Assignment Title:')
|
||||
: event.eventType === 'planner_note' ? I18n.t('To Do:') : I18n.t('Event Title:')
|
||||
: event.eventType === 'planner_note'
|
||||
? I18n.t('To Do:')
|
||||
: I18n.t('Event Title:')
|
||||
|
||||
let reservedText = ''
|
||||
if (event.isAppointmentGroupEvent()) {
|
||||
|
@ -360,11 +372,9 @@ export default class Calendar {
|
|||
.find('.fc-content')
|
||||
.prepend(
|
||||
$(
|
||||
`<span class='screenreader-only'>${
|
||||
htmlEscape(I18n.t('calendar_title', 'Calendar:'))
|
||||
} ${
|
||||
htmlEscape(event.contextInfo.name)
|
||||
}</span>`
|
||||
`<span class='screenreader-only'>${htmlEscape(
|
||||
I18n.t('calendar_title', 'Calendar:')
|
||||
)} ${htmlEscape(event.contextInfo.name)}</span>`
|
||||
)
|
||||
)
|
||||
$element
|
||||
|
@ -373,7 +383,7 @@ export default class Calendar {
|
|||
$element.find('.fc-title').toggleClass('calendar__event--completed', event.isCompleted())
|
||||
element.find('.fc-content').prepend($('<i />', {class: `icon-${event.iconType()}`}))
|
||||
return true
|
||||
};
|
||||
}
|
||||
|
||||
eventAfterRender = (event, element, view) => {
|
||||
this.enableExternalDrags(element)
|
||||
|
@ -392,7 +402,11 @@ export default class Calendar {
|
|||
.find('.ui-resizable-handle')
|
||||
.remove()
|
||||
}
|
||||
if (event.eventType.match(/assignment/) && event.isDueStrictlyAtMidnight() && view.name === 'month') {
|
||||
if (
|
||||
event.eventType.match(/assignment/) &&
|
||||
event.isDueStrictlyAtMidnight() &&
|
||||
view.name === 'month'
|
||||
) {
|
||||
element.find('.fc-time').empty()
|
||||
}
|
||||
if (
|
||||
|
@ -413,23 +427,23 @@ export default class Calendar {
|
|||
view
|
||||
)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
eventDragStart = (event, jsEvent, ui, view) => {
|
||||
$('.fc-highlight-skeleton').remove()
|
||||
this.lastEventDragged = event
|
||||
this.closeEventPopups()
|
||||
};
|
||||
}
|
||||
|
||||
eventResizeStart = (event, jsEvent, ui, view) => {
|
||||
this.closeEventPopups()
|
||||
};
|
||||
}
|
||||
|
||||
// event triggered by items being dropped from within the calendar
|
||||
eventDrop = (event, delta, revertFunc, jsEvent, ui, view) => {
|
||||
const minuteDelta = delta.asMinutes()
|
||||
return this._eventDrop(event, minuteDelta, event.allDay, revertFunc)
|
||||
};
|
||||
}
|
||||
|
||||
_eventDrop(event, minuteDelta, allDay, revertFunc) {
|
||||
let endDate, startDate
|
||||
|
@ -485,7 +499,7 @@ export default class Calendar {
|
|||
|
||||
eventResize = (event, delta, revertFunc, jsEvent, ui, view) => {
|
||||
return event.saveDates(null, revertFunc)
|
||||
};
|
||||
}
|
||||
|
||||
activeContexts() {
|
||||
const allowedContexts =
|
||||
|
@ -503,7 +517,7 @@ export default class Calendar {
|
|||
event = commonEventFactory(null, this.activeContexts())
|
||||
event.date = this.getCurrentDate()
|
||||
return new EditEventDetailsDialog(event, this.useBetterScheduler).show()
|
||||
};
|
||||
}
|
||||
|
||||
eventClick = (event, jsEvent, view) => {
|
||||
const $event = $(jsEvent.currentTarget)
|
||||
|
@ -515,7 +529,7 @@ export default class Calendar {
|
|||
$event.data('showEventDetailsDialog', detailsDialog)
|
||||
return detailsDialog.show(jsEvent)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
dayClick = (date, jsEvent, view) => {
|
||||
if (this.displayAppointmentEvents) {
|
||||
|
@ -528,15 +542,15 @@ export default class Calendar {
|
|||
event.date = date
|
||||
event.allDay = !date.hasTime()
|
||||
return new EditEventDetailsDialog(event, this.useBetterScheduler).show()
|
||||
};
|
||||
}
|
||||
|
||||
updateFragment(opts) {
|
||||
const replaceState = !!opts.replaceState
|
||||
opts = _.omit(opts, 'replaceState')
|
||||
const data = this.dataFromDocumentHash()
|
||||
let changed = false
|
||||
for (let k in opts) {
|
||||
let v = opts[k]
|
||||
for (const k in opts) {
|
||||
const v = opts[k]
|
||||
if (data[k] !== v) changed = true
|
||||
if (v) {
|
||||
data[k] = v
|
||||
|
@ -545,11 +559,11 @@ export default class Calendar {
|
|||
}
|
||||
}
|
||||
if (changed) {
|
||||
const fragment = "#" + $.param(data, this)
|
||||
if (replaceState || location.hash === "") {
|
||||
return history.replaceState(null, "", fragment)
|
||||
const fragment = '#' + $.param(data, this)
|
||||
if (replaceState || location.hash === '') {
|
||||
return history.replaceState(null, '', fragment)
|
||||
} else {
|
||||
return location.href = fragment
|
||||
return (location.href = fragment)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -557,7 +571,7 @@ export default class Calendar {
|
|||
viewRender = view => {
|
||||
this.setDateTitle(view.title)
|
||||
this.drawNowLine()
|
||||
};
|
||||
}
|
||||
|
||||
enableExternalDrags = eventEl => {
|
||||
return $(eventEl).draggable({
|
||||
|
@ -570,7 +584,7 @@ export default class Calendar {
|
|||
// clone doesn't seem to work :(
|
||||
helper: 'clone'
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
isSameWeek(date1, date2) {
|
||||
const week1 = fcUtil
|
||||
|
@ -605,12 +619,12 @@ export default class Calendar {
|
|||
const secondHeight =
|
||||
(($('.fc-time-grid').css('height') || '').replace('px', '') || 0) / 24 / 60 / 60
|
||||
this.$nowLine.css('top', `${seconds * secondHeight}px`)
|
||||
};
|
||||
}
|
||||
|
||||
setDateTitle = title => {
|
||||
this.header.setHeaderText(title)
|
||||
return this.schedulerNavigator.setTitle(title)
|
||||
};
|
||||
}
|
||||
|
||||
// event triggered by items being dropped from outside the calendar
|
||||
drop = (date, jsEvent, ui) => {
|
||||
|
@ -627,7 +641,7 @@ export default class Calendar {
|
|||
return
|
||||
}
|
||||
return this.calendar.fullCalendar('renderEvent', event)
|
||||
};
|
||||
}
|
||||
|
||||
// callback from minicalendar telling us an event from here was dragged there
|
||||
dropOnMiniCalendar(date, allDay, jsEvent, ui) {
|
||||
|
@ -674,7 +688,7 @@ export default class Calendar {
|
|||
}
|
||||
|
||||
return this.gotoDate(this.getCurrentDate())
|
||||
};
|
||||
}
|
||||
|
||||
reloadClick = event => {
|
||||
if (event != null) {
|
||||
|
@ -687,7 +701,7 @@ export default class Calendar {
|
|||
}
|
||||
return this.calendar.fullCalendar('refetchEvents')
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Subscriptions
|
||||
|
||||
|
@ -705,19 +719,19 @@ export default class Calendar {
|
|||
event._end = event.end ? fcUtil.clone(event.end) : null
|
||||
}
|
||||
return this.calendar.fullCalendar('updateEvent', event)
|
||||
};
|
||||
}
|
||||
|
||||
eventDeleting = event => {
|
||||
event.addClass('event_pending')
|
||||
return this.updateEvent(event)
|
||||
};
|
||||
}
|
||||
|
||||
eventDeleted = event => {
|
||||
if (event.isAppointmentGroupEvent() && event.calendarEvent.parent_event_id) {
|
||||
this.handleUnreserve(event)
|
||||
}
|
||||
return this.calendar.fullCalendar('removeEvents', event.id)
|
||||
};
|
||||
}
|
||||
|
||||
// when an appointment event was deleted, clear the reserved flag and increment the available slot count on the parent
|
||||
handleUnreserve = event => {
|
||||
|
@ -738,7 +752,7 @@ export default class Calendar {
|
|||
|
||||
return this.refetchEvents()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
eventSaving = event => {
|
||||
if (!event.start) {
|
||||
|
@ -750,7 +764,7 @@ export default class Calendar {
|
|||
} else {
|
||||
return this.updateEvent(event)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
eventSaved = event => {
|
||||
event.removeClass('event_pending')
|
||||
|
@ -768,7 +782,7 @@ export default class Calendar {
|
|||
// to dated, and in that case we don't know whether to just update it or
|
||||
// add it. Some new state would need to be kept to track that.
|
||||
this.closeEventPopups()
|
||||
};
|
||||
}
|
||||
|
||||
eventSaveFailed = event => {
|
||||
event.removeClass('event_pending')
|
||||
|
@ -777,7 +791,7 @@ export default class Calendar {
|
|||
} else {
|
||||
return this.updateEvent(event)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// When an assignment event is updated, update its related overrides.
|
||||
updateOverrides = event => {
|
||||
|
@ -786,7 +800,7 @@ export default class Calendar {
|
|||
override.updateAssignmentTitle(event.title)
|
||||
}
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
visibleContextListChanged = newList => {
|
||||
this.visibleContextList = newList
|
||||
|
@ -794,21 +808,21 @@ export default class Calendar {
|
|||
this.loadAgendaView()
|
||||
}
|
||||
return this.calendar.fullCalendar('refetchEvents')
|
||||
};
|
||||
}
|
||||
|
||||
ajaxStarted = () => {
|
||||
this.activeAjax += 1
|
||||
return this.header.animateLoading(true)
|
||||
};
|
||||
}
|
||||
|
||||
ajaxEnded = () => {
|
||||
this.activeAjax -= 1
|
||||
return this.header.animateLoading(this.activeAjax > 0)
|
||||
};
|
||||
}
|
||||
|
||||
refetchEvents = () => {
|
||||
return this.calendar.fullCalendar('refetchEvents')
|
||||
};
|
||||
}
|
||||
|
||||
// Methods
|
||||
|
||||
|
@ -821,12 +835,12 @@ export default class Calendar {
|
|||
}
|
||||
this.setCurrentDate(date)
|
||||
this.drawNowLine()
|
||||
};
|
||||
}
|
||||
|
||||
navigateDate = d => {
|
||||
const date = fcUtil.wrap(d)
|
||||
this.gotoDate(date)
|
||||
};
|
||||
}
|
||||
|
||||
handleArrow(type) {
|
||||
let start
|
||||
|
@ -939,7 +953,7 @@ export default class Calendar {
|
|||
this.scheduler.hide()
|
||||
return this.header.hidePrevNext()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
loadAgendaView() {
|
||||
const date = this.getCurrentDate()
|
||||
|
@ -980,7 +994,7 @@ export default class Calendar {
|
|||
})
|
||||
)
|
||||
}, 500)
|
||||
};
|
||||
}
|
||||
|
||||
showSchedulerSingle(group) {
|
||||
this.agenda.viewingGroup = group
|
||||
|
@ -993,7 +1007,7 @@ export default class Calendar {
|
|||
this.scheduler.doneClick()
|
||||
this.header.showSchedulerTitle()
|
||||
return this.schedulerNavigator.hide()
|
||||
};
|
||||
}
|
||||
|
||||
colorizeContexts = () => {
|
||||
// Get any custom colors that have been set
|
||||
|
@ -1033,7 +1047,7 @@ export default class Calendar {
|
|||
|
||||
$styleContainer.html(`<style>${html}</style>`)
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
dataFromDocumentHash = () => {
|
||||
let data = {}
|
||||
|
@ -1049,7 +1063,7 @@ export default class Calendar {
|
|||
data = {}
|
||||
}
|
||||
return data
|
||||
};
|
||||
}
|
||||
|
||||
onSchedulerStateChange = () => {
|
||||
const newState = this.schedulerStore.getState()
|
||||
|
@ -1065,7 +1079,7 @@ export default class Calendar {
|
|||
return this.loadAgendaView()
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
findAppointmentModeGroups = () => {
|
||||
if (this.schedulerState.inFindAppointmentMode && this.schedulerState.selectedCourse) {
|
||||
|
@ -1075,7 +1089,7 @@ export default class Calendar {
|
|||
} else {
|
||||
return []
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ensureCourseVisible(course) {
|
||||
$.publish('Calendar/ensureCourseVisible', course.asset_string)
|
||||
|
@ -1092,7 +1106,7 @@ export default class Calendar {
|
|||
range.end = fcUtil.unwrap(view.intervalEnd)
|
||||
}
|
||||
return range
|
||||
};
|
||||
}
|
||||
|
||||
findNextAppointment = () => {
|
||||
// determine whether any reservable appointment slots are visible
|
||||
|
@ -1133,5 +1147,5 @@ export default class Calendar {
|
|||
}
|
||||
}
|
||||
)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ export default class CalendarEvent extends Backbone.Model {
|
|||
return result
|
||||
}
|
||||
|
||||
fetch(otps={}) {
|
||||
fetch(otps = {}) {
|
||||
let sectionsDfd, syncDfd
|
||||
|
||||
this.showSpinner()
|
||||
|
@ -83,7 +83,7 @@ export default class CalendarEvent extends Backbone.Model {
|
|||
sectionsDfd = Depaginate(this.get('sections_url'))
|
||||
}
|
||||
|
||||
const combinedSuccess = (syncArgs=[], sectionsResp=[]) => {
|
||||
const combinedSuccess = (syncArgs = [], sectionsResp = []) => {
|
||||
this.hideSpinner()
|
||||
|
||||
const [syncResp, syncStatus, syncXhr] = syncArgs
|
||||
|
@ -101,8 +101,7 @@ export default class CalendarEvent extends Backbone.Model {
|
|||
ReactDOM.render(
|
||||
<div>
|
||||
<Spinner renderTitle={I18n.t('Loading')} size="medium" />
|
||||
</div>
|
||||
,
|
||||
</div>,
|
||||
this.view.el
|
||||
)
|
||||
}
|
||||
|
@ -123,7 +122,7 @@ export default class CalendarEvent extends Backbone.Model {
|
|||
if (errHandler) return errHandler()
|
||||
}
|
||||
|
||||
static mergeSectionsIntoCalendarEvent(eventData={}, sections) {
|
||||
static mergeSectionsIntoCalendarEvent(eventData = {}, sections) {
|
||||
eventData.recurring_calendar_events = ENV.RECURRING_CALENDAR_EVENTS_ENABLED
|
||||
eventData.course_sections = sections
|
||||
eventData.use_section_dates = !!(eventData.child_events && eventData.child_events.length)
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import I18n from 'i18n!calendar'
|
||||
import $ from 'jquery'
|
||||
import CommonEvent from '../calendar/CommonEvent'
|
||||
import CommonEvent from './CommonEvent'
|
||||
import fcUtil from '../util/fcUtil'
|
||||
import {extend} from '../legacyCoffeesScriptHelpers'
|
||||
import {publish} from 'vendor/jquery.ba-tinypubsub'
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import I18n from 'i18n!calendar'
|
||||
import $ from 'jquery'
|
||||
import CommonEvent from '../calendar/CommonEvent'
|
||||
import CommonEvent from './CommonEvent'
|
||||
import fcUtil from '../util/fcUtil'
|
||||
import {extend} from '../legacyCoffeesScriptHelpers'
|
||||
import 'jquery.instructure_date_and_time'
|
||||
|
|
|
@ -20,7 +20,7 @@ import I18n from 'i18n!calendar'
|
|||
import $ from 'jquery'
|
||||
import fcUtil from '../util/fcUtil'
|
||||
import semanticDateRange from '../util/semanticDateRange'
|
||||
import CommonEvent from '../calendar/CommonEvent'
|
||||
import CommonEvent from './CommonEvent'
|
||||
import natcompare from '../util/natcompare'
|
||||
import {extend} from '../legacyCoffeesScriptHelpers'
|
||||
import 'jquery.instructure_date_and_time'
|
||||
|
@ -147,10 +147,17 @@ Object.assign(CalendarEvent.prototype, {
|
|||
calculateAppointmentGroupEventStatus() {
|
||||
let status = I18n.t('Available')
|
||||
if (this.calendarEvent.available_slots > 0) {
|
||||
status = I18n.t('%{availableSlots} Available', {availableSlots: I18n.n(this.calendarEvent.available_slots)})
|
||||
status = I18n.t('%{availableSlots} Available', {
|
||||
availableSlots: I18n.n(this.calendarEvent.available_slots)
|
||||
})
|
||||
}
|
||||
if (this.calendarEvent.available_slots > 0 && (this.calendarEvent.child_events && this.calendarEvent.child_events.length)) {
|
||||
status = I18n.t('%{availableSlots} more available', {availableSlots: I18n.n(this.calendarEvent.available_slots)})
|
||||
if (
|
||||
this.calendarEvent.available_slots > 0 &&
|
||||
(this.calendarEvent.child_events && this.calendarEvent.child_events.length)
|
||||
) {
|
||||
status = I18n.t('%{availableSlots} more available', {
|
||||
availableSlots: I18n.n(this.calendarEvent.available_slots)
|
||||
})
|
||||
}
|
||||
if (this.calendarEvent.available_slots === 0) {
|
||||
status = I18n.t('Filled')
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import I18n from 'i18n!calendar'
|
||||
import fcUtil from '../util/fcUtil'
|
||||
import CommonEvent from '../calendar/CommonEvent'
|
||||
import CommonEvent from './CommonEvent'
|
||||
import {extend} from '../legacyCoffeesScriptHelpers'
|
||||
import 'jquery.instructure_date_and_time'
|
||||
import 'jquery.instructure_misc_helpers'
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import I18n from 'i18n!calendar'
|
||||
import fcUtil from '../util/fcUtil'
|
||||
import CommonEvent from '../calendar/CommonEvent'
|
||||
import CommonEvent from './CommonEvent'
|
||||
import {extend} from '../legacyCoffeesScriptHelpers'
|
||||
import 'jquery.instructure_date_and_time'
|
||||
import 'jquery.instructure_misc_helpers'
|
||||
|
@ -28,16 +28,15 @@ extend(ToDoItem, CommonEvent)
|
|||
export default function ToDoItem(data, contextInfo, actualContextInfo) {
|
||||
ToDoItem.__super__.constructor.call(this, data, contextInfo, actualContextInfo)
|
||||
this.eventType = 'todo_item'
|
||||
switch(this.object.plannable_type)
|
||||
{
|
||||
case 'wiki_page':
|
||||
this.deleteConfirmation = I18n.t('Are you sure you want to delete this page?')
|
||||
break;
|
||||
case 'discussion_topic':
|
||||
this.deleteConfirmation = I18n.t('Are you sure you want to delete this discussion?')
|
||||
break;
|
||||
default:
|
||||
this.deleteConfirmation = I18n.t('Are you sure you want to delete this To Do item?')
|
||||
switch (this.object.plannable_type) {
|
||||
case 'wiki_page':
|
||||
this.deleteConfirmation = I18n.t('Are you sure you want to delete this page?')
|
||||
break
|
||||
case 'discussion_topic':
|
||||
this.deleteConfirmation = I18n.t('Are you sure you want to delete this discussion?')
|
||||
break
|
||||
default:
|
||||
this.deleteConfirmation = I18n.t('Are you sure you want to delete this To Do item?')
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,10 +98,10 @@ Object.assign(ToDoItem.prototype, {
|
|||
const date_param = fcUtil.unwrap(todo_date).toISOString()
|
||||
const params = {}
|
||||
if (this.object.plannable_type === 'wiki_page') {
|
||||
params["wiki_page[student_planner_checkbox]"] = true
|
||||
params["wiki_page[student_todo_at]"] = date_param
|
||||
params['wiki_page[student_planner_checkbox]'] = true
|
||||
params['wiki_page[student_todo_at]'] = date_param
|
||||
if (title) {
|
||||
params["wiki_page[title]"] = title
|
||||
params['wiki_page[title]'] = title
|
||||
}
|
||||
} else {
|
||||
params.todo_date = date_param
|
||||
|
@ -115,11 +114,7 @@ Object.assign(ToDoItem.prototype, {
|
|||
|
||||
// called at the end of a drag and drop operation
|
||||
saveDates(success, error) {
|
||||
return this.save(
|
||||
this.saveParams(this.start),
|
||||
success,
|
||||
error
|
||||
)
|
||||
return this.save(this.saveParams(this.start), success, error)
|
||||
},
|
||||
|
||||
methodAndURLForSave() {
|
||||
|
@ -127,11 +122,13 @@ Object.assign(ToDoItem.prototype, {
|
|||
},
|
||||
|
||||
urlFragment() {
|
||||
switch(this.object.plannable_type) {
|
||||
switch (this.object.plannable_type) {
|
||||
case 'wiki_page':
|
||||
return `pages/${encodeURIComponent(this.object.plannable.url)}`
|
||||
default:
|
||||
return `${encodeURIComponent(this.object.plannable_type)}s/${encodeURIComponent(this.object.plannable_id)}`
|
||||
return `${encodeURIComponent(this.object.plannable_type)}s/${encodeURIComponent(
|
||||
this.object.plannable_id
|
||||
)}`
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -142,11 +139,28 @@ Object.assign(ToDoItem.prototype, {
|
|||
mergeEditResult(data) {
|
||||
// here we need to preserve the necessary fields that the planner api returns outside of plannable
|
||||
// (additionally we need to preserve the transformed ones from EventDataSource)
|
||||
const { type, context_code, all_context_codes, plannable_type, plannable_id,
|
||||
planner_override, new_activity, submissions, html_url } = this.object
|
||||
const {
|
||||
type,
|
||||
context_code,
|
||||
all_context_codes,
|
||||
plannable_type,
|
||||
plannable_id,
|
||||
planner_override,
|
||||
new_activity,
|
||||
submissions,
|
||||
html_url
|
||||
} = this.object
|
||||
|
||||
return {
|
||||
type, context_code, all_context_codes, plannable_type, plannable_id, planner_override, new_activity, submissions, html_url,
|
||||
type,
|
||||
context_code,
|
||||
all_context_codes,
|
||||
plannable_type,
|
||||
plannable_id,
|
||||
planner_override,
|
||||
new_activity,
|
||||
submissions,
|
||||
html_url,
|
||||
plannable_date: data.todo_date,
|
||||
plannable: data // replace the plannable with the wiki page / discussion topic API update result
|
||||
}
|
||||
|
|
|
@ -50,11 +50,7 @@ Object.assign(CommonEvent.prototype, {
|
|||
},
|
||||
|
||||
isAppointmentGroupFilledEvent() {
|
||||
return (
|
||||
this.object &&
|
||||
this.object.child_events &&
|
||||
this.object.child_events.length > 0
|
||||
)
|
||||
return this.object && this.object.child_events && this.object.child_events.length > 0
|
||||
},
|
||||
|
||||
isAppointmentGroupEvent() {
|
||||
|
@ -207,10 +203,7 @@ Object.assign(CommonEvent.prototype, {
|
|||
|
||||
assignmentType() {
|
||||
if (!this.assignment) return
|
||||
if (
|
||||
this.assignment.submission_types &&
|
||||
this.assignment.submission_types.length
|
||||
) {
|
||||
if (this.assignment.submission_types && this.assignment.submission_types.length) {
|
||||
const type = this.assignment.submission_types[0]
|
||||
if (type === 'online_quiz') return 'quiz'
|
||||
if (type === 'discussion_topic') return 'discussion'
|
||||
|
@ -219,7 +212,7 @@ Object.assign(CommonEvent.prototype, {
|
|||
},
|
||||
|
||||
plannerObjectType() {
|
||||
switch(this.object.plannable_type) {
|
||||
switch (this.object.plannable_type) {
|
||||
case 'discussion_topic':
|
||||
return 'discussion'
|
||||
case 'wiki_page':
|
||||
|
|
|
@ -21,11 +21,11 @@ import _ from 'underscore'
|
|||
import fcUtil from '../util/fcUtil'
|
||||
import I18n from 'i18n!EditAppointmentGroupDetails'
|
||||
import htmlEscape from 'str/htmlEscape'
|
||||
import commonEventFactory from '../calendar/commonEventFactory'
|
||||
import TimeBlockList from '../calendar/TimeBlockList'
|
||||
import commonEventFactory from './commonEventFactory'
|
||||
import TimeBlockList from './TimeBlockList'
|
||||
import editAppointmentGroupTemplate from 'jst/calendar/editAppointmentGroup'
|
||||
import genericSelectTemplate from 'jst/calendar/genericSelect'
|
||||
import ContextSelector from '../calendar/ContextSelector'
|
||||
import ContextSelector from './ContextSelector'
|
||||
import preventDefault from '../fn/preventDefault'
|
||||
import {publish as jqueryPublish} from 'vendor/jquery.ba-tinypubsub'
|
||||
import 'jquery.ajaxJSON'
|
||||
|
@ -75,7 +75,9 @@ export default class EditAppointmentGroupDetails {
|
|||
value="${htmlEscape(this.appointment_group.max_appointments_per_participant)}"
|
||||
min="1"
|
||||
style="width: 40px"
|
||||
aria-label="${htmlEscape(I18n.t('Maximum number of appointments a participant can attend'))}"
|
||||
aria-label="${htmlEscape(
|
||||
I18n.t('Maximum number of appointments a participant can attend')
|
||||
)}"
|
||||
/>`
|
||||
})
|
||||
)
|
||||
|
@ -120,8 +122,17 @@ export default class EditAppointmentGroupDetails {
|
|||
this.form.find('.ag_contexts_selector').click(preventDefault(this.toggleContextsMenu))
|
||||
|
||||
// make sure this is the spot
|
||||
const timeBlocks = (this.apptGroup.appointments || []).map(appt => [fcUtil.wrap(appt.start_at), fcUtil.wrap(appt.end_at), true])
|
||||
this.timeBlockList = new TimeBlockList(this.form.find(".time-block-list-body"), this.form.find(".splitter"), timeBlocks, { date: this.event && this.event.date })
|
||||
const timeBlocks = (this.apptGroup.appointments || []).map(appt => [
|
||||
fcUtil.wrap(appt.start_at),
|
||||
fcUtil.wrap(appt.end_at),
|
||||
true
|
||||
])
|
||||
this.timeBlockList = new TimeBlockList(
|
||||
this.form.find('.time-block-list-body'),
|
||||
this.form.find('.splitter'),
|
||||
timeBlocks,
|
||||
{date: this.event && this.event.date}
|
||||
)
|
||||
|
||||
this.form.find('[name="slot_duration"]').change(e => {
|
||||
if (this.form.find('[name="autosplit_option"]').is(':checked')) {
|
||||
|
@ -187,6 +198,7 @@ export default class EditAppointmentGroupDetails {
|
|||
creating() {
|
||||
return !this.editing()
|
||||
}
|
||||
|
||||
editing() {
|
||||
return this.apptGroup.id != null
|
||||
}
|
||||
|
@ -204,12 +216,13 @@ export default class EditAppointmentGroupDetails {
|
|||
this.checkBoxInputChange(checkbox, input)
|
||||
const apptLimit = parseInt(input.val())
|
||||
const apptCounts = {}
|
||||
this.apptGroup.appointments && this.apptGroup.appointments.forEach(a => {
|
||||
a.child_events.forEach(e => {
|
||||
if (!apptCounts[e.user.id]) apptCounts[e.user.id] = 0
|
||||
apptCounts[e.user.id] += 1
|
||||
this.apptGroup.appointments &&
|
||||
this.apptGroup.appointments.forEach(a => {
|
||||
a.child_events.forEach(e => {
|
||||
if (!apptCounts[e.user.id]) apptCounts[e.user.id] = 0
|
||||
apptCounts[e.user.id] += 1
|
||||
})
|
||||
})
|
||||
})
|
||||
return this.helpIconShowIf(checkbox, _.some(apptCounts, (count, userId) => count > apptLimit))
|
||||
}
|
||||
|
||||
|
@ -338,7 +351,7 @@ export default class EditAppointmentGroupDetails {
|
|||
}
|
||||
|
||||
const onSuccess = data => {
|
||||
(data.new_appointments || []).forEach(eventData => {
|
||||
;(data.new_appointments || []).forEach(eventData => {
|
||||
const event = commonEventFactory(eventData, this.contexts)
|
||||
jqueryPublish('CommonEvent/eventSaved', event)
|
||||
})
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import $ from 'jquery'
|
||||
import I18n from 'i18n!calendar'
|
||||
import EditAppointmentGroupDetails from '../calendar/EditAppointmentGroupDetails'
|
||||
import EditAppointmentGroupDetails from './EditAppointmentGroupDetails'
|
||||
import 'jqueryui/dialog'
|
||||
|
||||
const dialog = $('<div id="edit_event"><div class="wrapper"></div>')
|
||||
|
|
|
@ -20,7 +20,7 @@ import I18n from 'i18n!calendar'
|
|||
import $ from 'jquery'
|
||||
import moment from 'moment'
|
||||
import natcompare from '../util/natcompare'
|
||||
import commonEventFactory from '../calendar/commonEventFactory'
|
||||
import commonEventFactory from './commonEventFactory'
|
||||
import ValidatedFormView from '../views/ValidatedFormView'
|
||||
import SisValidationHelper from '../util/SisValidationHelper'
|
||||
import editAssignmentTemplate from 'jst/calendar/editAssignment'
|
||||
|
@ -33,10 +33,9 @@ import withinMomentDates from 'jsx/shared/helpers/momentDateHelper'
|
|||
import 'jquery.instructure_date_and_time'
|
||||
import 'jquery.instructure_forms'
|
||||
import 'jquery.instructure_misc_helpers'
|
||||
import '../calendar/fcMomentHandlebarsHelpers'
|
||||
import './fcMomentHandlebarsHelpers'
|
||||
|
||||
export default class EditAssignmentDetailsRewrite extends ValidatedFormView {
|
||||
|
||||
initialize(selector, event, contextChangeCB, closeCB) {
|
||||
this.event = event
|
||||
this.contextChangeCB = contextChangeCB
|
||||
|
|
|
@ -26,10 +26,10 @@ import 'jquery.instructure_date_and_time'
|
|||
import 'jquery.instructure_forms'
|
||||
import 'jquery.instructure_misc_helpers'
|
||||
import 'vendor/date'
|
||||
import commonEventFactory from '../calendar/commonEventFactory'
|
||||
import commonEventFactory from './commonEventFactory'
|
||||
import coupleTimeFields from '../util/coupleTimeFields'
|
||||
import fcUtil from '../util/fcUtil'
|
||||
import '../calendar/fcMomentHandlebarsHelpers'
|
||||
import './fcMomentHandlebarsHelpers'
|
||||
|
||||
export default class EditCalendarEventDetails {
|
||||
constructor(selector, event, contextChangeCB, closeCB) {
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
import $ from 'jquery'
|
||||
import I18n from 'i18n!calendar'
|
||||
import _ from 'underscore'
|
||||
import EditCalendarEventDetails from '../calendar/EditCalendarEventDetails'
|
||||
import EditAssignmentDetails from '../calendar/EditAssignmentDetails'
|
||||
import EditApptCalendarEventDialog from '../calendar/EditApptCalendarEventDialog'
|
||||
import EditAppointmentGroupDetails from '../calendar/EditAppointmentGroupDetails'
|
||||
import EditPlannerNoteDetails from '../calendar/EditPlannerNoteDetails'
|
||||
import EditToDoItemDetails from '../calendar/EditToDoItemDetails'
|
||||
import EditCalendarEventDetails from './EditCalendarEventDetails'
|
||||
import EditAssignmentDetails from './EditAssignmentDetails'
|
||||
import EditApptCalendarEventDialog from './EditApptCalendarEventDialog'
|
||||
import EditAppointmentGroupDetails from './EditAppointmentGroupDetails'
|
||||
import EditPlannerNoteDetails from './EditPlannerNoteDetails'
|
||||
import EditToDoItemDetails from './EditToDoItemDetails'
|
||||
import editEventTemplate from 'jst/calendar/editEvent'
|
||||
import 'jqueryui/dialog'
|
||||
import 'jqueryui/tabs'
|
||||
|
@ -69,7 +69,7 @@ export default class EditEventDetailsDialog {
|
|||
tabs.tabs('remove', 3)
|
||||
tabs.tabs('remove', 2)
|
||||
tabs.tabs('remove', 1)
|
||||
this.calendarEventForm.activate()
|
||||
this.calendarEventForm.activate()
|
||||
} else if (this.event.eventType.match(/assignment/)) {
|
||||
tabs.tabs('select', 1)
|
||||
if (this.canManageAppointments()) tabs.tabs('remove', 4)
|
||||
|
@ -117,7 +117,7 @@ export default class EditEventDetailsDialog {
|
|||
}
|
||||
}
|
||||
|
||||
contextChange(newContext){
|
||||
contextChange(newContext) {
|
||||
// Update the style of the dialog box to reflect the current context
|
||||
dialog.removeClass(dialog.data('group_class'))
|
||||
dialog.addClass(`group_${newContext}`).data('group_class', `group_${newContext}`)
|
||||
|
|
|
@ -36,7 +36,6 @@ RichContentEditor.preloadRemoteModule()
|
|||
// #
|
||||
// View for editing a calendar event on it's own page
|
||||
export default class EditCalendarEventView extends Backbone.View {
|
||||
|
||||
initialize() {
|
||||
this.render = this.render.bind(this)
|
||||
this.attachKeyboardShortcuts = this.attachKeyboardShortcuts.bind(this)
|
||||
|
@ -51,7 +50,7 @@ export default class EditCalendarEventView extends Backbone.View {
|
|||
super.initialize(...arguments)
|
||||
this.model.fetch().done(() => {
|
||||
const picked_params = _.pick(
|
||||
Object.assign({}, this.model.attributes, deparam()),
|
||||
{...this.model.attributes, ...deparam()},
|
||||
'start_at',
|
||||
'start_date',
|
||||
'start_time',
|
||||
|
@ -152,7 +151,8 @@ export default class EditCalendarEventView extends Backbone.View {
|
|||
if (confirm(msg)) {
|
||||
return this.$el.disableWhileLoading(
|
||||
this.model.destroy({
|
||||
success: () => this.redirectWithMessage(
|
||||
success: () =>
|
||||
this.redirectWithMessage(
|
||||
I18n.t('event_deleted', '%{event_title} deleted successfully', {
|
||||
event_title: this.model.get('title')
|
||||
})
|
||||
|
@ -170,10 +170,12 @@ export default class EditCalendarEventView extends Backbone.View {
|
|||
)
|
||||
return $('.show_if_using_sections input').prop('disabled', !this.model.get('use_section_dates'))
|
||||
}
|
||||
|
||||
toggleUseSectionDates(e) {
|
||||
this.model.set('use_section_dates', !this.model.get('use_section_dates'))
|
||||
return this.updateRemoveChildEvents(e)
|
||||
}
|
||||
|
||||
toggleHtmlView(event) {
|
||||
if (event != null) event.preventDefault()
|
||||
|
||||
|
@ -230,7 +232,8 @@ export default class EditCalendarEventView extends Backbone.View {
|
|||
$dialog.dialog('close')
|
||||
this.$el.disableWhileLoading(
|
||||
this.model.save(eventData, {
|
||||
success: () => this.redirectWithMessage(I18n.t('event_saved', 'Event Saved Successfully'))
|
||||
success: () =>
|
||||
this.redirectWithMessage(I18n.t('event_saved', 'Event Saved Successfully'))
|
||||
})
|
||||
)
|
||||
return $dialog.remove()
|
||||
|
@ -305,6 +308,7 @@ export default class EditCalendarEventView extends Backbone.View {
|
|||
|
||||
return data
|
||||
}
|
||||
|
||||
static title() {
|
||||
return super.title('event', 'Event')
|
||||
}
|
||||
|
|
|
@ -27,29 +27,30 @@ import 'jquery.instructure_forms'
|
|||
import 'jquery.instructure_misc_helpers'
|
||||
import 'vendor/date'
|
||||
import fcUtil from '../util/fcUtil'
|
||||
import commonEventFactory from '../calendar/commonEventFactory'
|
||||
import commonEventFactory from './commonEventFactory'
|
||||
import ValidatedFormView from '../views/ValidatedFormView'
|
||||
import '../calendar/fcMomentHandlebarsHelpers'
|
||||
import './fcMomentHandlebarsHelpers'
|
||||
|
||||
export default class EditPlannerNoteDetails extends ValidatedFormView {
|
||||
|
||||
events = {
|
||||
...EditPlannerNoteDetails.prototype.events,
|
||||
'change .context_id': 'contextChange'
|
||||
}
|
||||
|
||||
template = editPlannerNoteTemplate
|
||||
|
||||
constructor(selector, event, contextChangeCB, closeCB) {
|
||||
super({
|
||||
title: event.title,
|
||||
contexts: event.possibleContexts().filter((context) =>
|
||||
// to avoid confusion over the audience of the planner note,
|
||||
// don't offer to create new planner notes linked to courses the user teaches
|
||||
context && context.asset_string && (
|
||||
context.asset_string === event.contextCode() ||
|
||||
context.asset_string.startsWith('user_') ||
|
||||
ENV.CALENDAR.MANAGE_CONTEXTS.indexOf(context.asset_string) < 0
|
||||
)
|
||||
contexts: event.possibleContexts().filter(
|
||||
context =>
|
||||
// to avoid confusion over the audience of the planner note,
|
||||
// don't offer to create new planner notes linked to courses the user teaches
|
||||
context &&
|
||||
context.asset_string &&
|
||||
(context.asset_string === event.contextCode() ||
|
||||
context.asset_string.startsWith('user_') ||
|
||||
ENV.CALENDAR.MANAGE_CONTEXTS.indexOf(context.asset_string) < 0)
|
||||
),
|
||||
date: event.startDate(),
|
||||
details: htmlEscape(event.description)
|
||||
|
@ -138,7 +139,7 @@ export default class EditPlannerNoteDetails extends ValidatedFormView {
|
|||
setupTimeAndDatePickers() {
|
||||
// select the appropriate fields
|
||||
const $date = this.$el.find('.date_field')
|
||||
const $time = this.$el.find(".time_field.note_time")
|
||||
const $time = this.$el.find('.time_field.note_time')
|
||||
|
||||
// set them up as appropriate variants of datetime_field
|
||||
$date.datetime_field({
|
||||
|
@ -168,7 +169,7 @@ export default class EditPlannerNoteDetails extends ValidatedFormView {
|
|||
}
|
||||
// check if input box was cleared for explicitly undated
|
||||
if (params.todo_date) {
|
||||
const { time } = data
|
||||
const {time} = data
|
||||
let due_at = params.todo_date.toString('yyyy-MM-dd')
|
||||
if (time) {
|
||||
due_at += time.toString(' HH:mm')
|
||||
|
|
|
@ -27,10 +27,9 @@ import 'jquery.instructure_misc_helpers'
|
|||
import 'vendor/date'
|
||||
import fcUtil from '../util/fcUtil'
|
||||
import ValidatedFormView from '../views/ValidatedFormView'
|
||||
import '../calendar/fcMomentHandlebarsHelpers'
|
||||
import './fcMomentHandlebarsHelpers'
|
||||
|
||||
export default class EditToDoItemDetails extends ValidatedFormView {
|
||||
|
||||
template = editToDoItemTemplate
|
||||
|
||||
constructor(selector, event, contextChangeCB, closeCB) {
|
||||
|
@ -58,18 +57,18 @@ export default class EditToDoItemDetails extends ValidatedFormView {
|
|||
}
|
||||
|
||||
activate() {
|
||||
let title;
|
||||
switch(this.event.object.plannable_type) {
|
||||
case 'wiki_page':
|
||||
title = I18n.t('Page')
|
||||
break
|
||||
case 'discussion_topic':
|
||||
title = I18n.t('Discussion')
|
||||
break
|
||||
default:
|
||||
title = I18n.t('To Do Item')
|
||||
let title
|
||||
switch (this.event.object.plannable_type) {
|
||||
case 'wiki_page':
|
||||
title = I18n.t('Page')
|
||||
break
|
||||
case 'discussion_topic':
|
||||
title = I18n.t('Discussion')
|
||||
break
|
||||
default:
|
||||
title = I18n.t('To Do Item')
|
||||
}
|
||||
$("#edit_event_tabs .edit_todo_item_option").text(title)
|
||||
$('#edit_event_tabs .edit_todo_item_option').text(title)
|
||||
|
||||
$('#edit_todo_item_form_holder .more_options_link').attr('href', this.event.editUrl)
|
||||
}
|
||||
|
@ -77,7 +76,7 @@ export default class EditToDoItemDetails extends ValidatedFormView {
|
|||
setupTimeAndDatePickers() {
|
||||
// select the appropriate fields
|
||||
const $date = this.$el.find('.date_field')
|
||||
const $time = this.$el.find(".time_field.note_time")
|
||||
const $time = this.$el.find('.time_field.note_time')
|
||||
|
||||
// set them up as appropriate variants of datetime_field
|
||||
$date.datetime_field({
|
||||
|
@ -99,7 +98,7 @@ export default class EditToDoItemDetails extends ValidatedFormView {
|
|||
|
||||
const todo_date = data.date
|
||||
if (todo_date) {
|
||||
const { time } = data
|
||||
const {time} = data
|
||||
let due_at = todo_date.toString('yyyy-MM-dd')
|
||||
if (time) {
|
||||
due_at += time.toString(' HH:mm')
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
import $ from 'jquery'
|
||||
import _ from 'lodash'
|
||||
import fcUtil from '../util/fcUtil'
|
||||
import commonEventFactory from '../calendar/commonEventFactory'
|
||||
import commonEventFactory from './commonEventFactory'
|
||||
import 'jquery.ajaxJSON'
|
||||
import 'vendor/jquery.ba-tinypubsub'
|
||||
|
||||
|
@ -290,10 +290,7 @@ export default class EventDataSource {
|
|||
|
||||
processAppointmentData(group) {
|
||||
const {id} = group
|
||||
if (
|
||||
this.cache.appointmentGroups[id] &&
|
||||
this.cache.appointmentGroups[id].is_manageable
|
||||
) {
|
||||
if (this.cache.appointmentGroups[id] && this.cache.appointmentGroups[id].is_manageable) {
|
||||
group.is_manageable = true
|
||||
} else {
|
||||
group.is_scheduleable = true
|
||||
|
@ -490,24 +487,29 @@ export default class EventDataSource {
|
|||
list.requestID = options.requestID
|
||||
return donecb(list)
|
||||
}
|
||||
const eventDataSources = [
|
||||
['/api/v1/calendar_events', this.indexParams(params)]
|
||||
]
|
||||
params.context_codes = params.context_codes.filter(context => !context.match(/^appointment_group_/))
|
||||
const eventDataSources = [['/api/v1/calendar_events', this.indexParams(params)]]
|
||||
params.context_codes = params.context_codes.filter(
|
||||
context => !context.match(/^appointment_group_/)
|
||||
)
|
||||
eventDataSources.push(['/api/v1/calendar_events', this.assignmentParams(params)])
|
||||
if (ENV.STUDENT_PLANNER_ENABLED) {
|
||||
eventDataSources.push(['/api/v1/planner_notes', params])
|
||||
}
|
||||
if (ENV.PLANNER_ENABLED) {
|
||||
const [admin_contexts, student_contexts] = _.partition(params.context_codes, (cc) => (
|
||||
ENV.CALENDAR.MANAGE_CONTEXTS.indexOf(cc) >= 0
|
||||
))
|
||||
const [admin_contexts, student_contexts] = _.partition(
|
||||
params.context_codes,
|
||||
cc => ENV.CALENDAR.MANAGE_CONTEXTS.indexOf(cc) >= 0
|
||||
)
|
||||
if (student_contexts.length) {
|
||||
const pparams = {filter: 'ungraded_todo_items', ...params, context_codes: student_contexts}
|
||||
eventDataSources.push(['/api/v1/planner/items', pparams])
|
||||
}
|
||||
if (admin_contexts.length) {
|
||||
const pparams = {filter: 'all_ungraded_todo_items', ...params, context_codes: admin_contexts}
|
||||
const pparams = {
|
||||
filter: 'all_ungraded_todo_items',
|
||||
...params,
|
||||
context_codes: admin_contexts
|
||||
}
|
||||
eventDataSources.push(['/api/v1/planner/items', pparams])
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
import $ from 'jquery'
|
||||
import I18n from 'i18n!calendar'
|
||||
import _ from 'underscore'
|
||||
import calendarDefaults from '../calendar/CalendarDefaults'
|
||||
import calendarDefaults from './CalendarDefaults'
|
||||
import 'vendor/jquery.ba-tinypubsub'
|
||||
|
||||
export default class MiniCalendar {
|
||||
|
|
|
@ -22,8 +22,8 @@ import I18n from 'i18n!calendar'
|
|||
import fcUtil from '../util/fcUtil'
|
||||
import appointmentGroupListTemplate from 'jst/calendar/appointmentGroupList'
|
||||
import schedulerRightSideAdminSectionTemplate from 'jst/calendar/schedulerRightSideAdminSection'
|
||||
import EditAppointmentGroupDialog from '../calendar/EditAppointmentGroupDialog'
|
||||
import MessageParticipantsDialog from '../calendar/MessageParticipantsDialog'
|
||||
import EditAppointmentGroupDialog from './EditAppointmentGroupDialog'
|
||||
import MessageParticipantsDialog from './MessageParticipantsDialog'
|
||||
import deleteItemTemplate from 'jst/calendar/deleteItem'
|
||||
import semanticDateRange from '../util/semanticDateRange'
|
||||
import 'jquery.instructure_date_and_time'
|
||||
|
|
|
@ -21,12 +21,12 @@ import I18n from 'i18n!calendar'
|
|||
import htmlEscape from 'str/htmlEscape'
|
||||
import Popover from '../util/Popover'
|
||||
import fcUtil from '../util/fcUtil'
|
||||
import commonEventFactory from '../calendar/commonEventFactory'
|
||||
import EditEventDetailsDialog from '../calendar/EditEventDetailsDialog'
|
||||
import commonEventFactory from './commonEventFactory'
|
||||
import EditEventDetailsDialog from './EditEventDetailsDialog'
|
||||
import eventDetailsTemplate from 'jst/calendar/eventDetails'
|
||||
import deleteItemTemplate from 'jst/calendar/deleteItem'
|
||||
import reservationOverLimitDialog from 'jst/calendar/reservationOverLimitDialog'
|
||||
import MessageParticipantsDialog from '../calendar/MessageParticipantsDialog'
|
||||
import MessageParticipantsDialog from './MessageParticipantsDialog'
|
||||
import preventDefault from '../fn/preventDefault'
|
||||
import _ from 'underscore'
|
||||
import axios from 'axios'
|
||||
|
@ -134,7 +134,12 @@ export default class ShowEventDetailsDialog {
|
|||
if (!errorHandled) {
|
||||
// defer to the default error dialog
|
||||
$.ajaxJSON.unhandledXHRs.push(request)
|
||||
return $.fn.defaultAjaxError.func.call($.fn.defaultAjaxError.object, data, request, ...otherArgs)
|
||||
return $.fn.defaultAjaxError.func.call(
|
||||
$.fn.defaultAjaxError.object,
|
||||
data,
|
||||
request,
|
||||
...otherArgs
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -288,7 +293,9 @@ export default class ShowEventDetailsDialog {
|
|||
) {
|
||||
const MAX_PAGE_SIZE = 25
|
||||
axios
|
||||
.get(`api/v1/calendar_events/${this.event.object.parent_event_id}/participants?per_page=${MAX_PAGE_SIZE}`)
|
||||
.get(
|
||||
`api/v1/calendar_events/${this.event.object.parent_event_id}/participants?per_page=${MAX_PAGE_SIZE}`
|
||||
)
|
||||
.then(response => {
|
||||
if (response.data && response.data.length) {
|
||||
const $ul = $('<ul>')
|
||||
|
@ -297,20 +304,21 @@ export default class ShowEventDetailsDialog {
|
|||
$ul.append($li)
|
||||
})
|
||||
|
||||
if(response.data.length > (MAX_PAGE_SIZE - 1)) {
|
||||
const $lidot = $('<li>').text("(...)")
|
||||
if (response.data.length > MAX_PAGE_SIZE - 1) {
|
||||
const $lidot = $('<li>').text('(...)')
|
||||
$ul.append($lidot)
|
||||
}
|
||||
|
||||
const $header = $('<th>').attr("id", 'attendees_header_text').attr("scope", 'row').text('Attendees')
|
||||
const $header = $('<th>')
|
||||
.attr('id', 'attendees_header_text')
|
||||
.attr('scope', 'row')
|
||||
.text('Attendees')
|
||||
$('#reservations').empty()
|
||||
$('#reservations').append($header)
|
||||
$('#reservations').append($ul)
|
||||
|
||||
} else {
|
||||
$('#reservations').remove()
|
||||
}
|
||||
|
||||
})
|
||||
.catch(() => $('#reservations').remove())
|
||||
}
|
||||
|
@ -357,7 +365,7 @@ export default class ShowEventDetailsDialog {
|
|||
this.popover = new Popover(jsEvent, eventDetailsTemplate(params))
|
||||
this.popover.el.data('showEventDetailsDialog', this)
|
||||
|
||||
const element = document.getElementById("event-details-trap-focus")
|
||||
const element = document.getElementById('event-details-trap-focus')
|
||||
this.popover.trapFocus(element)
|
||||
|
||||
this.popover.el.find('.view_event_link').click(preventDefault(this.openShowPage))
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
|
||||
import $ from 'jquery'
|
||||
import I18n from 'i18n!calendar'
|
||||
import TimeBlockListManager from '../calendar/TimeBlockListManager'
|
||||
import TimeBlockRow from '../calendar/TimeBlockRow'
|
||||
import TimeBlockListManager from './TimeBlockListManager'
|
||||
import TimeBlockRow from './TimeBlockRow'
|
||||
import 'jquery.instructure_date_and_time'
|
||||
import 'jquery.instructure_forms'
|
||||
import 'vendor/date'
|
||||
|
|
|
@ -19,13 +19,15 @@
|
|||
import fcUtil from '../util/fcUtil'
|
||||
|
||||
export default class TimeBlockListManager {
|
||||
|
||||
// takes an optional array of Date pairs
|
||||
constructor(blocks) {
|
||||
this.blocks = []
|
||||
if (blocks) {
|
||||
for (let i = 0, len = blocks.length; i < len; i++) {
|
||||
let ref = blocks[i], start = ref[0], end = ref[1], locked = ref[2]
|
||||
const ref = blocks[i],
|
||||
start = ref[0],
|
||||
end = ref[1],
|
||||
locked = ref[2]
|
||||
this.add(start, end, locked)
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +60,7 @@ export default class TimeBlockListManager {
|
|||
}
|
||||
})
|
||||
|
||||
return this.blocks = consolidatedBlocks
|
||||
return (this.blocks = consolidatedBlocks)
|
||||
}
|
||||
|
||||
// split each block into multiple blocks of the given length
|
||||
|
@ -95,6 +97,6 @@ export default class TimeBlockListManager {
|
|||
}
|
||||
|
||||
reset() {
|
||||
return this.blocks = []
|
||||
return (this.blocks = [])
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import I18n from 'i18n!calendar'
|
|||
import timeBlockRowTemplate from 'jst/calendar/TimeBlockRow'
|
||||
import fcUtil from '../util/fcUtil'
|
||||
import datePickerFormat from 'jsx/shared/helpers/datePickerFormat'
|
||||
import '../calendar/fcMomentHandlebarsHelpers' // make sure fcMomentToString and fcMomentToDateString are available to TimeBlockRow.handlebars
|
||||
import './fcMomentHandlebarsHelpers' // make sure fcMomentToString and fcMomentToDateString are available to TimeBlockRow.handlebars
|
||||
|
||||
export default class TimeBlockRow {
|
||||
constructor(TimeBlockList, data) {
|
||||
|
@ -151,10 +151,15 @@ export default class TimeBlockRow {
|
|||
}
|
||||
|
||||
blank() {
|
||||
return (this.$date.data('blank') && this.$start_time.data('blank') && this.$end_time.data('blank'))
|
||||
return (
|
||||
this.$date.data('blank') && this.$start_time.data('blank') && this.$end_time.data('blank')
|
||||
)
|
||||
}
|
||||
|
||||
incomplete() {
|
||||
return (!this.blank() && (this.$date.data('blank') || this.$start_time.data('blank') || this.$end_time.data('blank')))
|
||||
return (
|
||||
!this.blank() &&
|
||||
(this.$date.data('blank') || this.$start_time.data('blank') || this.$end_time.data('blank'))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
import I18n from 'i18n!calendar'
|
||||
import $ from 'jquery'
|
||||
import undatedEventsTemplate from 'jst/calendar/undatedEvents'
|
||||
import ShowEventDetailsDialog from '../calendar/ShowEventDetailsDialog'
|
||||
import ShowEventDetailsDialog from './ShowEventDetailsDialog'
|
||||
import 'jqueryui/draggable'
|
||||
import 'jqueryui/droppable'
|
||||
import 'jquery.disableWhileLoading'
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import CommonEvent from '../calendar/CommonEvent'
|
||||
import Assignment from '../calendar/CommonEvent.Assignment'
|
||||
import AssignmentOverride from '../calendar/CommonEvent.AssignmentOverride'
|
||||
import CalendarEvent from '../calendar/CommonEvent.CalendarEvent'
|
||||
import PlannerNote from '../calendar/CommonEvent.PlannerNote'
|
||||
import ToDoItem from '../calendar/CommonEvent.ToDoItem'
|
||||
import CommonEvent from './CommonEvent'
|
||||
import Assignment from './CommonEvent.Assignment'
|
||||
import AssignmentOverride from './CommonEvent.AssignmentOverride'
|
||||
import CalendarEvent from './CommonEvent.CalendarEvent'
|
||||
import PlannerNote from './CommonEvent.PlannerNote'
|
||||
import ToDoItem from './CommonEvent.ToDoItem'
|
||||
import splitAssetString from '../str/splitAssetString'
|
||||
|
||||
export default function commonEventFactory(data, contexts) {
|
||||
|
@ -36,11 +36,15 @@ export default function commonEventFactory(data, contexts) {
|
|||
let actualContextCode = data.context_code
|
||||
let contextCode = data.effective_context_code || actualContextCode
|
||||
|
||||
const type = data.assignment_overrides ? 'assignment_override' :
|
||||
data.assignment || data.assignment_group_id ? 'assignment' :
|
||||
data.type === 'planner_note' ? 'planner_note' :
|
||||
data.plannable ? 'todo_item' :
|
||||
'calendar_event'
|
||||
const type = data.assignment_overrides
|
||||
? 'assignment_override'
|
||||
: data.assignment || data.assignment_group_id
|
||||
? 'assignment'
|
||||
: data.type === 'planner_note'
|
||||
? 'planner_note'
|
||||
: data.plannable
|
||||
? 'todo_item'
|
||||
: 'calendar_event'
|
||||
|
||||
data = data.assignment_overrides
|
||||
? {assignment: data.assignment, assignment_override: data.assignment_overrides[0]}
|
||||
|
|
|
@ -150,12 +150,12 @@ export default function sidebar(contexts, selectedContexts, dataSource) {
|
|||
const $colorPickerBtn = $('.ContextList__MoreBtn')
|
||||
|
||||
$skipLink.focus(() => {
|
||||
$skipLink.removeClass("screenreader-only")
|
||||
});
|
||||
$skipLink.removeClass('screenreader-only')
|
||||
})
|
||||
|
||||
$skipLink.focusout(() => {
|
||||
$skipLink.addClass("screenreader-only")
|
||||
});
|
||||
$skipLink.addClass('screenreader-only')
|
||||
})
|
||||
|
||||
setupCalendarFeedsWithSpecialAccessibilityConsiderationsForNVDA()
|
||||
|
||||
|
|
|
@ -51,11 +51,11 @@ export default {
|
|||
// @obj.cache.use 'localStorage'
|
||||
//
|
||||
// @api public
|
||||
use (store) {
|
||||
use(store) {
|
||||
const possibleStores = {
|
||||
memory: {},
|
||||
sessionStorage,
|
||||
localStorage,
|
||||
localStorage
|
||||
}
|
||||
this.store = possibleStores[store]
|
||||
},
|
||||
|
@ -66,8 +66,13 @@ export default {
|
|||
//
|
||||
// @return String
|
||||
// @api private
|
||||
toKey (...key) {
|
||||
return this.prefix + _.flatten(key).map(arg => JSON.stringify(arg)).join('|')
|
||||
toKey(...key) {
|
||||
return (
|
||||
this.prefix +
|
||||
_.flatten(key)
|
||||
.map(arg => JSON.stringify(arg))
|
||||
.join('|')
|
||||
)
|
||||
},
|
||||
|
||||
// #
|
||||
|
@ -82,7 +87,7 @@ export default {
|
|||
//
|
||||
// @return String|Object|Array|Boolean
|
||||
// @api public
|
||||
get (...key) {
|
||||
get(...key) {
|
||||
const val = this.store[this.toKey(key)]
|
||||
if (val) {
|
||||
return JSON.parse(val)
|
||||
|
@ -105,7 +110,7 @@ export default {
|
|||
// .set('value2', 'key2')
|
||||
//
|
||||
// @api public
|
||||
set (...args) {
|
||||
set(...args) {
|
||||
const key = args.slice(0, args.length - 1)
|
||||
const value = args[args.length - 1]
|
||||
this.store[this.toKey(key)] = JSON.stringify(value)
|
||||
|
@ -114,7 +119,7 @@ export default {
|
|||
|
||||
// #
|
||||
// given a key, remove its contents from the cache
|
||||
remove (...key) {
|
||||
remove(...key) {
|
||||
delete this.store[this.toKey(key)]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
import PaginatedCollection from '../collections/PaginatedCollection'
|
||||
import AssignmentGroup from '../models/AssignmentGroup'
|
||||
import _ from 'underscore'
|
||||
import SubmissionCollection from '../collections/SubmissionCollection'
|
||||
import SubmissionCollection from './SubmissionCollection'
|
||||
import ModuleCollection from '../collections/ModuleCollection'
|
||||
|
||||
const PER_PAGE_LIMIT = 50
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
// You should have received a copy of the GNU Affero General Public License along
|
||||
// with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import PaginatedCollection from '../collections/PaginatedCollection'
|
||||
import Message from '../models/Message'
|
||||
|
||||
|
@ -41,7 +40,7 @@ export default class MessageCollection extends PaginatedCollection {
|
|||
if (newPos > lastPos) {
|
||||
range.reverse()
|
||||
}
|
||||
return range.forEach(x => x.set('selected', true));
|
||||
return range.forEach(x => x.set('selected', true))
|
||||
}
|
||||
}
|
||||
MessageCollection.prototype.model = Message
|
||||
|
|
|
@ -18,34 +18,32 @@
|
|||
import PaginatedCollection from '../collections/PaginatedCollection'
|
||||
|
||||
export default class SyllabusCalendarEventsCollection extends PaginatedCollection {
|
||||
|
||||
constructor (context_codes) {
|
||||
constructor(context_codes) {
|
||||
super()
|
||||
this.url = '/api/v1/planner/items'
|
||||
this.context_codes = context_codes
|
||||
}
|
||||
|
||||
fetch (options) {
|
||||
const mergedData = Object.assign({}, options.data, {
|
||||
fetch(options) {
|
||||
const mergedData = {
|
||||
...options.data,
|
||||
context_codes: this.context_codes,
|
||||
filter: 'all_ungraded_todo_items',
|
||||
})
|
||||
const mergedOptions = Object.assign({}, options, {
|
||||
data: mergedData,
|
||||
})
|
||||
filter: 'all_ungraded_todo_items'
|
||||
}
|
||||
const mergedOptions = {...options, data: mergedData}
|
||||
return super.fetch(mergedOptions)
|
||||
}
|
||||
|
||||
// Overridden to make the id unique when aggregated in a collection with other
|
||||
// models and to match the fields used by the SyllabusView and template.
|
||||
parse (apiNote) {
|
||||
parse(apiNote) {
|
||||
return apiNote.map(note => ({
|
||||
id: `planner_${note.plannable_type}_${note.plannable_id}`,
|
||||
type: note.plannable_type,
|
||||
title: note.plannable.title,
|
||||
todo_at: note.plannable.todo_date,
|
||||
start_at: note.plannable.todo_date,
|
||||
html_url: note.html_url,
|
||||
html_url: note.html_url
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue