Run prettier on app/coffeescripts/ from views to xhr
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: If5fd9ede922f25781c944fb32d966bf8e69fae4d Reviewed-on: https://gerrit.instructure.com/212260 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
5643aa7693
commit
7b1d44f998
|
@ -24,7 +24,6 @@ import EntryCollection from '../../collections/EntryCollection'
|
|||
import rEscape from '../../regexp/rEscape'
|
||||
|
||||
export default class DiscussionFilterResultsView extends EntryCollectionView {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.defaults = {
|
||||
...EntryCollectionView.prototype.defaults,
|
||||
|
|
|
@ -66,7 +66,7 @@ export default class DiscussionToolbarView extends View {
|
|||
this.$unread.prop('checked', false)
|
||||
this.$unread.button('refresh')
|
||||
return this.maybeDisableFields()
|
||||
};
|
||||
}
|
||||
|
||||
toggleUnread() {
|
||||
// setTimeout so the ui can update the button before the rest
|
||||
|
|
|
@ -24,7 +24,6 @@ import '../../jquery/scrollIntoView'
|
|||
import 'underscore.flattenObjects'
|
||||
|
||||
export default class EntriesView extends Backbone.View {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.defaults = {
|
||||
initialPage: 0,
|
||||
|
|
|
@ -29,7 +29,6 @@ import htmlEscape from 'str/htmlEscape'
|
|||
import AssignmentExternalTools from 'jsx/assignments/AssignmentExternalTools'
|
||||
|
||||
export default class TopicView extends Backbone.View {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.events = {
|
||||
// #
|
||||
|
@ -192,13 +191,11 @@ export default class TopicView extends Backbone.View {
|
|||
}
|
||||
if (this.reply == null) {
|
||||
this.reply = new Reply(this, {topLevel: true, focus: true})
|
||||
this.reply.on(
|
||||
'edit',
|
||||
() => (this.$addRootReply != null ? this.$addRootReply.hide() : undefined)
|
||||
this.reply.on('edit', () =>
|
||||
this.$addRootReply != null ? this.$addRootReply.hide() : undefined
|
||||
)
|
||||
this.reply.on(
|
||||
'hide',
|
||||
() => (this.$addRootReply != null ? this.$addRootReply.show() : undefined)
|
||||
this.reply.on('hide', () =>
|
||||
this.$addRootReply != null ? this.$addRootReply.show() : undefined
|
||||
)
|
||||
this.reply.on('save', entry => {
|
||||
ENV.DISCUSSION.CAN_SUBSCRIBE = true
|
||||
|
|
|
@ -34,7 +34,7 @@ export default function GradeChangeLoggingContentView(options) {
|
|||
this.onFail = this.onFail.bind(this)
|
||||
this.options = options
|
||||
this.collection = new GradeChangeLoggingCollection()
|
||||
Backbone.View.apply(this,arguments)
|
||||
Backbone.View.apply(this, arguments)
|
||||
this.dateRangeSearch = new DateRangeSearchView({
|
||||
name: 'gradeChangeLogging'
|
||||
})
|
||||
|
|
|
@ -22,6 +22,6 @@ import MutationAuditLog from 'jsx/audit_logs/MutationAuditLog'
|
|||
|
||||
export default class GraphQLMutationContentView extends Backbone.View {
|
||||
render() {
|
||||
ReactDOM.render(<MutationAuditLog/>, this.el);
|
||||
ReactDOM.render(<MutationAuditLog />, this.el)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,9 +88,7 @@ export default class LoggingContentPaneView extends Backbone.View {
|
|||
}
|
||||
|
||||
initMutationLog() {
|
||||
return this.permissions.mutation ?
|
||||
new GraphQLMutationContentView() :
|
||||
new Backbone.View()
|
||||
return this.permissions.mutation ? new GraphQLMutationContentView() : new Backbone.View()
|
||||
}
|
||||
}
|
||||
LoggingContentPaneView.initClass()
|
||||
|
|
|
@ -127,8 +127,7 @@ export default class ToggleShowByView extends Backbone.View {
|
|||
>
|
||||
<RadioInput id="show_by_date" label={I18n.t('Show by Date')} value="date" context="off" />
|
||||
<RadioInput id="show_by_type" label={I18n.t('Show by Type')} value="type" context="off" />
|
||||
</RadioInputGroup>
|
||||
,
|
||||
</RadioInputGroup>,
|
||||
this.el
|
||||
)
|
||||
}
|
||||
|
@ -137,15 +136,16 @@ export default class ToggleShowByView extends Backbone.View {
|
|||
let groups = this.showByDate() ? this.groupedByDate : this.groupedByAG
|
||||
this.setAssignmentGroupAssociations(groups)
|
||||
groups = _.filter(groups, group => {
|
||||
const hasWeight = this.course.get('apply_assignment_group_weights') && group.get('group_weight') > 0
|
||||
const hasWeight =
|
||||
this.course.get('apply_assignment_group_weights') && group.get('group_weight') > 0
|
||||
return group.get('assignments').length > 0 || hasWeight
|
||||
})
|
||||
return this.assignmentGroups.reset(groups)
|
||||
}
|
||||
|
||||
setAssignmentGroupAssociations(groups) {
|
||||
(groups || []).forEach(assignment_group => {
|
||||
(assignment_group.get('assignments').models || []).forEach(assignment => {
|
||||
;(groups || []).forEach(assignment_group => {
|
||||
;(assignment_group.get('assignments').models || []).forEach(assignment => {
|
||||
// we are keeping this change on the frontend only (for keyboard nav), will not persist in the db
|
||||
assignment.collection = assignment_group
|
||||
assignment.set('assignment_group_id', assignment_group.id)
|
||||
|
@ -159,7 +159,13 @@ export default class ToggleShowByView extends Backbone.View {
|
|||
}
|
||||
|
||||
cacheKey() {
|
||||
return ['course', this.course.get('id'), 'user', ENV.current_user_id, 'assignments_show_by_date']
|
||||
return [
|
||||
'course',
|
||||
this.course.get('id'),
|
||||
'user',
|
||||
ENV.current_user_id,
|
||||
'assignments_show_by_date'
|
||||
]
|
||||
}
|
||||
|
||||
toggleShowBy(sort) {
|
||||
|
|
|
@ -34,7 +34,6 @@ import '../../jquery/scrollIntoView'
|
|||
const capitalize = string => string.charAt(0).toUpperCase() + string.slice(1)
|
||||
|
||||
export default class AutocompleteView extends Backbone.View {
|
||||
|
||||
static initClass() {
|
||||
// Public: Limit selection to one result.
|
||||
this.optionProperty('single')
|
||||
|
|
|
@ -26,7 +26,6 @@ import 'vendor/bootstrap/bootstrap-dropdown'
|
|||
import 'vendor/bootstrap-select/bootstrap-select'
|
||||
|
||||
export default class CourseSelectionView extends View {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.events = {change: 'onChange'}
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ import 'vendor/bootstrap/bootstrap-dropdown'
|
|||
import 'vendor/bootstrap-select/bootstrap-select'
|
||||
|
||||
export default class InboxHeaderView extends View {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.els = {
|
||||
'#compose-btn': '$composeBtn',
|
||||
|
|
|
@ -35,7 +35,6 @@ import 'jquery.elastic'
|
|||
// #
|
||||
// reusable message composition dialog
|
||||
export default class MessageFormDialog extends DialogBaseView {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.template = template
|
||||
|
||||
|
@ -173,9 +172,7 @@ export default class MessageFormDialog extends DialogBaseView {
|
|||
this.$fullDialog.addClass('compose-message-dialog')
|
||||
|
||||
// add attachment and media buttons to bottom bar
|
||||
this.$fullDialog
|
||||
.find('.ui-dialog-buttonpane')
|
||||
.prepend(composeButtonBarTemplate({}))
|
||||
this.$fullDialog.find('.ui-dialog-buttonpane').prepend(composeButtonBarTemplate({}))
|
||||
|
||||
return (this.$addMediaComment = this.$fullDialog.find('.attach-media'))
|
||||
}
|
||||
|
@ -313,7 +310,7 @@ export default class MessageFormDialog extends DialogBaseView {
|
|||
contextView.render()
|
||||
}
|
||||
|
||||
this.$fullDialog.on('click', '.message-body', (e) => this.handleBodyClick(e))
|
||||
this.$fullDialog.on('click', '.message-body', e => this.handleBodyClick(e))
|
||||
this.$fullDialog.on('click', '.attach-file', () => this.addAttachment())
|
||||
this.$fullDialog.on(
|
||||
'click',
|
||||
|
|
|
@ -64,7 +64,8 @@ export default class MessageView extends View {
|
|||
if (
|
||||
(e && e.target.className.match(/star|read-state/)) ||
|
||||
this.$selectCheckbox[0].contains(e.target)
|
||||
) return
|
||||
)
|
||||
return
|
||||
|
||||
if (e.shiftKey) return this.model.collection.selectRange(this.model)
|
||||
|
||||
|
@ -97,8 +98,8 @@ export default class MessageView extends View {
|
|||
? I18n.t('Starred "%{subject}", Click to unstar.', {subject})
|
||||
: I18n.t('Starred "(No Subject)", Click to unstar.')
|
||||
: subject
|
||||
? I18n.t('Not starred "%{subject}", Click to star.', {subject})
|
||||
: I18n.t('Not starred "(No Subject)", Click to star.')
|
||||
? I18n.t('Not starred "%{subject}", Click to star.', {subject})
|
||||
: I18n.t('Not starred "(No Subject)", Click to star.')
|
||||
this.$starBtnScreenReaderMessage.text(text)
|
||||
}
|
||||
|
||||
|
@ -159,11 +160,11 @@ Object.assign(MessageView.prototype, {
|
|||
'.select-checkbox': '$selectCheckbox'
|
||||
},
|
||||
events: {
|
||||
'click': 'onSelect',
|
||||
click: 'onSelect',
|
||||
'click .open-message': 'onSelect',
|
||||
'click .star-btn': 'toggleStar',
|
||||
'click .read-state': 'toggleRead',
|
||||
'mousedown': 'onMouseDown'
|
||||
mousedown: 'onMouseDown'
|
||||
},
|
||||
messages: {
|
||||
read: I18n.t('Mark as read'),
|
||||
|
|
|
@ -21,7 +21,6 @@ import {View} from 'Backbone'
|
|||
import AutocompleteView from './AutocompleteView'
|
||||
|
||||
export default class SearchView extends View {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.els = {'#search-autocomplete': '$autocomplete'}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import _ from 'underscore'
|
|||
import {View} from 'Backbone'
|
||||
|
||||
export default class SearchableSubmenuView extends View {
|
||||
|
||||
initialize() {
|
||||
super.initialize(...arguments)
|
||||
const content_type = this.$el.children('[data-content-type]').data('content-type')
|
||||
|
|
|
@ -29,7 +29,6 @@ import 'jquery.elastic'
|
|||
// reusable message composition dialog
|
||||
|
||||
export default class SubmissionCommentFormDialog extends DialogBaseView {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.template = template
|
||||
|
||||
|
|
|
@ -113,30 +113,28 @@ export default class SyllabusView extends Backbone.View {
|
|||
let lastEvent = null
|
||||
const dateCollator = function(memo, json) {
|
||||
let due_at, end_at, html_url, start_at, todo_at
|
||||
let related_id = json['related_id']
|
||||
let related_id = json.related_id
|
||||
if (related_id == null) {
|
||||
related_id = json['id']
|
||||
related_id = json.id
|
||||
}
|
||||
if (json['type'] === 'assignment') {
|
||||
if (json.type === 'assignment') {
|
||||
if (html_url_for_assignment) {
|
||||
html_url = json['html_url']
|
||||
}
|
||||
} else {
|
||||
if (html_url_for_event) {
|
||||
html_url = json['html_url']
|
||||
html_url = json.html_url
|
||||
}
|
||||
} else if (html_url_for_event) {
|
||||
html_url = json.html_url
|
||||
}
|
||||
const title = json['title']
|
||||
if (json['start_at']) {
|
||||
start_at = $.fudgeDateForProfileTimezone(Date.parse(json['start_at']))
|
||||
const title = json.title
|
||||
if (json.start_at) {
|
||||
start_at = $.fudgeDateForProfileTimezone(Date.parse(json.start_at))
|
||||
}
|
||||
if (json['end_at']) {
|
||||
end_at = $.fudgeDateForProfileTimezone(Date.parse(json['end_at']))
|
||||
if (json.end_at) {
|
||||
end_at = $.fudgeDateForProfileTimezone(Date.parse(json.end_at))
|
||||
}
|
||||
if (json['type'] === 'assignment') {
|
||||
if (json.type === 'assignment') {
|
||||
due_at = start_at
|
||||
} else if (json['type'] === 'wiki_page' || json['type'] === 'discussion_topic') {
|
||||
todo_at = $.fudgeDateForProfileTimezone(Date.parse(json['todo_at']))
|
||||
} else if (json.type === 'wiki_page' || json.type === 'discussion_topic') {
|
||||
todo_at = $.fudgeDateForProfileTimezone(Date.parse(json.todo_at))
|
||||
}
|
||||
|
||||
let override = null
|
||||
|
@ -151,7 +149,7 @@ export default class SyllabusView extends Backbone.View {
|
|||
let orig_start_date = null
|
||||
if (start_at) {
|
||||
start_date = new Date(start_at.getFullYear(), start_at.getMonth(), start_at.getDate())
|
||||
orig_start_date = Date.parse(json['start_at'])
|
||||
orig_start_date = Date.parse(json.start_at)
|
||||
}
|
||||
|
||||
let end_date = null
|
||||
|
@ -161,7 +159,7 @@ export default class SyllabusView extends Backbone.View {
|
|||
|
||||
if (
|
||||
!lastDate ||
|
||||
(lastDate['date'] != null ? lastDate['date'].getTime() : undefined) !==
|
||||
(lastDate.date != null ? lastDate.date.getTime() : undefined) !==
|
||||
(start_date != null ? start_date.getTime() : undefined)
|
||||
) {
|
||||
lastDate = {
|
||||
|
@ -173,21 +171,19 @@ export default class SyllabusView extends Backbone.View {
|
|||
|
||||
memo.push(lastDate)
|
||||
lastEvent = null
|
||||
} else {
|
||||
if (lastEvent) {
|
||||
lastEvent['last'] = false
|
||||
}
|
||||
} else if (lastEvent) {
|
||||
lastEvent.last = false
|
||||
}
|
||||
|
||||
lastEvent = {
|
||||
related_id: related_id,
|
||||
type: json['type'],
|
||||
title: title,
|
||||
html_url: html_url,
|
||||
start_at: start_at,
|
||||
end_at: end_at,
|
||||
due_at: due_at,
|
||||
todo_at: todo_at,
|
||||
related_id,
|
||||
type: json.type,
|
||||
title,
|
||||
html_url,
|
||||
start_at,
|
||||
end_at,
|
||||
due_at,
|
||||
todo_at,
|
||||
same_day:
|
||||
(start_date != null ? start_date.getTime() : undefined) ===
|
||||
(end_date != null ? end_date.getTime() : undefined),
|
||||
|
@ -195,12 +191,12 @@ export default class SyllabusView extends Backbone.View {
|
|||
(start_at != null ? start_at.getTime() : undefined) ===
|
||||
(end_at != null ? end_at.getTime() : undefined),
|
||||
last: true,
|
||||
override: override,
|
||||
json: json,
|
||||
workflow_state: json['workflow_state']
|
||||
override,
|
||||
json,
|
||||
workflow_state: json.workflow_state
|
||||
}
|
||||
|
||||
lastDate['events'].push(lastEvent)
|
||||
lastDate.events.push(lastEvent)
|
||||
|
||||
if (!(related_id in relatedEvents)) {
|
||||
relatedEvents[related_id] = []
|
||||
|
@ -215,13 +211,13 @@ export default class SyllabusView extends Backbone.View {
|
|||
|
||||
// Remove extraneous override information for single events
|
||||
let overrides_present = false
|
||||
for (let id in relatedEvents) {
|
||||
for (const id in relatedEvents) {
|
||||
const events = relatedEvents[id]
|
||||
if (events.length === 1) {
|
||||
events[0]['override'] = null
|
||||
events[0].override = null
|
||||
} else {
|
||||
for (let event of Array.from(events)) {
|
||||
overrides_present |= event['override'] !== null
|
||||
for (const event of Array.from(events)) {
|
||||
overrides_present |= event.override !== null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import template from 'jst/courses/roster/createUsers'
|
|||
import wrapper from 'jst/EmptyDialogFormWrapper'
|
||||
|
||||
export default class CreateUsersView extends DialogFormView {
|
||||
|
||||
static initClass() {
|
||||
this.optionProperty('rolesCollection')
|
||||
this.optionProperty('courseModel')
|
||||
|
|
|
@ -25,7 +25,6 @@ import '../../../jquery.rails_flash_notifications'
|
|||
import 'jquery.disableWhileLoading'
|
||||
|
||||
export default class EditRolesView extends DialogBaseView {
|
||||
|
||||
static initClass() {
|
||||
this.mixin(RosterDialogMixin)
|
||||
|
||||
|
@ -65,7 +64,9 @@ export default class EditRolesView extends DialogBaseView {
|
|||
const enrollments = this.model.enrollments()
|
||||
|
||||
// section ids that already have the new role
|
||||
const existing_section_ids = _.filter(enrollments, en => en.role_id === new_role_id).map(en => en.course_section_id)
|
||||
const existing_section_ids = _.filter(enrollments, en => en.role_id === new_role_id).map(
|
||||
en => en.course_section_id
|
||||
)
|
||||
|
||||
const new_enrollments = []
|
||||
const deleted_enrollments = []
|
||||
|
|
|
@ -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 I18n from 'i18n!course_settings'
|
||||
import $ from 'jquery'
|
||||
import _ from 'underscore'
|
||||
|
@ -29,7 +28,6 @@ import '../../../jquery.rails_flash_notifications'
|
|||
import 'jquery.disableWhileLoading'
|
||||
|
||||
export default class EditSectionsView extends DialogBaseView {
|
||||
|
||||
static initClass() {
|
||||
this.mixin(RosterDialogMixin)
|
||||
|
||||
|
@ -88,9 +86,9 @@ export default class EditSectionsView extends DialogBaseView {
|
|||
const $sections = this.$('#user_sections')
|
||||
return (() => {
|
||||
const result = []
|
||||
for (let e of Array.from(this.model.sectionEditableEnrollments())) {
|
||||
for (const e of Array.from(this.model.sectionEditableEnrollments())) {
|
||||
var section
|
||||
if ((section = ENV.CONTEXTS['sections'][e.course_section_id])) {
|
||||
if ((section = ENV.CONTEXTS.sections[e.course_section_id])) {
|
||||
result.push(
|
||||
$sections.append(
|
||||
sectionTemplate({
|
||||
|
@ -145,7 +143,7 @@ export default class EditSectionsView extends DialogBaseView {
|
|||
const newEnrollments = []
|
||||
const deferreds = []
|
||||
// create new enrollments
|
||||
for (let id of Array.from(newSections)) {
|
||||
for (const id of Array.from(newSections)) {
|
||||
url = `/api/v1/sections/${id}/enrollments`
|
||||
const data = {
|
||||
enrollment: {
|
||||
|
@ -173,7 +171,7 @@ export default class EditSectionsView extends DialogBaseView {
|
|||
const enrollmentsToRemove = _.filter(this.model.sectionEditableEnrollments(), en =>
|
||||
_.includes(sectionsToRemove, en.course_section_id)
|
||||
)
|
||||
for (let en of Array.from(enrollmentsToRemove)) {
|
||||
for (const en of Array.from(enrollmentsToRemove)) {
|
||||
url = `${ENV.COURSE_ROOT_URL}/unenroll/${en.id}`
|
||||
deferreds.push($.ajaxJSON(url, 'DELETE'))
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import linkToStudentsViewTemplate from 'jst/courses/roster/LinkToStudentsView'
|
|||
import 'jquery.disableWhileLoading'
|
||||
|
||||
export default class LinkToStudentsView extends DialogBaseView {
|
||||
|
||||
static initClass() {
|
||||
this.mixin(RosterDialogMixin)
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ let linkToStudentsDialog = null
|
|||
let invitationDialog = null
|
||||
|
||||
export default class RosterUserView extends Backbone.View {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.tagName = 'tr'
|
||||
|
||||
|
@ -104,8 +103,8 @@ export default class RosterUserView extends Backbone.View {
|
|||
)
|
||||
? ENV.permissions.manage_admin_users
|
||||
: this.model.hasEnrollmentType('ObserverEnrollment')
|
||||
? ENV.permissions.manage_admin_users || ENV.permissions.manage_students
|
||||
: ENV.permissions.manage_students
|
||||
? ENV.permissions.manage_admin_users || ENV.permissions.manage_students
|
||||
: ENV.permissions.manage_students
|
||||
json.customLinks = this.model.get('custom_links')
|
||||
|
||||
if (json.canViewLoginIdColumn) {
|
||||
|
@ -125,7 +124,7 @@ export default class RosterUserView extends Backbone.View {
|
|||
const observerEnrollments = _.filter(json.enrollments, en => en.type === 'ObserverEnrollment')
|
||||
json.enrollments = _.reject(json.enrollments, en => en.type === 'ObserverEnrollment')
|
||||
|
||||
json.sections = _.map(json.enrollments, en => ENV.CONTEXTS['sections'][en.course_section_id])
|
||||
json.sections = _.map(json.enrollments, en => ENV.CONTEXTS.sections[en.course_section_id])
|
||||
|
||||
const users = {}
|
||||
if (
|
||||
|
@ -134,7 +133,7 @@ export default class RosterUserView extends Backbone.View {
|
|||
) {
|
||||
users[''] = {name: I18n.t('nobody', 'nobody')}
|
||||
} else {
|
||||
for (let en of Array.from(observerEnrollments)) {
|
||||
for (const en of Array.from(observerEnrollments)) {
|
||||
if (!en.observed_user) {
|
||||
continue
|
||||
}
|
||||
|
@ -147,7 +146,7 @@ export default class RosterUserView extends Backbone.View {
|
|||
|
||||
return (() => {
|
||||
const result = []
|
||||
for (let id in users) {
|
||||
for (const id in users) {
|
||||
user = users[id]
|
||||
const ob = {
|
||||
role: I18n.t('observing_user', 'Observing: %{user_name}', {user_name: user.name})
|
||||
|
@ -202,7 +201,7 @@ export default class RosterUserView extends Backbone.View {
|
|||
return
|
||||
}
|
||||
const deferreds = []
|
||||
for (let en of Array.from(this.model.get('enrollments'))) {
|
||||
for (const en of Array.from(this.model.get('enrollments'))) {
|
||||
if (en.enrollment_state !== 'inactive') {
|
||||
const url = `/api/v1/courses/${ENV.course.id}/enrollments/${en.id}?task=deactivate`
|
||||
en.enrollment_state = 'inactive'
|
||||
|
@ -226,7 +225,7 @@ export default class RosterUserView extends Backbone.View {
|
|||
|
||||
reactivateUser() {
|
||||
const deferreds = []
|
||||
for (let en of Array.from(this.model.get('enrollments'))) {
|
||||
for (const en of Array.from(this.model.get('enrollments'))) {
|
||||
const url = `/api/v1/courses/${ENV.course.id}/enrollments/${en.id}/reactivate`
|
||||
en.enrollment_state = 'active'
|
||||
deferreds.push($.ajaxJSON(url, 'PUT'))
|
||||
|
|
|
@ -23,7 +23,6 @@ import ValidatedMixin from '../../ValidatedMixin'
|
|||
import AddPeopleApp from 'jsx/add_people/add_people_app'
|
||||
|
||||
export default class RosterView extends Backbone.View {
|
||||
|
||||
static initClass() {
|
||||
this.mixin(ValidatedMixin)
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ export default class FeatureFlagAdminView extends Backbone.View {
|
|||
}
|
||||
|
||||
shouldShowTitles(features) {
|
||||
const counts = _.map(this.featureGroups, key => features[key] ? features[key].length : 0)
|
||||
const counts = _.map(this.featureGroups, key => (features[key] ? features[key].length : 0))
|
||||
return _.reject(counts, count => count === 0).length > 1
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
import _ from 'underscore'
|
||||
import CollectionView from '../CollectionView'
|
||||
import FeatureFlagView from '../feature_flags/FeatureFlagView'
|
||||
import FeatureFlagView from './FeatureFlagView'
|
||||
import template from 'jst/feature_flags/featureFlagList'
|
||||
|
||||
export default class FeatureFlagListView extends CollectionView {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
import $ from 'jquery'
|
||||
import Backbone from 'Backbone'
|
||||
import FeatureFlagDialog from '../feature_flags/FeatureFlagDialog'
|
||||
import FeatureFlagDialog from './FeatureFlagDialog'
|
||||
import template from 'jst/feature_flags/featureFlag'
|
||||
import I18n from 'i18n!feature_flags'
|
||||
|
||||
|
@ -90,11 +90,11 @@ export default class FeatureFlagView extends Backbone.View {
|
|||
checkSiteAdmin() {
|
||||
const deferred = $.Deferred()
|
||||
if (!this.model.isSiteAdmin()) {
|
||||
return deferred.resolve();
|
||||
return deferred.resolve()
|
||||
}
|
||||
const view = new FeatureFlagDialog({
|
||||
deferred,
|
||||
message: I18n.t("This will affect every customer. Are you sure?"),
|
||||
message: I18n.t('This will affect every customer. Are you sure?'),
|
||||
title: this.model.get('display_name'),
|
||||
hasCancelButton: true
|
||||
})
|
||||
|
|
|
@ -57,7 +57,9 @@ export default class OutcomeDetailView extends DialogBaseView {
|
|||
outcome: this.model
|
||||
})
|
||||
|
||||
this.allAlignments.on('fetched:last', () => this.alignmentsForView.reset(this.allAlignments.toArray()));
|
||||
this.allAlignments.on('fetched:last', () =>
|
||||
this.alignmentsForView.reset(this.allAlignments.toArray())
|
||||
)
|
||||
|
||||
return this.allAlignments.fetch()
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import $ from 'jquery'
|
|||
import '../../../jquery/outerclick'
|
||||
|
||||
export default class AddUnassignedMenu extends PopoverMenuView {
|
||||
|
||||
static initClass() {
|
||||
this.child('usersView', '[data-view=users]')
|
||||
this.child('inputFilterView', '[data-view=inputFilter]')
|
||||
|
|
|
@ -24,12 +24,13 @@ import '../../../jquery/outerclick'
|
|||
|
||||
export default class AssignToGroupMenu extends PopoverMenuView {
|
||||
static initClass() {
|
||||
this.prototype.defaults = Object.assign({}, PopoverMenuView.prototype.defaults, {zIndex: 10})
|
||||
this.prototype.defaults = {...PopoverMenuView.prototype.defaults, zIndex: 10}
|
||||
|
||||
this.prototype.events = Object.assign({}, PopoverMenuView.prototype.events, {
|
||||
this.prototype.events = {
|
||||
...PopoverMenuView.prototype.events,
|
||||
'click .set-group': 'setGroup',
|
||||
'focusin .focus-bound': 'boundFocused'
|
||||
})
|
||||
}
|
||||
|
||||
this.prototype.tagName = 'div'
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ import Group from '../../../models/Group'
|
|||
import template from 'jst/groups/manage/groupCategoryDetail'
|
||||
|
||||
export default class GroupCategoryDetailView extends View {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.template = template
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ export default class GroupCategoryView extends View {
|
|||
|
||||
filterChange(event) {
|
||||
const search_term = event.target.value
|
||||
if (search_term === _previousSearchTerm) return //Don't rerender if nothing has changed
|
||||
if (search_term === _previousSearchTerm) return // Don't rerender if nothing has changed
|
||||
|
||||
this.options.unassignedUsersView.setFilter(search_term)
|
||||
|
||||
|
@ -155,8 +155,8 @@ export default class GroupCategoryView extends View {
|
|||
this.model.get('allows_multiple_memberships')
|
||||
? I18n.t('everyone', 'Everyone (%{count})', {count})
|
||||
: ENV.group_user_type === 'student'
|
||||
? I18n.t('unassigned_students', 'Unassigned Students (%{count})', {count})
|
||||
: I18n.t('unassigned_users', 'Unassigned Users (%{count})', {count})
|
||||
? I18n.t('unassigned_students', 'Unassigned Students (%{count})', {count})
|
||||
: I18n.t('unassigned_users', 'Unassigned Users (%{count})', {count})
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -75,10 +75,11 @@ export default class GroupEditView extends DialogFormView {
|
|||
}
|
||||
|
||||
toJSON() {
|
||||
const json = Object.assign({}, super.toJSON(...arguments), {
|
||||
const json = {
|
||||
...super.toJSON(...arguments),
|
||||
role: this.groupCategory.get('role'),
|
||||
nameOnly: this.options.nameOnly
|
||||
})
|
||||
}
|
||||
return json
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,11 +52,11 @@ export default class GroupUserView extends View {
|
|||
|
||||
toJSON() {
|
||||
const group = this.model.get('group')
|
||||
const result = Object.assign(
|
||||
{groupId: group && group.id},
|
||||
this,
|
||||
super.toJSON(...arguments)
|
||||
)
|
||||
const result = {
|
||||
groupId: group && group.id,
|
||||
...this,
|
||||
...super.toJSON(...arguments)
|
||||
}
|
||||
result.shouldMarkInactive =
|
||||
this.options.markInactiveStudents && this.model.attributes.is_inactive
|
||||
result.isLeader = this.isLeader()
|
||||
|
@ -65,8 +65,16 @@ export default class GroupUserView extends View {
|
|||
|
||||
isLeader() {
|
||||
// transpiled from: @model.get('group')?.get?('leader')?.id == @model.get('id')
|
||||
let ref, ref1;
|
||||
return ((ref = this.model.get('group')) != null ? typeof ref.get === "function" ? (ref1 = ref.get('leader')) != null ? ref1.id : void 0 : void 0 : void 0) === this.model.get('id');
|
||||
let ref, ref1
|
||||
return (
|
||||
((ref = this.model.get('group')) != null
|
||||
? typeof ref.get === 'function'
|
||||
? (ref1 = ref.get('leader')) != null
|
||||
? ref1.id
|
||||
: void 0
|
||||
: void 0
|
||||
: void 0) === this.model.get('id')
|
||||
)
|
||||
}
|
||||
}
|
||||
GroupUserView.initClass()
|
||||
|
|
|
@ -27,7 +27,6 @@ import 'jqueryui/draggable'
|
|||
import 'jqueryui/droppable'
|
||||
|
||||
export default class GroupUsersView extends PaginatedCollectionView {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.defaults = {
|
||||
...PaginatedCollectionView.prototype.defaults,
|
||||
|
@ -223,7 +222,7 @@ export default class GroupUsersView extends PaginatedCollectionView {
|
|||
|
||||
// enable draggable on the child GroupUserView (view)
|
||||
_initDrag(view) {
|
||||
view.$el.draggable(Object.assign({}, this.dragOptions))
|
||||
view.$el.draggable({...this.dragOptions})
|
||||
return view.$el.on('dragstart', (event, ui) => {
|
||||
ui.helper.css('width', view.$el.width())
|
||||
$(event.target).draggable('option', 'containment', 'document')
|
||||
|
|
|
@ -22,7 +22,6 @@ import GroupCategoryCloneView from './GroupCategoryCloneView'
|
|||
import groupHasSubmissions from '../../../util/groupHasSubmissions'
|
||||
|
||||
export default class GroupView extends View {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.tagName = 'li'
|
||||
|
||||
|
@ -79,7 +78,7 @@ export default class GroupView extends View {
|
|||
} else {
|
||||
// enable droppable on the child GroupView (view)
|
||||
if (!this.$el.data('droppable')) {
|
||||
this.$el.droppable(Object.assign({}, this.dropOptions)).on('drop', this._onDrop.bind(this))
|
||||
this.$el.droppable({...this.dropOptions}).on('drop', this._onDrop.bind(this))
|
||||
}
|
||||
return this.$el.removeClass('slots-full')
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import wrapper from 'jst/EmptyDialogFormWrapper'
|
|||
import groupHasSubmissions from '../../../util/groupHasSubmissions'
|
||||
|
||||
export default class RandomlyAssignMembersView extends DialogFormView {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.defaults = {
|
||||
title: I18n.t('randomly_assigning_members', 'Randomly Assigning Students'),
|
||||
|
|
|
@ -22,7 +22,7 @@ let $document, $window
|
|||
const CLASS_ATTRIBUTE = 'ui-cnvs-scrollable'
|
||||
const SCROLL_RATE = 10
|
||||
|
||||
let $footer = $window = $document = null
|
||||
let $footer = ($window = $document = null)
|
||||
const p = str => parseInt(str, 10)
|
||||
|
||||
export default {
|
||||
|
|
|
@ -78,7 +78,7 @@ export default class UnassignedUsersView extends GroupUsersView {
|
|||
this.collection.load('first')
|
||||
this.$el
|
||||
.parent()
|
||||
.droppable(Object.assign({}, this.dropOptions))
|
||||
.droppable({...this.dropOptions})
|
||||
.unbind('drop')
|
||||
.on('drop', this._onDrop.bind(this))
|
||||
this.scrollContainer = this.heightContainer = this.$el
|
||||
|
|
|
@ -15,57 +15,56 @@
|
|||
// 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 I18n from "i18n!context_modules";
|
||||
import I18n from 'i18n!context_modules'
|
||||
|
||||
import Backbone from "Backbone";
|
||||
import template from "jst/modules/ProgressionModuleView";
|
||||
import Backbone from 'Backbone'
|
||||
import template from 'jst/modules/ProgressionModuleView'
|
||||
|
||||
let ProgressionModuleView;
|
||||
let ProgressionModuleView
|
||||
|
||||
export default ProgressionModuleView = (function() {
|
||||
ProgressionModuleView = class ProgressionModuleView extends Backbone.View {
|
||||
static initClass() {
|
||||
|
||||
this.prototype.tagName = 'li';
|
||||
this.prototype.className = 'progressionModule';
|
||||
this.prototype.template = template;
|
||||
this.prototype.tagName = 'li'
|
||||
this.prototype.className = 'progressionModule'
|
||||
this.prototype.template = template
|
||||
|
||||
this.prototype.statuses = {
|
||||
"started" : I18n.t("module_started", "In Progress"),
|
||||
"completed" : I18n.t("module_complete", "Complete"),
|
||||
"unlocked" : I18n.t("module_unlocked", "Unlocked"),
|
||||
"locked" : I18n.t("module_locked", "Locked")
|
||||
};
|
||||
started: I18n.t('module_started', 'In Progress'),
|
||||
completed: I18n.t('module_complete', 'Complete'),
|
||||
unlocked: I18n.t('module_unlocked', 'Unlocked'),
|
||||
locked: I18n.t('module_locked', 'Locked')
|
||||
}
|
||||
|
||||
this.prototype.iconClasses = {
|
||||
'ModuleItem' : "icon-module",
|
||||
'File' : "icon-paperclip",
|
||||
'Page' : "icon-document",
|
||||
'Discussion' : "icon-discussion",
|
||||
'Assignment' : "icon-assignment",
|
||||
'Quiz' : "icon-quiz",
|
||||
'ExternalTool' : "icon-link",
|
||||
'Lti::MessageHandler' : "icon-link"
|
||||
};
|
||||
ModuleItem: 'icon-module',
|
||||
File: 'icon-paperclip',
|
||||
Page: 'icon-document',
|
||||
Discussion: 'icon-discussion',
|
||||
Assignment: 'icon-assignment',
|
||||
Quiz: 'icon-quiz',
|
||||
ExternalTool: 'icon-link',
|
||||
'Lti::MessageHandler': 'icon-link'
|
||||
}
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
const json = super.toJSON(...arguments);
|
||||
json.student_id = this.model.collection.student_id;
|
||||
json.status_text = this.statuses[json.state];
|
||||
json[json.state] = true;
|
||||
const json = super.toJSON(...arguments)
|
||||
json.student_id = this.model.collection.student_id
|
||||
json.status_text = this.statuses[json.state]
|
||||
json[json.state] = true
|
||||
|
||||
for (let item of json.items) {
|
||||
item.icon_class = this.iconClasses[item.type] || this.iconClasses['ModuleItem'];
|
||||
for (const item of json.items) {
|
||||
item.icon_class = this.iconClasses[item.type] || this.iconClasses.ModuleItem
|
||||
}
|
||||
return json;
|
||||
return json
|
||||
}
|
||||
|
||||
afterRender() {
|
||||
super.afterRender(...arguments);
|
||||
return this.model.collection.syncHeight();
|
||||
super.afterRender(...arguments)
|
||||
return this.model.collection.syncHeight()
|
||||
}
|
||||
};
|
||||
ProgressionModuleView.initClass();
|
||||
return ProgressionModuleView;
|
||||
})();
|
||||
}
|
||||
ProgressionModuleView.initClass()
|
||||
return ProgressionModuleView
|
||||
})()
|
||||
|
|
|
@ -15,30 +15,29 @@
|
|||
// 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 Backbone from "Backbone";
|
||||
import ModuleCollection from "../../collections/ModuleCollection";
|
||||
import template from "jst/modules/ProgressionStudentView";
|
||||
import collectionTemplate from "jst/modules/ProgressionModuleCollection";
|
||||
import PaginatedCollectionView from "../PaginatedCollectionView";
|
||||
import ProgressionModuleView from "./ProgressionModuleView";
|
||||
import Backbone from 'Backbone'
|
||||
import ModuleCollection from '../../collections/ModuleCollection'
|
||||
import template from 'jst/modules/ProgressionStudentView'
|
||||
import collectionTemplate from 'jst/modules/ProgressionModuleCollection'
|
||||
import PaginatedCollectionView from '../PaginatedCollectionView'
|
||||
import ProgressionModuleView from './ProgressionModuleView'
|
||||
|
||||
export default class ProgressionStudentView extends Backbone.View {
|
||||
|
||||
initialize() {
|
||||
super.initialize(...arguments);
|
||||
this.$index = this.model.collection.view.$el;
|
||||
this.$students = this.$index.find('#progression_students');
|
||||
return this.$modules = this.$index.find('#progression_modules');
|
||||
super.initialize(...arguments)
|
||||
this.$index = this.model.collection.view.$el
|
||||
this.$students = this.$index.find('#progression_students')
|
||||
return (this.$modules = this.$index.find('#progression_modules'))
|
||||
}
|
||||
|
||||
afterRender() {
|
||||
super.afterRender(...arguments);
|
||||
if (!this.model.collection.currentStudentView) this.showProgressions();
|
||||
return this.syncHeight();
|
||||
super.afterRender(...arguments)
|
||||
if (!this.model.collection.currentStudentView) this.showProgressions()
|
||||
return this.syncHeight()
|
||||
}
|
||||
|
||||
createProgressions() {
|
||||
const studentId = this.model.get('id');
|
||||
const studentId = this.model.get('id')
|
||||
const modules = new ModuleCollection(null, {
|
||||
course_id: ENV.COURSE_ID,
|
||||
per_page: 50,
|
||||
|
@ -46,12 +45,12 @@ export default class ProgressionStudentView extends Backbone.View {
|
|||
student_id: studentId,
|
||||
include: ['items']
|
||||
}
|
||||
});
|
||||
modules.student_id = studentId;
|
||||
modules.syncHeight = this.syncHeight;
|
||||
modules.fetch();
|
||||
})
|
||||
modules.student_id = studentId
|
||||
modules.syncHeight = this.syncHeight
|
||||
modules.fetch()
|
||||
|
||||
const studentUrl = `${ENV.COURSE_USERS_PATH}/${studentId}`;
|
||||
const studentUrl = `${ENV.COURSE_USERS_PATH}/${studentId}`
|
||||
this.progressions = new PaginatedCollectionView({
|
||||
collection: modules,
|
||||
itemView: ProgressionModuleView,
|
||||
|
@ -59,46 +58,46 @@ export default class ProgressionStudentView extends Backbone.View {
|
|||
student: this.model.attributes,
|
||||
studentUrl,
|
||||
autoFetch: true
|
||||
});
|
||||
})
|
||||
|
||||
this.progressions.render();
|
||||
return this.progressions.$el.appendTo(this.$modules);
|
||||
this.progressions.render()
|
||||
return this.progressions.$el.appendTo(this.$modules)
|
||||
}
|
||||
|
||||
showProgressions() {
|
||||
this.$modules.attr('aria-busy', 'true');
|
||||
this.$modules.attr('aria-busy', 'true')
|
||||
if (this.model.collection.currentStudentView != null) {
|
||||
this.model.collection.currentStudentView.hideProgressions();
|
||||
this.model.collection.currentStudentView.hideProgressions()
|
||||
}
|
||||
this.model.collection.currentStudentView = this;
|
||||
this.model.collection.currentStudentView = this
|
||||
|
||||
this.syncHeight();
|
||||
this.$el.addClass('active').attr('aria-selected', true);
|
||||
this.syncHeight()
|
||||
this.$el.addClass('active').attr('aria-selected', true)
|
||||
if (!this.progressions) {
|
||||
return this.createProgressions();
|
||||
return this.createProgressions()
|
||||
} else {
|
||||
return this.progressions.show();
|
||||
return this.progressions.show()
|
||||
}
|
||||
}
|
||||
|
||||
hideProgressions() {
|
||||
this.progressions.hide();
|
||||
return this.$el.removeClass('active').removeAttr('aria-selected');
|
||||
this.progressions.hide()
|
||||
return this.$el.removeClass('active').removeAttr('aria-selected')
|
||||
}
|
||||
|
||||
syncHeight = () => {
|
||||
return setTimeout(() => {
|
||||
this.$students.height(this.$modules.height());
|
||||
return this.$students.find('.collectionViewItems').
|
||||
height((this.$students.height() || 0) - (this.$students.find('.header').height() || 16) - 16);
|
||||
}
|
||||
, 0);
|
||||
this.$students.height(this.$modules.height())
|
||||
return this.$students
|
||||
.find('.collectionViewItems')
|
||||
.height(
|
||||
(this.$students.height() || 0) - (this.$students.find('.header').height() || 16) - 16
|
||||
)
|
||||
}, 0)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ProgressionStudentView.prototype.tagName = 'li'
|
||||
ProgressionStudentView.prototype.className = 'student'
|
||||
ProgressionStudentView.prototype.template = template
|
||||
ProgressionStudentView.prototype.events = {click: 'showProgressions'}
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ export default class RelockModulesDialog extends DialogBaseView {
|
|||
{
|
||||
text: I18n.t('continue', 'Continue'),
|
||||
class: 'btn-primary',
|
||||
click: (e) => this.cancel(e)
|
||||
click: e => this.cancel(e)
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ import {subscribe} from 'vendor/jquery.ba-tinypubsub'
|
|||
// It uses OutcomeView and OutcomeGroupView to render
|
||||
|
||||
export default class ContentView extends Backbone.View {
|
||||
|
||||
initialize({readOnly, setQuizMastery, useForScoring, instructionsTemplate, renderInstructions}) {
|
||||
this.readOnly = readOnly
|
||||
this.setQuizMastery = setQuizMastery
|
||||
|
@ -147,7 +146,7 @@ export default class ContentView extends Backbone.View {
|
|||
focusStyleClass: 'MoveDialog__folderItem--focused',
|
||||
selectedStyleClass: 'MoveDialog__folderItem--selected',
|
||||
onlyShowSubtrees: true,
|
||||
onClick: function() {
|
||||
onClick() {
|
||||
TreeBrowserView.prototype.setActiveTree(this, treeBrowser)
|
||||
}
|
||||
}).render()
|
||||
|
|
|
@ -30,7 +30,6 @@ import 'jquery.disableWhileLoading'
|
|||
|
||||
// Creates a popup dialog similar to the main outcomes browser minus the toolbar.
|
||||
export default class FindDialog extends DialogBaseView {
|
||||
|
||||
dialogOptions() {
|
||||
return {
|
||||
id: 'import_dialog',
|
||||
|
@ -43,12 +42,12 @@ export default class FindDialog extends DialogBaseView {
|
|||
buttons: [
|
||||
{
|
||||
text: I18n.t('#buttons.cancel', 'Cancel'),
|
||||
click: (e) => this.cancel(e)
|
||||
click: e => this.cancel(e)
|
||||
},
|
||||
{
|
||||
text: I18n.t('#buttons.import', 'Import'),
|
||||
class: 'btn-primary',
|
||||
click: (e) => this.import(e)
|
||||
click: e => this.import(e)
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -125,11 +124,12 @@ export default class FindDialog extends DialogBaseView {
|
|||
source_outcome_group_id: model.get('id'),
|
||||
async: true
|
||||
})
|
||||
.pipe((resp) => {
|
||||
progress.set('url', resp.url);
|
||||
progress.poll();
|
||||
return progress.pollDfd;
|
||||
}).pipe(() => $.ajaxJSON(progress.get('results').outcome_group_url, 'GET'));
|
||||
.pipe(resp => {
|
||||
progress.set('url', resp.url)
|
||||
progress.poll()
|
||||
return progress.pollDfd
|
||||
})
|
||||
.pipe(() => $.ajaxJSON(progress.get('results').outcome_group_url, 'GET'))
|
||||
} else {
|
||||
url = this.selectedGroup.get('outcomes_url')
|
||||
dfd = $.ajaxJSON(url, 'POST', {outcome_id: model.get('id')})
|
||||
|
@ -153,7 +153,14 @@ export default class FindDialog extends DialogBaseView {
|
|||
this.close()
|
||||
return $.flashMessage(I18n.t('flash.importSuccess', 'Import successful'))
|
||||
})
|
||||
.fail(() => $.flashError(I18n.t('flash.importError', "An error occurred while importing. Please try again later.")));
|
||||
.fail(() =>
|
||||
$.flashError(
|
||||
I18n.t(
|
||||
'flash.importError',
|
||||
'An error occurred while importing. Please try again later.'
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,10 +90,12 @@ export default class FindDirectoryView extends OutcomesDirectoryView {
|
|||
// wait for. This adds a 'setTimeout' which calls reset that fixes display
|
||||
// issues and hooks up the click handlers to the sidebar.
|
||||
return this.$el.disableWhileLoading(
|
||||
$.when(...Array.from(dfds || [])).done(() => setTimeout(() => {
|
||||
this.reset();
|
||||
return this.$el.find('[tabindex=0]:first').focus();
|
||||
}))
|
||||
$.when(...Array.from(dfds || [])).done(() =>
|
||||
setTimeout(() => {
|
||||
this.reset()
|
||||
return this.$el.find('[tabindex=0]:first').focus()
|
||||
})
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ import 'jqueryui/draggable'
|
|||
// and provides an API for keydown events and for selecting
|
||||
// elements.
|
||||
export default class OutcomeIconBase extends Backbone.View {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.tagName = 'li'
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import outcomeFormTemplate from 'jst/outcomes/outcomeForm'
|
|||
import criterionTemplate from 'jst/outcomes/_criterion'
|
||||
import criterionHeaderTemplate from 'jst/outcomes/_criterionHeader'
|
||||
import {showConfirmOutcomeEdit} from 'jsx/outcomes/ConfirmOutcomeEditModal'
|
||||
import { addCriterionInfoButton } from 'jsx/outcomes/CriterionInfo'
|
||||
import {addCriterionInfoButton} from 'jsx/outcomes/CriterionInfo'
|
||||
import 'jqueryui/dialog'
|
||||
|
||||
// For outcomes in the main content view.
|
||||
|
@ -128,14 +128,19 @@ export default class OutcomeView extends OutcomeContentBase {
|
|||
|
||||
editRating(e) {
|
||||
e.preventDefault()
|
||||
const childIdx = $(e.currentTarget).closest('.rating').index()
|
||||
const $th = $(`.criterion thead tr > th:nth-child(${childIdx+1})`)
|
||||
const childIdx = $(e.currentTarget)
|
||||
.closest('.rating')
|
||||
.index()
|
||||
const $th = $(`.criterion thead tr > th:nth-child(${childIdx + 1})`)
|
||||
const $showWrapper = $(e.currentTarget).parents('.show:first')
|
||||
const $editWrapper = $showWrapper.next()
|
||||
|
||||
$showWrapper.attr('aria-expanded', 'false').hide()
|
||||
$editWrapper.attr('aria-expanded', 'true').show()
|
||||
$th.find('h5').attr('aria-expanded', 'false').hide()
|
||||
$th
|
||||
.find('h5')
|
||||
.attr('aria-expanded', 'false')
|
||||
.hide()
|
||||
return $editWrapper.find('.outcome_rating_description').focus()
|
||||
}
|
||||
|
||||
|
@ -145,7 +150,7 @@ export default class OutcomeView extends OutcomeContentBase {
|
|||
if (this.$('.rating').length > 1) {
|
||||
const deleteBtn = $(e.currentTarget)
|
||||
const childIdx = deleteBtn.closest('.rating').index()
|
||||
const $th = $(`.criterion thead tr > th:nth-child(${childIdx+1})`)
|
||||
const $th = $(`.criterion thead tr > th:nth-child(${childIdx + 1})`)
|
||||
let focusTarget = deleteBtn
|
||||
.closest('.rating')
|
||||
.prev()
|
||||
|
@ -165,8 +170,10 @@ export default class OutcomeView extends OutcomeContentBase {
|
|||
|
||||
saveRating(e) {
|
||||
e.preventDefault()
|
||||
const childIdx = $(e.currentTarget).closest('.rating').index()
|
||||
const $th = $(`.criterion thead tr > th:nth-child(${childIdx+1})`)
|
||||
const childIdx = $(e.currentTarget)
|
||||
.closest('.rating')
|
||||
.index()
|
||||
const $th = $(`.criterion thead tr > th:nth-child(${childIdx + 1})`)
|
||||
const $editWrapper = $(e.currentTarget).parents('.edit:first')
|
||||
const $showWrapper = $editWrapper.prev()
|
||||
$th.find('h5').text($editWrapper.find('input.outcome_rating_description').val())
|
||||
|
@ -179,7 +186,10 @@ export default class OutcomeView extends OutcomeContentBase {
|
|||
$showWrapper.find('.points').text(points)
|
||||
$editWrapper.attr('aria-expanded', 'false').hide()
|
||||
$showWrapper.attr('aria-expanded', 'true').show()
|
||||
$th.find('h5').attr('aria-expanded', 'true').show()
|
||||
$th
|
||||
.find('h5')
|
||||
.attr('aria-expanded', 'true')
|
||||
.show()
|
||||
$showWrapper.find('.edit_rating').focus()
|
||||
return this.updateRatings()
|
||||
}
|
||||
|
@ -187,21 +197,21 @@ export default class OutcomeView extends OutcomeContentBase {
|
|||
insertRating(e) {
|
||||
e.preventDefault()
|
||||
const $rating = $(criterionTemplate({description: '', points: '', _index: 99}))
|
||||
const childIdx = $(e.currentTarget).closest('.rating-header').index()
|
||||
const childIdx = $(e.currentTarget)
|
||||
.closest('.rating-header')
|
||||
.index()
|
||||
const $ratingHeader = $(criterionHeaderTemplate({description: '', _index: 99}))
|
||||
const $tr = $('.criterion tbody tr')
|
||||
$(e.currentTarget)
|
||||
.closest('.rating-header')
|
||||
.after($ratingHeader)
|
||||
$tr.find(`> td:nth-child(${childIdx+1})`).after($rating)
|
||||
$tr.find(`> td:nth-child(${childIdx + 1})`).after($rating)
|
||||
$rating
|
||||
.find('.show')
|
||||
.hide()
|
||||
.next()
|
||||
.show(200)
|
||||
$ratingHeader
|
||||
.hide()
|
||||
.show(200)
|
||||
$ratingHeader.hide().show(200)
|
||||
$rating.find('.edit input:first').focus()
|
||||
return this.updateRatings()
|
||||
}
|
||||
|
@ -272,13 +282,15 @@ export default class OutcomeView extends OutcomeContentBase {
|
|||
case 'edit':
|
||||
case 'add':
|
||||
this.$el.html(
|
||||
outcomeFormTemplate(_.extend(data, {
|
||||
calculationMethods: this.model.calculationMethods(),
|
||||
use_rce_enhancements: ENV.use_rce_enhancements
|
||||
}))
|
||||
outcomeFormTemplate(
|
||||
_.extend(data, {
|
||||
calculationMethods: this.model.calculationMethods(),
|
||||
use_rce_enhancements: ENV.use_rce_enhancements
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
addCriterionInfoButton(this.$el.find("#react-info-link")[0])
|
||||
addCriterionInfoButton(this.$el.find('#react-info-link')[0])
|
||||
|
||||
this.readyForm()
|
||||
break
|
||||
|
|
|
@ -33,7 +33,6 @@ import '../../jquery.rails_flash_notifications'
|
|||
|
||||
// The outcome group "directory" browser.
|
||||
export default class OutcomesDirectoryView extends PaginatedView {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.tagName = 'ul'
|
||||
this.prototype.className = 'outcome-level'
|
||||
|
|
|
@ -28,7 +28,6 @@ import FindDirectoryView from './FindDirectoryView'
|
|||
let findDialog
|
||||
|
||||
export default class SidebarView extends Backbone.View {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.directoryWidth = 200
|
||||
this.prototype.entryHeight = 30
|
||||
|
@ -130,7 +129,7 @@ export default class SidebarView extends Backbone.View {
|
|||
// Select the directory view and optionally select an Outcome or Group.
|
||||
selectDir(dir, selectedModel) {
|
||||
// If root selection is an outcome, don't have a dir. Get root most dir to clear selection.
|
||||
const useDir = dir ? dir : this.directories[0]
|
||||
const useDir = dir || this.directories[0]
|
||||
if (useDir && !selectedModel) useDir.clearSelection()
|
||||
|
||||
// remove all directories after the selected dir from @directories and the view
|
||||
|
@ -172,11 +171,11 @@ export default class SidebarView extends Backbone.View {
|
|||
|
||||
selectedGroup() {
|
||||
let g = null
|
||||
this._findLastDir((d) => {
|
||||
if (d.selectedModel instanceof OutcomeGroup) {
|
||||
return g = d.selectedModel;
|
||||
}
|
||||
});
|
||||
this._findLastDir(d => {
|
||||
if (d.selectedModel instanceof OutcomeGroup) {
|
||||
return (g = d.selectedModel)
|
||||
}
|
||||
})
|
||||
return g || this.rootOutcomeGroup
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import OutcomeGroup from '../../models/OutcomeGroup'
|
|||
|
||||
// Manage the toolbar buttons.
|
||||
export default class ToolbarView extends Backbone.View {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.events = {
|
||||
'click .go_back': 'goBack',
|
||||
|
|
|
@ -27,7 +27,6 @@ import {completeUpload} from 'jsx/shared/upload_file'
|
|||
import template from 'jst/profiles/avatarDialog'
|
||||
|
||||
export default class AvatarDialogView extends DialogBaseView {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.template = template
|
||||
|
||||
|
@ -151,10 +150,10 @@ export default class AvatarDialogView extends DialogBaseView {
|
|||
const message = _.isString(errors.base)
|
||||
? errors.base
|
||||
: _.isArray(errors.base)
|
||||
? errors.base.reduce(errorReducer, '')
|
||||
: I18n.t(
|
||||
'Your profile photo could not be uploaded. You may have exceeded your upload limit.'
|
||||
)
|
||||
? errors.base.reduce(errorReducer, '')
|
||||
: I18n.t(
|
||||
'Your profile photo could not be uploaded. You may have exceeded your upload limit.'
|
||||
)
|
||||
|
||||
$.flashError(message)
|
||||
return this.enableSelectButton()
|
||||
|
@ -217,7 +216,7 @@ export default class AvatarDialogView extends DialogBaseView {
|
|||
}).then(_.partial(this.updateDomAvatar, url))
|
||||
}
|
||||
|
||||
updateDomAvatar = (url) => {
|
||||
updateDomAvatar = url => {
|
||||
$('.profile_pic_link, .profile-link').css('background-image', `url('${url}')`)
|
||||
return this.close()
|
||||
}
|
||||
|
|
|
@ -46,7 +46,9 @@ export default class ProfileShow extends Backbone.View {
|
|||
if (!confirm(I18n.t('Are you sure you want to report this profile picture?'))) return
|
||||
const link = $(e.currentTarget)
|
||||
$('.avatar').hide()
|
||||
return $.ajaxJSON(link.attr('href'), 'POST', {}, data => $.flashMessage(I18n.t('The profile picture has been reported')))
|
||||
return $.ajaxJSON(link.attr('href'), 'POST', {}, data =>
|
||||
$.flashMessage(I18n.t('The profile picture has been reported'))
|
||||
)
|
||||
}
|
||||
|
||||
handleDeclarativeClick(event) {
|
||||
|
|
|
@ -23,7 +23,6 @@ import 'jquery.instructure_forms'
|
|||
import 'jquery.disableWhileLoading'
|
||||
|
||||
export default class FileUploadQuestion extends View {
|
||||
|
||||
static initClass() {
|
||||
// TODO: Handle quota errors?
|
||||
// TODO: Handle upload errors?
|
||||
|
|
|
@ -42,7 +42,7 @@ export default class IndexView extends Backbone.View {
|
|||
this.filterResults()
|
||||
return this.announceCount()
|
||||
}, 200)
|
||||
//ie10 x-close workaround
|
||||
// ie10 x-close workaround
|
||||
}
|
||||
|
||||
initialize() {
|
||||
|
|
|
@ -65,17 +65,18 @@ export default class LDBLoginPopup extends Backbone.View {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
initialize(options) {
|
||||
// @property {window} whnd The popup window handle.
|
||||
// @private
|
||||
let whnd = undefined
|
||||
let whnd
|
||||
|
||||
// @property {CSSStyleSheet[]} styleSheets
|
||||
// @private
|
||||
//
|
||||
// The set of stylesheets to inject into the dialog, parsed from the current
|
||||
// page's available stylesheets.
|
||||
let styleSheets = undefined
|
||||
let styleSheets
|
||||
|
||||
// @property {jQuery} $delegate
|
||||
// @private
|
||||
|
@ -92,7 +93,7 @@ export default class LDBLoginPopup extends Backbone.View {
|
|||
// instead of binding to 'click', 'mousedown', or 'keydown' handlers on all
|
||||
// of window, document, and document.body to ensure that everything gets
|
||||
// captured.
|
||||
let $inputSink = undefined
|
||||
let $inputSink
|
||||
|
||||
_.extend(this.options, options)
|
||||
|
||||
|
@ -258,7 +259,7 @@ export default class LDBLoginPopup extends Backbone.View {
|
|||
})
|
||||
|
||||
if (this.options.sticky) {
|
||||
let relaunch = undefined
|
||||
let relaunch
|
||||
|
||||
this.on('login_failure.sticky', () => (relaunch = true))
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import template from 'jst/quizzes/QuizItemGroupView'
|
|||
import QuizItemView from './QuizItemView'
|
||||
|
||||
export default class ItemGroupView extends CollectionView {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.template = template
|
||||
this.prototype.itemView = QuizItemView
|
||||
|
@ -72,8 +71,8 @@ export default class ItemGroupView extends CollectionView {
|
|||
const title = model.get('title').toLowerCase()
|
||||
let numMatches = 0
|
||||
const keys = term.toLowerCase().split(' ')
|
||||
for (let part of keys) {
|
||||
//not using match to avoid javascript string to regex oddness
|
||||
for (const part of keys) {
|
||||
// not using match to avoid javascript string to regex oddness
|
||||
if (title.indexOf(part) !== -1) {
|
||||
numMatches++
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import template from 'jst/quizzes/QuizItemView'
|
|||
import 'jquery.disableWhileLoading'
|
||||
|
||||
export default class ItemView extends Backbone.View {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.template = template
|
||||
|
||||
|
@ -48,7 +47,7 @@ export default class ItemView extends Backbone.View {
|
|||
'click .delete-item': 'onDelete',
|
||||
'click .migrate': 'migrateQuiz',
|
||||
'click .quiz-copy-to': 'copyQuizTo',
|
||||
'click .quiz-send-to': 'sendQuizTo',
|
||||
'click .quiz-send-to': 'sendQuizTo'
|
||||
}
|
||||
|
||||
this.prototype.messages = {
|
||||
|
|
|
@ -23,7 +23,6 @@ import 'jquery.instructure_forms'
|
|||
import 'jquery.ajaxJSON'
|
||||
|
||||
export default class SelfEnrollmentForm extends Backbone.View {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.events = {
|
||||
'change input[name=initial_action]': 'changeAction',
|
||||
|
@ -147,7 +146,7 @@ export default class SelfEnrollmentForm extends Backbone.View {
|
|||
logOut(refresh = false) {
|
||||
return $.ajaxJSON('/logout', 'DELETE', {}, () => {
|
||||
if (refresh) location.reload(true)
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
logOutAndRefresh(e) {
|
||||
|
|
|
@ -59,7 +59,7 @@ export default class EditRubricPage {
|
|||
}
|
||||
this.$els.dialog.show()
|
||||
return this.$els.dialog.$el.find('.alert').focus()
|
||||
};
|
||||
}
|
||||
|
||||
onOutcomeImport(model) {
|
||||
return rubricEditing.onFindOutcome(model)
|
||||
|
|
|
@ -28,7 +28,6 @@ import 'jqueryui/dialog'
|
|||
import 'mathquill'
|
||||
|
||||
export default class EquationEditorView extends Backbone.View {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.template = template
|
||||
|
||||
|
@ -44,7 +43,7 @@ export default class EquationEditorView extends Backbone.View {
|
|||
}
|
||||
}
|
||||
|
||||
//#
|
||||
// #
|
||||
// class method
|
||||
//
|
||||
// like $.text() / Sizzle.getText(elems), except it also gets alt
|
||||
|
@ -59,7 +58,7 @@ export default class EquationEditorView extends Backbone.View {
|
|||
// Get the text from text nodes and CDATA nodes
|
||||
if ([3, 4].includes(elem.nodeType)) {
|
||||
if (elem.nodeValue.match(/^<img/)) {
|
||||
//if the "text" is really just an unparsed "img" node
|
||||
// if the "text" is really just an unparsed "img" node
|
||||
// then we really want the alt element
|
||||
return self.getEquationText($(elem.nodeValue))
|
||||
} else {
|
||||
|
@ -78,7 +77,7 @@ export default class EquationEditorView extends Backbone.View {
|
|||
} else if (elem.nodeType !== 8) {
|
||||
return self.getEquationText(elem.childNodes)
|
||||
}
|
||||
}).join('');
|
||||
}).join('')
|
||||
}
|
||||
|
||||
getEquationText(elems) {
|
||||
|
@ -113,7 +112,7 @@ export default class EquationEditorView extends Backbone.View {
|
|||
{
|
||||
class: 'btn-primary',
|
||||
text: I18n.t('button.insert_equation', 'Insert Equation'),
|
||||
click: (e) => this.onSubmit(e)
|
||||
click: e => this.onSubmit(e)
|
||||
}
|
||||
]
|
||||
})
|
||||
|
|
|
@ -24,7 +24,7 @@ import htmlEscape from 'str/htmlEscape'
|
|||
import FileBrowser from 'jsx/shared/rce/FileBrowser'
|
||||
import DialogBaseView from '../DialogBaseView'
|
||||
import template from 'jst/tinymce/InsertUpdateImageView'
|
||||
import { send } from 'jsx/shared/rce/RceCommandShim'
|
||||
import {send} from 'jsx/shared/rce/RceCommandShim'
|
||||
import FindFlickrImageView from '../FindFlickrImageView'
|
||||
|
||||
export default class InsertUpdateImageView extends DialogBaseView {
|
||||
|
@ -75,21 +75,23 @@ export default class InsertUpdateImageView extends DialogBaseView {
|
|||
case 'tabUploaded':
|
||||
loadTab(done => {
|
||||
ReactDOM.render(
|
||||
<FileBrowser allowUpload={true}
|
||||
contentTypes={["image/*"]}
|
||||
selectFile={this.setSelectedImage}
|
||||
useContextAssets={true} />,
|
||||
<FileBrowser
|
||||
allowUpload
|
||||
contentTypes={['image/*']}
|
||||
selectFile={this.setSelectedImage}
|
||||
useContextAssets
|
||||
/>,
|
||||
this.$el[0].querySelector('#tabUploaded'),
|
||||
done
|
||||
)
|
||||
})
|
||||
break;
|
||||
break
|
||||
case 'tabFlickr':
|
||||
loadTab(done => {
|
||||
new FindFlickrImageView().render().$el.appendTo(ui.panel)
|
||||
done()
|
||||
})
|
||||
break;
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,7 +172,7 @@ export default class InsertUpdateImageView extends DialogBaseView {
|
|||
if (val) res[key] = val
|
||||
}
|
||||
if (this.$("[name='image[data-decorative]']").is(':checked')) {
|
||||
res['alt'] = ''
|
||||
res.alt = ''
|
||||
res['data-decorative'] = true
|
||||
}
|
||||
res['data-mce-src'] = res.src
|
||||
|
|
|
@ -31,7 +31,6 @@ import 'jquery.instructure_date_and_time'
|
|||
RichContentEditor.preloadRemoteModule()
|
||||
|
||||
export default class WikiPageEditView extends ValidatedFormView {
|
||||
|
||||
static initClass() {
|
||||
this.mixin({
|
||||
els: {
|
||||
|
@ -137,7 +136,7 @@ export default class WikiPageEditView extends ValidatedFormView {
|
|||
return this.$studentTodoAtContainer.toggle()
|
||||
}
|
||||
|
||||
handleStudentTodoUpdate = (newDate) => {
|
||||
handleStudentTodoUpdate = newDate => {
|
||||
this.studentTodoAtDateValue = newDate
|
||||
return this.renderStudentTodoAtDate()
|
||||
}
|
||||
|
|
|
@ -37,13 +37,14 @@ export default class WikiPageIndexEditDialog extends DialogFormView {
|
|||
|
||||
this.prototype.wrapperTemplate = wrapperTemplate
|
||||
}
|
||||
|
||||
template() {
|
||||
return ''
|
||||
}
|
||||
|
||||
initialize(options = {}) {
|
||||
this.returnFocusTo = options.returnFocusTo
|
||||
return super.initialize({...dialogDefaults, ...options});
|
||||
return super.initialize({...dialogDefaults, ...options})
|
||||
}
|
||||
|
||||
setupDialog() {
|
||||
|
|
|
@ -231,7 +231,7 @@ export default class WikiPageIndexItemView extends Backbone.View {
|
|||
.find('.al-trigger')
|
||||
$(cogs[curIndex]).focus()
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
useAsFrontPage(ev) {
|
||||
|
@ -257,7 +257,7 @@ export default class WikiPageIndexItemView extends Backbone.View {
|
|||
const cogs = $('.collectionViewItems').find('.al-trigger')
|
||||
$(cogs[curIndex]).focus()
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
sendWikiPageTo(ev) {
|
||||
|
|
|
@ -119,7 +119,7 @@ export default class WikiPageIndexView extends PaginatedCollectionView {
|
|||
if (!this.$sortHeaders) return
|
||||
|
||||
const {sortOrders} = this.collection
|
||||
for (let sortHeader of Array.from(this.$sortHeaders)) {
|
||||
for (const sortHeader of Array.from(this.$sortHeaders)) {
|
||||
const $sortHeader = $(sortHeader)
|
||||
const $i = $sortHeader.find('i')
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ export default class ComboBox {
|
|||
// items are opaque to the combo box. Whenever the selection changes, the
|
||||
// 'change' event on this object will be triggered with the item as
|
||||
// argument.
|
||||
constructor (items, opts = {}) {
|
||||
constructor(items, opts = {}) {
|
||||
this.items = items
|
||||
|
||||
// override item transforms
|
||||
|
@ -73,7 +73,7 @@ export default class ComboBox {
|
|||
|
||||
// #
|
||||
// Select a specific item by value.
|
||||
select (value) {
|
||||
select(value) {
|
||||
const oldIndex = this._index()
|
||||
this.$menu.val(value)
|
||||
|
||||
|
@ -89,21 +89,21 @@ export default class ComboBox {
|
|||
|
||||
// #
|
||||
// Retrieve the currently selected item.
|
||||
selected () {
|
||||
selected() {
|
||||
return this.items[this._index()]
|
||||
}
|
||||
|
||||
// #
|
||||
// @api private
|
||||
// The index of the selected item.
|
||||
_index () {
|
||||
_index() {
|
||||
return this.$menu[0].selectedIndex
|
||||
}
|
||||
|
||||
// #
|
||||
// @api private
|
||||
// Select the previous item in the combo.
|
||||
_previous = (e) => {
|
||||
_previous = e => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
|
@ -115,7 +115,7 @@ export default class ComboBox {
|
|||
// #
|
||||
// @api private
|
||||
// Select the next item in the combo.
|
||||
_next = (e) => {
|
||||
_next = e => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
|
@ -126,14 +126,14 @@ export default class ComboBox {
|
|||
// #
|
||||
// @api private
|
||||
// Default item to value conversion.
|
||||
_value (item) {
|
||||
_value(item) {
|
||||
return item.value
|
||||
}
|
||||
|
||||
// #
|
||||
// @api private
|
||||
// Default item to label conversion.
|
||||
_label (item) {
|
||||
_label(item) {
|
||||
return item.label
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import I18n from 'i18n!recipient_input'
|
|||
import $ from 'jquery'
|
||||
import _ from 'underscore'
|
||||
import contextList from '../util/contextList'
|
||||
import _TokenInput from '../widget/TokenInput'
|
||||
import _TokenInput from './TokenInput'
|
||||
import avatarTemplate from 'jst/_avatar'
|
||||
import _inherits from '@babel/runtime/helpers/esm/inheritsLoose'
|
||||
import newless from 'newless'
|
||||
|
|
|
@ -36,21 +36,31 @@ const datepickerDefaults = {
|
|||
|
||||
// localization values understood by $.datepicker
|
||||
isRTL: isRTL(),
|
||||
get prevText(){ return I18n.t('prevText', 'Prev')}, // title text for previous month icon
|
||||
get nextText(){ return I18n.t('nextText', 'Next')}, // title text for next month icon
|
||||
get prevText() {
|
||||
return I18n.t('prevText', 'Prev')
|
||||
}, // title text for previous month icon
|
||||
get nextText() {
|
||||
return I18n.t('nextText', 'Next')
|
||||
}, // title text for next month icon
|
||||
monthNames: I18n.lookup('date.month_names').slice(1), // names of months
|
||||
monthNamesShort: I18n.lookup('date.abbr_month_names').slice(1), // abbreviated names of months
|
||||
dayNames: I18n.lookup('date.day_names'), // title text for column headings
|
||||
dayNamesShort: I18n.lookup('date.abbr_day_names'), // title text for column headings
|
||||
dayNamesMin: I18n.lookup('date.datepicker.column_headings'), // column headings for days (Sunday = 0)
|
||||
get firstDay(){ return I18n.t('first_day_index', '0')}, // first day of the week (Sun = 0)
|
||||
get showMonthAfterYear(){ return I18n.t('#date.formats.medium_month').slice(0, 2) === '%Y'} // "month year" or "year month"
|
||||
get firstDay() {
|
||||
return I18n.t('first_day_index', '0')
|
||||
}, // first day of the week (Sun = 0)
|
||||
get showMonthAfterYear() {
|
||||
return I18n.t('#date.formats.medium_month').slice(0, 2) === '%Y'
|
||||
} // "month year" or "year month"
|
||||
}
|
||||
|
||||
// adds datepicker and suggest functionality to the specified $field
|
||||
export default class DatetimeField {
|
||||
constructor ($field, options = {}) {
|
||||
['alertScreenreader', 'setFromValue', 'setDatetime', 'setTime', 'setDate'].forEach(m => this[m] = this[m].bind(this))
|
||||
constructor($field, options = {}) {
|
||||
;['alertScreenreader', 'setFromValue', 'setDatetime', 'setTime', 'setDate'].forEach(
|
||||
m => (this[m] = this[m].bind(this))
|
||||
)
|
||||
let $wrapper
|
||||
this.$field = $field
|
||||
this.$field.data({instance: this})
|
||||
|
@ -75,7 +85,7 @@ export default class DatetimeField {
|
|||
this.setFromValue()
|
||||
}
|
||||
|
||||
processTimeOptions (options) {
|
||||
processTimeOptions(options) {
|
||||
// default undefineds to false
|
||||
let {timeOnly, dateOnly} = options
|
||||
const {alwaysShowTime} = options
|
||||
|
@ -95,16 +105,21 @@ export default class DatetimeField {
|
|||
this.alwaysShowTime = this.allowTime && (timeOnly || alwaysShowTime)
|
||||
}
|
||||
|
||||
addDatePicker (options) {
|
||||
addDatePicker(options) {
|
||||
this.$field.wrap('<div class="input-append" />')
|
||||
const $wrapper = this.$field.parent('.input-append')
|
||||
if (!this.isReadonly()) {
|
||||
const datepickerOptions = $.extend({}, this.datepickerDefaults(), {
|
||||
timePicker: this.allowTime,
|
||||
beforeShow: () => this.$field.trigger('detachTooltip'),
|
||||
onClose: () => this.$field.trigger('reattachTooltip'),
|
||||
firstDay: moment.localeData(ENV.MOMENT_LOCALE).firstDayOfWeek(),
|
||||
}, options.datepicker)
|
||||
const datepickerOptions = $.extend(
|
||||
{},
|
||||
this.datepickerDefaults(),
|
||||
{
|
||||
timePicker: this.allowTime,
|
||||
beforeShow: () => this.$field.trigger('detachTooltip'),
|
||||
onClose: () => this.$field.trigger('reattachTooltip'),
|
||||
firstDay: moment.localeData(ENV.MOMENT_LOCALE).firstDayOfWeek()
|
||||
},
|
||||
options.datepicker
|
||||
)
|
||||
this.$field.datepicker(datepickerOptions)
|
||||
|
||||
// TEMPORARY FIX: Hide from aria screenreader until the jQuery UI datepicker is updated for accessibility.
|
||||
|
@ -116,7 +131,7 @@ export default class DatetimeField {
|
|||
return $wrapper
|
||||
}
|
||||
|
||||
addSuggests ($sibling, options = {}) {
|
||||
addSuggests($sibling, options = {}) {
|
||||
if (this.isReadonly()) return
|
||||
this.courseTimezone = options.courseTimezone || ENV.CONTEXT_TIMEZONE
|
||||
this.$suggest = $('<div class="datetime_suggest" />').insertAfter($sibling)
|
||||
|
@ -125,7 +140,7 @@ export default class DatetimeField {
|
|||
}
|
||||
}
|
||||
|
||||
addHiddenInput () {
|
||||
addHiddenInput() {
|
||||
this.$hiddenInput = $('<input type="hidden">').insertAfter(this.$field)
|
||||
this.$hiddenInput.attr('name', this.$field.attr('name'))
|
||||
this.$hiddenInput.val(this.$field.val())
|
||||
|
@ -134,7 +149,7 @@ export default class DatetimeField {
|
|||
}
|
||||
|
||||
// public API
|
||||
setDate (date) {
|
||||
setDate(date) {
|
||||
if (!this.showDate) {
|
||||
this.implicitDate = date
|
||||
return this.setFromValue()
|
||||
|
@ -143,21 +158,21 @@ export default class DatetimeField {
|
|||
}
|
||||
}
|
||||
|
||||
setTime (date) {
|
||||
setTime(date) {
|
||||
return this.setFormattedDatetime(date, 'time.formats.tiny')
|
||||
}
|
||||
|
||||
setDatetime (date) {
|
||||
setDatetime(date) {
|
||||
return this.setFormattedDatetime(date, 'date.formats.full')
|
||||
}
|
||||
|
||||
// private API
|
||||
setFromValue () {
|
||||
setFromValue() {
|
||||
this.parseValue()
|
||||
this.update()
|
||||
}
|
||||
|
||||
normalizeValue (value) {
|
||||
normalizeValue(value) {
|
||||
if (value == null) return value
|
||||
|
||||
// trim leading/trailing whitespace
|
||||
|
@ -187,7 +202,7 @@ export default class DatetimeField {
|
|||
}
|
||||
}
|
||||
|
||||
parseValue () {
|
||||
parseValue() {
|
||||
const value = this.normalizeValue(this.$field.val())
|
||||
this.datetime = tz.parse(value)
|
||||
if (this.datetime && !this.showDate && this.implicitDate) {
|
||||
|
@ -199,7 +214,7 @@ export default class DatetimeField {
|
|||
this.invalid = !this.blank && this.datetime === null
|
||||
}
|
||||
|
||||
setFormattedDatetime (datetime, format) {
|
||||
setFormattedDatetime(datetime, format) {
|
||||
if (datetime) {
|
||||
this.blank = false
|
||||
this.datetime = datetime
|
||||
|
@ -216,14 +231,14 @@ export default class DatetimeField {
|
|||
this.update()
|
||||
}
|
||||
|
||||
update (updates) {
|
||||
update(updates) {
|
||||
this.updateData()
|
||||
this.updateSuggest()
|
||||
this.updateAria()
|
||||
}
|
||||
|
||||
updateData () {
|
||||
const iso8601 = this.datetime && this.datetime.toISOString() || ''
|
||||
updateData() {
|
||||
const iso8601 = (this.datetime && this.datetime.toISOString()) || ''
|
||||
this.$field.data({
|
||||
'unfudged-date': this.datetime,
|
||||
date: this.fudged,
|
||||
|
@ -243,24 +258,24 @@ export default class DatetimeField {
|
|||
this.$field.data({
|
||||
'time-hour': null,
|
||||
'time-minute': null,
|
||||
'time-ampm': null,
|
||||
'time-ampm': null
|
||||
})
|
||||
} else if (tz.useMeridian()) {
|
||||
this.$field.data({
|
||||
'time-hour': tz.format(this.datetime, '%-l'),
|
||||
'time-minute': tz.format(this.datetime, '%M'),
|
||||
'time-ampm': tz.format(this.datetime, '%P'),
|
||||
'time-ampm': tz.format(this.datetime, '%P')
|
||||
})
|
||||
} else {
|
||||
this.$field.data({
|
||||
'time-hour': tz.format(this.datetime, '%-k'),
|
||||
'time-minute': tz.format(this.datetime, '%M'),
|
||||
'time-ampm': null,
|
||||
'time-ampm': null
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
updateSuggest () {
|
||||
updateSuggest() {
|
||||
if (this.isReadonly()) return
|
||||
|
||||
let localText = this.formatSuggest()
|
||||
|
@ -277,7 +292,7 @@ export default class DatetimeField {
|
|||
this.$suggest.toggleClass('invalid_datetime', this.invalid).text(localText)
|
||||
}
|
||||
|
||||
alertScreenreader () {
|
||||
alertScreenreader() {
|
||||
// only alert if the value in the field changed (e.g. don't alert on arrow
|
||||
// keys). not debouncing around alertScreenreader itself, because if so,
|
||||
// the retrieval of val() here gets delayed and can do weird stuff while
|
||||
|
@ -289,11 +304,11 @@ export default class DatetimeField {
|
|||
}
|
||||
}
|
||||
|
||||
updateAria () {
|
||||
updateAria() {
|
||||
this.$field.attr('aria-invalid', !!this.invalid)
|
||||
}
|
||||
|
||||
formatSuggest () {
|
||||
formatSuggest() {
|
||||
if (this.blank) {
|
||||
return ''
|
||||
} else if (this.invalid) {
|
||||
|
@ -303,7 +318,7 @@ export default class DatetimeField {
|
|||
}
|
||||
}
|
||||
|
||||
formatSuggestCourse () {
|
||||
formatSuggestCourse() {
|
||||
if (this.blank) {
|
||||
return ''
|
||||
} else if (this.invalid) {
|
||||
|
@ -315,7 +330,7 @@ export default class DatetimeField {
|
|||
}
|
||||
}
|
||||
|
||||
formatString () {
|
||||
formatString() {
|
||||
if (this.showDate && this.showTime) {
|
||||
return I18n.t('#date.formats.full_with_weekday')
|
||||
} else if (this.showDate) {
|
||||
|
@ -325,11 +340,11 @@ export default class DatetimeField {
|
|||
}
|
||||
}
|
||||
|
||||
isReadonly () {
|
||||
isReadonly() {
|
||||
return !!this.$field.attr('readonly')
|
||||
}
|
||||
|
||||
datepickerDefaults () {
|
||||
datepickerDefaults() {
|
||||
return datepickerDefaults
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import $ from 'jquery'
|
||||
import _ from 'underscore'
|
||||
import TokenSelectorList from '../widget/TokenSelectorList'
|
||||
import TokenSelectorList from './TokenSelectorList'
|
||||
import RecipientCollection from '../collections/RecipientCollection'
|
||||
import 'jquery.instructure_misc_helpers'
|
||||
import '../jquery/scrollIntoView'
|
||||
|
@ -106,16 +106,14 @@ export default class TokenSelector {
|
|||
}
|
||||
} else if (this.selectionToggleable() && $(e.target).closest('a.toggle').length) {
|
||||
this.toggleSelection()
|
||||
} else if (this.selectionExpanded()) {
|
||||
this.collapse()
|
||||
} else if (this.selectionExpandable()) {
|
||||
this.expandSelection()
|
||||
} else {
|
||||
if (this.selectionExpanded()) {
|
||||
this.collapse()
|
||||
} else if (this.selectionExpandable()) {
|
||||
this.expandSelection()
|
||||
} else {
|
||||
this.toggleSelection(true)
|
||||
this.clear()
|
||||
this.close()
|
||||
}
|
||||
this.toggleSelection(true)
|
||||
this.clear()
|
||||
this.close()
|
||||
}
|
||||
}
|
||||
return this.input.focus()
|
||||
|
@ -452,15 +450,15 @@ export default class TokenSelector {
|
|||
? this.selection.next().length
|
||||
? this.selection.next()
|
||||
: this.selection.parent('ul').next().length
|
||||
? this.selection
|
||||
.parent('ul')
|
||||
.next()
|
||||
.find('li')
|
||||
.first()
|
||||
: null
|
||||
? this.selection
|
||||
.parent('ul')
|
||||
.next()
|
||||
.find('li')
|
||||
.first()
|
||||
: null
|
||||
: this.list != null
|
||||
? this.list.first()
|
||||
: undefined,
|
||||
? this.list.first()
|
||||
: undefined,
|
||||
preserveMode
|
||||
)
|
||||
if (this.selection != null ? this.selection.hasClass('message') : undefined) {
|
||||
|
@ -476,15 +474,15 @@ export default class TokenSelector {
|
|||
: undefined)
|
||||
? this.selection.prev()
|
||||
: this.selection.parent('ul').prev().length
|
||||
? this.selection
|
||||
.parent('ul')
|
||||
.prev()
|
||||
.find('li')
|
||||
.last()
|
||||
: null
|
||||
? this.selection
|
||||
.parent('ul')
|
||||
.prev()
|
||||
.find('li')
|
||||
.last()
|
||||
: null
|
||||
: this.list != null
|
||||
? this.list.last()
|
||||
: undefined
|
||||
? this.list.last()
|
||||
: undefined
|
||||
)
|
||||
if (this.selection != null ? this.selection.hasClass('message') : undefined) {
|
||||
return this.selectPrev()
|
||||
|
@ -543,6 +541,7 @@ export default class TokenSelector {
|
|||
}
|
||||
return postData
|
||||
}
|
||||
|
||||
collectionForQuery(query) {
|
||||
if (this.lastFetch != null) {
|
||||
this.lastFetch.abort()
|
||||
|
|
|
@ -21,7 +21,6 @@ import PaginatedView from '../views/PaginatedView'
|
|||
import 'jquery.disableWhileLoading'
|
||||
|
||||
export default class TokenSelectorList extends PaginatedView {
|
||||
|
||||
static initClass() {
|
||||
this.prototype.tagName = 'div'
|
||||
this.prototype.className = 'list'
|
||||
|
|
|
@ -24,7 +24,7 @@ import $ from 'jquery'
|
|||
export default class UploadMediaTrackForm {
|
||||
// video url needs to be the url to mp4 version of the video.
|
||||
// it will be passed along to amara.org
|
||||
constructor (mediaCommentId, video_url) {
|
||||
constructor(mediaCommentId, video_url) {
|
||||
this.mediaCommentId = mediaCommentId
|
||||
this.video_url = video_url
|
||||
const templateVars = {
|
||||
|
@ -32,20 +32,25 @@ export default class UploadMediaTrackForm {
|
|||
video_url: this.video_url,
|
||||
is_amazon_url: this.video_url.search(/.mp4/) !== -1
|
||||
}
|
||||
this.$dialog = $(template(templateVars)).appendTo('body').dialog({
|
||||
width: 650,
|
||||
resizable: false,
|
||||
buttons: [{
|
||||
'data-text-while-loading': I18n.t('cancel', 'Cancel'),
|
||||
text: I18n.t('cancel', 'Cancel'),
|
||||
click: () => this.$dialog.remove()
|
||||
}, {
|
||||
class: 'btn-primary',
|
||||
'data-text-while-loading': I18n.t('uploading', 'Uploading...'),
|
||||
text: I18n.t('upload', 'Upload'),
|
||||
click: this.onSubmit
|
||||
}]
|
||||
})
|
||||
this.$dialog = $(template(templateVars))
|
||||
.appendTo('body')
|
||||
.dialog({
|
||||
width: 650,
|
||||
resizable: false,
|
||||
buttons: [
|
||||
{
|
||||
'data-text-while-loading': I18n.t('cancel', 'Cancel'),
|
||||
text: I18n.t('cancel', 'Cancel'),
|
||||
click: () => this.$dialog.remove()
|
||||
},
|
||||
{
|
||||
class: 'btn-primary',
|
||||
'data-text-while-loading': I18n.t('uploading', 'Uploading...'),
|
||||
text: I18n.t('upload', 'Upload'),
|
||||
click: this.onSubmit
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
onSubmit = () => {
|
||||
|
@ -53,31 +58,43 @@ export default class UploadMediaTrackForm {
|
|||
submitDfd.fail(() => this.$dialog.find('.invalidInputMsg').show())
|
||||
|
||||
this.$dialog.disableWhileLoading(submitDfd)
|
||||
this.getFileContent().fail(() => submitDfd.reject()).done((content) => {
|
||||
const params = {
|
||||
content,
|
||||
locale: this.$dialog.find('[name="locale"]').val(),
|
||||
}
|
||||
this.getFileContent()
|
||||
.fail(() => submitDfd.reject())
|
||||
.done(content => {
|
||||
const params = {
|
||||
content,
|
||||
locale: this.$dialog.find('[name="locale"]').val()
|
||||
}
|
||||
|
||||
if (!params.content || !params.locale) return submitDfd.reject()
|
||||
if (!params.content || !params.locale) return submitDfd.reject()
|
||||
|
||||
|
||||
return $.ajaxJSON(`/media_objects/${this.mediaCommentId}/media_tracks`, 'POST', params, () => {
|
||||
submitDfd.resolve()
|
||||
this.$dialog.dialog('close')
|
||||
$.flashMessage(I18n.t('track_uploaded_successfully', 'Track uploaded successfully; please refresh your browser.'))
|
||||
}, () => {
|
||||
submitDfd.reject()
|
||||
return $.ajaxJSON(
|
||||
`/media_objects/${this.mediaCommentId}/media_tracks`,
|
||||
'POST',
|
||||
params,
|
||||
() => {
|
||||
submitDfd.resolve()
|
||||
this.$dialog.dialog('close')
|
||||
$.flashMessage(
|
||||
I18n.t(
|
||||
'track_uploaded_successfully',
|
||||
'Track uploaded successfully; please refresh your browser.'
|
||||
)
|
||||
)
|
||||
},
|
||||
() => {
|
||||
submitDfd.reject()
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
getFileContent () {
|
||||
getFileContent() {
|
||||
const dfd = new $.Deferred()
|
||||
const file = this.$dialog.find('input[name="content"]')[0].files[0]
|
||||
if (file) {
|
||||
const reader = new FileReader()
|
||||
reader.onload = function (e) {
|
||||
reader.onload = function(e) {
|
||||
const content = e.target.result
|
||||
return dfd.resolve(content)
|
||||
}
|
||||
|
|
|
@ -22,28 +22,27 @@ import 'jqueryui/dialog'
|
|||
import 'vendor/jquery.ba-tinypubsub'
|
||||
|
||||
const assignmentRubricDialog = {
|
||||
|
||||
// the markup for the trigger should look like:
|
||||
// <a class="rubric_dialog_trigger" href="#" data-rubric-exists="<%= !!attached_rubric %>" data-url="<%= context_url(@topic.assignment.context, :context_assignment_rubric_url, @topic.assignment.id) %>">
|
||||
// <%= attached_rubric ? t(:show_rubric, "Show Rubric") : t(:add_rubric, "Add Rubric") %>
|
||||
// </a>
|
||||
initTriggers () {
|
||||
initTriggers() {
|
||||
const $trigger = $('.rubric_dialog_trigger')
|
||||
if ($trigger) {
|
||||
this.noRubricExists = $trigger.data('noRubricExists')
|
||||
const selector = $trigger.data('focusReturnsTo')
|
||||
try {
|
||||
this.$focusReturnsTo = $(document.querySelector(selector))
|
||||
} catch(err) {}
|
||||
} catch (err) {}
|
||||
|
||||
$trigger.click((event) => {
|
||||
$trigger.click(event => {
|
||||
event.preventDefault()
|
||||
assignmentRubricDialog.openDialog()
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
initDialog () {
|
||||
initDialog() {
|
||||
this.dialogInited = true
|
||||
|
||||
this.$dialog = $(`<div><h4>${htmlEscape(I18n.t('loading', 'Loading...'))}</h4></div>`).dialog({
|
||||
|
@ -55,11 +54,13 @@ const assignmentRubricDialog = {
|
|||
close: () => this.$focusReturnsTo.focus()
|
||||
})
|
||||
|
||||
return $.get(ENV.DISCUSSION.GRADED_RUBRICS_URL, (html) => {
|
||||
return $.get(ENV.DISCUSSION.GRADED_RUBRICS_URL, html => {
|
||||
// if there is not already a rubric, we want to click the "add rubric" button for them,
|
||||
// since that is the point of why they clicked the link.
|
||||
if (assignmentRubricDialog.noRubricExists) {
|
||||
$.subscribe('edit_rubric/initted', () => assignmentRubricDialog.$dialog.find('.btn.add_rubric_link').click())
|
||||
$.subscribe('edit_rubric/initted', () =>
|
||||
assignmentRubricDialog.$dialog.find('.btn.add_rubric_link').click()
|
||||
)
|
||||
}
|
||||
|
||||
// weird hackery because the server returns a <div id="rubrics" style="display:none">
|
||||
|
@ -68,7 +69,7 @@ const assignmentRubricDialog = {
|
|||
})
|
||||
},
|
||||
|
||||
openDialog () {
|
||||
openDialog() {
|
||||
if (!this.dialogInited) this.initDialog()
|
||||
this.$dialog.dialog('open')
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import $ from 'jquery'
|
|||
// We don't actually care about some of this stuff, but we stub out all XHR so
|
||||
// that things that try to use it don't blow up.
|
||||
export default class FakeXHR {
|
||||
constructor () {
|
||||
constructor() {
|
||||
this.readyState = 0
|
||||
this.timeout = 0
|
||||
this.withCredentials = false
|
||||
|
@ -32,7 +32,7 @@ export default class FakeXHR {
|
|||
|
||||
// #
|
||||
// we assume all responses are json
|
||||
setResponse (body) {
|
||||
setResponse(body) {
|
||||
this.readyState = 4
|
||||
this.responseText = body
|
||||
|
||||
|
@ -54,17 +54,23 @@ export default class FakeXHR {
|
|||
return (this.responseType = 'json')
|
||||
}
|
||||
|
||||
abort () {}
|
||||
getAllResponseHeaders () {
|
||||
abort() {}
|
||||
|
||||
getAllResponseHeaders() {
|
||||
if (this.responseText) {
|
||||
return ''
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
getResponseHeader () {}
|
||||
open () {}
|
||||
overrideMimeType () {}
|
||||
send () {}
|
||||
setRequestHeader () {}
|
||||
|
||||
getResponseHeader() {}
|
||||
|
||||
open() {}
|
||||
|
||||
overrideMimeType() {}
|
||||
|
||||
send() {}
|
||||
|
||||
setRequestHeader() {}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue