aboutsummaryrefslogtreecommitdiffstats
path: root/web/cobrands
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2016-12-16 15:02:53 +0100
committerMarius Halden <marius.h@lden.org>2016-12-16 15:02:53 +0100
commitdbf56159e44c1560a413022451bf1a1c4cb22a52 (patch)
tree275599a1894ca48d8dbf3c2843064c3dbf4affc7 /web/cobrands
parenta1603b96cae9258761f8cc59d76e0512f49afc3d (diff)
parent38490f6ea18064c232bda6ebfbaee052bd8f0951 (diff)
Merge tag 'v2.0.1' into fiksgatami-dev-v2
Diffstat (limited to 'web/cobrands')
-rw-r--r--web/cobrands/bromley/map.js1
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js112
-rw-r--r--web/cobrands/sass/_base.scss2
-rw-r--r--web/cobrands/sass/_report_list_pins.scss8
4 files changed, 121 insertions, 2 deletions
diff --git a/web/cobrands/bromley/map.js b/web/cobrands/bromley/map.js
new file mode 100644
index 000000000..0753907cc
--- /dev/null
+++ b/web/cobrands/bromley/map.js
@@ -0,0 +1 @@
+fixmystreet.maps.tile_base = [ [ "", "a-" ], "https://{S}fix.bromley.gov.uk/tilma" ];
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index fed983a2c..e4c5ba71c 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -390,6 +390,87 @@ $.extend(fixmystreet.set_up, {
});
},
+ manage_duplicates: function() {
+ // Deal with changes to report state by inspector/other staff, specifically
+ // displaying nearby reports if it's changed to 'duplicate'.
+ function refresh_duplicate_list() {
+ var report_id = $("#report_inspect_form .js-report-id").text();
+ var args = {
+ filter_category: $("#report_inspect_form select#category").val(),
+ latitude: $('input[name="latitude"]').val(),
+ longitude: $('input[name="longitude"]').val()
+ };
+ $("#js-duplicate-reports ul").html("<li>Loading...</li>");
+ var nearby_url = '/report/'+report_id+'/nearby.json';
+ $.getJSON(nearby_url, 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");
+
+ (function() {
+ var timeout;
+ $reports.on('mouseenter', function(){
+ clearTimeout(timeout);
+ fixmystreet.maps.markers_highlight(parseInt($(this).data('reportId'), 10));
+ }).on('mouseleave', function(){
+ timeout = setTimeout(fixmystreet.maps.markers_highlight, 50);
+ });
+ })();
+
+ $("#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;
+ });
+
+ show_nearby_pins(data, report_id);
+ });
+ }
+
+ function show_nearby_pins(data, report_id) {
+ var markers = fixmystreet.maps.markers_list( data.pins, true );
+ // We're replacing all the features in the markers layer with the
+ // possible duplicates, but the list of pins from the server doesn't
+ // include the current report. So we need to extract the feature for
+ // the current report and include it in the list of features we're
+ // showing on the layer.
+ var report_marker = fixmystreet.maps.get_marker_by_id(parseInt(report_id, 10));
+ if (report_marker) {
+ markers.unshift(report_marker);
+ }
+ fixmystreet.markers.removeAllFeatures();
+ fixmystreet.markers.addFeatures( markers );
+ }
+
+ function state_change() {
+ // The duplicate report list only makes sense when state is 'duplicate'
+ if ($(this).val() !== "duplicate") {
+ $("#js-duplicate-reports").addClass("hidden");
+ return;
+ } else {
+ $("#js-duplicate-reports").removeClass("hidden");
+ }
+ // If this report is already marked as a duplicate of another, then
+ // there's no need to refresh the list of duplicate reports
+ var duplicate_of = $("#report_inspect_form [name=duplicate_of]").val();
+ if (!!duplicate_of) {
+ return;
+ }
+
+ refresh_duplicate_list();
+ }
+
+ $("#report_inspect_form").on("change.state", "select#state", state_change);
+ $("#js-change-duplicate-report").click(refresh_duplicate_list);
+ },
+
contribute_as: function() {
$('.content').on('change', '.js-contribute-as', function(){
@@ -563,6 +644,9 @@ $.extend(fixmystreet.set_up, {
return;
}
+ // Focus on form
+ $('html,body').scrollTop($('#report_inspect_form').offset().top);
+
// On the manage/inspect report form, we already have all the extra inputs
// in the DOM, we just need to hide/show them as appropriate.
$('form#report_inspect_form [name=category]').change(function() {
@@ -570,8 +654,33 @@ $.extend(fixmystreet.set_up, {
selector = "[data-category='" + category + "']";
$("form#report_inspect_form [data-category]:not(" + selector + ")").addClass("hidden");
$("form#report_inspect_form " + selector).removeClass("hidden");
+ // And update the associated priority list
+ var priorities = $("form#report_inspect_form " + selector).data('priorities');
+ var $select = $('#problem_priority'),
+ curr_pri = $select.val();
+ $select.find('option:gt(0)').remove();
+ $.each(priorities.split('&'), function(i, kv) {
+ if (!kv) {
+ return;
+ }
+ kv = kv.split('=', 2);
+ $select.append($('<option>', { value: kv[0], text: decodeURIComponent(kv[1]) }));
+ });
+ $select.val(curr_pri);
});
+ // The inspect form submit button can change depending on the selected state
+ $("#report_inspect_form [name=state]").change(function(){
+ var state = $(this).val();
+ var $submit = $("#report_inspect_form input[type=submit]");
+ var value = $submit.attr('data-value-'+state);
+ if (value !== undefined) {
+ $submit.val(value);
+ } else {
+ $submit.val($submit.data('valueOriginal'));
+ }
+ }).change();
+
$('.js-toggle-public-update').each(function() {
var $checkbox = $(this);
var toggle_public_update = function() {
@@ -943,7 +1052,7 @@ fixmystreet.update_pin = function(lonlat, savePushState) {
// something from it, then pre-fill the category field in the report,
// if it's a value already present in the drop-down.
var category = $("#filter_categories").val();
- if (category !== undefined && $("#form_category option[value="+category+"]").length) {
+ if (category !== undefined && $("#form_category option[value='"+category+"']").length) {
$("#form_category").val(category);
}
@@ -1090,6 +1199,7 @@ fixmystreet.display = {
$twoColReport.appendTo('#map_sidebar');
$('body').addClass('with-actions');
fixmystreet.set_up.report_page_inspect();
+ fixmystreet.set_up.manage_duplicates();
} else {
$sideReport.appendTo('#map_sidebar');
}
diff --git a/web/cobrands/sass/_base.scss b/web/cobrands/sass/_base.scss
index f3753905b..7fb0c797f 100644
--- a/web/cobrands/sass/_base.scss
+++ b/web/cobrands/sass/_base.scss
@@ -289,7 +289,7 @@ select.form-control {
&[multiple] {
height: auto;
}
- .js &[multiple] {
+ .js &.js-multiple[multiple] {
height: 2.2em;
}
}
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;