1 package Reaction::UI::ViewPort::Object::Mutable;
5 use aliased 'Reaction::UI::ViewPort::Object';
6 use aliased 'Reaction::UI::ViewPort::Field::Mutable::Text';
7 use aliased 'Reaction::UI::ViewPort::Field::Mutable::Array';
8 use aliased 'Reaction::UI::ViewPort::Field::Mutable::String';
9 use aliased 'Reaction::UI::ViewPort::Field::Mutable::Number';
10 use aliased 'Reaction::UI::ViewPort::Field::Mutable::Integer';
11 use aliased 'Reaction::UI::ViewPort::Field::Mutable::Boolean';
12 use aliased 'Reaction::UI::ViewPort::Field::Mutable::Password';
13 use aliased 'Reaction::UI::ViewPort::Field::Mutable::DateTime';
14 use aliased 'Reaction::UI::ViewPort::Field::Mutable::ChooseOne';
15 use aliased 'Reaction::UI::ViewPort::Field::Mutable::ChooseMany';
16 use aliased 'Reaction::UI::ViewPort::Field::Mutable::File';
18 use namespace::clean -except => [ qw(meta) ];
21 #this her for now. mutable fields need an action to build correctly
24 isa => 'Reaction::InterfaceModel::Action',
30 foreach my $field (@{$self->fields}) {
31 return 1 if $field->is_modified;
36 sub _build_fields_for_type_Num {
37 my ($self, $attr, $args) = @_;
38 $self->_build_simple_field(attribute => $attr, class => Number, %$args);
41 sub _build_fields_for_type_Int {
42 my ($self, $attr, $args) = @_;
43 $self->_build_simple_field(attribute => $attr, class => Integer, %$args);
46 sub _build_fields_for_type_Bool {
47 my ($self, $attr, $args) = @_;
48 $self->_build_simple_field(attribute => $attr, class => Boolean, %$args);
51 sub _build_fields_for_type_Reaction_Types_Core_SimpleStr {
52 my ($self, $attr, $args) = @_;
53 $self->_build_simple_field(attribute => $attr, class => String, %$args);
56 sub _build_fields_for_type_Reaction_Types_File_File {
57 my ($self, $attr, $args) = @_;
58 $self->_build_simple_field(attribute => $attr, class => File, %$args);
61 sub _build_fields_for_type_Str {
62 my ($self, $attr, $args) = @_;
63 if ($attr->has_valid_values) { # There's probably a better way to do this
64 $self->_build_simple_field(attribute => $attr, class => ChooseOne, %$args);
66 $self->_build_simple_field(attribute => $attr, class => Text, %$args);
70 sub _build_fields_for_type_Reaction_Types_Core_Password {
71 my ($self, $attr, $args) = @_;
72 $self->_build_simple_field(attribute => $attr, class => Password, %$args);
75 sub _build_fields_for_type_Reaction_Types_DateTime_DateTime {
76 my ($self, $attr, $args) = @_;
77 $self->_build_simple_field(attribute => $attr, class => DateTime, %$args);
80 sub _build_fields_for_type_Enum {
81 my ($self, $attr, $args) = @_;
82 $self->_build_simple_field(attribute => $attr, class => ChooseOne, %$args);
85 #this needs to be fixed. somehow. beats the shit our of me. really.
86 #implements build_fields_for_type_Reaction_InterfaceModel_Object => as {
87 sub _build_fields_for_type_DBIx_Class_Row {
88 my ($self, $attr, $args) = @_;
89 $self->_build_simple_field(attribute => $attr, class => ChooseOne, %$args);
92 sub _build_fields_for_type_ArrayRef {
93 my ($self, $attr, $args) = @_;
94 if ($attr->has_valid_values) {
95 $self->_build_simple_field(attribute => $attr, class => ChooseMany, %$args);
97 $self->_build_simple_field
101 layout => 'field/mutable/hidden_array',
106 sub _build_fields_for_type_MooseX_Types_Common_String_SimpleStr {
107 my ($self, $attr, $args) = @_;
108 $self->_build_simple_field(attribute => $attr, class => String, %$args);
111 sub _build_fields_for_type_MooseX_Types_Common_String_Password {
112 my ($self, $attr, $args) = @_;
113 $self->_build_simple_field(attribute => $attr, class => Password, %$args);
116 sub _build_fields_for_type_MooseX_Types_DateTime_DateTime {
117 my ($self, $attr, $args) = @_;
118 $self->_build_simple_field(attribute => $attr, class => DateTime, %$args);
121 sub _build_fields_for_type_DateTime {
122 my ($self, $attr, $args) = @_;
123 $self->_build_simple_field(attribute => $attr, class => DateTime, %$args);
126 __PACKAGE__->meta->make_immutable;
134 Reaction::UI::ViewPort::Object::Mutable - Allow the user to to perform an InterfaceModel Action
138 use aliased 'Reaction::UI::ViewPort::Object::Mutable';
141 $controller->push_viewport(Mutable,
142 model => $interface_model_action,
147 This subclass of L<Reaction::UI::ViewPort::Object> is used for rendering a
148 collection of C<Reaction::UI::ViewPort::Field::Mutable::*> objects for user editing.
154 L<Reaction::InterfaceModel::Action>
160 Returns true if any of the L<fields|Reaction::UI::ViewPort::Object/fields> has been
163 =head1 INTERNAL METHODS
165 The builder methods are resolved in the same way as described in L<Reaction::UI::ViewPort::Object>,
166 but they create L<Reaction::UI::ViewPort::Field::Mutable> objects.
168 =head2 Mutable Field Types
170 L<Text|Reaction::UI::ViewPort::Field::Mutable::Text>,
171 L<Array|Reaction::UI::ViewPort::Field::Mutable::Array>,
172 L<String|Reaction::UI::ViewPort::Field::Mutable::String>,
173 L<Number|Reaction::UI::ViewPort::Field::Mutable::Number>,
174 L<Integer|Reaction::UI::ViewPort::Field::Mutable::Integer>,
175 L<Boolean|Reaction::UI::ViewPort::Field::Mutable::Boolean>,
176 L<Password|Reaction::UI::ViewPort::Field::Mutable::Password>,
177 L<DateTime|Reaction::UI::ViewPort::Field::Mutable::DateTime>,
178 L<ChooseOne|Reaction::UI::ViewPort::Field::Mutable::ChooseOne>,
179 L<ChooseMany|Reaction::UI::ViewPort::Field::Mutable::ChooseMany>,
180 L<Files|Reaction::UI::ViewPort::Field::Mutable::File>
182 =head2 _build_fields_for_type_Num
184 =head2 _build_fields_for_type_Int
186 =head2 _build_fields_for_type_Bool
188 =head2 _build_fields_for_type_Reaction_Types_Core_SimpleStr
190 =head2 _build_fields_for_type_Reaction_Types_File_File
192 =head2 _build_fields_for_type_Str
194 =head2 _build_fields_for_type_Reaction_Types_Core_Password
196 =head2 _build_fields_for_type_Reaction_Types_DateTime_DateTime
198 =head2 _build_fields_for_type_Enum
200 =head2 _build_fields_for_type_DBIx_Class_Row
202 =head2 _build_fields_for_type_ArrayRef
206 L<Reaction::UI::ViewPort::Object>
208 L<Reaction::UI::ViewPort>
210 L<Reaction::InterfaceModel::Action>
214 See L<Reaction::Class> for authors.
218 See L<Reaction::Class> for the license.