1 package Reaction::UI::ViewPort::Field::Role::Mutable::Simple;
3 use Reaction::Role::Parameterized;
5 use aliased 'Reaction::UI::ViewPort::Field::Role::Mutable';
7 use namespace::clean -except => [ qw(meta) ];
9 parameter value_type => (
10 predicate => 'has_value_type'
17 with Mutable, $p->has_value_type ? { value_type => $p->value_type } : ();
20 is => 'rw', lazy_build => 1, trigger => sub { shift->adopt_value_string },
23 # FIXME - Copied from Reaction::UI::ViewPort::Field::Role::Mutable
24 # as we broke has '+attr' in Moose.
25 has is_modified => ( #sould be bool?
26 is => 'ro', writer => '_set_modified',
27 required => 1, default => 0, init_arg => undef
30 around value_string => sub {
34 # recursive call. be VERY careful we don't go infinite here
35 my $old = $self->value_string;
37 if ((defined $old xor defined $new) || (defined $old && $old ne $new)) {
38 $self->_set_modified(1);
43 if (@_ && defined($_[0]) && !ref($_[0]) && $_[0] eq ''
44 && !$self->value_is_required) {
48 return $self->$orig(@_);
51 # the user needs to implement this because, honestly, you're always going
52 # to need to do something custom and the only common thing really is
53 # "you probably set $self->value at the end"
54 requires 'adopt_value_string';
56 around accept_events => sub { ('value_string', shift->(@_)) };
58 around force_events => sub { (value_string => '', shift->(@_)) };