diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 9 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Zurich.pm | 89 | ||||
-rw-r--r-- | templates/web/zurich/admin/index-dm.html | 2 | ||||
-rw-r--r-- | templates/web/zurich/admin/report_edit.html | 132 |
4 files changed, 151 insertions, 81 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index e453a9565..2551de071 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -721,15 +721,6 @@ sub report_edit : Path('report_edit') : Args(1) { # do this here otherwise lastupdate and confirmed times # do not display correctly $problem->discard_changes; - - if ( $c->cobrand->moniker eq 'zurich' && $c->req->param('body') ) { - my $problem_body = $c->req->param('body'); - my $admin_body = $c->stash->{body}; - if ($admin_body->id ne $problem_body) { - $c->detach('index'); - } - } - } } diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index 9e9d8542a..aa5a3a8c2 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -121,6 +121,33 @@ sub admin_report_edit { unless $allowed_bodies{$problem->bodies_str}; } + if ($type eq 'super') { + + my @bodies = $c->model('DB::Body')->all(); + @bodies = sort { strcoll($a->name, $b->name) } @bodies; + $c->stash->{bodies} = \@bodies; + + # Can change category to any other + my @categories = $c->model('DB::Contact')->not_deleted->all; + $c->stash->{categories} = [ map { $_->category } @categories ]; + + } elsif ($type eq 'dm') { + + # Can assign to: + my @bodies = $c->model('DB::Body')->search( [ + { 'me.parent' => $body->parent->id }, # Other DMs on the same level + { 'me.parent' => $body->id }, # Their subdivisions + { 'me.parent' => undef, 'bodies.id' => undef }, # External bodies + ], { join => 'bodies', distinct => 1 } ); + @bodies = sort { strcoll($a->name, $b->name) } @bodies; + $c->stash->{bodies} = \@bodies; + + # Can change category to any other + my @categories = $c->model('DB::Contact')->not_deleted->all; + $c->stash->{categories} = [ map { $_->category } @categories ]; + + } + # Problem updates upon submission if ( ($type eq 'super' || $type eq 'dm') && $c->req->param('submit') ) { $c->forward('check_token'); @@ -128,34 +155,55 @@ sub admin_report_edit { # Predefine the hash so it's there for lookups # XXX Note you need to shallow copy each time you set it, due to a bug? in FilterColumn. my $extra = $problem->extra || {}; - $extra->{internal_notes} = $c->req->param('internal_notes'); $extra->{publish_photo} = $c->req->params->{publish_photo} || 0; $extra->{third_personal} = $c->req->params->{third_personal} || 0; $problem->extra( { %$extra } ); + # Workflow things + my $redirect = 0; + my $new_cat = $c->req->params->{category}; + if ( $new_cat && $new_cat ne $problem->category ) { + my $cat = $c->model('DB::Contact')->search( { category => $c->req->params->{category} } )->first; + $problem->category( $new_cat ); + $problem->bodies_str( $cat->body_id ); + $problem->whensent( undef ); + $redirect = 1 if $cat->body_id ne $body->id; + } elsif ( my $subdiv = $c->req->params->{body_subdivision} ) { + $problem->state( 'in progress' ); + $problem->bodies_str( $subdiv ); + $problem->whensent( undef ); + $redirect = 1; + } elsif ( my $external = $c->req->params->{body_external} ) { + $problem->state( 'closed' ); + $problem->bodies_str( $external ); + $problem->whensent( undef ); + $redirect = 1; + } else { + $problem->state( $c->req->params->{state} ) if $c->req->params->{state}; + } + + $problem->title( $c->req->param('title') ); + $problem->detail( $c->req->param('detail') ); + $problem->lastupdate( \'ms_current_timestamp()' ); $problem->update; - } - if ($type eq 'super') { + $c->stash->{status_message} = + '<p><em>' . _('Updated!') . '</em></p>'; - my @bodies = $c->model('DB::Body')->all(); - @bodies = sort { strcoll($a->name, $b->name) } @bodies; - $c->stash->{bodies} = \@bodies; + # do this here otherwise lastupdate and confirmed times + # do not display correctly + $problem->discard_changes; - } elsif ($type eq 'dm') { + if ( $redirect ) { + $c->detach('index'); + } - # Can assign to: - my @bodies = $c->model('DB::Body')->search( [ - { 'me.parent' => $body->parent->id }, # Other DMs on the same level - { 'me.parent' => $body->id }, # Their subdivisions - { 'me.parent' => undef, 'bodies.id' => undef }, # External bodies - ], { join => 'bodies', distinct => 1 } ); - @bodies = sort { strcoll($a->name, $b->name) } @bodies; - $c->stash->{bodies} = \@bodies; + return 1; + } - } elsif ($type eq 'sdm') { + if ($type eq 'sdm') { # Has cut-down edit template for adding update and sending back up only $c->stash->{template} = 'admin/report_edit-sdm.html'; @@ -167,9 +215,7 @@ sub admin_report_edit { $problem->state( 'confirmed' ); $problem->update; # log here - $c->res->redirect( '/admin/summary' ); - return 1; } elsif ($c->req->param('no_more_updates')) { $c->forward('check_token'); @@ -178,9 +224,7 @@ sub admin_report_edit { $problem->state( 'planned' ); $problem->update; # log here - $c->res->redirect( '/admin/summary' ); - return 1; } elsif ($c->req->param('submit')) { $c->forward('check_token'); @@ -207,13 +251,14 @@ sub admin_report_edit { } $c->stash->{status_message} = '<p><em>' . _('Updated!') . '</em></p>'; - $c->stash->{updates} = [ $c->model('DB::Comment') ->search( { problem_id => $problem->id }, { order_by => 'created' } ) ->all ]; - return 1; } + + return 1; + } return 0; diff --git a/templates/web/zurich/admin/index-dm.html b/templates/web/zurich/admin/index-dm.html index cf7ebf13d..4f755cb69 100644 --- a/templates/web/zurich/admin/index-dm.html +++ b/templates/web/zurich/admin/index-dm.html @@ -12,6 +12,8 @@ } %] +[% status_message %] + <h2>New reports</h2> [% INCLUDE list, problems = unconfirmed.all %] diff --git a/templates/web/zurich/admin/report_edit.html b/templates/web/zurich/admin/report_edit.html index 85f8b901f..2cf65db82 100644 --- a/templates/web/zurich/admin/report_edit.html +++ b/templates/web/zurich/admin/report_edit.html @@ -7,26 +7,7 @@ <input type="hidden" name="token" value="[% token %]" > <input type="hidden" name="submit" value="1" > -<!-- -[% IF NOT state OR state.0 == 'unconfirmed' %] -<p>[% loc('Body:') %] - <select name="body_external"> - [% FOR body IN bodies %] - [% NEXT IF !body.parent AND !body.bodies %] - <option value="[% body.id %]"[% IF body.id == problem.bodies_str%] selected[% END %]>[% body.name %]</option> - [% END %] - </select> - -<p>[% loc('Body:') %] - <select name="body_external"> - [% FOR body IN bodies %] - [% NEXT IF body.parent OR body.bodies %] - <option value="[% body.id %]"[% IF body.id == problem.bodies_str%] selected[% END %]>[% body.name %]</option> - [% END %] - </select> - -[% END %] ---> +<div style="float:left; width:48%; margin-right:2%"> <ul> [%- cobrand_data = problem.cobrand_data %] @@ -36,37 +17,10 @@ <li><label for='detail'>[% loc('Details:') %]</label> <textarea name='detail' id='detail' cols=60 rows=5>[% problem.detail | html %]</textarea></li> <li>[% loc('Co-ordinates:') %] [% problem.local_coords.join(',') %] ([% problem.latitude %],[% problem.longitude %]) ([% loc('originally entered') %] ‘[% problem.postcode | html %]’, [% IF problem.used_map %][% loc('used map') %][% ELSE %][% loc("didn't use map") %][% END %])</li> -<li>[% loc('Body:') %] - <select name="body"> - [% FOR body IN bodies %] - <option value="[% body.id %]"[% IF body.id == problem.bodies_str%] selected[% END %]>[% body.name %]</option> - [% END %] - </select> - <input type="checkbox" name="third_personal" id="third_personal" value="1"[% ' checked' IF problem.extra.third_personal %]> - <label for="third_personal" class="inline">Include reporter personal details</label> -</li> -<li>[% loc('State:') %] <select name="state" id="state"> - [% FOREACH state IN [ - ['unconfirmed',loc('Submitted')] - ['confirmed', loc('Open')], - ['in progress', loc('In progress')], - ['planned', loc('Planned')], - ['fixed - council', loc('Closed')], - ['closed', loc('Closed')], - ['hidden', loc('Hidden')], - ] %] - <option [% 'selected ' IF state.0 == problem.state %] value="[% state.0 %]">[% state.1 %]</option> - [% END %] -</select></li> - -<li><label for="internal_notes">[% loc('Internal notes:') %]</label> -<textarea name='internal_notes' id='internal_notes' cols=60 rows=5>[% problem.extra.internal_notes | html %]</textarea></li> - -<li>[% loc('Category:') %] [% problem.category | html %] </li> <input type="hidden" name="anonymous" value="[% problem.anonymous %]"> -<li>[% loc('Name:') %] <input type='text' name='name' id='name' value='[% problem.name | html %]'></li> -<li>[% loc('Email:') %] <input type='text' id='email' name='email' value='[% problem.user.email | html %]'> +<li>[% loc('Name:') %] [% problem.name | html %] <input type='hidden' name='name' id='name' value='[% problem.name | html %]'></li> +<li>[% loc('Email:') %] [% problem.user.email | html %] <input type='hidden' id='email' name='email' value='[% problem.user.email | html %]'> [% IF problem.extra.email_confirmed %][% loc('Confirmed') %][% END %] </li> <li>[% loc('Phone:') %] [% IF problem.user.phone %][% problem.user.phone | html %][% ELSE %]<em>[% loc('None') %]</em>[% END %]</li> @@ -86,7 +40,85 @@ <label class="inline" for="publish_photo">[% loc("Publish photo") %]</label></li> [% END %] </ul> -<input type="submit" name="Submit changes" value="[% loc('Submit changes') %]" ></form> +</div> + +<div style="float:right;width:48%"> + +<p><label for="internal_notes">[% loc('Internal notes:') %]</label> +<textarea name='internal_notes' id='internal_notes' cols=60 rows=5>[% problem.extra.internal_notes | html %]</textarea></p> + +[% IF problem.state == 'unconfirmed' OR problem.state == 'confirmed' %] + + <p>[% loc('State:') %] <select name="state" id="state"> + <option value="">--</option> + [% FOREACH s IN [ + ['unconfirmed',loc('Submitted')] + ['confirmed', loc('Open')], + ['hidden', loc('Hidden')], + ] %] + <option [% 'selected ' IF s.0 == problem.state %] value="[% s.0 %]">[% s.1 %]</option> + [% END %] + </select></p> + +<ul> +<li><label for="body_subdivision">[% loc('Assign to subdivision:') %]</label> + <select name="body_subdivision" id="body_subdivision"> + <option value="">--</option> + [% FOR body IN bodies %] + [% NEXT UNLESS body.parent.id == c.user.from_body.id %] + <option value="[% body.id %]"[% IF body.id == problem.bodies_str %] selected[% END %]>[% body.name %]</option> + [% END %] + </select> + +<li> +<label for="category"> +[% loc('Category:') %] [% problem.category %]<br> +[% loc('Assign to different category:') %]</label> + <select name="category" id="category"> + <option value="">--</option> + [% FOREACH cat IN categories %] + <option value="[% cat %]">[% cat %]</option> + [% END %] + </select></li> + +<li><label for="body_external">[% loc('Assign to external body:') %]</label> + <select name="body_external" id="body_external"> + <option value="">--</option> + [% FOR body IN bodies %] + [% NEXT IF body.parent OR body.bodies %] + <option value="[% body.id %]"[% IF body.id == problem.bodies_str %] selected[% END %]>[% body.name %]</option> + [% END %] + </select> + <br> + <input type="checkbox" name="third_personal" id="third_personal" value="1"[% ' checked' IF problem.extra.third_personal %]> + <label for="third_personal" class="inline">Include reporter personal details</label> + +</ul> + +[% ELSIF problem.state == 'planned' %] + + <p>[% loc('State:') %] <select name="state" id="state"> + <option value="">--</option> + [% FOREACH s IN [ + ['planned', loc('Planned')], + ['hidden', loc('Hidden')], + ] %] + <option [% 'selected ' IF s.0 == problem.state %] value="[% s.0 %]">[% s.1 %]</option> + [% END %] + </select></p> + + <ul> + <li>TODO: Leave public update to finish</li> + </ul> + +[% END %] + +</div> + +<div style="clear:both"></div> +<p align="right"><input type="submit" name="Submit changes" value="[% loc('Submit changes') %]" ></p> + +</form> [% INCLUDE 'admin/list_updates.html' %] |