Skip to content

Commit

Permalink
Merge branch 'issues/commercial/787-bristol-assets'
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Nov 11, 2016
2 parents 881fc51 + cab0360 commit dace204
Show file tree
Hide file tree
Showing 20 changed files with 1,393 additions and 373 deletions.
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/App/Controller/Report/New.pm
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ sub set_report_extras : Private {
foreach my $contact (@$contacts) {
my $metas = $contact->get_metadata_for_input;
foreach my $field ( @$metas ) {
if ( lc( $field->{required} ) eq 'true' ) {
if ( lc( $field->{required} ) eq 'true' && !$c->cobrand->category_extra_hidden($field->{code})) {
unless ( $c->get_param($param_prefix . $field->{code}) ) {
$c->stash->{field_errors}->{ $field->{code} } = _('This information is required');
}
Expand Down
9 changes: 9 additions & 0 deletions perllib/FixMyStreet/Cobrand/Default.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1177,4 +1177,13 @@ sub lookup_by_ref_regex {
return qr/^\s*ref:\s*(\d+)\s*$/;
}

=head2 category_extra_hidden
Return true if an Open311 service attribute should be a hidden field.
=cut

sub category_extra_hidden {
my ($self, $meta) = @_;
}

1;
5 changes: 5 additions & 0 deletions perllib/FixMyStreet/Cobrand/UK.pm
Original file line number Diff line number Diff line change
Expand Up @@ -396,5 +396,10 @@ sub lookup_by_ref_regex {
return qr/^\s*(\d+)\s*$/;
}

sub category_extra_hidden {
my ($self, $meta) = @_;
return 1 if $meta eq 'usrn' || $meta eq 'asset_id';
return 0;
}

1;
3 changes: 2 additions & 1 deletion templates/web/angus/maps/fms.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<script type="text/javascript" src="[% version('/js/map-OpenLayers.js') %]"></script>
<script type="text/javascript" src="[% version('/js/map-bing-ol.js') %]"></script>
<script type="text/javascript" src="[% version('/js/map-fms.js') %]"></script>
<script src="[% version('/cobrands/angus/position_map.js') %]" charset="utf-8"></script>
<script src="[% version('/cobrands/fixmystreet/assets.js') %]"></script>
<script src="[% version('/cobrands/angus/js.js') %]"></script>
[% END %]

[% map_html = INCLUDE maps/openlayers.html include_key = 1 %]
2 changes: 1 addition & 1 deletion templates/web/base/admin/category_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h2>[% loc('Extra data:') %] </h2>
[% FOR meta IN contact.get_metadata_for_input %]
<li>
[% meta.order %], <code>[% meta.code %]</code>, [% meta.datatype %],
[% meta.required ? loc('required') : loc('optional') %]
[% meta.required == 'true' ? loc('required') : loc('optional') %]
<br><small>[% meta.description %]</small>
[% IF meta.variable != 'false' AND meta.exists('values') %]
<ul>
Expand Down
34 changes: 21 additions & 13 deletions templates/web/base/report/new/category_extras_fields.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
[%- FOR meta IN category_extras.$category %]
[%- meta_name = meta.code -%]

<label for="[% cat_prefix %]form_[% meta_name %]">[% meta.description %]</label>
[% IF field_errors.$meta_name %]
<p class='form-error'>[% field_errors.$meta_name %]</p>
[% END -%]
[% IF meta.variable != 'false' %]
[% IF meta.exists('values') %]
<select class="form-control" name="[% cat_prefix %][% meta_name %]" id="[% cat_prefix %]form_[% meta_name %]"[% meta.required == 'true' ? ' required' : '' %]>
[% FOR option IN meta.values %]
<option value="[% option.key %]"[% IF option.key == report_meta.$meta_name.value %] selected[% END %]>[% option.name %]</option>
[% IF c.cobrand.category_extra_hidden(meta_name) %]

<input type="hidden" value="" name="[% cat_prefix %][% meta_name %]" id="[% cat_prefix %]form_[% meta_name %]">

[% ELSE %]

<label for="[% cat_prefix %]form_[% meta_name %]">[% meta.description %]</label>
[% IF field_errors.$meta_name %]
<p class='form-error'>[% field_errors.$meta_name %]</p>
[% END -%]
[% IF meta.variable != 'false' %]
[% IF meta.exists('values') %]
<select class="form-control" name="[% cat_prefix %][% meta_name %]" id="[% cat_prefix %]form_[% meta_name %]"[% meta.required == 'true' ? ' required' : '' %]>
[% FOR option IN meta.values %]
<option value="[% option.key %]"[% IF option.key == report_meta.$meta_name.value %] selected[% END %]>[% option.name %]</option>
[% END %]
</select>
[% ELSE %]
<input class="form-control" type="text" value="[% report_meta.$meta_name.value | html %]" name="[% cat_prefix %][% meta_name %]" id="[% cat_prefix %]form_[% meta_name %]"[% meta.required == 'true' ? ' required' : '' %]>
[% END %]
</select>
[% ELSE %]
<input class="form-control" type="text" value="[% report_meta.$meta_name.value | html %]" name="[% cat_prefix %][% meta_name %]" id="[% cat_prefix %]form_[% meta_name %]"[% meta.required == 'true' ? ' required' : '' %]>
[% END %]

[% END %]
[% END %]
[%- END %]
8 changes: 4 additions & 4 deletions templates/web/base/report/new/category_wrapper.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<div id="form_category_row">
[% IF js %]
<div id="form_category_row">
<label for="form_category">[% loc('Category') %]</label>
<select class="form-control" name="category" id="form_category" required><option>[% loc('Loading...') %]</option></select>
</div>
<label for="form_category">[% loc('Category') %]</label>
<select class="form-control" name="category" id="form_category" required><option>[% loc('Loading...') %]</option></select>
[% ELSE %]
[% IF category_options.size %]
[% IF field_errors.category %]
Expand All @@ -11,6 +10,7 @@
[% PROCESS "report/new/category.html" %]
[% END %]
[% END %]
</div>

[%- IF category_extras %]
[% PROCESS "report/new/category_extras.html" %]
Expand Down
4 changes: 4 additions & 0 deletions templates/web/bristol/footer_extra_js.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<script src="[% version('/js/OpenLayers.Projection.OrdnanceSurvey.js') %]"></script>
<script src="[% version('/cobrands/fixmystreet-uk-councils/js.js') %]"></script>
<script src="[% version('/cobrands/fixmystreet/assets.js') %]"></script>
<script src="[% version('/cobrands/bristol/js.js') %]"></script>
2 changes: 1 addition & 1 deletion templates/web/bristol/maps/bristol.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[% map_js = BLOCK %]
<script type="text/javascript" src="[% version('/js/OpenLayers.2.11.zurich.js') %]"></script>
<script type="text/javascript" src="[% version('/js/OpenLayers/OpenLayers.bristol.js') %]"></script>
<script type="text/javascript" src="[% version('/js/map-OpenLayers.js') %]"></script>
<script type="text/javascript" src="[% version('/js/map-wmts-base.js') %]"></script>
<script type="text/javascript" src="[% version('/js/map-wmts-bristol.js') %]"></script>
Expand Down
12 changes: 0 additions & 12 deletions web/cobrands/angus/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,3 @@ label[for=pc] {
.nav-menu--breadcrumb {
display: none;
}

.streetlight-spot:before {
content: "";
display: inline-block;
width: 10px;
height: 10px;
border: 2px solid #000;
background-color: #ffff00;
margin: 0 0.3em 0 0.2em;
border-radius: 100%;
vertical-align: -2px;
}
15 changes: 15 additions & 0 deletions web/cobrands/angus/js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
$(fixmystreet.add_assets({
wfs_url: "https://data.angus.gov.uk/geoserver/services/wfs",
wfs_feature: "lighting_column_v",
wfs_fault_feature: "lighting_faults_v",
asset_category: "Street lighting",
asset_item: 'street light',
asset_type: 'spot',
max_resolution: 2.388657133579254,
min_resolution: 0.5971642833948135,
asset_id_field: 'n',
attributes: {
column_id: 'n'
},
geometryName: 'g'
}));
6 changes: 0 additions & 6 deletions web/cobrands/angus/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,6 @@ body.mappage {
#category_meta h4 {
display: none;
}

#category_meta_message {
padding-top: 0.5em;
font-size: 0.9em;
text-align: center;
}
}

.angus_footer {
Expand Down
Loading

0 comments on commit dace204

Please sign in to comment.