diff --git a/apps/home/static/home/js/tabs/subs.js b/apps/home/static/home/js/tabs/subs.js index e6b9434..fa0460d 100644 --- a/apps/home/static/home/js/tabs/subs.js +++ b/apps/home/static/home/js/tabs/subs.js @@ -301,3 +301,30 @@ $(subTableId).on("click", ".js-openSubStyle", async event => { $("#stylesTab").click(); await openDataModal(styleModalId, styleId, `/api/message-styles/${styleId}/`); }); + + +// region Sub Recommendations + +$(document).ready(async () => { + const response = await ajaxRequest("/api/subscription-recommendations/", "GET"); + response.results.forEach(recommendation => { + const template = $($("#subscriptionRecommendationTemplate").html()); + + template.find(".js-title").text(recommendation.name); + template.find(".js-desc").text(recommendation.description); + template.find(".js-url").text(recommendation.url).attr("href", recommendation.url); + + $(".js-subscription-recommendations-group").append(template); + }); +}); + +$(".js-subscription-recommendations-group").on("click", ".js-subRecBtn", async function() { + const name = $(this).find(".js-title").text(); + const url = $(this).find(".js-url").text(); + + $("#subRecommendationModal").modal("hide"); + await openDataModal(subModalId, -1); + + $("#subName").val(name); + $("#subUrl").val(url); +}); \ No newline at end of file diff --git a/apps/home/templates/home/index.html b/apps/home/templates/home/index.html index 3667f70..083ccc0 100644 --- a/apps/home/templates/home/index.html +++ b/apps/home/templates/home/index.html @@ -176,6 +176,17 @@ + diff --git a/apps/home/templates/home/modals/editSub.html b/apps/home/templates/home/modals/editSub.html index 54ad967..2f0ef6a 100644 --- a/apps/home/templates/home/modals/editSub.html +++ b/apps/home/templates/home/modals/editSub.html @@ -65,8 +65,9 @@ + +