1 package SL::Presenter::Part;
5 use Exporter qw(import);
6 our @EXPORT = qw(part_picker);
9 my ($self, $name, $value, %params) = @_;
10 my $name_e = $self->escape($name);
13 $self->input_tag($name, (ref $value && $value->can('id') ? $value->id : ''), class => 'part_autocomplete', type => 'hidden') .
14 $self->input_tag("", delete $params{type}, id => $self->name_to_id("$name_e\_type"), type => 'hidden') .
15 $self->input_tag("", (ref $value && $value->can('description')) ? $value->description : '', id => $self->name_to_id("$name_e\_name"), %params) .
16 $self->input_tag("", delete $params{column}, id => $self->name_to_id("$name_e\_column"), type => 'hidden');
18 $self->html_tag('span', $ret, class => 'part_picker');
29 SL::Presenter::Part - Part lelated presenter stuff
43 =item C<part_picker NAME, VALUE, PARAMS>
45 All-in-one picker widget for parts. The name will be both id and name of the
46 resulting hidden C<id> input field. An additional dummy input will be generated
47 which is used to find parts. For a detailed description of it's behaviour, see
48 section L</PART PICKER SPECIFICATION>.
50 C<VALUE> can be an id or C<Rose::DB:Object> instance.
52 If C<PARAMS> contains C<type> only parts of this type will be used for
53 autocompletion. You may comma separate multiple types as in C<part,assembly>.
55 Obsolete parts will by default not displayed for selection. However they are
56 accepted as default values and can persist during updates. As with other
57 selectors though, they are not selectable once overridden.
59 Currently you must include C<js/autocomplete_part.js> in your controller, the
60 presenter can not do this from the template.
64 =head1 PART PICKER SPECIFICATION
66 The following list of design goals were applied:
72 Parts should not be perceived by the user as distinct inputs of partnumber and
73 description but as a single object
77 Easy to use without documentation for novice users
81 Fast to use with keyboard for experienced users
85 Possible to use without any keyboard interaction for mouse (or touchscreen)
90 Must not leave the current page in event of ambiguity (cf. current select_item
95 Should be useable with hand scanners or similar alternative keyboard devices
99 Should not require a feedback/check loop in the common case
103 Should not be constraint to exact matches
107 The implementation consists of the following parts which will be referenced later:
113 A hidden input (id input), used to hold the id of the selected part. The only
114 input that gets submitted
118 An input (dummy input) containing a description of the currently selected part,
119 also used by the user to search for parts
123 A jquery.autocomplete mechanism attached to the dummy field
127 A popup layer for both feedback and input of additional data in case of
132 An internal status of the part picker, indicating wether id input and dummy
133 input are consistent. After leaving the dummy input the part picker must
134 place itself in a consistent status.
138 A clickable icon (popup trigger) attached to the dummy input, which triggers the popup layer.
148 Popup triggers are not displayed with css menu, because the spritemap is not loaded.
154 Sven Schöling E<lt>s.schoeling@linet-services.deE<gt>