diff options
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Dashboard.pm | 7 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 7 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/View/Web.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 28 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Oxfordshire.pm | 13 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Comment.pm | 68 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/State.pm | 3 |
7 files changed, 67 insertions, 67 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm index fbe5a2dc9..f3989e760 100644 --- a/perllib/FixMyStreet/App/Controller/Dashboard.pm +++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm @@ -24,6 +24,8 @@ sub example : Local : Args(0) { my ( $self, $c ) = @_; $c->stash->{template} = 'dashboard/index.html'; + $c->stash->{filter_states} = $c->cobrand->state_groups_inspect; + $c->stash->{children} = {}; for my $i (1..3) { $c->stash->{children}{$i} = { id => $i, name => "Ward $i" }; @@ -93,6 +95,7 @@ sub index : Path : Args(0) { $c->stash->{body} = $body; # Set up the data for the dropdowns + $c->stash->{filter_states} = $c->cobrand->state_groups_inspect; # Just take the first area ID we find my $area_id = $body->body_areas->first->area_id; @@ -145,12 +148,10 @@ sub index : Path : Args(0) { # List of reports underneath summary table $c->stash->{q_state} = $c->get_param('state') || ''; - if ( $c->stash->{q_state} eq 'fixed' ) { + if ( $c->stash->{q_state} eq 'fixed - council' ) { $prob_where->{'me.state'} = [ FixMyStreet::DB::Result::Problem->fixed_states() ]; } elsif ( $c->stash->{q_state} ) { $prob_where->{'me.state'} = $c->stash->{q_state}; - $prob_where->{'me.state'} = { IN => [ 'planned', 'action scheduled' ] } - if $prob_where->{'me.state'} eq 'action scheduled'; } my $params = { %$prob_where, diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index b597cb7a8..8f8205719 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -558,12 +558,11 @@ sub stash_report_filter_status : Private { if ($c->user and ($c->user->is_superuser or ( $c->stash->{body} and $c->user->belongs_to_body($c->stash->{body}->id) ))) { + $c->stash->{filter_states} = $c->cobrand->state_groups_inspect; foreach my $state (FixMyStreet::DB::Result::Problem->visible_states()) { if ($status{$state}) { - %filter_problem_states = (%filter_problem_states, ($state => 1)); - my $pretty_state = $state; - $pretty_state =~ tr/ /_/; - $filter_status{$pretty_state} = 1; + $filter_problem_states{$state} = 1; + $filter_status{$state} = 1; } } } diff --git a/perllib/FixMyStreet/App/View/Web.pm b/perllib/FixMyStreet/App/View/Web.pm index 93c459e26..93aa0e2fb 100644 --- a/perllib/FixMyStreet/App/View/Web.pm +++ b/perllib/FixMyStreet/App/View/Web.pm @@ -170,12 +170,8 @@ sub decode { sub prettify_state { my ($self, $c, $text, $single_fixed) = @_; - # New template to prevent interaction with current one - my $tt = FixMyStreet::Template->new({ INCLUDE_PATH => $self->{include_path} }); - my $var; - $tt->process('report/state-list.html', { state => $text }, \$var); - $var =~ s/ - .*// if $single_fixed; - return $var; + + return FixMyStreet::DB->resultset("State")->display($text, $single_fixed); } 1; diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 5dcdc9a4b..4e5228a25 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -179,7 +179,7 @@ sub restriction { return $self->moniker ? { cobrand => $self->moniker } : {}; } -=head2 base_url_with_lang +=head2 base_url_with_lang =cut @@ -358,7 +358,7 @@ sub front_stats_data { Returns any disambiguating information available. Defaults to none. -=cut +=cut sub disambiguate_location { FixMyStreet->config('GEOCODING_DISAMBIGUATION') or {}; } @@ -820,7 +820,7 @@ sub is_two_tier { 0; } =item council_rss_alert_options -Generate a set of options for council rss alerts. +Generate a set of options for council rss alerts. =cut @@ -1066,6 +1066,28 @@ sub show_unconfirmed_reports { 0; } +sub state_groups_admin { + my $rs = FixMyStreet::DB->resultset("State"); + my @fixed = FixMyStreet::DB::Result::Problem->fixed_states; + [ + [ $rs->display('confirmed'), [ FixMyStreet::DB::Result::Problem->open_states ] ], + @fixed ? [ $rs->display('fixed'), [ FixMyStreet::DB::Result::Problem->fixed_states ] ] : (), + [ $rs->display('closed'), [ FixMyStreet::DB::Result::Problem->closed_states ] ], + [ $rs->display('hidden'), [ FixMyStreet::DB::Result::Problem->hidden_states ] ] + ] +} + +sub state_groups_inspect { + my $rs = FixMyStreet::DB->resultset("State"); + my @fixed = FixMyStreet::DB::Result::Problem->fixed_states; + [ + [ $rs->display('confirmed'), [ grep { $_ ne 'planned' } FixMyStreet::DB::Result::Problem->open_states ] ], + @fixed ? [ $rs->display('fixed'), [ 'fixed - council' ] ] : (), + [ $rs->display('closed'), [ grep { $_ ne 'closed' } FixMyStreet::DB::Result::Problem->closed_states ] ], + [ $rs->display('hidden'), [ 'hidden' ] ] + ] +} + =head2 never_confirm_updates If true then we never send an email to confirm an update diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm index a061ff46c..b3d6b28c3 100644 --- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm +++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm @@ -122,12 +122,19 @@ sub path_to_pin_icons { sub pin_hover_title { my ($self, $problem, $title) = @_; - my $state = $self->{c}->render_fragment( - 'report/state-list.html', - { state => $problem->state }); + my $state = FixMyStreet::DB->resultset("State")->display($problem->state, 1); return "$state: $title"; } +sub state_groups_inspect { + [ + [ _('New'), [ 'confirmed', 'investigating' ] ], + [ _('Scheduled'), [ 'action scheduled' ] ], + [ _('Fixed'), [ 'fixed - council' ] ], + [ _('Closed'), [ 'not responsible', 'duplicate', 'unable to fix' ] ], + ] +} + sub open311_config { my ($self, $row, $h, $params) = @_; diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index d688eb8b9..562f29693 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -227,8 +227,6 @@ sub meta_line { my $meta = ''; - $c->stash->{last_state} ||= ''; - if ($self->anonymous or !$self->name) { $meta = sprintf( _( 'Posted anonymously at %s' ), Utils::prettify_dt( $self->confirmed ) ) } elsif ($self->user->from_body) { @@ -257,60 +255,36 @@ sub meta_line { $meta = sprintf( _( 'Posted by %s at %s' ), FixMyStreet::Template::html_filter($self->name), Utils::prettify_dt( $self->confirmed ) ) } + if ($self->get_extra_metadata('defect_raised')) { + $meta .= ', ' . _( 'and a defect raised' ); + } + + return $meta; +}; + +sub problem_state_display { + my ( $self, $c ) = @_; + my $update_state = ''; + my $cobrand = $c->cobrand->moniker; if ($self->mark_fixed) { - $update_state = _( 'marked as fixed' ); + return FixMyStreet::DB->resultset("State")->display('fixed', 1); } elsif ($self->mark_open) { - $update_state = _( 'reopened' ); + return FixMyStreet::DB->resultset("State")->display('confirmed', 1); } elsif ($self->problem_state) { my $state = $self->problem_state; - - if ($state eq 'confirmed') { - if ($c->stash->{last_state}) { - $update_state = _( 'reopened' ) - } - } elsif ($state eq 'investigating') { - $update_state = _( 'marked as investigating' ) - } elsif ($state eq 'planned') { - $update_state = _( 'marked as planned' ) - } elsif ($state eq 'in progress') { - $update_state = _( 'marked as in progress' ) - } elsif ($state eq 'action scheduled') { - $update_state = _( 'marked as action scheduled' ) - } elsif ($state eq 'closed') { - $update_state = _( 'marked as closed' ) - } elsif ($state =~ /^fixed/) { - $update_state = _( 'marked as fixed' ) - } elsif ($state eq 'unable to fix') { - $update_state = _( 'marked as no further action' ) - } elsif ($state eq 'not responsible') { - $update_state = _( "marked as not the council's responsibility" ) - } elsif ($state eq 'duplicate') { - $update_state = _( 'closed as a duplicate report' ) - } elsif ($state eq 'internal referral') { - $update_state = _( 'marked as an internal referral' ) - } - - if ($c->cobrand->moniker eq 'bromley' || $self->problem->to_body_named('Bromley')) { - if ($state eq 'not responsible') { - $update_state = 'marked as third party responsibility' + if ($state eq 'not responsible') { + $update_state = _( "not the council's responsibility" ); + if ($cobrand eq 'bromley' || $self->problem->to_body_named('Bromley')) { + $update_state = 'third party responsibility'; } + } else { + $update_state = FixMyStreet::DB->resultset("State")->display($state, 1); } - } - if ($update_state ne $c->stash->{last_state} and $update_state) { - $meta .= ", $update_state"; - } - - if ($self->get_extra_metadata('defect_raised')) { - $meta .= ', ' . _( 'and a defect raised' ); - } - - $c->stash->{last_state} = $update_state; - - return $meta; -}; + return $update_state; +} 1; diff --git a/perllib/FixMyStreet/DB/ResultSet/State.pm b/perllib/FixMyStreet/DB/ResultSet/State.pm index 03bbb5e3b..8b6a8963e 100644 --- a/perllib/FixMyStreet/DB/ResultSet/State.pm +++ b/perllib/FixMyStreet/DB/ResultSet/State.pm @@ -54,7 +54,7 @@ sub fixed { [ $_[0]->_filter(sub { $_->type eq 'fixed' }) ] } # This function can be used to return that label's display name. sub display { - my ($rs, $label) = @_; + my ($rs, $label, $single_fixed) = @_; my $unchanging = { unconfirmed => _("Unconfirmed"), hidden => _("Hidden"), @@ -62,6 +62,7 @@ sub display { 'fixed - council' => _("Fixed - Council"), 'fixed - user' => _("Fixed - User"), }; + $label = 'fixed' if $single_fixed && $label =~ /^fixed - (council|user)$/; return $unchanging->{$label} if $unchanging->{$label}; my ($state) = $rs->_filter(sub { $_->label eq $label }); return $label unless $state; |