Revision a9c191de
Von Sven Schöling vor fast 8 Jahren hinzugefügt
SL/IC.pm | ||
---|---|---|
602 | 602 |
|
603 | 603 |
$main::lxdebug->leave_sub(); |
604 | 604 |
|
605 |
return @{ $form->{parts} };
|
|
605 |
return $form->{parts};
|
|
606 | 606 |
} |
607 | 607 |
|
608 | 608 |
sub _create_filter_for_priceupdate { |
bin/mozilla/ic.pl | ||
---|---|---|
668 | 668 |
$lxdebug->leave_sub(); |
669 | 669 |
} #end generate_report |
670 | 670 |
|
671 |
sub ajax_autocomplete { |
|
672 |
$main::lxdebug->enter_sub(); |
|
673 |
|
|
674 |
my $form = $main::form; |
|
675 |
my %myconfig = %main::myconfig; |
|
676 |
|
|
677 |
$form->{column} = 'description' unless $form->{column} =~ /^partnumber|description$/; |
|
678 |
$form->{$form->{column}} = $form->{q} || ''; |
|
679 |
$form->{limit} = ($form->{limit} * 1) || 10; |
|
680 |
$form->{searchitems} ||= ''; |
|
681 |
|
|
682 |
my @results = IC->all_parts(\%myconfig, $form); |
|
683 |
|
|
684 |
print $form->ajax_response_header(), |
|
685 |
$form->parse_html_template('ic/ajax_autocomplete'); |
|
686 |
|
|
687 |
$main::lxdebug->leave_sub(); |
|
688 |
} |
|
689 |
|
|
690 | 671 |
sub back_to_record { |
691 | 672 |
_check_io_auth(); |
692 | 673 |
|
scripts/locales.pl | ||
---|---|---|
57 | 57 |
our @lost = (); |
58 | 58 |
|
59 | 59 |
my %ignore_unused_templates = ( |
60 |
map { $_ => 1 } qw(ct/testpage.html generic/autocomplete.html oe/periodic_invoices_email.txt part/testpage.html t/render.html t/render.js task_server/failure_notification_email.txt
|
|
60 |
map { $_ => 1 } qw(ct/testpage.html oe/periodic_invoices_email.txt part/testpage.html t/render.html t/render.js task_server/failure_notification_email.txt |
|
61 | 61 |
failed_background_jobs_report/email.txt) |
62 | 62 |
); |
63 | 63 |
|
templates/webpages/generic/autocomplete.html | ||
---|---|---|
1 |
[%#- |
|
2 |
Autocompletion |
|
3 |
|
|
4 |
This template enables auto completion for input fields. |
|
5 |
Calling Syntax is: |
|
6 |
|
|
7 |
INCLUDE 'generic/autocomplete', [ |
|
8 |
{ SPEC_1 }, |
|
9 |
{ SPEC_2 }, |
|
10 |
... |
|
11 |
] |
|
12 |
|
|
13 |
where SPEC is a hash containing the following keys: |
|
14 |
|
|
15 |
script : the script that is called for autocompletion, defaults to the invoking script |
|
16 |
action : action in the ajax script, defaults to 'ajax_autocomplete' |
|
17 |
selector : a jquery selector, specifying the input fields |
|
18 |
column : specifies the column that is represented by the bound field. typically description or name. |
|
19 |
params : additional params that should be included in the request, like customer/vendor information. expects a hash. |
|
20 |
|
|
21 |
TODO FIELDS: |
|
22 |
- addition fields like type, vc etc. |
|
23 |
- additional dependencies, see jquery.autocomplete documentation |
|
24 |
- hook function on select, again see jquery documentation |
|
25 |
- limit: maximum number of results shown. |
|
26 |
|
|
27 |
a simple SPEC would look like this: |
|
28 |
|
|
29 |
{ selector => '#description', column => 'description' } |
|
30 |
# field with id="description" should be autocompleted with descriptions |
|
31 |
|
|
32 |
{ script => 'ic.pl', selector => '[name^="partnumber_"]', column => 'partnumber' } |
|
33 |
# let ic.pl autocomplete by partnumbers, bind this to all fields where the name begins with "partnumber_" |
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
The Backend Side |
|
38 |
|
|
39 |
The called function will recieve the queried string as hashkey "q" in form, as well as every other param specified here. |
|
40 |
It should generate a generic ajax header (see form), followed by newline separated list of possible completion values. |
|
41 |
|
|
42 |
%] |
|
43 |
<script type='text/javascript'> |
|
44 |
[%- FOREACH token = AUTOCOMPLETES %] |
|
45 |
[%- DEFAULT token.script = script %] |
|
46 |
[%- DEFAULT token.action = 'ajax_autocomplete' %] |
|
47 |
[%- DEFAULT token.INPUT_ENCODING = 'utf8' %] |
|
48 |
[%- FOREACH key = token.params.keys %] |
|
49 |
[%- token.additional_url = token.additional_url _ '&' _ key _ '=' _ token.params.$key %] |
|
50 |
[%- END %] |
|
51 |
[%- token.url = token.script |
|
52 |
_ '?action=' _ token.action |
|
53 |
_ '&INPUT_ENCODING=' _ token.INPUT_ENCODING %] |
|
54 |
[%- SET token.url = token.url _ '&column=' _ token.column IF token.column %] |
|
55 |
[%- SET token.url = token.url _ token.additional_url IF token.additional_url %] |
|
56 |
$(document).ready( $('[% token.selector %]').autocomplete('[% token.url %]')); |
|
57 |
[%- END %] |
|
58 |
</script> |
templates/webpages/ic/ajax_autocomplete.html | ||
---|---|---|
1 |
[%- USE HTML %] |
|
2 |
[%- FOREACH part = parts %] |
|
3 |
[% IF loop.count < limit %] |
|
4 |
[% part.$column %] |
|
5 |
[%- END %] |
|
6 |
[%- END %] |
Auch abrufbar als: Unified diff
Reste von altem autocomplete feature entfernt