Fix TNL-5011 (#13031)
Vote button is now disabled for yourself, but count is still visible
This commit is contained in:
@@ -107,10 +107,10 @@
|
||||
},
|
||||
can_vote: {
|
||||
enable: function() {
|
||||
return this.$(".action-vote").closest(".actions-item").removeClass("is-hidden");
|
||||
this.$('.action-vote').closest('.actions-item').removeClass('is-disabled');
|
||||
},
|
||||
disable: function() {
|
||||
return this.$(".action-vote").closest(".actions-item").addClass("is-hidden");
|
||||
this.$('.action-vote').closest('.actions-item').addClass('is-disabled');
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -415,17 +415,19 @@
|
||||
updates = {
|
||||
upvoted_ids: (is_voting ? _.union : _.difference)(user.get('upvoted_ids'), [this.model.id])
|
||||
};
|
||||
return DiscussionUtil.updateWithUndo(user, updates, {
|
||||
url: url,
|
||||
type: "POST",
|
||||
$elem: $(event.currentTarget)
|
||||
}, gettext("We had some trouble saving your vote. Please try again.")).done(function() {
|
||||
if (is_voting) {
|
||||
return self.model.vote();
|
||||
} else {
|
||||
return self.model.unvote();
|
||||
}
|
||||
});
|
||||
if (!$(event.target.closest(".actions-item")).hasClass('is-disabled')) {
|
||||
return DiscussionUtil.updateWithUndo(user, updates, {
|
||||
url: url,
|
||||
type: "POST",
|
||||
$elem: $(event.currentTarget)
|
||||
}, gettext("We had some trouble saving your vote. Please try again.")).done(function() {
|
||||
if (is_voting) {
|
||||
return self.model.vote();
|
||||
} else {
|
||||
return self.model.unvote();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
DiscussionContentShowView.prototype.togglePin = function(event) {
|
||||
|
||||
@@ -474,7 +474,7 @@
|
||||
});
|
||||
it("doesn't show voting button if can_vote ability is disabled", function() {
|
||||
this.view.render();
|
||||
return expect(this.view.$el.find(".action-vote").closest(".actions-item")).toHaveClass('is-hidden');
|
||||
return expect(this.view.$el.find(".action-vote").closest(".actions-item")).toHaveClass('is-disabled');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,6 +18,28 @@
|
||||
&.is-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&.is-disabled {
|
||||
a {
|
||||
pointer-events: none;
|
||||
|
||||
.action-icon {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.action-label {
|
||||
padding-right: 0px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-color: transparent;
|
||||
|
||||
.action-label {
|
||||
color: $forum-color-active-text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.more-wrapper {
|
||||
|
||||
Reference in New Issue
Block a user