1 package Reaction::UI::Widget::Field::Mutable::ChooseMany;
3 use Reaction::UI::WidgetClass;
5 use namespace::clean -except => [ qw(meta) ];
6 extends 'Reaction::UI::Widget::Field::Mutable';
10 implements fragment action_buttons {
12 qw(add_all_values do_add_values do_remove_values remove_all_values)
14 arg "event_id_${event}" => event_id $event;
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;
24 arg field_name => event_id 'no_current_value';
25 arg '_' => {value => 1};
26 render 'hidden_value';
30 implements fragment selected_values {
31 arg event_id_remove_values => event_id 'remove_values';
32 render value_option => over $_{viewport}->current_value_choices;
35 implements fragment available_values {
36 arg event_id_add_values => event_id 'add_values';
37 render value_option => over $_{viewport}->available_value_choices;
40 implements fragment value_option {
41 arg option_name => $_->{name};
42 arg option_value => $_->{value};
45 implements fragment hidden_value {
46 arg hidden_value => $_->{value};
49 __PACKAGE__->meta->make_immutable;
58 Reaction::UI::Widget::Field::Mutable::ChooseMany - Choose a number of items
62 See L<Reaction::UI::Widget::Field::Mutable>
64 This needs a refactor to not be tied to a dual select box, but ENOTIME
70 Sets the following events by the name C<event_id_$name> as arguments with their viewport
80 Renders the C<hidden_value> fragment to store the currently selected values either once
81 for every item in the viewport's C<current_value_choices> (with the C<field_name> argument
82 set to the viewport's event id for C<value>. Or, if no current values exist, uses the
83 C<no_current_value> event id from the viewport and sets the topic argument C<_> to 1.
85 =head2 selected_values
87 Sets C<event_id_remove_values> to the viewport's event id for C<remove_values> and renders
88 the C<value_option> fragment over the viewport's C<current_value_choices>.
90 =head2 available_values
92 Sets C<event_id_add_values> to the viewport's event id for C<add_values> and renders
93 the C<value_option> fragment over the viewport's C<available_value_choices>.
97 Sets the C<option_name> argument to the current topic argument's C<name> key and the
98 C<option_value> to the current topic argument's C<value> key.
102 Sets C<hidden_value> to the current topic's C<value> key.
106 renders C<available_values>, C<action_buttons>, C<selected_values> and C<current_values>
112 share/skin/base/layout/field/mutable/choose_many.tt
114 This layout set provides a table containing two lists separated by action buttons that
115 allow the user to add values from the available list to the selected list.
119 share/skin/default/layout/field/mutable/choose_many.tt
121 Same as in the C<base> skin, except that after each action button a C<br> element will
126 See L<Reaction::Class> for authors.
130 See L<Reaction::Class> for the license.