Commit | Line | Data |
---|---|---|
2f670e13 | 1 | package Reaction::UI::Widget::Field::Mutable::ChooseMany; |
8f19d042 | 2 | |
3 | use Reaction::UI::WidgetClass; | |
4 | ||
bae75bee | 5 | use namespace::clean -except => [ qw(meta) ]; |
6 | extends 'Reaction::UI::Widget::Field::Mutable'; | |
9de685fc | 7 | |
bae75bee | 8 | |
9 | ||
10 | implements fragment action_buttons { | |
11 | foreach my $event ( | |
12 | qw(add_all_values do_add_values do_remove_values remove_all_values) | |
13 | ) { | |
14 | arg "event_id_${event}" => event_id $event; | |
15 | } | |
16 | }; | |
17 | ||
18 | implements fragment current_values { | |
19 | my $current_choices = $_{viewport}->current_value_choices; | |
20 | if( @$current_choices ){ | |
21 | arg field_name => event_id 'value'; | |
22 | render hidden_value => over $current_choices; | |
23 | } else { | |
24 | arg field_name => event_id 'no_current_value'; | |
25 | arg '_' => {value => 1}; | |
26 | render 'hidden_value'; | |
27 | } | |
28 | }; | |
29 | ||
30 | implements fragment selected_values { | |
31 | arg event_id_remove_values => event_id 'remove_values'; | |
32 | render value_option => over $_{viewport}->current_value_choices; | |
33 | }; | |
34 | ||
35 | implements fragment available_values { | |
36 | arg event_id_add_values => event_id 'add_values'; | |
37 | render value_option => over $_{viewport}->available_value_choices; | |
38 | }; | |
39 | ||
40 | implements fragment value_option { | |
41 | arg option_name => $_->{name}; | |
42 | arg option_value => $_->{value}; | |
8f19d042 | 43 | }; |
44 | ||
bae75bee | 45 | implements fragment hidden_value { |
46 | arg hidden_value => $_->{value}; | |
47 | }; | |
48 | ||
49 | __PACKAGE__->meta->make_immutable; | |
50 | ||
51 | ||
8f19d042 | 52 | 1; |
53 | ||
6ab43711 | 54 | __END__; |
8f19d042 | 55 | |
5a1a893e | 56 | =head1 NAME |
8f19d042 | 57 | |
5a1a893e | 58 | Reaction::UI::Widget::Field::ChooseMany |
8f19d042 | 59 | |
5a1a893e | 60 | =head1 DESCRIPTION |
8f19d042 | 61 | |
5a1a893e | 62 | See L<Reaction::UI::Widget::Field> |
9de685fc | 63 | |
5a1a893e | 64 | This needs a refactor to not be tied to a dual select box, but ENOTIME |
9de685fc | 65 | |
5a1a893e | 66 | =head1 FRAGMENTS |
9de685fc | 67 | |
5a1a893e | 68 | =head2 field |
9de685fc | 69 | |
5a1a893e | 70 | renders C<available_values>, C<action_buttons>, C<selected_values> and C<current_values> |
9de685fc | 71 | |
5a1a893e | 72 | =head2 current values |
9de685fc | 73 | |
5a1a893e | 74 | renders the viewport's current_value_choices over hidden_value |
9de685fc | 75 | |
5a1a893e | 76 | =head2 hidden_value |
9de685fc | 77 | |
5a1a893e | 78 | C<content> is the value of the current choice |
9de685fc | 79 | |
5a1a893e | 80 | =head2 available_value |
9de685fc | 81 | |
5a1a893e | 82 | rendersthe viewport's current_available_value_choices over the option fragment |
9de685fc | 83 | |
5a1a893e | 84 | =head2 selected_value |
9de685fc | 85 | |
5a1a893e | 86 | rendersthe viewport's current_selected_value_choices over the option fragment |
8f19d042 | 87 | |
5a1a893e | 88 | =head2 option |
8f19d042 | 89 | |
5a1a893e | 90 | C<content> is a dummy value but C<v_value> and C<v_name> are both set. |
8f19d042 | 91 | |
5a1a893e | 92 | =head1 AUTHORS |
8f19d042 | 93 | |
5a1a893e | 94 | See L<Reaction::Class> for authors. |
95 | ||
96 | =head1 LICENSE | |
97 | ||
98 | See L<Reaction::Class> for the license. | |
8f19d042 | 99 | |
100 | =cut |