Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
c6c5e50d
Commit
c6c5e50d
authored
May 10, 2013
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hook up notification framework to default AJAX error callback
And delete `CMS.ServerError`
parent
e2f5acef
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
42 additions
and
55 deletions
+42
-55
cms/static/js/models/settings/advanced.js
+0
-1
cms/static/js/views/checklists_view.js
+2
-4
cms/static/js/views/course_info_edit.js
+5
-8
cms/static/js/views/server_error.js
+0
-17
cms/static/js/views/settings/advanced_view.js
+2
-5
cms/static/js/views/settings/main_settings_view.js
+0
-1
cms/static/js/views/settings/settings_grading_view.js
+14
-18
cms/static/js/views/validating_view.js
+0
-1
cms/templates/base.html
+19
-0
No files found.
cms/static/js/models/settings/advanced.js
View file @
c6c5e50d
...
@@ -40,7 +40,6 @@ CMS.Models.Settings.Advanced = Backbone.Model.extend({
...
@@ -40,7 +40,6 @@ CMS.Models.Settings.Advanced = Backbone.Model.extend({
// data
// data
data
:
JSON
.
stringify
({
deleteKeys
:
self
.
deleteKeys
})
data
:
JSON
.
stringify
({
deleteKeys
:
self
.
deleteKeys
})
})
})
.
fail
(
function
(
hdr
,
status
,
error
)
{
CMS
.
ServerError
(
self
,
"Deleting keys:"
+
status
);
})
.
done
(
function
(
data
,
status
,
error
)
{
.
done
(
function
(
data
,
status
,
error
)
{
// clear deleteKeys on success
// clear deleteKeys on success
self
.
deleteKeys
=
[];
self
.
deleteKeys
=
[];
...
...
cms/static/js/views/checklists_view.js
View file @
c6c5e50d
...
@@ -22,8 +22,7 @@ CMS.Views.Checklists = Backbone.View.extend({
...
@@ -22,8 +22,7 @@ CMS.Views.Checklists = Backbone.View.extend({
}
}
);
);
},
},
reset
:
true
,
reset
:
true
error
:
CMS
.
ServerError
}
}
);
);
},
},
...
@@ -90,8 +89,7 @@ CMS.Views.Checklists = Backbone.View.extend({
...
@@ -90,8 +89,7 @@ CMS.Views.Checklists = Backbone.View.extend({
'task'
:
model
.
attributes
.
items
[
task_index
].
short_description
,
'task'
:
model
.
attributes
.
items
[
task_index
].
short_description
,
'state'
:
model
.
attributes
.
items
[
task_index
].
is_checked
'state'
:
model
.
attributes
.
items
[
task_index
].
is_checked
});
});
},
}
error
:
CMS
.
ServerError
});
});
}
}
});
});
cms/static/js/views/course_info_edit.js
View file @
c6c5e50d
...
@@ -105,7 +105,7 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({
...
@@ -105,7 +105,7 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({
var
targetModel
=
this
.
eventModel
(
event
);
var
targetModel
=
this
.
eventModel
(
event
);
targetModel
.
set
({
date
:
this
.
dateEntry
(
event
).
val
(),
content
:
this
.
$codeMirror
.
getValue
()
});
targetModel
.
set
({
date
:
this
.
dateEntry
(
event
).
val
(),
content
:
this
.
$codeMirror
.
getValue
()
});
// push change to display, hide the editor, submit the change
// push change to display, hide the editor, submit the change
targetModel
.
save
({}
,
{
error
:
CMS
.
ServerError
}
);
targetModel
.
save
({});
this
.
closeEditor
(
this
);
this
.
closeEditor
(
this
);
analytics
.
track
(
'Saved Course Update'
,
{
analytics
.
track
(
'Saved Course Update'
,
{
...
@@ -166,11 +166,9 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({
...
@@ -166,11 +166,9 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({
success
:
function
()
{
success
:
function
()
{
cacheThis
.
render
();
cacheThis
.
render
();
},
},
reset
:
true
,
reset
:
true
error
:
CMS
.
ServerError
});
});
},
}
error
:
CMS
.
ServerError
});
});
},
},
...
@@ -254,8 +252,7 @@ CMS.Views.ClassInfoHandoutsView = Backbone.View.extend({
...
@@ -254,8 +252,7 @@ CMS.Views.ClassInfoHandoutsView = Backbone.View.extend({
}
}
);
);
},
},
reset
:
true
,
reset
:
true
error
:
CMS
.
ServerError
});
});
},
},
...
@@ -296,7 +293,7 @@ CMS.Views.ClassInfoHandoutsView = Backbone.View.extend({
...
@@ -296,7 +293,7 @@ CMS.Views.ClassInfoHandoutsView = Backbone.View.extend({
onSave
:
function
(
event
)
{
onSave
:
function
(
event
)
{
this
.
model
.
set
(
'data'
,
this
.
$codeMirror
.
getValue
());
this
.
model
.
set
(
'data'
,
this
.
$codeMirror
.
getValue
());
this
.
render
();
this
.
render
();
this
.
model
.
save
({}
,
{
error
:
CMS
.
ServerError
}
);
this
.
model
.
save
({});
this
.
$form
.
hide
();
this
.
$form
.
hide
();
this
.
closeEditor
(
this
);
this
.
closeEditor
(
this
);
...
...
cms/static/js/views/server_error.js
deleted
100644 → 0
View file @
e2f5acef
CMS
.
ServerError
=
function
(
model
,
error
)
{
var
m
=
new
CMS
.
Models
.
SystemFeedback
({
"type"
:
"error"
,
"title"
:
"Server Error"
,
"message"
:
error
.
responseText
,
"actions"
:
{
"primary"
:
{
"text"
:
"Dismiss"
,
"click"
:
function
(
model
)
{
model
.
hide
();
}
}
}
});
new
CMS
.
Views
.
Notification
({
model
:
m
});
return
m
;
};
cms/static/js/views/settings/advanced_view.js
View file @
c6c5e50d
...
@@ -23,7 +23,6 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
...
@@ -23,7 +23,6 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
// because these are outside of this.$el, they can't be in the event hash
// because these are outside of this.$el, they can't be in the event hash
$
(
'.save-button'
).
on
(
'click'
,
this
,
this
.
saveView
);
$
(
'.save-button'
).
on
(
'click'
,
this
,
this
.
saveView
);
$
(
'.cancel-button'
).
on
(
'click'
,
this
,
this
.
revertView
);
$
(
'.cancel-button'
).
on
(
'click'
,
this
,
this
.
revertView
);
this
.
listenTo
(
this
.
model
,
'error'
,
CMS
.
ServerError
);
this
.
listenTo
(
this
.
model
,
'invalid'
,
this
.
handleValidationError
);
this
.
listenTo
(
this
.
model
,
'invalid'
,
this
.
handleValidationError
);
},
},
render
:
function
()
{
render
:
function
()
{
...
@@ -144,8 +143,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
...
@@ -144,8 +143,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
'course'
:
course_location_analytics
'course'
:
course_location_analytics
});
});
},
}
error
:
CMS
.
ServerError
});
});
},
},
revertView
:
function
(
event
)
{
revertView
:
function
(
event
)
{
...
@@ -155,8 +153,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
...
@@ -155,8 +153,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
self
.
model
.
clear
({
silent
:
true
});
self
.
model
.
clear
({
silent
:
true
});
self
.
model
.
fetch
({
self
.
model
.
fetch
({
success
:
function
()
{
self
.
render
();
},
success
:
function
()
{
self
.
render
();
},
reset
:
true
,
reset
:
true
error
:
CMS
.
ServerError
});
});
},
},
renderTemplate
:
function
(
key
,
value
)
{
renderTemplate
:
function
(
key
,
value
)
{
...
...
cms/static/js/views/settings/main_settings_view.js
View file @
c6c5e50d
...
@@ -26,7 +26,6 @@ CMS.Views.Settings.Details = CMS.Views.ValidatingView.extend({
...
@@ -26,7 +26,6 @@ CMS.Views.Settings.Details = CMS.Views.ValidatingView.extend({
var
dateIntrospect
=
new
Date
();
var
dateIntrospect
=
new
Date
();
this
.
$el
.
find
(
'#timezone'
).
html
(
"("
+
dateIntrospect
.
getTimezone
()
+
")"
);
this
.
$el
.
find
(
'#timezone'
).
html
(
"("
+
dateIntrospect
.
getTimezone
()
+
")"
);
this
.
listenTo
(
this
.
model
,
'error'
,
CMS
.
ServerError
);
this
.
listenTo
(
this
.
model
,
'invalid'
,
this
.
handleValidationError
);
this
.
listenTo
(
this
.
model
,
'invalid'
,
this
.
handleValidationError
);
this
.
selectorToField
=
_
.
invert
(
this
.
fieldToSelectorMap
);
this
.
selectorToField
=
_
.
invert
(
this
.
fieldToSelectorMap
);
},
},
...
...
cms/static/js/views/settings/settings_grading_view.js
View file @
c6c5e50d
...
@@ -44,7 +44,6 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
...
@@ -44,7 +44,6 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
self
.
render
();
self
.
render
();
}
}
);
);
this
.
listenTo
(
this
.
model
,
'error'
,
CMS
.
ServerError
);
this
.
listenTo
(
this
.
model
,
'invalid'
,
this
.
handleValidationError
);
this
.
listenTo
(
this
.
model
,
'invalid'
,
this
.
handleValidationError
);
this
.
model
.
get
(
'graders'
).
on
(
'remove'
,
this
.
render
,
this
);
this
.
model
.
get
(
'graders'
).
on
(
'remove'
,
this
.
render
,
this
);
this
.
model
.
get
(
'graders'
).
on
(
'reset'
,
this
.
render
,
this
);
this
.
model
.
get
(
'graders'
).
on
(
'reset'
,
this
.
render
,
this
);
...
@@ -65,7 +64,7 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
...
@@ -65,7 +64,7 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
gradeCollection
.
each
(
function
(
gradeModel
)
{
gradeCollection
.
each
(
function
(
gradeModel
)
{
$
(
gradelist
).
append
(
self
.
template
({
model
:
gradeModel
}));
$
(
gradelist
).
append
(
self
.
template
({
model
:
gradeModel
}));
var
newEle
=
gradelist
.
children
().
last
();
var
newEle
=
gradelist
.
children
().
last
();
var
newView
=
new
CMS
.
Views
.
Settings
.
GraderView
({
el
:
newEle
,
var
newView
=
new
CMS
.
Views
.
Settings
.
GraderView
({
el
:
newEle
,
model
:
gradeModel
,
collection
:
gradeCollection
});
model
:
gradeModel
,
collection
:
gradeCollection
});
});
});
...
@@ -119,7 +118,7 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
...
@@ -119,7 +118,7 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
gradeBarWidth
:
null
,
// cache of value since it won't change (more certain)
gradeBarWidth
:
null
,
// cache of value since it won't change (more certain)
renderCutoffBar
:
function
()
{
renderCutoffBar
:
function
()
{
var
gradeBar
=
this
.
$el
.
find
(
'.grade-bar'
);
var
gradeBar
=
this
.
$el
.
find
(
'.grade-bar'
);
this
.
gradeBarWidth
=
gradeBar
.
width
();
this
.
gradeBarWidth
=
gradeBar
.
width
();
var
gradelist
=
gradeBar
.
children
(
'.grades'
);
var
gradelist
=
gradeBar
.
children
(
'.grades'
);
// HACK fixing a duplicate call issue by undoing previous call effect. Need to figure out why called 2x
// HACK fixing a duplicate call issue by undoing previous call effect. Need to figure out why called 2x
...
@@ -128,11 +127,11 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
...
@@ -128,11 +127,11 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
// Can probably be simplified to one variable now.
// Can probably be simplified to one variable now.
var
removable
=
false
;
var
removable
=
false
;
var
draggable
=
false
;
// first and last are not removable, first is not draggable
var
draggable
=
false
;
// first and last are not removable, first is not draggable
_
.
each
(
this
.
descendingCutoffs
,
_
.
each
(
this
.
descendingCutoffs
,
function
(
cutoff
,
index
)
{
function
(
cutoff
,
index
)
{
var
newBar
=
this
.
gradeCutoffTemplate
({
var
newBar
=
this
.
gradeCutoffTemplate
({
descriptor
:
cutoff
[
'designation'
]
,
descriptor
:
cutoff
[
'designation'
]
,
width
:
nextWidth
,
width
:
nextWidth
,
removable
:
removable
});
removable
:
removable
});
gradelist
.
append
(
newBar
);
gradelist
.
append
(
newBar
);
if
(
draggable
)
{
if
(
draggable
)
{
...
@@ -152,7 +151,7 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
...
@@ -152,7 +151,7 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
},
},
this
);
this
);
// add fail which is not in data
// add fail which is not in data
var
failBar
=
this
.
gradeCutoffTemplate
({
descriptor
:
this
.
failLabel
(),
var
failBar
=
this
.
gradeCutoffTemplate
({
descriptor
:
this
.
failLabel
(),
width
:
nextWidth
,
removable
:
false
});
width
:
nextWidth
,
removable
:
false
});
$
(
failBar
).
find
(
"span[contenteditable=true]"
).
attr
(
"contenteditable"
,
false
);
$
(
failBar
).
find
(
"span[contenteditable=true]"
).
attr
(
"contenteditable"
,
false
);
gradelist
.
append
(
failBar
);
gradelist
.
append
(
failBar
);
...
@@ -221,12 +220,12 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
...
@@ -221,12 +220,12 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
},
},
saveCutoffs
:
function
()
{
saveCutoffs
:
function
()
{
this
.
model
.
save
(
'grade_cutoffs'
,
this
.
model
.
save
(
'grade_cutoffs'
,
_
.
reduce
(
this
.
descendingCutoffs
,
_
.
reduce
(
this
.
descendingCutoffs
,
function
(
object
,
cutoff
)
{
function
(
object
,
cutoff
)
{
object
[
cutoff
[
'designation'
]]
=
cutoff
[
'cutoff'
]
/
100.0
;
object
[
cutoff
[
'designation'
]]
=
cutoff
[
'cutoff'
]
/
100.0
;
return
object
;
return
object
;
},
},
{}));
{}));
},
},
...
@@ -244,7 +243,7 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
...
@@ -244,7 +243,7 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
this
.
descendingCutoffs
.
push
({
designation
:
this
.
GRADES
[
gradeLength
],
cutoff
:
failBarWidth
});
this
.
descendingCutoffs
.
push
({
designation
:
this
.
GRADES
[
gradeLength
],
cutoff
:
failBarWidth
});
this
.
descendingCutoffs
[
gradeLength
-
1
][
'cutoff'
]
=
Math
.
round
(
targetWidth
);
this
.
descendingCutoffs
[
gradeLength
-
1
][
'cutoff'
]
=
Math
.
round
(
targetWidth
);
var
$newGradeBar
=
this
.
gradeCutoffTemplate
({
descriptor
:
this
.
GRADES
[
gradeLength
],
var
$newGradeBar
=
this
.
gradeCutoffTemplate
({
descriptor
:
this
.
GRADES
[
gradeLength
],
width
:
targetWidth
,
removable
:
true
});
width
:
targetWidth
,
removable
:
true
});
var
gradeDom
=
this
.
$el
.
find
(
'.grades'
);
var
gradeDom
=
this
.
$el
.
find
(
'.grades'
);
gradeDom
.
children
().
last
().
before
(
$newGradeBar
);
gradeDom
.
children
().
last
().
before
(
$newGradeBar
);
...
@@ -317,7 +316,6 @@ CMS.Views.Settings.GraderView = CMS.Views.ValidatingView.extend({
...
@@ -317,7 +316,6 @@ CMS.Views.Settings.GraderView = CMS.Views.ValidatingView.extend({
'blur :input'
:
"inputUnfocus"
'blur :input'
:
"inputUnfocus"
},
},
initialize
:
function
()
{
initialize
:
function
()
{
this
.
listenTo
(
this
.
model
,
'error'
,
CMS
.
ServerError
);
this
.
listenTo
(
this
.
model
,
'invalid'
,
this
.
handleValidationError
);
this
.
listenTo
(
this
.
model
,
'invalid'
,
this
.
handleValidationError
);
this
.
selectorToField
=
_
.
invert
(
this
.
fieldToSelectorMap
);
this
.
selectorToField
=
_
.
invert
(
this
.
fieldToSelectorMap
);
this
.
render
();
this
.
render
();
...
@@ -362,9 +360,8 @@ CMS.Views.Settings.GraderView = CMS.Views.ValidatingView.extend({
...
@@ -362,9 +360,8 @@ CMS.Views.Settings.GraderView = CMS.Views.ValidatingView.extend({
}
}
},
},
deleteModel
:
function
(
e
)
{
deleteModel
:
function
(
e
)
{
this
.
model
.
destroy
(
this
.
model
.
destroy
();
{
error
:
CMS
.
ServerError
});
e
.
preventDefault
();
e
.
preventDefault
();
}
}
});
});
\ No newline at end of file
cms/static/js/views/validating_view.js
View file @
c6c5e50d
...
@@ -3,7 +3,6 @@ CMS.Views.ValidatingView = Backbone.View.extend({
...
@@ -3,7 +3,6 @@ CMS.Views.ValidatingView = Backbone.View.extend({
// decorates the fields. Needs wiring per class, but this initialization shows how
// decorates the fields. Needs wiring per class, but this initialization shows how
// either have your init call this one or copy the contents
// either have your init call this one or copy the contents
initialize
:
function
()
{
initialize
:
function
()
{
this
.
listenTo
(
this
.
model
,
'error'
,
CMS
.
ServerError
);
this
.
listenTo
(
this
.
model
,
'invalid'
,
this
.
handleValidationError
);
this
.
listenTo
(
this
.
model
,
'invalid'
,
this
.
handleValidationError
);
this
.
selectorToField
=
_
.
invert
(
this
.
fieldToSelectorMap
);
this
.
selectorToField
=
_
.
invert
(
this
.
fieldToSelectorMap
);
},
},
...
...
cms/templates/base.html
View file @
c6c5e50d
...
@@ -109,6 +109,25 @@
...
@@ -109,6 +109,25 @@
</
%
text>
</
%
text>
<script
src=
"${static.url('js/models/feedback.js')}"
></script>
<script
src=
"${static.url('js/models/feedback.js')}"
></script>
<script
src=
"${static.url('js/views/feedback.js')}"
></script>
<script
src=
"${static.url('js/views/feedback.js')}"
></script>
<script
type=
"text/javascript"
>
$
(
document
).
ajaxError
(
function
(
event
,
jqXHR
,
ajaxSettings
,
thrownError
)
{
var
m
=
new
CMS
.
Models
.
SystemFeedback
({
"type"
:
"error"
,
"title"
:
"Server Error"
,
"message"
:
jqXHR
.
responseText
,
"actions"
:
{
"primary"
:
{
"text"
:
"Dismiss"
,
"click"
:
function
(
model
)
{
model
.
hide
();
}
}
}
});
new
CMS
.
Views
.
Notification
({
model
:
m
});
return
m
;
})
</script>
<!-- view -->
<!-- view -->
<div
class=
"wrapper wrapper-view"
>
<div
class=
"wrapper wrapper-view"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment