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