Revision 57faab8f
Von Sven Schöling vor mehr als 10 Jahren hinzugefügt
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 |
); |
Auch abrufbar als: Unified diff
Part api Funktion um eine Ware als json abzufragen