Disable button while adding/removing bookmark to a unit.
TNL-4004
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
toggleBookmark: function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
this.$el.prop('disabled', true);
|
||||
|
||||
if (this.$el.hasClass('bookmarked')) {
|
||||
this.removeBookmark();
|
||||
} else {
|
||||
@@ -48,6 +50,9 @@
|
||||
var response = jqXHR.responseText ? JSON.parse(jqXHR.responseText) : '';
|
||||
var userMessage = response ? response.user_message : '';
|
||||
view.showError(userMessage);
|
||||
},
|
||||
complete: function () {
|
||||
view.$el.prop('disabled', false);
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -65,6 +70,9 @@
|
||||
},
|
||||
error: function() {
|
||||
view.showError();
|
||||
},
|
||||
complete: function() {
|
||||
view.$el.prop('disabled', false);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -85,6 +85,8 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
|
||||
|
||||
bookmarkButtonView.$el.click();
|
||||
|
||||
expect(bookmarkButtonView.$el).toHaveAttr('disabled', 'disabled');
|
||||
|
||||
AjaxHelpers.expectRequest(
|
||||
requests, firstActionData.method,
|
||||
firstActionData.url,
|
||||
@@ -96,12 +98,14 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
|
||||
expect(firstActionData.event).toHaveBeenTriggeredOn(bookmarkButtonView.$el);
|
||||
bookmarkButtonView[firstActionData.handler].reset();
|
||||
|
||||
expect(bookmarkButtonView.$el).not.toHaveAttr('disabled');
|
||||
verifyBookmarkButtonState(bookmarkButtonView, secondActionData.bookmarked);
|
||||
|
||||
spyOn(bookmarkButtonView, secondActionData.handler).andCallThrough();
|
||||
spyOnEvent(bookmarkButtonView.$el, secondActionData.event);
|
||||
|
||||
bookmarkButtonView.$el.click();
|
||||
expect(bookmarkButtonView.$el).toHaveAttr('disabled', 'disabled');
|
||||
|
||||
AjaxHelpers.expectRequest(
|
||||
requests,
|
||||
@@ -114,6 +118,7 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
|
||||
AjaxHelpers.respondWithJson(requests, {});
|
||||
expect(secondActionData.event).toHaveBeenTriggeredOn(bookmarkButtonView.$el);
|
||||
|
||||
expect(bookmarkButtonView.$el).not.toHaveAttr('disabled');
|
||||
verifyBookmarkButtonState(bookmarkButtonView, firstActionData.bookmarked);
|
||||
bookmarkButtonView.undelegateEvents();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user