1 package SL::Presenter::Part;
7 use Exporter qw(import);
8 our @EXPORT = qw(part_picker);
11 my ($self, $name, $value, %params) = @_;
13 $value = SL::DB::Manager::Part->find_by(id => $value) if $value && !ref $value;
14 my $id = delete($params{id}) || $self->name_to_id($name);
17 $self->input_tag($name, (ref $value && $value->can('id') ? $value->id : ''), class => 'part_autocomplete', type => 'hidden', id => $id) .
18 join('', map { $params{$_} ? $self->input_tag("", delete $params{$_}, id => "${id}_${_}", type => 'hidden') : '' } qw(column type unit convertible_unit)) .
19 $self->input_tag("", (ref $value && $value->can('description')) ? $value->description : '', id => "${id}_name", %params);
21 $self->html_tag('span', $ret, class => 'part_picker');
32 SL::Presenter::Part - Part lelated presenter stuff
46 =item C<part_picker $name, $value, %params>
48 All-in-one picker widget for parts. The name will be both id and name
49 of the resulting hidden C<id> input field (but the ID can be
50 overwritten with C<$params{id}>).
52 An additional dummy input will be generated which is used to find
53 parts. For a detailed description of it's behaviour, see section
54 C<PART PICKER SPECIFICATION>.
56 C<$value> can be a parts id or a C<Rose::DB:Object> instance.
58 All-in-one picker widget for parts. The name will be both id and name of the
59 resulting hidden C<id> input field. An additional dummy input will be generated
60 which is used to find parts. For a detailed description of it's behaviour, see
61 section L</PART PICKER SPECIFICATION>.
63 If C<%params> contains C<type> only parts of this type will be used
64 for autocompletion. You may comma separate multiple types as in
67 If C<%params> contains C<unit> only parts with this unit will be used
68 for autocompletion. You may comma separate multiple units as in
71 If C<%params> contains C<convertible_unit> only parts with a unit
72 that's convertible to unit will be used for autocompletion.
74 Obsolete parts will by default not displayed for selection. However they are
75 accepted as default values and can persist during updates. As with other
76 selectors though, they are not selectable once overridden.
78 Currently you must include C<js/autocomplete_part.js> in your controller, the
79 presenter can not do this from the template.
83 =head1 PART PICKER SPECIFICATION
85 The following list of design goals were applied:
91 Parts should not be perceived by the user as distinct inputs of partnumber and
92 description but as a single object
96 Easy to use without documentation for novice users
100 Fast to use with keyboard for experienced users
104 Possible to use without any keyboard interaction for mouse (or touchscreen)
109 Must not leave the current page in event of ambiguity (cf. current select_item
114 Should be useable with hand scanners or similar alternative keyboard devices
118 Should not require a feedback/check loop in the common case
122 Should not be constraint to exact matches
126 The implementation consists of the following parts which will be referenced later:
132 A hidden input (id input), used to hold the id of the selected part. The only
133 input that gets submitted
137 An input (dummy input) containing a description of the currently selected part,
138 also used by the user to search for parts
142 A jquery.autocomplete mechanism attached to the dummy field
146 A popup layer for both feedback and input of additional data in case of
151 An internal status of the part picker, indicating wether id input and dummy
152 input are consistent. After leaving the dummy input the part picker must
153 place itself in a consistent status.
157 A clickable icon (popup trigger) attached to the dummy input, which triggers the popup layer.
167 Popup triggers are not displayed with css menu, because the spritemap is not loaded.
173 Sven Schöling E<lt>s.schoeling@linet-services.deE<gt>