Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 68b29955

Von Sven Schöling vor fast 8 Jahren hinzugefügt

  • ID 68b299559a5478f84b6866e8efeb9346267fc49b
  • Vorgänger dbd35a96
  • Nachfolger 120225aa

Part: exact_match robuster mit localized $::form

Behebt Bugs mit vergessenen Filtern wie unit_obj.convertible_unit

Unterschiede anzeigen:

SL/Controller/Part.pm
500 500

  
501 501
  # if someone types something, and hits enter, assume he entered the full name.
502 502
  # if something matches, treat that as sole match
503
  # unfortunately get_models can't do more than one per package atm, so we d it
504
  # the oldfashioned way.
503
  # since we need a second get models instance with different filters for that,
504
  # we only modify the original filter temporarily in place
505 505
  if ($::form->{prefer_exact}) {
506
    local $::form->{filter}{'all::ilike'} = delete local $::form->{filter}{'all:substr:multi::ilike'};
507

  
508
    my $exact_models = SL::Controller::Helper::GetModels->new(
509
      controller   => $self,
510
      sorted       => 0,
511
      paginated    => { per_page => 2 },
512
      with_objects => [ qw(unit_obj classification) ],
513
    );
506 514
    my $exact_matches;
507
    if (1 == scalar @{ $exact_matches = SL::DB::Manager::Part->get_all(
508
      query => [
509
        obsolete => 0,
510
        SL::DB::Manager::Part->type_filter($::form->{filter}{part_type}),
511
        SL::DB::Manager::PartClassification->classification_filter($::form->{filter}{classification_id}),
512
        or => [
513
          description => { ilike => $::form->{filter}{'all:substr:multi::ilike'} },
514
          partnumber  => { ilike => $::form->{filter}{'all:substr:multi::ilike'} },
515
        ]
516
      ],
517
      limit => 2,
518
    ) }) {
515
    if (1 == scalar @{ $exact_matches = $exact_models->get }) {
519 516
      $self->parts($exact_matches);
520 517
    }
521 518
  }

Auch abrufbar als: Unified diff