view Lib/Form/Filter/Depends.pm @ 134:44977efed303

Significant performance optimizations Fixed recursion problems due converting objects to JSON Added cache support for the templates Added discovery feature for the web methods
author wizard
date Mon, 21 Jun 2010 02:39:53 +0400
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;