| 1 | 113 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 113 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | |||
| 4 | =head1 NAME | ||
| 5 | |||
| 6 | Jifty::Action::Autocomplete - An action for making autocompletion suggestions | ||
| 7 | |||
| 8 | =head1 DESCRIPTION | ||
| 9 | |||
| 10 | A built-in L<Jifty::Action> which returns suggested autocompletions | ||
| 11 | for a given argument of an action. Generally this is called by Jifty's | ||
| 12 | internals through C</__jifty/autocomplete.xml>. | ||
| 13 | |||
| 14 | This action gets its data to C</__jifty/autocomplete.xml> by filling in the | ||
| 15 | C<completions> of the L<Jifty::Result/content>. | ||
| 16 | |||
| 17 | =cut | ||
| 18 | |||
| 19 | |||
| 20 | |||
| 21 | package Jifty::Action::Autocomplete; | ||
| 22 | 113 | ▶ | use base qw/Jifty::Action/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 23 | |||
| 24 | =head2 arguments | ||
| 25 | |||
| 26 | The arguments for C<Autocomplete> are: | ||
| 27 | |||
| 28 | =over 4 | ||
| 29 | |||
| 30 | =item action | ||
| 31 | |||
| 32 | The L<moniker|Jifty::Manual::Glossary/moniker> of an action we want to pull a | ||
| 33 | field to autocomplete from. | ||
| 34 | |||
| 35 | =item argument | ||
| 36 | |||
| 37 | The fully qualified name of the L<argument|Jifty::Manual::Glossary/argument> | ||
| 38 | to C<action> that we want to complete. | ||
| 39 | |||
| 40 | =back | ||
| 41 | |||
| 42 | =cut | ||
| 43 | |||
| 44 | 0 | ▶ | sub arguments { |
|
Subroutine
arguments: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 45 | { | ||
| 46 | 0 | moniker => {}, | |
| 47 | argument => {} | ||
| 48 | } | ||
| 49 | } | ||
| 50 | |||
| 51 | =head2 take_action | ||
| 52 | |||
| 53 | Find the submitted action in the L<Jifty::Request> named by the | ||
| 54 | C<action> above, and ask it for autocompletion possibilities for the | ||
| 55 | L<argument> in question. | ||
| 56 | |||
| 57 | =cut | ||
| 58 | |||
| 59 | 0 | ▶ | sub take_action { |
|
Subroutine
take_action: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 60 | 0 | my $self = shift; | |
| 61 | |||
| 62 | # Load the arguments | ||
| 63 | 0 | my $moniker = $self->argument_value('moniker'); | |
| 64 | 0 | my $argument = $self->argument_value('argument'); | |
| 65 | |||
| 66 | # Load the action associated with the moniker | ||
| 67 | 0 | my $request_action = Jifty->web->request->action($moniker); | |
| 68 | 0 | my $action = Jifty->web->new_action_from_request($request_action); | |
| 69 | |||
| 70 | # Call the autocompleter for that action and argument and set the result | ||
| 71 | 0 | my @completions = $action->_autocomplete_argument($argument); | |
| 72 | 0 | $self->result->content->{completions} = \@completions; | |
| 73 | |||
| 74 | 0 | return 1; | |
| 75 | } | ||
| 76 | |||
| 77 | =head1 SEE ALSO | ||
| 78 | |||
| 79 | L<Jifty::Action> | ||
| 80 | |||
| 81 | =head1 LICENSE | ||
| 82 | |||
| 83 | Jifty is Copyright 2005-2010 Best Practical Solutions, LLC. | ||
| 84 | Jifty is distributed under the same terms as Perl itself. | ||
| 85 | |||
| 86 | =cut | ||
| 87 | |||
| 88 | 113 | 1; | |
| 89 | |||