aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.cypress/cypress/integration/peterborough.js2
-rw-r--r--conf/systemd.example2
-rw-r--r--perllib/FixMyStreet/DB/Result/Contact.pm8
-rw-r--r--web/cobrands/buckinghamshire/assets.js3
-rw-r--r--web/cobrands/cheshireeast/assets.js3
-rw-r--r--web/cobrands/eastsussex/assets.js41
-rw-r--r--web/cobrands/fixmystreet/assets.js104
-rw-r--r--web/cobrands/hounslow/assets.js1
-rw-r--r--web/cobrands/peterborough/assets.js1
9 files changed, 82 insertions, 83 deletions
diff --git a/.cypress/cypress/integration/peterborough.js b/.cypress/cypress/integration/peterborough.js
index be1515028..452795d8c 100644
--- a/.cypress/cypress/integration/peterborough.js
+++ b/.cypress/cypress/integration/peterborough.js
@@ -33,7 +33,7 @@ describe('new report form', function() {
it('correctly changes the asset select message', function() {
cy.get('select:eq(4)').select('Street lighting');
- cy.get('.category_meta_message').should('contain', 'You can pick a street light from the map');
+ cy.get('.category_meta_message').should('contain', 'You can pick a light from the map');
cy.get('select:eq(4)').select('Trees');
cy.get('.category_meta_message').should('contain', 'You can pick a tree from the map');
});
diff --git a/conf/systemd.example b/conf/systemd.example
index 1f8edf13c..7f22b091a 100644
--- a/conf/systemd.example
+++ b/conf/systemd.example
@@ -7,7 +7,7 @@ After=network.target
Type=forking
User=fms
PIDFile=/var/www/fixmystreet/fixmystreet.pid
-ExecStartPre=mkdir /var/www/fixmystreet/logs
+ExecStartPre=/bin/mkdir -p /var/www/fixmystreet/logs
ExecStart=/var/www/fixmystreet/fixmystreet/script/server \
--port 9000 \
--env deployment \
diff --git a/perllib/FixMyStreet/DB/Result/Contact.pm b/perllib/FixMyStreet/DB/Result/Contact.pm
index 1fa38e8a2..5cf3302dd 100644
--- a/perllib/FixMyStreet/DB/Result/Contact.pm
+++ b/perllib/FixMyStreet/DB/Result/Contact.pm
@@ -180,10 +180,12 @@ sub disable_form_field {
sub sent_by_open311 {
my $self = shift;
my $body = $self->body;
+ my $method = $self->send_method || '';
+ my $body_method = $body->send_method || '';
return 1 if
- (!$body->can_be_devolved && $body->send_method eq 'Open311')
- || ($body->can_be_devolved && $body->send_method eq 'Open311' && !$self->send_method)
- || ($body->can_be_devolved && $self->send_method eq 'Open311');
+ (!$body->can_be_devolved && $body_method eq 'Open311')
+ || ($body->can_be_devolved && $body_method eq 'Open311' && !$method)
+ || ($body->can_be_devolved && $method eq 'Open311');
return 0;
}
diff --git a/web/cobrands/buckinghamshire/assets.js b/web/cobrands/buckinghamshire/assets.js
index 1030d11db..7c8995e41 100644
--- a/web/cobrands/buckinghamshire/assets.js
+++ b/web/cobrands/buckinghamshire/assets.js
@@ -61,9 +61,8 @@ var labeled_defaults = $.extend(true, {}, defaults, {
select_action: true,
feature_code: 'feature_id',
stylemap: streetlight_stylemap,
- asset_item_message: 'You can pick a <b class="asset-spot">ITEM</b> from the map &raquo;',
construct_asset_name: function(id) {
- var code = id.replace(/[0-9]/g, '');
+ var code = id.replace(/[O0-9]+[A-Z]*/g, '');
return {id: id, name: streetlight_code_to_type[code]};
},
actions: {
diff --git a/web/cobrands/cheshireeast/assets.js b/web/cobrands/cheshireeast/assets.js
index d9eb25821..4e5df342d 100644
--- a/web/cobrands/cheshireeast/assets.js
+++ b/web/cobrands/cheshireeast/assets.js
@@ -42,8 +42,7 @@ fixmystreet.assets.add(labeled_defaults, {
filter_key: 'feature_gr',
filter_value: 'LCOL',
asset_group: 'Street lights',
- asset_item: 'street light',
- asset_item_message: 'You can pick a <b class="asset-spot">street light</b> from the map &raquo;'
+ asset_item: 'street light'
});
fixmystreet.assets.add(defaults, {
diff --git a/web/cobrands/eastsussex/assets.js b/web/cobrands/eastsussex/assets.js
index 296c8ede4..6f5304cd0 100644
--- a/web/cobrands/eastsussex/assets.js
+++ b/web/cobrands/eastsussex/assets.js
@@ -72,18 +72,10 @@ fixmystreet.assets.add(defaults, {
asset_item: 'street light',
asset_category: ["Burning By Day", "Intermittent", "Lamp Dim", "Lamp Flashing", "Lamp Obscured", "Lamp Out", "Missing Number", "Noisy Column", "Vandalism" ],
select_action: true,
+ feature_code: 'Name',
actions: {
- asset_found: function(asset) {
- var id = asset.attributes.Name || '';
- if (id !== '') {
- $('.category_meta_message').html('You have selected <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;');
- }
+ asset_found: fixmystreet.assets.named_select_action_found,
+ asset_not_found: fixmystreet.assets.named_select_action_not_found
}
});
@@ -106,22 +98,19 @@ fixmystreet.assets.add(defaults, {
asset_item: 'drain',
asset_category: ["Blocked Drain", "Culvert", "Broken Drain Cover", "Smell", "Sunken Drain", "Missing Drain Cover"],
select_action: true,
+ construct_selected_asset_message: function(asset) {
+ var last_clean = asset.attributes.Gully_Last_Clean_Date__c || '';
+ var next_clean = asset.attributes.Gully_Next_Clean_Date__c || '';
+ if (last_clean !== '' || next_clean !== '') {
+ var message = '';
+ if (last_clean) { message += '<b>Last Cleaned</b>: ' + last_clean; }
+ if (next_clean) { message += ' <b>Next Clean</b>: ' + next_clean; }
+ return message;
+ }
+ },
actions: {
- asset_found: function(asset) {
- var last_clean = asset.attributes.Gully_Last_Clean_Date__c || '';
- var next_clean = asset.attributes.Gully_Next_Clean_Date__c || '';
- if (last_clean !== '' || next_clean !== '') {
- var message = '';
- if (last_clean) { message += '<b>Last Cleaned</b>: ' + last_clean; }
- if (next_clean) { message += ' <b>Next Clean</b>: ' + next_clean; }
- $('.category_meta_message').html(message);
- } 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;');
- }
+ asset_found: fixmystreet.assets.named_select_action_found,
+ asset_not_found: fixmystreet.assets.named_select_action_not_found
}
});
diff --git a/web/cobrands/fixmystreet/assets.js b/web/cobrands/fixmystreet/assets.js
index e816fb4e5..ffa342e5f 100644
--- a/web/cobrands/fixmystreet/assets.js
+++ b/web/cobrands/fixmystreet/assets.js
@@ -179,6 +179,18 @@ OpenLayers.Layer.VectorAsset = OpenLayers.Class(OpenLayers.Layer.Vector, {
return (f1.attributes[asset_id_field] == f2.attributes[asset_id_field]);
},
+ construct_selected_asset_message: function(asset) {
+ var id = asset.attributes[this.fixmystreet.feature_code] || '';
+ if (id === '') {
+ return;
+ }
+ var data = { id: id, name: this.fixmystreet.asset_item };
+ if (this.fixmystreet.construct_asset_name) {
+ data = this.fixmystreet.construct_asset_name(id) || data;
+ }
+ return 'You have selected ' + data.name + ' <b>' + data.id + '</b>';
+ },
+
find_matching_feature: function(feature, layer) {
if (!layer) {
return false;
@@ -402,12 +414,13 @@ function check_zoom_message_visibility() {
if (this.fixmystreet.non_interactive && !this.fixmystreet.display_zoom_message) {
return;
}
- var select = this.fixmystreet.asset_group ? 'category_group' : 'form_category';
- var category = $("select#" + select).val() || '',
- prefix = category.replace(/[^a-z]/gi, ''),
- id = "category_meta_message_" + prefix,
- $p = $('#' + id);
if (this.relevant()) {
+ var select = this.fixmystreet.asset_group ? 'category_group' : 'form_category',
+ category = $("select#" + select).val() || '',
+ prefix = category.replace(/[^a-z]/gi, ''),
+ id = "category_meta_message_" + prefix,
+ $p = $('#' + id),
+ message;
if ($p.length === 0) {
$p = $("<p>").prop("id", id).prop('class', 'category_meta_message');
if ($('html').hasClass('mobile')) {
@@ -419,30 +432,48 @@ function check_zoom_message_visibility() {
}
if (this.getVisibility() && this.inRange) {
- if (typeof this.fixmystreet.asset_item_message !== 'undefined') {
- $p.html(this.fixmystreet.asset_item_message);
- } else {
- $p.html('You can pick a <b class="asset-' + this.fixmystreet.asset_type + '">' + this.fixmystreet.asset_item + '</b> from the map &raquo;');
- }
+ message = get_asset_pick_message.call(this);
} else {
- $p.html('Zoom in to pick a ' + this.fixmystreet.asset_item + ' from the map');
+ message = 'Zoom in to pick a ' + this.fixmystreet.asset_item + ' from the map';
}
+ $p.html(message);
+ } else {
+ update_message_display.call(this, null);
+ }
+}
- } else if (this.fixmystreet.asset_group) {
- prefix = this.fixmystreet.asset_group.replace(/[^a-z]/gi, '');
- id = "category_meta_message_" + prefix;
- $p = $('#' + id);
- $p.remove();
+function get_asset_pick_message() {
+ var message;
+ if (typeof this.fixmystreet.asset_item_message !== 'undefined') {
+ message = this.fixmystreet.asset_item_message;
+ message = message.replace('ITEM', this.fixmystreet.asset_item);
+ } else {
+ message = 'You can pick a <b class="asset-' + this.fixmystreet.asset_type + '">' + this.fixmystreet.asset_item + '</b> from the map &raquo;';
+ }
+ return message;
+}
+
+function update_message_display(message) {
+ if (this.fixmystreet.asset_group) {
+ _update_message(message, this.fixmystreet.asset_group);
} else {
$.each(this.fixmystreet.asset_category, function(i, c) {
- var prefix = c.replace(/[^a-z]/gi, ''),
- id = "category_meta_message_" + prefix,
- $p = $('#' + id);
- $p.remove();
+ _update_message(message, c);
});
}
}
+function _update_message(message, c) {
+ var prefix = c.replace(/[^a-z]/gi, ''),
+ id = "category_meta_message_" + prefix,
+ $p = $('#' + id);
+ if (message) {
+ $p.html(message);
+ } else {
+ $p.remove();
+ }
+}
+
function layer_visibilitychanged() {
if (this.fixmystreet.road) {
if (!this.getVisibility()) {
@@ -817,35 +848,16 @@ fixmystreet.assets = {
return new OpenLayers.Style(f);
},
named_select_action_found: function(asset) {
- var id = asset.attributes[this.fixmystreet.feature_code] || '';
- if (id !== '') {
- var data = { id: id, name: this.fixmystreet.asset_item };
- if (this.fixmystreet.construct_asset_name) {
- data = this.fixmystreet.construct_asset_name(id) || data;
- }
- $('.category_meta_message').html('You have selected ' + data.name + ' <b>' + data.id + '</b>');
- } else {
- var message = this.fixmystreet.asset_item_message;
- message = message.replace('ITEM', this.fixmystreet.asset_item);
- $('.category_meta_message').html(message);
+ var fn = this.fixmystreet.construct_selected_asset_message || this.construct_selected_asset_message;
+ var message = fn.call(this, asset);
+ if (!message) {
+ message = get_asset_pick_message.call(this);
}
+ $('.category_meta_message').html(message);
},
named_select_action_not_found: function() {
- var message = this.fixmystreet.asset_item_message;
- message = message.replace('ITEM', this.fixmystreet.asset_item);
- if (this.fixmystreet.asset_group) {
- var prefix = this.fixmystreet.asset_group.replace(/[^a-z]/gi, '');
- var id = "category_meta_message_" + prefix;
- var $p = $('#' + id);
- $p.html(message);
- } else {
- $.each(this.fixmystreet.asset_category, function(i, c) {
- var prefix = c.replace(/[^a-z]/gi, ''),
- id = "category_meta_message_" + prefix,
- $p = $('#' + id);
- $p.html(message);
- });
- }
+ var message = get_asset_pick_message.call(this);
+ update_message_display.call(this, message);
},
selectedFeature: function() {
diff --git a/web/cobrands/hounslow/assets.js b/web/cobrands/hounslow/assets.js
index 375a74e3f..9521d73b8 100644
--- a/web/cobrands/hounslow/assets.js
+++ b/web/cobrands/hounslow/assets.js
@@ -136,7 +136,6 @@ var labeled_defaults = $.extend(true, {}, defaults, {
select_action: true,
stylemap: streetlight_stylemap,
feature_code: 'FeatureId',
- asset_item_message: 'You can pick a <b class="asset-spot">ITEM</b> from the map &raquo;',
construct_asset_name: function(id) {
if (id.split) {
var code = id.split("/").slice(-1)[0];
diff --git a/web/cobrands/peterborough/assets.js b/web/cobrands/peterborough/assets.js
index 3d718116e..1da72264d 100644
--- a/web/cobrands/peterborough/assets.js
+++ b/web/cobrands/peterborough/assets.js
@@ -143,7 +143,6 @@ fixmystreet.assets.add(light_defaults, {
options.category !== UNKNOWN_LIGHT_CATEGORY_NAME
) || options.category === "Lighting enquiry";
},
- asset_item_message: 'You can pick a <b class="asset-spot">street light</b> from the map &raquo;',
select_action: true,
actions: {
asset_found: function(asset) {