Revision 05531e45
Von Kivitendo Admin vor etwa 8 Jahren hinzugefügt
SL/Controller/Part.pm | ||
---|---|---|
29 | 29 |
if (1 == scalar @{ $exact_matches = SL::DB::Manager::Part->get_all( |
30 | 30 |
query => [ |
31 | 31 |
obsolete => 0, |
32 |
SL::DB::Manager::Part->type_filter($::form->{filter}{type}), |
|
32 |
SL::DB::Manager::Part->type_filter($::form->{filter}{part_type}),
|
|
33 | 33 |
or => [ |
34 | 34 |
description => { ilike => $::form->{filter}{'all:substr:multi::ilike'} }, |
35 | 35 |
partnumber => { ilike => $::form->{filter}{'all:substr:multi::ilike'} }, |
... | ... | |
48 | 48 |
id => $_->id, |
49 | 49 |
partnumber => $_->partnumber, |
50 | 50 |
description => $_->description, |
51 |
type => $_->type,
|
|
51 |
part_type => $_->part_type,
|
|
52 | 52 |
unit => $_->unit, |
53 | 53 |
cvars => { map { ($_->config->name => { value => $_->value_as_text, is_valid => $_->is_valid }) } @{ $_->cvars_by_config } }, |
54 | 54 |
} |
SL/DB/Manager/Part.pm | ||
---|---|---|
16 | 16 |
|
17 | 17 |
__PACKAGE__->make_manager_methods; |
18 | 18 |
__PACKAGE__->add_filter_specs( |
19 |
type => sub { |
|
19 |
part_type => sub {
|
|
20 | 20 |
my ($key, $value, $prefix) = @_; |
21 | 21 |
return __PACKAGE__->type_filter($value, $prefix); |
22 | 22 |
}, |
SL/Presenter/Part.pm | ||
---|---|---|
37 | 37 |
|
38 | 38 |
my $ret = |
39 | 39 |
$self->input_tag($name, (ref $value && $value->can('id') ? $value->id : ''), class => "@classes", type => 'hidden', id => $id) . |
40 |
join('', map { $params{$_} ? $self->input_tag("", delete $params{$_}, id => "${id}_${_}", type => 'hidden') : '' } qw(type unit convertible_unit)) . |
|
40 |
join('', map { $params{$_} ? $self->input_tag("", delete $params{$_}, id => "${id}_${_}", type => 'hidden') : '' } qw(part_type unit convertible_unit)) .
|
|
41 | 41 |
$self->input_tag("", ref $value ? $value->displayable_name : '', id => "${id}_name", %params); |
42 | 42 |
|
43 | 43 |
$::request->layout->add_javascripts('autocomplete_part.js'); |
... | ... | |
105 | 105 |
|
106 | 106 |
C<$value> can be a parts id or a C<Rose::DB:Object> instance. |
107 | 107 |
|
108 |
If C<%params> contains C<type> only parts of this type will be used |
|
108 |
If C<%params> contains C<part_type> only parts of this type will be used
|
|
109 | 109 |
for autocompletion. You may comma separate multiple types as in |
110 | 110 |
C<part,assembly>. |
111 | 111 |
|
js/autocomplete_part.js | ||
---|---|---|
28 | 28 |
UNDEFINED: CLASSES.UNDEFINED |
29 | 29 |
} |
30 | 30 |
var real_id = $real.attr('id'); |
31 |
var $dummy = $('#' + real_id + '_name'); |
|
32 |
var $type = $('#' + real_id + '_type');
|
|
33 |
var $unit = $('#' + real_id + '_unit'); |
|
31 |
var $dummy = $('#' + real_id + '_name');
|
|
32 |
var $part_type = $('#' + real_id + '_part_type');
|
|
33 |
var $unit = $('#' + real_id + '_unit');
|
|
34 | 34 |
var $convertible_unit = $('#' + real_id + '_convertible_unit'); |
35 | 35 |
var state = STATES.PICKED; |
36 | 36 |
var last_real = $real.val(); |
... | ... | |
63 | 63 |
current: $real.val(), |
64 | 64 |
}; |
65 | 65 |
|
66 |
if ($type && $type.val())
|
|
67 |
data['filter.type'] = $type.val().split(',');
|
|
66 |
if ($part_type && $part_type.val())
|
|
67 |
data['filter.part_type'] = $part_type.val().split(',');
|
|
68 | 68 |
|
69 | 69 |
if ($unit && $unit.val()) |
70 | 70 |
data['filter.unit'] = $unit.val().split(','); |
... | ... | |
244 | 244 |
var pp = { |
245 | 245 |
real: function() { return $real }, |
246 | 246 |
dummy: function() { return $dummy }, |
247 |
type: function() { return $type },
|
|
247 |
part_type: function() { return $part_type },
|
|
248 | 248 |
unit: function() { return $unit }, |
249 | 249 |
convertible_unit: function() { return $convertible_unit }, |
250 | 250 |
update_results: update_results, |
templates/webpages/part/test_page.html | ||
---|---|---|
6 | 6 |
Alle: <br> |
7 | 7 |
[% L.part_picker('part_id') %] text<br> |
8 | 8 |
Nur Waren: <br> |
9 |
[% L.part_picker('part_id2', undef, type='part') %]<br> |
|
9 |
[% L.part_picker('part_id2', undef, part_type='part') %]<br>
|
|
10 | 10 |
Nur Dienstleistungen: <br> |
11 |
[% L.part_picker('part_id3', undef, type='service') %]<br> |
|
11 |
[% L.part_picker('part_id3', undef, part_type='service') %]<br>
|
|
12 | 12 |
Waren und Dienstleistungen: <br> |
13 |
[% L.part_picker('part_id4', undef, type='part,service') %]<br> |
|
13 |
[% L.part_picker('part_id4', undef, part_type='part,service') %]<br>
|
|
14 | 14 |
Pre-filled:<br> |
15 | 15 |
[% L.part_picker('part_id5', pre_filled_part) %]<br> |
16 | 16 |
Convertible unit 'Std': (only select parts with unit Tag/Std/Min)<br> |
... | ... | |
18 | 18 |
|
19 | 19 |
<h2>Styling</h2> |
20 | 20 |
|
21 |
Ina span: |
|
22 |
<span>Leading text: [% L.part_picker('p1', undef, type='part,service') %] and text after with spacing</span><br> |
|
23 |
<span>Leading text:[% L.part_picker('p2', undef, type='part,service') %]and text after without spacing</span><br> |
|
24 |
<div>Leading text: [% L.part_picker('p3', undef, type='part,service') %] and text after with spacing with div</div><br> |
|
25 |
<div>Leading text:[% L.part_picker('p4', undef, type='part,service') %]and text after with spacing with div</div><br> |
|
21 |
In a span:
|
|
22 |
<span>Leading text: [% L.part_picker('p1', undef, part_type='part,service') %] and text after with spacing</span><br>
|
|
23 |
<span>Leading text:[% L.part_picker('p2', undef, part_type='part,service') %]and text after without spacing</span><br>
|
|
24 |
<div>Leading text: [% L.part_picker('p3', undef, part_type='part,service') %] and text after with spacing with div</div><br>
|
|
25 |
<div>Leading text:[% L.part_picker('p4', undef, part_type='part,service') %]and text after with spacing with div</div><br>
|
|
26 | 26 |
|
27 |
<span>Picker + input next to each other: [% L.part_picker('p5', undef, type='part,service', width="100%") %]<input type=text></span> |
|
27 |
<span>Picker + input next to each other: [% L.part_picker('p5', undef, part_type='part,service', width="100%") %]<input type=text></span>
|
|
28 | 28 |
|
29 |
<div>[% L.part_picker('p6', undef, type='part,service', style="width:500px") %] 500px width</div> |
|
30 |
<div>[% L.part_picker('p7', undef, type='part,service', style="width:200px") %] 200px width</div> |
|
31 |
<div>[% L.part_picker('p8', undef, type='part,service', style="height:40px") %] 40px height</div> |
|
29 |
<div>[% L.part_picker('p6', undef, part_type='part,service', style="width:500px") %] 500px width</div>
|
|
30 |
<div>[% L.part_picker('p7', undef, part_type='part,service', style="width:200px") %] 200px width</div>
|
|
31 |
<div>[% L.part_picker('p8', undef, part_type='part,service', style="height:40px") %] 40px height</div>
|
|
32 | 32 |
|
33 | 33 |
[%# FOREACH i IN 1..50 %] |
34 | 34 |
[%# L.part_picker('part_id_' _ i) %] <br> |
... | ... | |
41 | 41 |
<table> |
42 | 42 |
<tr> |
43 | 43 |
<th>Part picker in table heading</th> |
44 |
<th>[% L.part_picker('p9', undef, type='part,service') %]</th> |
|
44 |
<th>[% L.part_picker('p9', undef, part_type='part,service') %]</th>
|
|
45 | 45 |
</tr> |
46 | 46 |
<tr> |
47 | 47 |
<td>Part picker in table cell</td> |
48 |
<td>[% L.part_picker('p10', undef, type='part,service') %]</td> |
|
48 |
<td>[% L.part_picker('p10', undef, part_type='part,service') %]</td>
|
|
49 | 49 |
</tr> |
50 | 50 |
</table> |
51 | 51 |
|
... | ... | |
54 | 54 |
<table> |
55 | 55 |
<tr class=listheading> |
56 | 56 |
<th>Part picker in table heading</th> |
57 |
<th>[% L.part_picker('p11', undef, type='part,service') %]</th> |
|
57 |
<th>[% L.part_picker('p11', undef, part_type='part,service') %]</th>
|
|
58 | 58 |
</tr> |
59 | 59 |
<tr class=listrow> |
60 | 60 |
<td>Part picker in table cell</td> |
61 |
<td>[% L.part_picker('p12', undef, type='part,service') %]</td> |
|
61 |
<td>[% L.part_picker('p12', undef, part_type='part,service') %]</td>
|
|
62 | 62 |
</tr> |
63 | 63 |
</table> |
Auch abrufbar als: Unified diff
PartPicker - Parameter "type" heißt jetzt "part_type"