From df6fc9853fde7e7562a3eeb421fc918d0b836cee Mon Sep 17 00:00:00 2001 From: Zarino Zappia Date: Tue, 9 Jan 2024 12:11:58 +0000 Subject: [PATCH] Make dataset favouriting work on the new area page --- hub/static/css/_area.scss | 22 +++++++++++ hub/static/js/area.esm.js | 26 ++++++------ hub/templates/hub/area/_favourite.html | 4 +- hub/templates/hub/new_area_page.html | 55 +++++++++++--------------- 4 files changed, 59 insertions(+), 48 deletions(-) diff --git a/hub/static/css/_area.scss b/hub/static/css/_area.scss index 93e45010e..290ec8930 100644 --- a/hub/static/css/_area.scss +++ b/hub/static/css/_area.scss @@ -91,6 +91,14 @@ grid-row: span 3; } +.area-data-favourites { + display: none; // will be shown later on + + svg { + margin: 0 0.33rem; + } +} + .area-data-more { display: none; // will be shown later on margin-top: map-get($spacers, 3); @@ -130,3 +138,17 @@ display: none; } } + +.area-content[data-section="favourites"] { + .area-data-favourites { + display: block; + } + + .area-data-grid > :not(.dataset-card--favourite) { + display: none; + } + + .area-section:not(:has(.dataset-card--favourite)) { + display: none; + } +} diff --git a/hub/static/js/area.esm.js b/hub/static/js/area.esm.js index 9dc30f58f..f9d701478 100644 --- a/hub/static/js/area.esm.js +++ b/hub/static/js/area.esm.js @@ -63,19 +63,19 @@ function setUpAreaPage() { trackEvent('area_page_switch_section', { "section": section }) }) - // $('.js-favourite-this-dataset, .js-unfavourite-this-dataset').on('submit', function(e){ - // e.preventDefault(); - // var $form = $(this); - // $.ajax({ - // url: $form.attr('action'), - // type: $form.attr('method') || 'get', - // data: $form.serialize(), - // accepts: 'application/json; charset=utf-8', - // dataType: 'json' - // }).done(function(){ - // $form.parents('.dataset-card').toggleClass('dataset-card--favourite'); - // }); - // }); + $('.js-favourite-this-dataset, .js-unfavourite-this-dataset').on('submit', function(e){ + e.preventDefault(); + var $form = $(this); + $.ajax({ + url: $form.attr('action'), + type: $form.attr('method') || 'get', + data: $form.serialize(), + accepts: 'application/json; charset=utf-8', + dataType: 'json' + }).done(function(){ + $form.parents('.dataset-card').toggleClass('dataset-card--favourite'); + }); + }); updateUI() } diff --git a/hub/templates/hub/area/_favourite.html b/hub/templates/hub/area/_favourite.html index bffce1c7a..7e05ea201 100644 --- a/hub/templates/hub/area/_favourite.html +++ b/hub/templates/hub/area/_favourite.html @@ -1,10 +1,10 @@ -
+ {% csrf_token %}
-
+ {% csrf_token %} -
{% if mp.cen_member or mp.nzsg_member %} @@ -150,9 +152,6 @@

APPGs