Reaction::UI::Widget::Field::Mutable::ChooseMany - Choose a number of items


Reaction documentation Contained in the Reaction distribution.

Index


Code Index:

NAME

Top

Reaction::UI::Widget::Field::Mutable::ChooseMany - Choose a number of items

DESCRIPTION

Top

See Reaction::UI::Widget::Field::Mutable

This needs a refactor to not be tied to a dual select box, but ENOTIME

FRAGMENTS

Top

action_buttons

Sets the following events by the name event_id_$name as arguments with their viewport event ids as values:

  add_all_values
  do_add_values
  do_remove_values
  remove_all_values

current_values

Renders the hidden_value fragment to store the currently selected values either once for every item in the viewport's current_value_choices (with the field_name argument set to the viewport's event id for value. Or, if no current values exist, uses the no_current_value event id from the viewport and sets the topic argument _ to 1.

selected_values

Sets event_id_remove_values to the viewport's event id for remove_values and renders the value_option fragment over the viewport's current_value_choices.

available_values

Sets event_id_add_values to the viewport's event id for add_values and renders the value_option fragment over the viewport's available_value_choices.

value_option

Sets the option_name argument to the current topic argument's name key and the option_value to the current topic argument's value key.

hidden_value

Sets hidden_value to the current topic's value key.

field

renders available_values, action_buttons, selected_values and current_values

LAYOUT SETS

Top

base

  share/skin/base/layout/field/mutable/choose_many.tt

This layout set provides a table containing two lists separated by action buttons that allow the user to add values from the available list to the selected list.

default

  share/skin/default/layout/field/mutable/choose_many.tt

Same as in the base skin, except that after each action button a br element will be rendered.

AUTHORS

Top

See Reaction::Class for authors.

LICENSE

Top

See Reaction::Class for the license.


Reaction documentation Contained in the Reaction distribution.

package Reaction::UI::Widget::Field::Mutable::ChooseMany;

use Reaction::UI::WidgetClass;

use namespace::clean -except => [ qw(meta) ];
extends 'Reaction::UI::Widget::Field::Mutable';



implements fragment action_buttons {
  foreach my $event (
    qw(add_all_values do_add_values do_remove_values remove_all_values)
      ) {
    arg "event_id_${event}" => event_id $event;
  }
};

implements fragment current_values {
  my $current_choices = $_{viewport}->current_value_choices;
  if( @$current_choices ){
    arg field_name => event_id 'value';
    render hidden_value => over $current_choices;
  } else {
    arg field_name => event_id 'no_current_value';
    arg '_' => {value => 1};
    render 'hidden_value';
  }
};

implements fragment selected_values {
  arg event_id_remove_values => event_id 'remove_values';
  render value_option => over $_{viewport}->current_value_choices;
};

implements fragment available_values {
  arg event_id_add_values => event_id 'add_values';
  render value_option => over $_{viewport}->available_value_choices;
};

implements fragment value_option {
  arg option_name => $_->{name};
  arg option_value => $_->{value};
};

implements fragment hidden_value {
  arg hidden_value => $_->{value};
};

__PACKAGE__->meta->make_immutable;


1;

__END__;