diff options
author | Dave Arter <davea@mysociety.org> | 2016-11-17 10:58:12 +0000 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2016-12-13 16:14:56 +0000 |
commit | 2906f139d37b308e071fc8ed388f87fa45ce7b00 (patch) | |
tree | fd234c01678b2b9306b6d51db6e8816168927437 | |
parent | e6a01721c87b7e3463093e64e97e08ed96f54bce (diff) |
Better preserve chosen duplicate report if state is changed
-rw-r--r-- | templates/web/base/report/_inspect.html | 6 | ||||
-rw-r--r-- | web/cobrands/fixmystreet/fixmystreet.js | 12 |
2 files changed, 13 insertions, 5 deletions
diff --git a/templates/web/base/report/_inspect.html b/templates/web/base/report/_inspect.html index 3479058c3..655c70128 100644 --- a/templates/web/base/report/_inspect.html +++ b/templates/web/base/report/_inspect.html @@ -79,10 +79,12 @@ </p> <div id="js-duplicate-reports" class="[% "hidden" UNLESS problem.duplicate_of %]"> <input type="hidden" name="duplicate_of" value="[% problem.duplicate_of.id %]"> - [% loc('Which report is it a duplicate of?') %] + <p class="[% "hidden" UNLESS problem.duplicate_of %]"><strong>[% loc('Duplicate of') %]</strong></p> + <p class="[% "hidden" IF problem.duplicate_of %]">[% loc('Which report is it a duplicate of?') %]</p> <ul> [% IF problem.duplicate_of %] - [% INCLUDE 'report/_item.html' item_extra_class = 'item-list__item--with-pin item-list--reports__item--selected' problem = problem.duplicate_of %] + [% INCLUDE 'report/_item.html' item_extra_class = 'item-list--reports__item--selected' problem = problem.duplicate_of %] + <li class="item-list__item"><a class="btn" href="#" id="js-change-duplicate-report">[% loc('Choose another') %]</a></li> [% END %] </ul> </div> diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index 1fc17ac9b..22e021edf 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -399,7 +399,6 @@ $.extend(fixmystreet.set_up, { if (state !== "duplicate") { $("#js-duplicate-reports").addClass("hidden"); - $("#js-duplicate-reports ul").empty(); return; } @@ -414,16 +413,23 @@ $.extend(fixmystreet.set_up, { args.latitude = $('input[name="latitude"]').val(); args.longitude = $('input[name="longitude"]').val(); + $("#js-duplicate-reports").removeClass("hidden"); + + var duplicate_of = $("#report_inspect_form [name=duplicate_of]").val(); + if (!!duplicate_of) { + return; + } + + $("#js-duplicate-reports ul").html("<li>Loading...</li>"); + var report_id = $("#report_inspect_form [name=report_id]").val(); $.getJSON('/report/'+report_id+'/nearby', args, function(data) { - 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"); $("#js-duplicate-reports ul").empty().prepend($reports); $reports.find("a").click(function() { |