do not include .git directory
[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
bae75bee 5use namespace::clean -except => [ qw(meta) ];
6extends 'Reaction::UI::Widget::Field::Mutable';
9de685fc 7
bae75bee 8
9
10implements 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
18implements 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
30implements fragment selected_values {
31 arg event_id_remove_values => event_id 'remove_values';
32 render value_option => over $_{viewport}->current_value_choices;
33};
34
35implements fragment available_values {
36 arg event_id_add_values => event_id 'add_values';
37 render value_option => over $_{viewport}->available_value_choices;
38};
39
40implements fragment value_option {
41 arg option_name => $_->{name};
42 arg option_value => $_->{value};
8f19d042 43};
44
bae75bee 45implements fragment hidden_value {
46 arg hidden_value => $_->{value};
47};
48
49__PACKAGE__->meta->make_immutable;
50
51
8f19d042 521;
53
6ab43711 54__END__;
8f19d042 55
5a1a893e 56=head1 NAME
8f19d042 57
e516f7e6 58Reaction::UI::Widget::Field::Mutable::ChooseMany - Choose a number of items
8f19d042 59
5a1a893e 60=head1 DESCRIPTION
8f19d042 61
f9b32c83 62See L<Reaction::UI::Widget::Field::Mutable>
9de685fc 63
5a1a893e 64This needs a refactor to not be tied to a dual select box, but ENOTIME
9de685fc 65
5a1a893e 66=head1 FRAGMENTS
9de685fc 67
f9b32c83 68=head2 action_buttons
9de685fc 69
f9b32c83 70Sets the following events by the name C<event_id_$name> as arguments with their viewport
71event ids as values:
72
73 add_all_values
74 do_add_values
75 do_remove_values
76 remove_all_values
77
78=head2 current_values
79
80Renders the C<hidden_value> fragment to store the currently selected values either once
81for every item in the viewport's C<current_value_choices> (with the C<field_name> argument
82set to the viewport's event id for C<value>. Or, if no current values exist, uses the
83C<no_current_value> event id from the viewport and sets the topic argument C<_> to 1.
84
85=head2 selected_values
86
87Sets C<event_id_remove_values> to the viewport's event id for C<remove_values> and renders
88the C<value_option> fragment over the viewport's C<current_value_choices>.
9de685fc 89
f9b32c83 90=head2 available_values
9de685fc 91
f9b32c83 92Sets C<event_id_add_values> to the viewport's event id for C<add_values> and renders
93the C<value_option> fragment over the viewport's C<available_value_choices>.
94
95=head2 value_option
96
97Sets the C<option_name> argument to the current topic argument's C<name> key and the
98C<option_value> to the current topic argument's C<value> key.
9de685fc 99
5a1a893e 100=head2 hidden_value
9de685fc 101
f9b32c83 102Sets C<hidden_value> to the current topic's C<value> key.
103
104=head2 field
105
106renders C<available_values>, C<action_buttons>, C<selected_values> and C<current_values>
107
108=head1 LAYOUT SETS
9de685fc 109
f9b32c83 110=head2 base
9de685fc 111
f9b32c83 112 share/skin/base/layout/field/mutable/choose_many.tt
9de685fc 113
f9b32c83 114This layout set provides a table containing two lists separated by action buttons that
115allow the user to add values from the available list to the selected list.
9de685fc 116
f9b32c83 117=head2 default
8f19d042 118
f9b32c83 119 share/skin/default/layout/field/mutable/choose_many.tt
8f19d042 120
f9b32c83 121Same as in the C<base> skin, except that after each action button a C<br> element will
122be rendered.
8f19d042 123
5a1a893e 124=head1 AUTHORS
8f19d042 125
5a1a893e 126See L<Reaction::Class> for authors.
127
128=head1 LICENSE
129
130See L<Reaction::Class> for the license.
8f19d042 131
132=cut