364
|
1 package IMPL::Web::View::Metadata::FormProvider;
|
|
2 use strict;
|
|
3
|
366
|
4 ues IMPL::lang ;
|
364
|
5 use IMPL::declare {
|
365
|
6 require => {
|
366
|
7 Meta => 'IMPL::Web::View::Metadata::FormMeta',
|
|
8
|
|
9 Exception => 'IMPL::Exception',
|
|
10 ArgException => '-IMPL::InvalidArgumentException'
|
365
|
11 },
|
364
|
12 base => [
|
|
13 'IMPL::Object' => undef
|
|
14 ]
|
|
15 };
|
|
16
|
366
|
17 sub PopulateProperties {
|
364
|
18 my ($this,$meta) = @_;
|
|
19
|
366
|
20 die ArgException->new(meta => 'A FormMeta is required')
|
|
21 unless is($meta,Meta);
|
|
22
|
|
23 my @props;
|
|
24
|
|
25 # return empty list of properties in case of multiple values
|
|
26 return \@props if $meta->isMultiple;
|
|
27
|
|
28 my $navi = SchemaNavigator->new($meta->schema);
|
|
29
|
|
30 foreach my $decl (@{$meta->schema->content->childNodes}) {
|
|
31
|
|
32 my $schema = $navi->NavigateName($decl->name);
|
367
|
33 $navi->SchemaBack();
|
366
|
34
|
|
35 my @nodes = $meta->model && $meta->model->selectNodes( sub { $_->schemaSource == $decl } );
|
|
36
|
|
37 my %args = (
|
|
38 name => $decl->name,
|
|
39 decl => $decl,
|
|
40 schema => $schema,
|
|
41 nodes => \@nodes,
|
|
42 errors => [grep _IsErrorRelates(\@nodes,$decl,$_), @{$meta->errors || []}]
|
|
43 );
|
|
44
|
|
45 my ($model,$type);
|
|
46
|
|
47 if ($decl->isMultiple) {
|
|
48 $model = \@nodes;
|
|
49 $type = 'ARRAY';
|
|
50 $args{holdingType} = $decl->type;
|
|
51 } else {
|
|
52 $model = shift @nodes;
|
|
53 $type = $decl->type;
|
|
54 }
|
|
55
|
367
|
56 push @props, Meta->new($this,$model,$type,\%args);
|
366
|
57 }
|
364
|
58 }
|
|
59
|
367
|
60 sub GetItems {
|
|
61 my ($this,$meta) = @_;
|
|
62
|
|
63 if ($meta->isMultiple)
|
|
64 }
|
|
65
|
|
66 sub GetItem {
|
|
67 my ($this,$meta,$index) = @_;
|
|
68 }
|
|
69
|
365
|
70
|
367
|
71
|
364
|
72
|
|
73 1; |