Revision 33 (by ahitrov@rambler.ru, 2010/06/09 10:07:25) Коррективы в установке ImageMagick
Инлайновое редактирование и отображение дополнительных полей в контрольке связи
<% spacer(h=>5) %>
<form action="store_document_links.html" method="POST">
<table bgcolor="silver" cellpadding="0" cellspacing="1" width="100%">
<tr>
<th>�������</th>
<th>��������</th>
% if ( @props ) {
%	foreach my $prop ( @props ) {
<th><% $prop->{shortname} || $prop->{rusname} %></th>
%	}
% }
<th>�����</th>
</tr>
% my $i = 0;
% foreach my $link ( @$links ) {
%	my $doc = ref $destination ? $docs->{$link->source_id} : $docs->{$link->dest_id};
<tr bgcolor="<% $i++ % 2 ? 'white' : '#f0f0f0' %>">
%	if ( ref $doc ) {
%		my $style = $link->status ? '' : ' color:#606060;';
<td style="width:40px; text-align:center;"><input type="checkbox" name="links" value="link_<% $link->id %>_<% $doc->id %>_<% $link->class %>"></td>
<td><a href="document.html?class=<% $doc->class %>&id=<% $doc->id %>" target="_blank" style="<% $style %>"><% $doc->name %></a></td>
%	} else {
<td><input type="checkbox" name="links" value="link_<% $link->id %>_<% ref $destination ? $link->source_id : $link->dest_id %>_<% $link->class %>"></td>
<td>!!!������� �����!!!</td>
%	}
%	if ( @props ) {
%		foreach my $prop ( @props ) {
%			my $field = $prop->{attr};
%			if ( exists $prop->{inline} ) {
%				$inline_status = 1;
%				if ( $prop->{type} =~ /^(string|integer|float)$/ ) {
<td><input type="text" name="<% 'update_'.$link->id.'_'.$field %>" value="<% $link->$field |h %>" style="<% $prop->{inline_width} ? 'width:'.$prop->{inline_width}.'px;' : 'width:65px; ' %> <% $prop->{inline_style} || '' %>"></td>
%				} elsif ($prop->{type} eq 'checkbox') {
%					my $checked = $link->$field ? ' checked' : '';
<td align="center"><input type="checkbox" name="<% 'update_'.$link->id.'_'.$field %>"<% $checked %>>
%				} elsif ($prop->{type} eq 'select') {
%					my $options = {};
%					if ($toopi && (ref($toopi) eq 'HASH') && (exists($toopi->{$link->class}))) {
%						%{ $options } = %{ $toopi->{$link->class} };
%					}
%					my $values = $options->{$prop->{attr}};
<td><select name="<% 'update_'.$link->id.'_'.$field %>">
%					if ( ref $values eq 'ARRAY' ) {
%						foreach my $val ( @$values ) {
%							my $selected = $val eq $link->$field ? ' selected' : '';
<option value="<% $val %>"<% $selected %>><% $val %>
%						}
%					}
</select>
%				} elsif ($prop->{type} eq 'status') {
%					my $cases = $prop->{cases};
%					if ( ref $cases eq 'ARRAY' ) {
<td><select name="<% 'update_'.$link->id.'_'.$field %>" style="<% $prop->{inline_width} ? 'width:'.$prop->{inline_width}.'px;' : '' %> <% $prop->{inline_style} || '' %>">
%						foreach my $case ( @$cases ) {
%							my $selected = $case->[0] eq $link->$field ? ' selected' : '';
<option value="<% $case->[0] %>"<% $selected %>><% $case->[1] %>
%						}
</select>
%					}

%				}
%			} else {
<td><% $link->$field %></td>
%			}
%		}
%	}
<td><a href="link.html?class=<% $link->class %>&id=<% $link->id %>" target="_blank">�������������</a>
%	if ( $inline_status ) {
<input type="hidden" name="update_<% $link->id %>_class" value="<% $link->class %>">
%	}
</td></tr>
% }
</table>
% if ( @$links ) {
<div style="padding:2px; text-align:right">
<input type="hidden" name="id" value="<% $document->id %>">
<input type="hidden" name="class" value="<% $document->class %>">
%	if ( ref $destination ) {
<input type="hidden" name="source_class" value="<% $links->[0]->class %>">
%	} else {
<input type="hidden" name="dest_class" value="<% $links->[0]->class %>">
%	}
%	if ( $inline_status ) {
<input type="submit" name="update" value="��������� ���������" class="input_btn">
%	}
<input type="submit" value="������� ��������� ����� ���������" class="input_btn"></div>
% }
</form>
<%args>

	$links	=> undef
	$docs	=> undef
	$destination	=> undef
	$source		=> undef

</%args>
<%init>

  return	if !ref $destination && !ref $source;
  return	unless ref $docs;
  return	unless ref $links eq 'ARRAY' && @$links;

  my $inline_status = 0;
  my $document = $destination || $source;
  my @props = $links->[0]->structure;
  @props = sort { $a->{column} <=> $b->{column} } grep { $_->{attr} ne 'class' && $_->{type} =~ /string|integer/ } grep { $_->{column} } @props;
  my $toopi = $project->links();

</%init>