Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 68d15545

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

  • ID 68d15545d1eabd0a60c8457b701106bdd01cf808
  • Vorgänger 11047a5a
  • Nachfolger 07516234

erste Idee: Ungültig für ChartPicker umgesetzt

Unterschiede anzeigen:

SL/DB/Manager/Chart.pm
38 38
    my ($key, $value) = @_;
39 39
    return __PACKAGE__->booked_filter($value);
40 40
  },
41
  invalid => sub {
42
    my ($key, $value) = @_;
43
    return __PACKAGE__->invalid_filter($value);
44
  },
45

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

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

  
53
  if ( $invalid ) {
54
     push @filter, ( id => [ \"SELECT id FROM chart" ] );
55
  } else {
56
     push @filter, ( id => [ \"SELECT id FROM chart WHERE NOT invalid" ] );
57
  };
58

  
59
  return @filter;
60
}
61

  
42 62

  
43 63
sub booked_filter {
44 64
  my ($class, $booked) = @_;
SL/Presenter/Chart.pm
29 29

  
30 30
sub chart_picker {
31 31
  my ($name, $value, %params) = @_;
32

  
33 32
  $value = SL::DB::Manager::Chart->find_by(id => $value) if $value && !ref $value;
34 33
  my $id = delete($params{id}) || name_to_id($name);
35 34
  my $fat_set_item = delete $params{fat_set_item};
......
40 39

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

  
46 45
  $::request->layout->add_javascripts('autocomplete_chart.js');
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 42
    var state   = STATES.PICKED;
42 43
    var last_real = $real.val();
43 44
    var last_dummy = $dummy.val();
......
84 85
      if ($category && $category.val())
85 86
        data['filter.category'] = $category.val().split(',');
86 87

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

  
91

  
87 92
      return data;
88 93
    }
89 94

  
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 14
All charts choose: [% P.chart.picker('chart_id_choose', '', choose=1, style=style) %]<br>
13 15
</p>
14 16

  

Auch abrufbar als: Unified diff