Revision 632

Date:
2016/12/14 23:53:09
Author:
ahitrov
Revision Log:
cloud

Files:

Legend:

 
Added
 
Removed
 
Modified
  • utf8/plugins/tag/comps/contenido/tag/components/block_tag_objects.msn

     
    1 <fieldset>
    2 <legend>Связанные объекты</legend>
    3 % foreach my $class ( @{$state->{tag}->tag_destinations} ) {
    4 % next unless exists $objects{$class};
    5 % my %props = map { $_->{attr} => $_ } grep { $_->{attr} eq 'id' || $_->{attr} eq 'name' || $_->{attr} eq 'status' || exists $_->{column} && $_->{column} } $class->new( $keeper )->structure;
    6 <h3><% $class->class_name %> <span><% $class %></span></h3>
    7
    8 <table width="100%" border="0" cellpadding="4" cellspacing="0" class="tlistdocs">
    9 <tr bgcolor="#efefef">
    10 <th>id</th>
    11 <th>Название</th>
    12 <%doc>
    13 % if ( exists $props{status} ) {
    14 <th>Статус</th>
    15 % }
    16 </%doc>
    17 </tr>
    18 % foreach my $object ( @{$objects{$class}} ) {
    19 % my $style = $object->contenido_status_style || ( exists $props{status} && $props{status} == 0 ? 'color:gray;' : '' );
    20 <tr valign="top">
    21 <td><a href="/contenido/document.html?id=<% $object->id %>&class=<% $object->class %>"<% $style ? ' style="'.$style.'"' : '' %>><% $object->id %></a></td>
    22 <td><a href="/contenido/document.html?id=<% $object->id %>&class=<% $object->class %>"<% $style ? ' style="'.$style.'"' : '' %>><% $object->name %></a></td>
    23 <%doc>
    24 % if ( exists $props{status} ) {
    25 % my $prop = $props{status};
    26 % my $status_map = exists $prop->{cases} && ref $prop->{cases} eq 'ARRAY' ? $prop->{cases} : $keeper->default_status();
    27 % my %cases = map { $_->[0] => $_->[1] } @$status_map;
    28 <td><% exists $cases{$object->status} ? $cases{$object->status}.' ('.$object->status.')' : 'н/с ('.$object->status.')' %></td>
    29 % }
    30 </%doc>
    31 </tr>
    32 % }
    33 % }
    34 </fieldset>
    35 <%args>
    36
    37 $tag => undef
    38
    39 </%args>
    40 <%init>
    41
    42 return unless ref $tag;
    43
    44 my %objects;
    45 my $found = 0;
    46 foreach my $class ( @{$state->{tag}->tag_destinations} ) {
    47 my $objects = $tag->get_objects( class => $class );
    48 if ( ref $objects eq 'ARRAY' && @$objects ) {
    49 $objects{$class} = $objects;
    50 $found = 1;
    51 }
    52 }
    53
    54 </%init>