Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision be89b08c

Von Jan Büren vor mehr als 1 Jahr hinzugefügt

  • ID be89b08c12d3dc1bdb8e5820f7fd998825fc7b8b
  • Vorgänger e477bd21
  • Nachfolger 1b5d286f

Drei Status für chart eingeführt: valid, invalid, all (POD erg.)

Unterschiede anzeigen:

SL/DB/Manager/Chart.pm
9 9
use SL::DB::Helper::Paginated;
10 10
use SL::DB::Helper::Filtered;
11 11
use SL::MoreCommon qw(listify);
12
use DateTime;
13 12
use SL::DBUtils;
13

  
14
use Carp;
15
use DateTime;
14 16
use Data::Dumper;
15 17

  
16 18
sub object_class { 'SL::DB::Chart' }
......
38 40
    my ($key, $value) = @_;
39 41
    return __PACKAGE__->booked_filter($value);
40 42
  },
41
  invalid => sub {
43
  status => sub {
42 44
    my ($key, $value) = @_;
43 45
    return __PACKAGE__->invalid_filter($value);
44 46
  },
45 47

  
46 48
);
47 49
sub invalid_filter {
48
  my ($class, $invalid) = @_;
50
  my ($class, $status) = @_;
51

  
52
  croak "Wrong call, need status invalid, all or valid, got:" . $status unless $status =~ m/invalid|all|valid/;
49 53

  
50
  $invalid //= 0;
51 54
  my @filter;
52 55

  
53
  if ( $invalid ) {
56
  if ($status eq 'all') {
54 57
     push @filter, ( id => [ \"SELECT id FROM chart" ] );
55
  } else {
58
  } elsif ($status eq 'valid') {
56 59
     push @filter, ( id => [ \"SELECT id FROM chart WHERE NOT invalid" ] );
57
  };
60
  } elsif ($status eq 'invalid') {
61
     push @filter, ( id => [ \"SELECT id FROM chart WHERE invalid" ] );
62
  } else { die "Wrong state for invalid_filter"; }
58 63

  
59 64
  return @filter;
60 65
}
SL/Presenter/Chart.pm
39 39

  
40 40
  my $ret =
41 41
    input_tag($name, (ref $value && $value->can('id') ? $value->id : ''), class => "@classes", type => 'hidden', id => $id) .
42
    join('', map { $params{$_} ? input_tag("", delete $params{$_}, id => "${id}_${_}", type => 'hidden') : '' } qw(type category choose booked invalid)) .
42
    join('', map { $params{$_} ? input_tag("", delete $params{$_}, id => "${id}_${_}", type => 'hidden') : '' } qw(type category choose booked status)) .
43 43
    input_tag("", (ref $value && $value->can('displayable_name')) ? $value->displayable_name : '', id => "${id}_name", %params);
44 44

  
45 45
  $::request->layout->add_javascripts('autocomplete_chart.js');
......
161 161
Without fat_set_item only the variables id and name (displayable name) are
162 162
available.
163 163

  
164
=item * status
165

  
166
If C<%params> contains C<status> only charts of this status will be used
167
for autocompletion. C<status> can be one of the following strings:
168
C<valid>, C<invalid> or C<all>. C<valid> is the default if C<status> is
169
not given.
170

  
164 171
=back
165 172

  
166 173
C<chart_picker> will register its javascript for inclusion in the next header
js/autocomplete_chart.js
38 38
    var $category = $('#' + real_id + '_category');  // hidden input_field of the chart_picker, added in Presenter, never changes
39 39
    var $choose = $('#' + real_id + '_choose');
40 40
    var $booked = $('#' + real_id + '_booked');
41
    var $invalid = $('#' + real_id + '_invalid');
41
    var $status = $('#' + real_id + '_status');
42 42
    var state   = STATES.PICKED;
43 43
    var last_real = $real.val();
44 44
    var last_dummy = $dummy.val();
......
85 85
      if ($category && $category.val())
86 86
        data['filter.category'] = $category.val().split(',');
87 87

  
88
      data['filter.invalid'] = ($invalid && $invalid.val()) ? 1 : 0;
89
      //data['invalid'] = 1;
90

  
88
      // show only valid charts
89
      data['filter.status'] = ($status && $status.val()) ? $status.val() : 'valid';
91 90

  
92 91
      return data;
93 92
    }
templates/webpages/chart/test_page.html
9 9
<p>
10 10
All charts: [% P.chart.picker('chart_id', '', style=style) %]text after icon<br>
11 11
Only booked charts: [% P.chart.picker('chart_id_booked', '', booked=1, style=style) %]<br>
12
Only valid charts: [% P.chart.picker('chart_id_valid', '', invalid=0, style=style) %]<br>
13
Only invalid charts: [% P.chart.picker('chart_id_invalid', '', invalid=1, style=style) %]<br>
12
Only valid charts: [% P.chart.picker('chart_id_valid', '', style=style) %]<br>
13
Only invalid charts: [% P.chart.picker('chart_id_invalid', '', status='invalid', style=style) %]<br>
14
Valid and invalid charts: [% P.chart.picker('chart_id_all', '', status='all', style=style) %]<br>
14 15
All charts choose: [% P.chart.picker('chart_id_choose', '', choose=1, style=style) %]<br>
15 16
</p>
16 17

  

Auch abrufbar als: Unified diff