Revision 522

Date:
2015/10/29 16:49:37
Author:
ahitrov
Revision Log:
Some system administration interface improvements
Mass section unlink for documents in browse mode

Files:

Legend:

 
Added
 
Removed
 
Modified
  • utf8/core/comps/contenido/components/__section_tree__.msn

     
    35 35
    36 36 my $sname = decode("utf-8", $sect->name());
    37 37 if ( defined $width_limit && $offset + length($sname) > $width_limit ) {
    38 $sname =~ s/<[^>]+>//sgi;
    38 39 $sname = substr($sname, 0, $width_limit - $offset);
    39 40 $sname .= '&nbsp;...';
    40 41 }
     
    47 48 my $html_sect = '<span'.($statstyle).(!$sect->status ? ' class="hiddensect"' : '').'>'.($section_access ? '<a href="'.$href.'"'.$statstyle.'>' : '').$sname.($section_access ? '</a>' : '') . '&nbsp;'.($sect->status != 1 && $statname ? '&nbsp;<span style="font-size:11px;">('.$statname.')</span>' : '').'</span>';
    48 49 my $style = ($offset == 1) ? ($viewmode ? ' style="font-size:16px;font-weight:bold;"':' style="font-size:14px;"') : ' style="font-size:12px;"';
    49 50
    50 $m->out(<<EOT);
    51 <tr>
    52 <td align="right">&nbsp;${$line_ref}&nbsp;<a href="section.html?id=$sect->{id}&move=up&ret=$root"><img src="/contenido/i/ico-up-9x10.gif" border=0 alt="Переместить секцию на шаг вверх"></a>&nbsp;<a href="section.html?id=$sect->{id}&move=down&ret=$root"><img src="/contenido/i/ico-down-9x10.gif" border=0 alt="Переместить секцию на шаг вниз"></a></td>
    53 <td><table cellpadding="0" cellspacing="0" border="0">
    54 <tr valign="top">
    55 <td width="10">&nbsp;</td>
    56 <td>$spacer</td>
    57 <td nowrap $style>$html_sect</td>
    58 </tr>
    59 </table>
    60 </td>
    61 EOT
    51 $m->out( $m->scomp( '.table_row.msn',
    52 sect => $sect,
    53 root => $root,
    54 style => $style,
    55 spacer => $spacer,
    56 viewmode => $viewmode,
    57 html_sect => $html_sect,
    58 line_ref => $line_ref,
    59 section_access => $section_access,
    60 )
    61 );
    62 62
    63 if ($viewmode) {
    64 my $fhref = '/contenido/?set_context=filter-'.$sect->id();
    65 my $new_doc_class = $sect->default_document_class;
    66 $m->out(qq^\n<td align="center" nowrap>^);
    67 $m->out(qq^<a href="section.html?id=$sect->{id}" title="Редактировать параметры секции"><img src="/contenido/i/actions/edit.gif" width="15" height="17" align="absmiddle" border="0"></a>&nbsp;&nbsp;&nbsp;^);
    68 $m->out(qq^<a href="$fhref">фильтр</a>^);
    69 $m->out(qq^&nbsp;&nbsp;&nbsp;<a href="document.html?sect_id=$sect->{id}&class=$new_doc_class">доб.докум</a>^) if $section_access == 2 and $new_doc_class;
    70 $m->out("</td>");
    71 } else {
    72 $m->out(qq^\n<td align="center" nowrap>^);
    73 $m->out(qq^<a href="section.html?id=$sect->{id}" title="Редактировать параметры секции"><img src="/contenido/i/actions/edit.gif" width="15" height="17" align="absmiddle" border="0"></a>&nbsp;&nbsp;&nbsp;^);
    74 $m->out("</td>");
    75 }
    76
    77 $m->out('</tr>');
    78 63 }
    79 64
    80 65 my $childs = $sect->{children} || [];
     
    109 94 my $line = 0;
    110 95
    111 96 </%init>
    97
    98 <%def .table_row.msn>
    99 <%args>
    100
    101 $sect => undef
    102 $root => undef
    103 $style => ''
    104 $spacer => ''
    105 $viewmode => undef
    106 $html_sect => ''
    107 $line_ref => undef
    108 $section_access => undef
    109
    110 </%args>
    111 <%init>
    112
    113 my ($fhref, $new_doc_class);
    114 if ( $viewmode ) {
    115 $fhref = '/contenido/?set_context=filter-'.$sect->id;
    116 $new_doc_class = $sect->default_document_class;
    117 }
    118
    119 </%init>
    120 <tr>
    121 <td align="right">&nbsp;<% $$line_ref %>&nbsp;<a href="section.html?id=<% $sect->id %>&move=up&ret=<% $root %>"><img src="/contenido/i/ico-up-9x10.gif" border=0 alt="Переместить секцию на шаг вверх"></a>&nbsp;<a href="section.html?id=<% $sect->id %>&move=down&ret=<% $root %>"><img src="/contenido/i/ico-down-9x10.gif" border=0 alt="Переместить секцию на шаг вниз"></a></td>
    122 <td><table cellpadding="0" cellspacing="0" border="0">
    123 <tr valign="top">
    124 <td width="10">&nbsp;</td>
    125 <td><% $spacer %></td>
    126 <td nowrap <% $style %>><% $html_sect %></td>
    127 </tr>
    128 </table>
    129 </td>
    130 % if ( $viewmode ) {
    131 <td align="center" nowrap>
    132 <a href="section.html?id=<% $sect->id %>" title="Редактировать параметры секции"><img src="/contenido/i/actions/edit.gif" width="15" height="17" align="absmiddle" border="0"></a>&nbsp;&nbsp;&nbsp;<a
    133 href="$fhref">фильтр</a>\
    134 % if ( $section_access == 2 and $new_doc_class ) {
    135 &nbsp;&nbsp;&nbsp;<a href="document.html?sect_id=<% $sect->id %>&class=<% $new_doc_class %>">доб.докум</a>\
    136 % }
    137 </td>
    138 % } else {
    139 <td align="center" nowrap><a href="section.html?id=<% $sect->id %>" title="Редактировать параметры секции"><img src="/contenido/i/actions/edit.gif" width="15" height="17" align="absmiddle" border="0"></a></td>
    140 % }
    141 </tr>
    142 </%def>
  • utf8/core/comps/contenido/components/inputs/parent.msn

     
    1 <select name="<% $name %>" class="selects">
    1 <select name="<% $name %>" class="selects"<% $style ? ' style="'.$style.'"' : '' %>>
    2 2 % select_index_tree( $root_sect, 0, $level, $check, \$color, $tree );
    3 3 </select>
    4 4 <%args>
    5 5
    6 $name => undef
    7 $check => undef
    6 $name => undef
    7 $check => undef
    8 8
    9 $root => 1
    10 $level => 15
    9 $root => 1
    10 $level => 15
    11 $style => undef
    11 12
    12 13 </%args>
    13 14 <%init>
  • utf8/core/comps/contenido/components/section_browse.msn

     
    11 11 });
    12 12 }
    13 13 % if ( @inline_pickups ) {
    14 $().ready(function() {
    14 $(document).ready(function() {
    15 15 % foreach my $pickup ( @inline_pickups ) {
    16 16 % my $lookup_opts = $pickup->{lookup_opts};
    17 17 % my $search_opts = join( '&', map { $_.'='.$lookup_opts->{$_} } keys %$lookup_opts );
     
    130 130 % my $name=$document->name ? $document->name : 'Безымянный документ N'.$document->id;
    131 131 % if ($document_access == 2) {
    132 132 %
    133 <a<% $document->contenido_status_style ? ' style="' . $document->contenido_status_style . '"' : '' %> href="document.html?id=<% $document->id %>&class=<% $document->class %><% $params_unclassed ? '&'.$params_unclassed : '' %>"><% $name | h %>&nbsp;</a>\
    133 <a<% $document->contenido_status_style ? ' style="' . $document->contenido_status_style . '"' : '' %> href="document.html?id=<% $document->id %>&class=<% $document->class %><% $params_unclassed ? '&'.$params_unclassed : '' %>"><% $name | h %></a>\
    134 134 %
    135 135 % } else {
    136 136 %
     
    157 157 % my $style = $col->{inline_style} ? $col->{inline_style} : ($col->{type} =~ /^(integer|float)$/ ? 'text-align:right; ' : '' );
    158 158 % $style .= $col->{inline_width} ? ' width:'.$col->{inline_width}.'px; ' : ' width:65px; ';
    159 159 <td><input type="text" name="<% 'update_'.$document->id.'_'.$attr %>" value="<% $document->$attr |h %>" style="<% $style %>">
    160 % } elsif ($col->{type} eq 'checkbox') {
    161 % my $checked = $document->$attr ? ' checked' : '';
    162 <td align="center"><input type="checkbox" class="<% $attr %>-check" name="<% 'update_'.$document->id.'_'.$attr %>"<% $checked %>>
    160 163 % } elsif ($col->{type} eq 'text') {
    161 164 % my $style = $col->{inline_style} ? $col->{inline_style} : '';
    162 165 % $style .= $col->{inline_width} ? ' width:'.$col->{inline_width}.'px; ' : ' width:100px; ';
     
    167 170 % s/>/&gt;/sgi;
    168 171 % }
    169 172 <td><textarea name="<% 'update_'.$document->id.'_'.$attr %>" style="<% $style %>"><% $value %></textarea>
    170 % } elsif ($col->{type} eq 'checkbox') {
    171 % my $checked = $document->$attr ? ' checked' : '';
    172 <td align="center"><input type="checkbox" class="<% $attr %>-check" name="<% 'update_'.$document->id.'_'.$attr %>"<% $checked %>>
    173 173 % } elsif ($col->{type} eq 'select') {
    174 174 % my $options = {};
    175 175 % if ($toopi && (ref($toopi) eq 'HASH') && (exists($toopi->{$document->class}))) {
     
    224 224 % }
    225 225 </select>
    226 226 % } else {
    227 <td><% $document->$attr %>\
    227 <td><% $document->$attr %><input type="hidden" name="<% 'update_'.$document->id.'_'.$attr %>" value="<% $document->$attr |h %>">\
    228 228 % }
    229 229 % } else {
    230 <td><input type="hidden" name="<% 'update_'.$document->id.'_'.$attr %>" value="<% $document->$attr |h %>">
    230 <td><% $document->$attr %><input type="hidden" name="<% 'update_'.$document->id.'_'.$attr %>" value="<% $document->$attr |h %>">\
    231 231 % }
    232 232 %
    233 233 % } elsif ($col->{attr} eq 'class') {
     
    317 317 <input type="hidden" name="<% $key %>" value="<% $value |h %>">
    318 318 % }
    319 319 % }
    320 % if ( $section->default_document_class || $section->default_table_class ) {
    321 <div style="display:inline-block; width:45%; margin:10px 0; min-height:80px; vertical-align:top;">
    322 <& /contenido/components/inputs/parent.msn, name => 'tree', check => $section->id, style => 'width:100%;' &>
    323 <div style="text-align:left; margin-top:5px;">
    324 <input type="submit" name="move" value="Перенести" class="input_btn"><input
    325 type="submit" name="link" value="Привязать" class="input_btn"><input
    326 type="submit" name="unlink" value="Отвязать от текущей" class="input_btn" onclick="return confirm('Объекты, не привязанные к другим секциям могут быть потеряны');">
    327 </div>
    328 </div>
    329 % }
    320 330 % if ( $inline_status || $delete_status ) {
    321 <div style="float:right; text-align:right; padding:5px 0 5px 10px; width:280px;">
    331 <div style="display:inline-block; width:45%; text-align:right; margin:5px; padding-top:29px; vertical-align:top;">
    322 332 % if ( $inline_status ) {
    323 <input type="submit" name="update" value="Сохранить изменения" class="input_btn">
    333 <input type="submit" name="update" value="Сохранить изменения" class="input_btn">\
    324 334 % }
    325 335 % if ( $delete_status ) {
    326 336 <input type="submit" name="delete" value="Удалить выбранные" class="input_btn" onclick="return confirm('Все отмеченные позиции будут удалены');">
    327 337 % }
    328 338 </div>
    329 339 % }
    330 % if ( $section->default_document_class || $section->default_table_class ) {
    331 <div style="float:left; width:450px; padding:5px 0;">
    332 <& /contenido/components/inputs/parent.msn, name => 'tree', check => $section->id &>
    333 <input type="submit" name="move" value="Перенести" class="input_btn"><input type="submit" name="link" value="Привязать" class="input_btn">
    334 </div>
    335 % }
    336 340 <br clear="all">
    337 341 </form>
    338 342 <%args>
  • utf8/core/comps/contenido/sections.html

     
    312 312 $updated{$oid}{$attr} = $value;
    313 313 }
    314 314 }
    315 warn Dumper \%updated;
    315 warn Dumper \%updated if $DEBUG;
    316 316 my %classes = map { $_->{class} => 1 } values %updated;
    317 317 my $parent_new = $keeper->get_section_by_id( $ARGS{tree} );
    318 318 my $document_access = $user->section_accesses($user, $parent_new->id);
     
    355 355 }
    356 356 }
    357 357 $m->redirect("sections.html?id=".$id.($return_params ? '&'.$return_params : ''));
    358 } elsif ( $ARGS{unlink} ) {
    359 my $return_params = join ('&', map { $_.'='.$filter_params{$_} } grep { $_ ne 's' } keys %filter_params );
    360 my $document_access = $user->section_accesses($user, $owner->id);
    361 my %updated;
    362 while ( my ($field, $value) = each %ARGS ) {
    363 if ( $field =~ /^delete_(\d+)_(\w+)$/ ) {
    364 my $oid = $1;
    365 my $attr = $2;
    366 $updated{$oid}{$attr} = $value;
    367 }
    368 }
    369 warn Dumper \%updated if $DEBUG;
    370 my %classes = map { $_->{class} => 1 } values %updated;
    371 if ( $document_access == 2 ) {
    372 foreach my $update_class ( keys %classes ) {
    373 my @ids;
    374 while ( my ($oid, $attr) = each %updated) {
    375 push @ids, $oid if exists $attr->{id} && $attr->{id} && ($attr->{class} eq $update_class);
    376 }
    377 my @objects = $keeper->get_documents (
    378 id => \@ids,
    379 class => $update_class
    380 ) if @ids;
    381 my ($prop) = grep { $_->{attr} eq 'sections' } $update_class->new( $keeper )->structure;
    382 if ( ref $prop && exists $prop->{db_type} && exists $prop->{db_field} ) {
    383 foreach my $object ( @objects ) {
    384 if ( $prop->{db_type} eq 'integer[]' ) {
    385 my @sections = grep { $_ != $owner->id } $object->sections;
    386 $object->sections( @sections );
    387 } else {
    388 $object->sections( undef );
    389 }
    390 $object->store;
    391 }
    392 }
    393 }
    394 }
    395 $m->redirect("sections.html?id=".$id.($return_params ? '&'.$return_params : ''));
    358 396 }
    359 397
    360 398 my %filter=();