Reaction::UI::ViewPort::Object::Mutable - Allow the user to to perform an InterfaceModel Action


Reaction documentation Contained in the Reaction distribution.

Index


Code Index:

NAME

Top

Reaction::UI::ViewPort::Object::Mutable - Allow the user to to perform an InterfaceModel Action

SYNOPSIS

Top

  use aliased 'Reaction::UI::ViewPort::Object::Mutable';

  ...
  $controller->push_viewport(Mutable,
    model => $interface_model_action,
  );

DESCRIPTION

Top

This subclass of Reaction::UI::ViewPort::Object is used for rendering a collection of Reaction::UI::ViewPort::Field::Mutable::* objects for user editing.

ATTRIBUTES

Top

model

Reaction::InterfaceModel::Action

METHODS

Top

is_modified

Returns true if any of the fields has been modified.

INTERNAL METHODS

Top

The builder methods are resolved in the same way as described in Reaction::UI::ViewPort::Object, but they create Reaction::UI::ViewPort::Field::Mutable objects.

Mutable Field Types

Text (Reaction::UI::ViewPort::Field::Mutable::Text), Array (Reaction::UI::ViewPort::Field::Mutable::Array), String (Reaction::UI::ViewPort::Field::Mutable::String), Number (Reaction::UI::ViewPort::Field::Mutable::Number), Integer (Reaction::UI::ViewPort::Field::Mutable::Integer), Boolean (Reaction::UI::ViewPort::Field::Mutable::Boolean), Password (Reaction::UI::ViewPort::Field::Mutable::Password), DateTime, ChooseOne (Reaction::UI::ViewPort::Field::Mutable::ChooseOne), ChooseMany, Files (Reaction::UI::ViewPort::Field::Mutable::File)

_build_fields_for_type_Num

_build_fields_for_type_Int

_build_fields_for_type_Bool

_build_fields_for_type_Reaction_Types_Core_SimpleStr

_build_fields_for_type_Reaction_Types_File_File

_build_fields_for_type_Str

_build_fields_for_type_Reaction_Types_Core_Password

_build_fields_for_type_Reaction_Types_DateTime_DateTime

_build_fields_for_type_Enum

_build_fields_for_type_DBIx_Class_Row

_build_fields_for_type_ArrayRef

SEE ALSO

Top

Reaction::UI::ViewPort::Object

Reaction::UI::ViewPort

Reaction::InterfaceModel::Action

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::ViewPort::Object::Mutable;

use Reaction::Class;

use aliased 'Reaction::UI::ViewPort::Object';
use aliased 'Reaction::UI::ViewPort::Field::Mutable::Text';
use aliased 'Reaction::UI::ViewPort::Field::Mutable::Array';
use aliased 'Reaction::UI::ViewPort::Field::Mutable::String';
use aliased 'Reaction::UI::ViewPort::Field::Mutable::Number';
use aliased 'Reaction::UI::ViewPort::Field::Mutable::Integer';
use aliased 'Reaction::UI::ViewPort::Field::Mutable::Boolean';
use aliased 'Reaction::UI::ViewPort::Field::Mutable::Password';
use aliased 'Reaction::UI::ViewPort::Field::Mutable::DateTime';
use aliased 'Reaction::UI::ViewPort::Field::Mutable::ChooseOne';
use aliased 'Reaction::UI::ViewPort::Field::Mutable::ChooseMany';
use aliased 'Reaction::UI::ViewPort::Field::Mutable::File';

use namespace::clean -except => [ qw(meta) ];
extends Object;

#this her for now. mutable fields need an action to build correctly
has model => (
  is => 'ro',
  isa => 'Reaction::InterfaceModel::Action',
  required => 1,
);

sub is_modified {
  my $self = shift;
  foreach my $field (@{$self->fields}) {
    return 1 if $field->is_modified;
  }
  return 0;
}

sub _build_fields_for_type_Num {
  my ($self, $attr, $args) = @_;
  $self->_build_simple_field(attribute => $attr, class => Number, %$args);
}

sub _build_fields_for_type_Int {
  my ($self, $attr, $args) = @_;
  $self->_build_simple_field(attribute => $attr, class => Integer, %$args);
}

sub _build_fields_for_type_Bool {
  my ($self,  $attr, $args) = @_;
  $self->_build_simple_field(attribute => $attr, class => Boolean, %$args);
}

sub _build_fields_for_type_Reaction_Types_Core_SimpleStr {
  my ($self, $attr, $args) = @_;
  $self->_build_simple_field(attribute => $attr, class => String, %$args);
}

sub _build_fields_for_type_Reaction_Types_File_File {
  my ($self, $attr, $args) = @_;
  $self->_build_simple_field(attribute => $attr, class => File, %$args);
}

sub _build_fields_for_type_Str {
  my ($self, $attr, $args) = @_;
  if ($attr->has_valid_values) { # There's probably a better way to do this
    $self->_build_simple_field(attribute => $attr, class => ChooseOne, %$args);
  } else {
    $self->_build_simple_field(attribute => $attr, class => Text, %$args);
  }
}

sub _build_fields_for_type_Reaction_Types_Core_Password {
  my ($self, $attr, $args) = @_;
  $self->_build_simple_field(attribute => $attr, class => Password, %$args);
}

sub _build_fields_for_type_Reaction_Types_DateTime_DateTime {
  my ($self, $attr, $args) = @_;
  $self->_build_simple_field(attribute => $attr, class => DateTime, %$args);
}

sub _build_fields_for_type_Enum {
  my ($self, $attr, $args) = @_;
    $self->_build_simple_field(attribute => $attr, class => ChooseOne, %$args);
}

#this needs to be fixed. somehow. beats the shit our of me. really.
#implements build_fields_for_type_Reaction_InterfaceModel_Object => as {
sub _build_fields_for_type_DBIx_Class_Row {
  my ($self, $attr, $args) = @_;
  $self->_build_simple_field(attribute => $attr, class => ChooseOne, %$args);
}

sub _build_fields_for_type_ArrayRef {
  my ($self, $attr, $args) = @_;
  if ($attr->has_valid_values) {
    $self->_build_simple_field(attribute => $attr, class => ChooseMany,  %$args);
  } else {
    $self->_build_simple_field
      (
       attribute => $attr,
       class     => Array,
       layout    => 'field/mutable/hidden_array',
       %$args);
  }
}

sub _build_fields_for_type_MooseX_Types_Common_String_SimpleStr {
  my ($self, $attr, $args) = @_;
  $self->_build_simple_field(attribute => $attr, class => String, %$args);
}

sub _build_fields_for_type_MooseX_Types_Common_String_Password {
  my ($self, $attr, $args) = @_;
  $self->_build_simple_field(attribute => $attr, class => Password, %$args);
}

sub _build_fields_for_type_MooseX_Types_DateTime_DateTime {
  my ($self, $attr, $args) = @_;
  $self->_build_simple_field(attribute => $attr, class => DateTime, %$args);
}

sub _build_fields_for_type_DateTime {
  my ($self, $attr, $args) = @_;
  $self->_build_simple_field(attribute => $attr, class => DateTime, %$args);
}

__PACKAGE__->meta->make_immutable;

1;

__END__;