Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bexley changes #2481

Merged
merged 6 commits into from
May 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion templates/web/base/report/new/category_wrapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

[% PROCESS "report/new/duplicate_suggestions.html" %]

<div id="js-post-category-messages" class="js-hide-if-invalid-category">
<div id="js-post-category-messages" class="js-hide-if-invalid-category_extras">
[%# This section includes 'Pick an asset' text, roadworks info, extra category questions %]

[%- IF category_extras OR report_extra_fields %]
Expand Down
105 changes: 91 additions & 14 deletions web/cobrands/bexley/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,70 @@ var defaults = {
strategy_class: OpenLayers.Strategy.FixMyStreet
};

var streetlight_default = {
fillColor: "#FFFF00",
fillOpacity: 0.6,
strokeColor: "#000000",
strokeOpacity: 0.8,
strokeWidth: 2,
pointRadius: 6
};

var pin_prefix = fixmystreet.pin_prefix || document.getElementById('js-map-data').getAttribute('data-pin_prefix');

var streetlight_select = {
externalGraphic: pin_prefix + "pin-spot.png",
fillColor: "#55BB00",
graphicWidth: 48,
graphicHeight: 64,
graphicXOffset: -24,
graphicYOffset: -56,
backgroundGraphic: pin_prefix + "pin-shadow.png",
backgroundWidth: 60,
backgroundHeight: 30,
backgroundXOffset: -7,
backgroundYOffset: -22,
popupYOffset: -40,
graphicOpacity: 1.0,

label: "${Unit_No}",
labelOutlineColor: "white",
labelOutlineWidth: 3,
labelYOffset: 65,
fontSize: '15px',
fontWeight: 'bold'
};

var streetlight_stylemap = new OpenLayers.StyleMap({
'default': new OpenLayers.Style(streetlight_default),
'select': new OpenLayers.Style(streetlight_select)
});

var labeled_defaults = $.extend(true, {}, defaults, {
select_action: true,
stylemap: streetlight_stylemap,
feature_code: 'Unit_No',
asset_type: 'spot',
asset_id_field: 'Unit_ID',
attributes: {
UnitID: 'Unit_ID'
},
actions: {
asset_found: function(asset) {
var id = asset.attributes[this.fixmystreet.feature_code] || '';
if (id !== '') {
var asset_name = this.fixmystreet.asset_item;
$('.category_meta_message').html('You have selected ' + asset_name + ' <b>' + id + '</b>');
} else {
$('.category_meta_message').html('You can pick a <b class="asset-spot">' + this.fixmystreet.asset_item + '</b> from the map &raquo;');
}
},
asset_not_found: function() {
$('.category_meta_message').html('You can pick a <b class="asset-spot">' + this.fixmystreet.asset_item + '</b> from the map &raquo;');
}
}
});

fixmystreet.assets.add(defaults, {
http_options: {
params: {
Expand All @@ -44,35 +108,48 @@ fixmystreet.assets.add(defaults, {
})
});

fixmystreet.assets.add(defaults, {
fixmystreet.assets.add(labeled_defaults, {
http_options: {
params: {
TYPENAME: "Bollards"
}
},
asset_type: 'spot',
asset_id_field: 'Unit_ID',
attributes: {
UnitID: 'Unit_ID'
},
asset_category: ["Damaged sign, bollard etc."],
asset_category: ["Keep left bollard"],
asset_item: 'bollard'
});

fixmystreet.assets.add(defaults, {
fixmystreet.assets.add(labeled_defaults, {
http_options: {
params: {
TYPENAME: "Lighting"
}
},
asset_type: 'spot',
asset_id_field: 'Unit_ID',
attributes: {
UnitID: 'Unit_ID'
},
asset_category: ["Lamp post", "Light in park or open space", "Zebra crossing light", "Traffic sign light", "Underpass light", "Keep left bollard", "Light in multi-storey car park", "Light in outside car park"],
asset_category: ["Lamp post", "Light in park or open space", "Underpass light", "Light in multi-storey car park", "Light in outside car park"],
asset_item: 'street light'
});

// We need to trigger the below function on subcategory change also
$(function(){
$("#problem_form").on("change.category", "#form_DALocation", function() {
$(fixmystreet).trigger('report_new:category_change', [ $('#form_category') ]);
});
});

fixmystreet.message_controller.register_category({
body: defaults.body,
category: function() {
var cat = $('#form_category').val();
if (cat === 'Dead animal') {
var where = $('#form_DALocation').val();
if (where === 'Garden' || where === 'Other private property') {
return true;
}
dracos marked this conversation as resolved.
Show resolved Hide resolved
}
return false;
},
keep_category_extras: true,
message: 'Please follow the link below to pay to remove a dead animal from a private property.'
});

})();

15 changes: 11 additions & 4 deletions web/cobrands/fixmystreet/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -966,11 +966,16 @@ fixmystreet.message_controller = (function() {
// This shows the reporting form
function enable_report_form() {
$(".js-hide-if-invalid-category").show();
$(".js-hide-if-invalid-category_extras").show();
}

// This hides the reporting form, apart from the category selection
function disable_report_form() {
// And perhaps the category_extras unless asked not to
function disable_report_form(keep_category_extras) {
$(".js-hide-if-invalid-category").hide();
if (!keep_category_extras) {
$(".js-hide-if-invalid-category_extras").hide();
}
}

// This hides the responsibility message, and (unless a
Expand Down Expand Up @@ -1046,17 +1051,19 @@ fixmystreet.message_controller = (function() {
var $msg;
if (typeof stopper.message === 'function') {
$msg = stopper.message();
$msg.attr('id', stopperId);
} else {
$msg = $('<p id="' + stopperId + '" class="box-warning">' + stopper.message + '</p>');
$msg = $('<p class="box-warning">' + stopper.message + '</p>');
}
$msg.attr('id', stopperId);
$msg.attr('role', 'alert');
$msg.attr('aria-live', 'assertive');

if ($id.length) {
$id.replaceWith($msg);
} else {
$msg.insertBefore('#js-post-category-messages');
}
disable_report_form();
disable_report_form(stopper.keep_category_extras);
});

return {
Expand Down