aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/open311-populate-service-list9
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm8
-rw-r--r--templates/web/default/report/new/fill_in_details.html25
-rw-r--r--web/js/fixmystreet.js2
4 files changed, 27 insertions, 17 deletions
diff --git a/bin/open311-populate-service-list b/bin/open311-populate-service-list
index 7e4411d6b..f9f183f26 100755
--- a/bin/open311-populate-service-list
+++ b/bin/open311-populate-service-list
@@ -75,7 +75,14 @@ while ( my $council = $council_list->next ) {
if ( lc( $service->{metadata} ) eq 'true' ) {
print "Fetching meta data for $service->{service_code}\n";
my $meta_data = $open311->get_service_meta_info( $service->{service_code} );
- $contact->extra( $meta_data );
+
+ # turn the data into something a bit more friendly to use
+ my %meta = ();
+ foreach my $attribute ( @{ $meta_data->{attribute} } ) {
+ $meta{ $attribute->{code} } = $attribute;
+ }
+
+ $contact->extra( \%meta );
$contact->update;
}
print "created contact for service code " . $service->{service_code} . " for council @{[$council->area_id]}\n";
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index cd943070d..5cf634e14 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -692,7 +692,7 @@ sub process_report : Private {
my @extra = ();
my $metas = $contacts[0]->extra;
- foreach my $field ( @{ $metas->{attribute} } ) {
+ foreach my $field ( sort { $a->{order} <=> $b->{order} } values %$metas ) {
if ( lc( $field->{required} ) eq 'true' ) {
unless ( $c->request->param( $field->{code} ) ) {
$c->stash->{field_errors}->{ $field->{code} } = _('This information is required');
@@ -705,8 +705,10 @@ sub process_report : Private {
};
}
- $c->stash->{report_meta} = \@extra if @extra;
- $report->extra( \@extra ) if @extra;
+ if ( @extra ) {
+ $c->stash->{report_meta} = \@extra;
+ $report->extra( \@extra );
+ }
} elsif ( @{ $c->stash->{area_ids_to_list} } ) {
# There was an area with categories, but we've not been given one. Bail.
diff --git a/templates/web/default/report/new/fill_in_details.html b/templates/web/default/report/new/fill_in_details.html
index 8e8134c3a..36b263864 100644
--- a/templates/web/default/report/new/fill_in_details.html
+++ b/templates/web/default/report/new/fill_in_details.html
@@ -100,23 +100,24 @@
<textarea name="detail" id="form_detail" rows="7" cols="26">[% report.detail | html %]</textarea>
</div>
-[% IF category_extras %]
+[%- IF category_extras %]
<div id="category_meta">
- [% IF report_meta %]
- [% FOR meta IN report_meta %]
- [% meta_name = meta.name %]
+ [%- IF report_meta %]
+ [%- FOR meta IN report_meta %]
+ [%- meta_name = meta.name -%]
+
[% IF field_errors.$meta_name %]
<div class='form-error'>[% field_errors.$meta_name %]</div>
-[% END %]
+[% END -%]
-<div class="form-field">
- <label for="form_[% meta %]">[% meta.description _ ':' %]</label>
- <input type="text" value="[% meta.value | html %]" name="[% meta_name %]" id="form_[% meta_name %]">
-</div>
- [% END %]
- [% END %]
+ <div class="form-field">
+ <label for="form_[% meta_name %]">[% meta.description _ ':' %]</label>
+ <input type="text" value="[% meta.value | html %]" name="[% meta_name %]" id="form_[% meta_name %]">
+ </div>
+ [%- END %]
+ [%- END %]
</div>
-[% END %]
+[%- END %]
[% IF c.cobrand.allow_photo_upload %]
[% IF field_errors.photo %]
diff --git a/web/js/fixmystreet.js b/web/js/fixmystreet.js
index 2ebf74751..22cd1c64f 100644
--- a/web/js/fixmystreet.js
+++ b/web/js/fixmystreet.js
@@ -61,7 +61,7 @@ $(function(){
if ( category_extras ) {
$('#category_meta').empty();
if ( category_extras[this.options[ this.selectedIndex ].text] ) {
- extras = category_extras[this.options[ this.selectedIndex ].text].attribute;
+ extras = category_extras[this.options[ this.selectedIndex ].text];
for ( i in extras ) {
meta = extras[i];
field = '<div class="form-field">';