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
cc6024e9
Commit
cc6024e9
authored
Jan 11, 2016
by
muzaffaryousaf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable button while adding/removing bookmark to a unit.
TNL-4004
parent
e8925972
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
lms/static/js/bookmarks/views/bookmark_button.js
+8
-0
lms/static/js/spec/bookmarks/bookmark_button_view_spec.js
+5
-0
No files found.
lms/static/js/bookmarks/views/bookmark_button.js
View file @
cc6024e9
...
@@ -26,6 +26,8 @@
...
@@ -26,6 +26,8 @@
toggleBookmark
:
function
(
event
)
{
toggleBookmark
:
function
(
event
)
{
event
.
preventDefault
();
event
.
preventDefault
();
this
.
$el
.
prop
(
'disabled'
,
true
);
if
(
this
.
$el
.
hasClass
(
'bookmarked'
))
{
if
(
this
.
$el
.
hasClass
(
'bookmarked'
))
{
this
.
removeBookmark
();
this
.
removeBookmark
();
}
else
{
}
else
{
...
@@ -48,6 +50,9 @@
...
@@ -48,6 +50,9 @@
var
response
=
jqXHR
.
responseText
?
JSON
.
parse
(
jqXHR
.
responseText
)
:
''
;
var
response
=
jqXHR
.
responseText
?
JSON
.
parse
(
jqXHR
.
responseText
)
:
''
;
var
userMessage
=
response
?
response
.
user_message
:
''
;
var
userMessage
=
response
?
response
.
user_message
:
''
;
view
.
showError
(
userMessage
);
view
.
showError
(
userMessage
);
},
complete
:
function
()
{
view
.
$el
.
prop
(
'disabled'
,
false
);
}
}
});
});
},
},
...
@@ -65,6 +70,9 @@
...
@@ -65,6 +70,9 @@
},
},
error
:
function
()
{
error
:
function
()
{
view
.
showError
();
view
.
showError
();
},
complete
:
function
()
{
view
.
$el
.
prop
(
'disabled'
,
false
);
}
}
});
});
},
},
...
...
lms/static/js/spec/bookmarks/bookmark_button_view_spec.js
View file @
cc6024e9
...
@@ -85,6 +85,8 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
...
@@ -85,6 +85,8 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
bookmarkButtonView
.
$el
.
click
();
bookmarkButtonView
.
$el
.
click
();
expect
(
bookmarkButtonView
.
$el
).
toHaveAttr
(
'disabled'
,
'disabled'
);
AjaxHelpers
.
expectRequest
(
AjaxHelpers
.
expectRequest
(
requests
,
firstActionData
.
method
,
requests
,
firstActionData
.
method
,
firstActionData
.
url
,
firstActionData
.
url
,
...
@@ -96,12 +98,14 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
...
@@ -96,12 +98,14 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
expect
(
firstActionData
.
event
).
toHaveBeenTriggeredOn
(
bookmarkButtonView
.
$el
);
expect
(
firstActionData
.
event
).
toHaveBeenTriggeredOn
(
bookmarkButtonView
.
$el
);
bookmarkButtonView
[
firstActionData
.
handler
].
reset
();
bookmarkButtonView
[
firstActionData
.
handler
].
reset
();
expect
(
bookmarkButtonView
.
$el
).
not
.
toHaveAttr
(
'disabled'
);
verifyBookmarkButtonState
(
bookmarkButtonView
,
secondActionData
.
bookmarked
);
verifyBookmarkButtonState
(
bookmarkButtonView
,
secondActionData
.
bookmarked
);
spyOn
(
bookmarkButtonView
,
secondActionData
.
handler
).
andCallThrough
();
spyOn
(
bookmarkButtonView
,
secondActionData
.
handler
).
andCallThrough
();
spyOnEvent
(
bookmarkButtonView
.
$el
,
secondActionData
.
event
);
spyOnEvent
(
bookmarkButtonView
.
$el
,
secondActionData
.
event
);
bookmarkButtonView
.
$el
.
click
();
bookmarkButtonView
.
$el
.
click
();
expect
(
bookmarkButtonView
.
$el
).
toHaveAttr
(
'disabled'
,
'disabled'
);
AjaxHelpers
.
expectRequest
(
AjaxHelpers
.
expectRequest
(
requests
,
requests
,
...
@@ -114,6 +118,7 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
...
@@ -114,6 +118,7 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
AjaxHelpers
.
respondWithJson
(
requests
,
{});
AjaxHelpers
.
respondWithJson
(
requests
,
{});
expect
(
secondActionData
.
event
).
toHaveBeenTriggeredOn
(
bookmarkButtonView
.
$el
);
expect
(
secondActionData
.
event
).
toHaveBeenTriggeredOn
(
bookmarkButtonView
.
$el
);
expect
(
bookmarkButtonView
.
$el
).
not
.
toHaveAttr
(
'disabled'
);
verifyBookmarkButtonState
(
bookmarkButtonView
,
firstActionData
.
bookmarked
);
verifyBookmarkButtonState
(
bookmarkButtonView
,
firstActionData
.
bookmarked
);
bookmarkButtonView
.
undelegateEvents
();
bookmarkButtonView
.
undelegateEvents
();
});
});
...
...
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