Mercurial > pub > Impl
comparison Lib/IMPL/Web/View/Metadata/FormMeta.pm @ 368:010ceafd0c5a
form metadata + tests
| author | cin |
|---|---|
| date | Wed, 04 Dec 2013 17:31:53 +0400 |
| parents | 608e74bc309f |
| children | d5c8b955bf8d |
comparison
equal
deleted
inserted
replaced
| 367:608e74bc309f | 368:010ceafd0c5a |
|---|---|
| 107 ); | 107 ); |
| 108 | 108 |
| 109 my ($model,$type); | 109 my ($model,$type); |
| 110 | 110 |
| 111 if ($decl->isMultiple) { | 111 if ($decl->isMultiple) { |
| 112 $model = \@nodes; | 112 $model = \@nodes; |
| 113 $type = 'ARRAY'; | 113 $type = 'ARRAY'; |
| 114 $args{holdingType} = $decl->type; | 114 $args{holdingType} = $schema->type; |
| 115 } else { | 115 } else { |
| 116 $model = shift @nodes; | 116 $model = shift @nodes; |
| 117 $type = $decl->type; | 117 $type = $schema->type; |
| 118 } | 118 } |
| 119 | 119 |
| 120 push @props, Meta->new($model,$type,\%args); | 120 push @props, Meta->new($model,$type,\%args); |
| 121 } | 121 } |
| 122 | 122 |
| 130 unless $this->isMultiple; | 130 unless $this->isMultiple; |
| 131 | 131 |
| 132 my $i = 0; | 132 my $i = 0; |
| 133 | 133 |
| 134 return [ | 134 return [ |
| 135 map $this->_GetItemMeta($_,$i++), @{$this->model || []} | 135 map $this->_GetItemMeta($_,$i++), @{$this->nodes} |
| 136 ]; | 136 ]; |
| 137 } | 137 } |
| 138 | 138 |
| 139 sub GetItem { | 139 sub GetItem { |
| 140 my ($this,$index) = @_; | 140 my ($this,$index) = @_; |
| 141 | 141 |
| 142 die OpException->new("The operation must be performed on the container") | 142 die OpException->new("The operation must be performed on the container") |
| 143 unless $this->isMultiple; | 143 unless $this->isMultiple; |
| 144 | 144 |
| 145 my $node = $this->model->[$index]; | 145 my $node = $this->nodes->[$index]; |
| 146 | 146 |
| 147 return $this->GetItemMeta($node,$index); | 147 return $this->_GetItemMeta($node,$index); |
| 148 } | 148 } |
| 149 | 149 |
| 150 sub _GetItemMeta { | 150 sub _GetItemMeta { |
| 151 my ($this,$node,$index) = @_; | 151 my ($this,$node,$index) = @_; |
| 152 | 152 |
| 153 my @nodes; | |
| 154 push @nodes,$node if $node; | |
| 155 | |
| 153 return Meta->new( | 156 return Meta->new( |
| 154 $node, | 157 $node, |
| 155 $this->decl->type, | 158 $this->schema->type, |
| 156 { | 159 { |
| 157 name => $index, | 160 name => $index, |
| 158 schema => $this->schema, | 161 schema => $this->schema, |
| 159 errors => [grep _IsOwnError([$node],$this->decl,$_), @{$this->errors ||[]} ], | 162 errors => [grep _IsErrorRelates([$node],$this->decl,$_), @{$this->errors ||[]} ], |
| 160 group => $this | 163 group => $this, |
| 164 nodes => \@nodes | |
| 161 } | 165 } |
| 162 ); | 166 ); |
| 163 } | 167 } |
| 164 | 168 |
| 165 1; | 169 1; |
