From 24185a7d1e90ac8980462b9f471e016504d73e3c Mon Sep 17 00:00:00 2001 From: groditi Date: Tue, 26 Feb 2008 04:14:37 +0000 Subject: first DRAFT of matching passwords widget so we can move it out of the model. not tested yet at all. --- .../UI/ViewPort/Field/Mutable/MatchingPasswords.pm | 33 ++++++++++++++++++++++ .../UI/Widget/Field/Mutable/MatchingPasswords.pm | 16 +++++++++++ .../layout/field/mutable/matching_passwords.tt | 8 ++++++ 3 files changed, 57 insertions(+) create mode 100644 lib/Reaction/UI/ViewPort/Field/Mutable/MatchingPasswords.pm create mode 100644 lib/Reaction/UI/Widget/Field/Mutable/MatchingPasswords.pm create mode 100644 share/skin/default/layout/field/mutable/matching_passwords.tt diff --git a/lib/Reaction/UI/ViewPort/Field/Mutable/MatchingPasswords.pm b/lib/Reaction/UI/ViewPort/Field/Mutable/MatchingPasswords.pm new file mode 100644 index 0000000..03cb922 --- /dev/null +++ b/lib/Reaction/UI/ViewPort/Field/Mutable/MatchingPasswords.pm @@ -0,0 +1,33 @@ +package Reaction::UI::ViewPort::Field::Mutable::MatchingPasswords; + +use Reaction::Class; +use aliased 'Reaction::UI::ViewPort::Field::Mutable::Password'; + +class MatchingPasswords is Password, which { + + has check_value => (is => 'rw', isa => 'Str', ); + + #maybe both check_value and value_string should have triggers ? + #that way if one even happens before the other it would still work? + around _adopt_value_string => sub { + my $orig = shift; + my ($self) = @_; + return $orig->(@_) if $self->check_value eq $self->value_string; + $self->message("Passwords do not match"); + }; + + #order is important check_value should happen before value here ... + #i don't like how this works, it's unnecessarily fragile, but how else ? + around accept_events => sub { ('check_value', shift->(@_)) }; + + around can_sync_to_action => sub { + my $orig = shift; + my ($self) = @_; + return $orig->(@_) if $self->check_value eq $self->value_string; + $self->message("Passwords do not match"); + return; + }; + +}; + +1; diff --git a/lib/Reaction/UI/Widget/Field/Mutable/MatchingPasswords.pm b/lib/Reaction/UI/Widget/Field/Mutable/MatchingPasswords.pm new file mode 100644 index 0000000..44c7103 --- /dev/null +++ b/lib/Reaction/UI/Widget/Field/Mutable/MatchingPasswords.pm @@ -0,0 +1,16 @@ +package Reaction::UI::Widget::Field::Mutable::MatchingPasswords; + +use Reaction::UI::WidgetClass; +use aliased 'Reaction::UI::Widget::Field::Mutable::Password'; + +class MatchingPasswords is Password, which { + + implements fragment check_value { + arg 'field_id' => event_id 'check_value'; + arg 'field_name' => event_id 'check_value'; + render 'field'; #piggyback! + }; + +}; + +1; diff --git a/share/skin/default/layout/field/mutable/matching_passwords.tt b/share/skin/default/layout/field/mutable/matching_passwords.tt new file mode 100644 index 0000000..d07b784 --- /dev/null +++ b/share/skin/default/layout/field/mutable/matching_passwords.tt @@ -0,0 +1,8 @@ +=extends field/mutable/password + +=for layout widget + +[% call_next %] +[% check_value %] + +=cut -- cgit v1.2.3-54-g00ecf