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
78a61c1f
Commit
78a61c1f
authored
Feb 09, 2016
by
Ehtesham
Committed by
muzaffaryousaf
Feb 24, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TNL-4029] Show error if server returns customised error message
parent
d226b55b
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
1 deletions
+79
-1
lms/static/js/dashboard/track_events.js
+7
-0
lms/static/js/edxnotes/plugins/store_error_handler.js
+33
-0
lms/static/js/edxnotes/views/notes_factory.js
+2
-1
lms/static/js/spec/edxnotes/plugins/store_error_handler_spec.js
+36
-0
lms/static/js/spec/main.js
+1
-0
No files found.
lms/static/js/dashboard/track_events.js
View file @
78a61c1f
...
@@ -34,6 +34,9 @@ var edx = edx || {};
...
@@ -34,6 +34,9 @@ var edx = edx || {};
// Emit an event when the 'course title link' is clicked.
// Emit an event when the 'course title link' is clicked.
edx
.
dashboard
.
trackCourseTitleClicked
=
function
(
$courseTitleLink
,
properties
){
edx
.
dashboard
.
trackCourseTitleClicked
=
function
(
$courseTitleLink
,
properties
){
var
trackProperty
=
properties
||
edx
.
dashboard
.
generateTrackProperties
;
var
trackProperty
=
properties
||
edx
.
dashboard
.
generateTrackProperties
;
if
(
!
window
.
analytics
)
{
return
;
}
window
.
analytics
.
trackLink
(
window
.
analytics
.
trackLink
(
$courseTitleLink
,
$courseTitleLink
,
'edx.bi.dashboard.course_title.clicked'
,
'edx.bi.dashboard.course_title.clicked'
,
...
@@ -102,6 +105,10 @@ var edx = edx || {};
...
@@ -102,6 +105,10 @@ var edx = edx || {};
};
};
edx
.
dashboard
.
xseriesTrackMessages
=
function
()
{
edx
.
dashboard
.
xseriesTrackMessages
=
function
()
{
if
(
!
window
.
analytics
)
{
return
;
}
$
(
'.xseries-action .btn'
).
each
(
function
(
i
,
element
)
{
$
(
'.xseries-action .btn'
).
each
(
function
(
i
,
element
)
{
var
data
=
edx
.
dashboard
.
generateProgramProperties
(
$
(
element
));
var
data
=
edx
.
dashboard
.
generateProgramProperties
(
$
(
element
));
...
...
lms/static/js/edxnotes/plugins/store_error_handler.js
0 → 100644
View file @
78a61c1f
(
function
(
define
,
undefined
)
{
'use strict'
;
define
([
'annotator_1.2.9'
],
function
(
Annotator
)
{
/**
* Modifies Annotator.Plugin.Store.prototype._onError to show custom error message
* if sent by server
*/
var
originalErrorHandler
=
Annotator
.
Plugin
.
Store
.
prototype
.
_onError
;
Annotator
.
Plugin
.
Store
.
prototype
.
_onError
=
function
(
xhr
)
{
var
serverResponse
;
// Try to parse json
if
(
xhr
.
responseText
)
{
try
{
serverResponse
=
JSON
.
parse
(
xhr
.
responseText
);
}
catch
(
exception
)
{
serverResponse
=
null
;
}
}
// if response includes an error message it will take precedence
if
(
serverResponse
&&
serverResponse
.
error_msg
)
{
Annotator
.
showNotification
(
serverResponse
.
error_msg
,
Annotator
.
Notification
.
ERROR
);
return
console
.
error
(
Annotator
.
_t
(
"API request failed:"
)
+
(
" '"
+
xhr
.
status
+
"'"
));
}
// Delegate to original error handler
originalErrorHandler
(
xhr
);
};
});
}).
call
(
this
,
define
||
RequireJS
.
define
);
lms/static/js/edxnotes/views/notes_factory.js
View file @
78a61c1f
...
@@ -4,7 +4,8 @@ define([
...
@@ -4,7 +4,8 @@ define([
'jquery'
,
'underscore'
,
'annotator_1.2.9'
,
'js/edxnotes/utils/logger'
,
'jquery'
,
'underscore'
,
'annotator_1.2.9'
,
'js/edxnotes/utils/logger'
,
'js/edxnotes/views/shim'
,
'js/edxnotes/plugins/scroller'
,
'js/edxnotes/views/shim'
,
'js/edxnotes/plugins/scroller'
,
'js/edxnotes/plugins/events'
,
'js/edxnotes/plugins/accessibility'
,
'js/edxnotes/plugins/events'
,
'js/edxnotes/plugins/accessibility'
,
'js/edxnotes/plugins/caret_navigation'
'js/edxnotes/plugins/caret_navigation'
,
'js/edxnotes/plugins/store_error_handler'
],
function
(
$
,
_
,
Annotator
,
NotesLogger
)
{
],
function
(
$
,
_
,
Annotator
,
NotesLogger
)
{
var
plugins
=
[
'Auth'
,
'Store'
,
'Scroller'
,
'Events'
,
'Accessibility'
,
'CaretNavigation'
,
'Tags'
],
var
plugins
=
[
'Auth'
,
'Store'
,
'Scroller'
,
'Events'
,
'Accessibility'
,
'CaretNavigation'
,
'Tags'
],
getOptions
,
setupPlugins
,
getAnnotator
;
getOptions
,
setupPlugins
,
getAnnotator
;
...
...
lms/static/js/spec/edxnotes/plugins/store_error_handler_spec.js
0 → 100644
View file @
78a61c1f
define
([
'jquery'
,
'underscore'
,
'annotator_1.2.9'
,
'common/js/spec_helpers/ajax_helpers'
,
'js/spec/edxnotes/helpers'
,
'js/edxnotes/views/notes_factory'
],
function
(
$
,
_
,
Annotator
,
AjaxHelpers
,
Helpers
,
NotesFactory
)
{
'use strict'
;
describe
(
'Store Error Handler Custom Message'
,
function
()
{
beforeEach
(
function
()
{
spyOn
(
Annotator
,
'showNotification'
);
loadFixtures
(
'js/fixtures/edxnotes/edxnotes_wrapper.html'
);
this
.
wrapper
=
document
.
getElementById
(
'edx-notes-wrapper-123'
);
});
afterEach
(
function
()
{
_
.
invoke
(
Annotator
.
_instances
,
'destroy'
);
});
it
(
'can handle custom error if sent from server'
,
function
()
{
var
requests
=
AjaxHelpers
.
requests
(
this
);
var
token
=
Helpers
.
makeToken
();
NotesFactory
.
factory
(
this
.
wrapper
,
{
endpoint
:
'/test_endpoint'
,
user
:
'a user'
,
usageId
:
'an usage'
,
courseId
:
'a course'
,
token
:
token
,
tokenUrl
:
'/test_token_url'
});
var
errorMsg
=
'can
\'
t create more notes'
;
AjaxHelpers
.
respondWithError
(
requests
,
400
,
{
error_msg
:
errorMsg
});
expect
(
Annotator
.
showNotification
).
toHaveBeenCalledWith
(
errorMsg
,
Annotator
.
Notification
.
ERROR
);
});
});
});
lms/static/js/spec/main.js
View file @
78a61c1f
...
@@ -705,6 +705,7 @@
...
@@ -705,6 +705,7 @@
'lms/include/js/spec/edxnotes/plugins/events_spec.js'
,
'lms/include/js/spec/edxnotes/plugins/events_spec.js'
,
'lms/include/js/spec/edxnotes/plugins/scroller_spec.js'
,
'lms/include/js/spec/edxnotes/plugins/scroller_spec.js'
,
'lms/include/js/spec/edxnotes/plugins/caret_navigation_spec.js'
,
'lms/include/js/spec/edxnotes/plugins/caret_navigation_spec.js'
,
'lms/include/js/spec/edxnotes/plugins/store_error_handler_spec.js'
,
'lms/include/js/spec/edxnotes/collections/notes_spec.js'
,
'lms/include/js/spec/edxnotes/collections/notes_spec.js'
,
'lms/include/js/spec/search/search_spec.js'
,
'lms/include/js/spec/search/search_spec.js'
,
'lms/include/js/spec/navigation_spec.js'
,
'lms/include/js/spec/navigation_spec.js'
,
...
...
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