favgroups: fix add to favgroup not working.
Fix the Add to Favgroup button not working when the user only has 1 favgroup.
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import Rails from "@rails/ujs";
|
||||||
|
|
||||||
let FavoriteGroup = {};
|
let FavoriteGroup = {};
|
||||||
|
|
||||||
FavoriteGroup.initialize_all = function() {
|
FavoriteGroup.initialize_all = function() {
|
||||||
@@ -23,8 +25,9 @@ FavoriteGroup.initialize_add_to_favgroup_dialog = function() {
|
|||||||
FavoriteGroup.open_favgroup_dialog = function(e) {
|
FavoriteGroup.open_favgroup_dialog = function(e) {
|
||||||
if ($(".add-to-favgroup").length === 1) {
|
if ($(".add-to-favgroup").length === 1) {
|
||||||
// If the user only has one favorite group we don't need to ask which group to add the post to.
|
// If the user only has one favorite group we don't need to ask which group to add the post to.
|
||||||
$(".add-to-favgroup").click();
|
let favgroup = $(".add-to-favgroup").get(0);
|
||||||
} else if ($(".add-to-favgroup").length > 1) {
|
Rails.fire(favgroup, "click");
|
||||||
|
} else {
|
||||||
$("#add-to-favgroup-dialog").dialog("open");
|
$("#add-to-favgroup-dialog").dialog("open");
|
||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user