Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 57faab8f

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

  • ID 57faab8f922edc190b6909b7626a445423de6676
  • Vorgänger 303a4d5d
  • Nachfolger ee74ea82

Part api Funktion um eine Ware als json abzufragen

Unterschiede anzeigen:

SL/Controller/Part.pm
10 10
use SL::JSON;
11 11

  
12 12
use Rose::Object::MakeMethods::Generic (
13
  'scalar --get_set_init' => [ qw(parts models) ],
13
  'scalar --get_set_init' => [ qw(parts models part) ],
14 14
);
15 15

  
16 16
# safety
......
33 33
        obsolete => 0,
34 34
        SL::DB::Manager::Part->type_filter($::form->{filter}{type}),
35 35
        or => [
36
          description => { ilike => $::form->{filter}{'all:substr::ilike'} },
37
          partnumber  => { ilike => $::form->{filter}{'all:substr::ilike'} },
36
          description => { ilike => $::form->{filter}{'all:substr:multi::ilike'} },
37
          partnumber  => { ilike => $::form->{filter}{'all:substr:multi::ilike'} },
38 38
        ]
39 39
      ],
40 40
      limit => 2,
......
72 72
  $_[0]->render('part/_part_picker_result', { layout => 0 });
73 73
}
74 74

  
75
sub action_show {
76
  my ($self) = @_;
77

  
78
  if ($::request->type eq 'json') {
79
    my $part_hash;
80
    if (!$self->part) {
81
      # TODO error
82
    } else {
83
      require Rose::DB::Object::Helpers;
84
        $part_hash          = $self->part->as_tree;
85
        $part_hash->{cvars} = $self->part->cvar_as_hashref;
86
    }
87

  
88
    $self->render(\ SL::JSON::to_json($part_hash), { layout => 0, type => 'json', process => 0 });
89
  }
90
}
91

  
75 92
sub init_parts {
93
  if ($::form->{no_paginate}) {
94
    $_[0]->models->disable_plugin('paginated');
95
  }
96

  
76 97
  $_[0]->models->get;
77 98
}
78 99

  
100
sub init_part {
101
  SL::DB::Part->new(id => $::form->{id} || $::form->{part}{id})->load;
102
}
103

  
79 104
sub init_models {
80 105
  my ($self) = @_;
81 106

  
......
83 108
    controller => $self,
84 109
    sorted => {
85 110
      _default  => {
86
        by => 'partnumber',
111
        by => 'description',
87 112
        dir  => 1,
88 113
      },
89 114
      partnumber  => t8('Partnumber'),
115
      description  => t8('Description'),
90 116
    },
91 117
    with_objects => [ qw(unit_obj) ],
92 118
  );
SL/DB/Part.pm
4 4

  
5 5
use Carp;
6 6
use List::MoreUtils qw(any);
7
use Rose::DB::Object::Helpers qw(as_tree);
7 8

  
8 9
use SL::DBUtils;
9 10
use SL::DB::MetaSetup::Part;
js/autocomplete_part.js
53 53

  
54 54
    function ajax_data(term) {
55 55
      var data = {
56
        'filter.all:substr::ilike': term,
56
        'filter.all:substr:multi::ilike': term,
57 57
        'filter.obsolete': 0,
58 58
        'filter.unit_obj.convertible_to': $convertible_unit && $convertible_unit.val() ? $convertible_unit.val() : '',
59 59
        no_paginate:  $('#no_paginate').prop('checked') ? 1 : 0,

Auch abrufbar als: Unified diff