aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2016-11-15 17:08:57 +0000
committerDave Arter <davea@mysociety.org>2016-12-13 15:01:31 +0000
commitdc151edce28d2e5bf873f8e86473a82b9c6f178a (patch)
tree601adbffc4d51d32aa879e40dde7fd724f7d0383 /web
parent5d5d196ef1fdec2bb5c2d444da0126ecb5adeb78 (diff)
Store and display selected duplicate report
Diffstat (limited to 'web')
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js21
-rw-r--r--web/cobrands/sass/_report_list_pins.scss8
2 files changed, 25 insertions, 4 deletions
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index a7e6f28f0..ac7ddacaf 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -414,12 +414,25 @@ $.extend(fixmystreet.set_up, {
args.latitude = $('input[name="latitude"]').val();
args.longitude = $('input[name="longitude"]').val();
- console.log(args);
-
$.getJSON('/ajax', args, function(data) {
- var $reports = $(data.current);
+ var report_id = $("#report_inspect_form [name=report_id]").val();
+ var duplicate_of = $("#report_inspect_form [name=duplicate_of]").val();
+ var $reports = $(data.current)
+ .filter("li")
+ .not("[data-report-id="+report_id+"]")
+ .slice(0, 5);
+ $reports.filter("[data-report-id="+duplicate_of+"]").addClass("item-list--reports__item--selected");
+
$("#js-duplicate-reports").removeClass("hidden");
- $reports.slice(0, 5).appendTo($("#js-duplicate-reports ul").empty());
+ $("#js-duplicate-reports ul").empty().prepend($reports);
+
+ $reports.find("a").click(function() {
+ var report_id = $(this).closest("li").data('reportId');
+ $("#report_inspect_form [name=duplicate_of]").val(report_id);
+ $("#js-duplicate-reports ul li").removeClass("item-list--reports__item--selected");
+ $(this).closest("li").addClass("item-list--reports__item--selected");
+ return false;
+ });
});
});
},
diff --git a/web/cobrands/sass/_report_list_pins.scss b/web/cobrands/sass/_report_list_pins.scss
index 74f0a5f90..eaeefbc10 100644
--- a/web/cobrands/sass/_report_list_pins.scss
+++ b/web/cobrands/sass/_report_list_pins.scss
@@ -50,6 +50,14 @@
color: #777;
}
}
+.item-list--reports__item--selected {
+ background: $base_bg;
+
+ a, a:hover, a:focus {
+ background-color: transparent;
+ }
+}
+
.item-list__item--empty {
background: none;