view Lib/Form/Filter/Depends.pm @ 59:0f3e369553bd

Rewritten property implementation (probably become slower but more flexible) Configuration infrastructure in progress (in the aspect of the lazy activation) Initial concept for the code generator
author wizard
date Tue, 09 Mar 2010 02:50:45 +0300
parents 16ada169ca75
children 76515373dac0
line wrap: on
line source

package Form::Filter::Depends;
use base qw(Form::Filter);

use Common;

BEGIN {
    DeclareProperty Fields => ACCESS_READ;
}

sub SUPPORTED_CONTEXT { Form::Filter::CTX_SINGLE | Form::Filter::CTX_SET }

sub CTOR {
    my ($this,$name,$message,@fields) = @_;
    
    $this->SUPER::CTOR($name,$message);
    $this->{$Fields} = \@fields;
}

sub Invoke {
    my ($this,$object,$context,$schemaTarget) = @_;

    foreach my $field (@{$this->{$Fields}}) {
        my $objProv = $object->Navigate($object->Form->MakeItemId($field,$object->Parent));

        if ( not $objProv or $objProv->isEmpty ) {
            return new Form::FilterResult(State => Form::FilterResult::STATE_STOP);
        }

    }

    return new Form::FilterResult(State => Form::FilterResult::STATE_SUCCESS_STAY);
}

1;