Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f16c5520

Von Sven Schöling vor mehr als 10 Jahren hinzugefügt

  • ID f16c552035ab973a9aed4a1dc29d0e16be7ff541
  • Vorgänger a4e4f1a7
  • Nachfolger e42bd22a

CustomerVendor: Picker nach Art von PartPicker

- reinit_widgets fähig
- Tab und Enter atomar
- unterstützt onChange und set_item:CustomerVendorPicker trigger
- unterstützt fat_set_item

Unterschiede anzeigen:

SL/Presenter/CustomerVendor.pm
5 5
use parent qw(Exporter);
6 6

  
7 7
use Exporter qw(import);
8
our @EXPORT = qw(customer vendor);
8
our @EXPORT = qw(customer vendor customer_vendor_picker);
9 9

  
10 10
use Carp;
11 11

  
......
36 36
  return $self->escaped_text($text);
37 37
}
38 38

  
39
sub customer_vendor_picker {
40
  my ($self, $name, $value, %params) = @_;
41

  
42
  $value = SL::DB::Manager::Customer->find_by(id => $value) if $value && !ref $value;
43
  my $id = delete($params{id}) || $self->name_to_id($name);
44
  my $fat_set_item = delete $params{fat_set_item};
45

  
46
  my @classes = $params{class} ? ($params{class}) : ();
47
  push @classes, 'customer_vendor_autocomplete';
48
  push @classes, 'customer-vendor-picker-fat-set-item' if $fat_set_item;
49

  
50
  my $ret =
51
    $self->input_tag($name, (ref $value && $value->can('id') ? $value->id : ''), class => "@classes", type => 'hidden', id => $id) .
52
    join('', map { $params{$_} ? $self->input_tag("", delete $params{$_}, id => "${id}_${_}", type => 'hidden') : '' } qw(type)) .
53
    $self->input_tag("", (ref $value && $value->can('name')) ? $value->name : '', id => "${id}_name", %params);
54

  
55
  $::request->presenter->need_reinit_widgets($id);
56

  
57
  $self->html_tag('span', $ret, class => 'customer_vendor_picker');
58
}
59

  
39 60
1;
40 61

  
41 62
__END__

Auch abrufbar als: Unified diff