0
|
1 package Schema::Form::Item;
|
|
2 use strict;
|
|
3 use Common;
|
|
4 our @ISA = qw(Object);
|
|
5
|
|
6 BEGIN {
|
|
7 DeclareProperty Name => ACCESS_READ;
|
|
8 DeclareProperty isMulti => ACCESS_READ;
|
|
9 DeclareProperty Filters => ACCESS_READ;
|
|
10 DeclareProperty Attributes => ACCESS_READ;
|
|
11 }
|
|
12
|
|
13 sub CTOR {
|
|
14 my ($this,$name,$multi,$filters,$attributes) = @_;
|
|
15
|
|
16 $this->{$Name} = $name or die new Exception("A name is required for the item");
|
|
17 $this->{$isMulti} = defined $multi ? $multi : 0;
|
|
18 $this->{$Filters} = $filters || [];
|
|
19 $this->{$Attributes} = $attributes || {};
|
|
20 }
|
|
21
|
|
22 sub AddFilter {
|
|
23 my ($this,$filter) = @_;
|
|
24
|
|
25 push @{$this->{$Filters}}, $filter;
|
|
26 }
|
|
27
|
|
28 sub isMandatory {
|
|
29 my ($this) = @_;
|
|
30
|
|
31 return ( grep $_->Name eq 'mandatory', $this->Filters ) ? 1 : 0 ;
|
|
32 }
|
|
33
|
|
34 sub GetFirstFilter {
|
|
35 my ($this,$filterName) = @_;
|
|
36
|
|
37 my ($filter) = grep $_->Name eq $filterName, $this->Filters;
|
|
38 return $filter;
|
|
39 }
|
|
40
|
|
41 1;
|