Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 48baa5eb

Von Martin Helmling martin.helmling@octosoft.eu vor etwa 7 Jahren hinzugefügt

  • ID 48baa5ebf4441c31d45d0111a0fe8b88d10a4dcd
  • Vorgänger c60cb1f0
  • Nachfolger b78e8bf7

Dateimanagement: Checkbox zum Löschen/Umbenennen fehlt teilweise bei ERP-Dokumenten

Umgebaut, damit jede einzelne Version eines Dokumentes löschbar ist

fix #51

Unterschiede anzeigen:

SL/Controller/File.pm
350 350
  foreach my $id_version (@{ $::form->{$ids} || [] }) {
351 351
    my ($id, $version) = split /_/, $id_version;
352 352
    my $dbfile = SL::File->get(id => $id);
353
    $dbfile->version($version) if $dbfile && $version;
354
    if ( $dbfile && $dbfile->delete ) {
355
      $files .= ' ' . $dbfile->file_name;
353
    if ( $dbfile ) {
354
      if ( $version ) {
355
        $dbfile->version($version);
356
        $files .= ' ' . $dbfile->file_name if $dbfile->delete_version;
357
      } else {
358
        $files .= ' ' . $dbfile->file_name if $dbfile->delete;
359
      }
356 360
    }
357 361
  }
358 362
  $self->js->flash('info', $infotext . $files) if $files;
SL/File.pm
72 72
  foreach my $fileobj (@fileobjs) {
73 73
    $main::lxdebug->message(LXDebug->DEBUG2(), "obj=" . $fileobj . " id=" . $fileobj->id." versions=".$fileobj->version_count);
74 74
    my $maxversion = $fileobj->version_count;
75
    $fileobj->version($maxversion);
75 76
    push @versionobjs, $fileobj;
76 77
    if ($maxversion > 1) {
77 78
      for my $version (2..$maxversion) {
......
162 163
  }
163 164
  if ($backend->delete(%params)) {
164 165
    my $do_delete = 0;
165
    if ( $params{last} || $params{all_but_notlast} ) {
166
      if ( $backend->get_version_count > 0 ) {
166
    if ( $params{last} || $params{version} || $params{all_but_notlast} ) {
167
      if ( $backend->get_version_count(%params) > 0 ) {
167 168
        $params{dbfile}->mtime(DateTime->now_local);
168 169
        $params{dbfile}->save;
169 170
      } else {
SL/File/Backend/Filesystem.pm
15 15
sub delete {
16 16
  my ($self, %params) = @_;
17 17
  die "no dbfile in backend delete" unless $params{dbfile};
18
  my $backend_data = $params{dbfile}->backend_data;
19
  $backend_data    = 0                               if $params{last};
20
  $backend_data    = $params{dbfile}->backend_data-1 if $params{all_but_notlast};
21

  
22
  if ($backend_data > 0 ) {
23
    for my $version ( 1..$backend_data) {
18
  my $last_version  = $params{dbfile}->backend_data;
19
  my $first_version = 1;
20
  $last_version     = 0                               if $params{last};
21
  $last_version     = $params{dbfile}->backend_data-1 if $params{all_but_notlast};
22
  $last_version     = $params{version}                if $params{version};
23
  $first_version    = $params{version}                if $params{version};
24

  
25
  if ($last_version > 0 ) {
26
    for my $version ( $first_version..$last_version) {
24 27
      my $file_path = $self->_filesystem_path($params{dbfile},$version);
25 28
      unlink($file_path);
26 29
    }
27
    if ($params{all_but_notlast}) {
30
    if ($params{version}) {
31
      for my $version ( $last_version+1 .. $params{dbfile}->backend_data) {
32
        my $from = $self->_filesystem_path($params{dbfile},$version);
33
        my $to   = $self->_filesystem_path($params{dbfile},$version - 1);
34
        die "file not exists in backend delete" unless -f $from;
35
        rename($from,$to);
36
      }
37
      $params{dbfile}->backend_data($params{dbfile}->backend_data-1);
38
    }
39
    elsif ($params{all_but_notlast}) {
28 40
      my $from = $self->_filesystem_path($params{dbfile},$params{dbfile}->backend_data);
29 41
      my $to   = $self->_filesystem_path($params{dbfile},1);
30 42
      die "file not exists in backend delete" unless -f $from;
......
32 44
      $params{dbfile}->backend_data(1);
33 45
    } else {
34 46
      $params{dbfile}->backend_data(0);
47
    }
48
    unless ($params{dbfile}->backend_data) {
35 49
      my $dir_path = $self->_filesystem_path($params{dbfile});
36 50
      rmdir($dir_path);
37 51
    }
SL/File/Object.pm
97 97
  SL::File->delete(dbfile => $_[0]->loaded_db_file, last => 1 )
98 98
}
99 99

  
100
sub delete_version {
101
  SL::File->delete(dbfile => $_[0]->loaded_db_file, version => $_[0]->version )
102
}
103

  
100 104
sub purge {
101 105
  SL::File->delete(dbfile => $_[0]->loaded_db_file, all_but_notlast => 1 )
102 106
}
templates/webpages/file/list.html
44 44
  [%- FOREACH file = source.files %]
45 45
   <tr class="listrow[% loop.count % 2 %]">
46 46
    [%- IF edit_attachments %]
47
    [%- IF file.newest %]
48
    <td>[%- L.checkbox_tag(checkname _ '[]', 'value'=file.id, 'class'=checkname) %]</td>
49
    [%- ELSE %]
50
    <td></td>
51
    [%- END %]
47
    <td>[%- L.checkbox_tag(checkname _ '[]', 'value'=file.id _ '_' _ file.version, 'class'=checkname) %]</td>
52 48
    <td></td>
53 49
    [%- END %]
54
    <td>[% file.mtime_as_timestamp_s %]</td>
50
    <td>[% file.mtime_as_timestamp_s %][% L.hidden_tag("version[]", file.version) %]</td>
55 51
    <td><a href="controller.pl?action=File/download&id=[% file.id %][%- IF file.version %]&version=[%- file.version %][%- END %]">
56 52
        <span id="[% "filename_" _ file.id %][%- IF file.version %]_[% file.version %][%- END %]">[% file.file_name %]</span></a></td>
57 53
    [%- IF file_type == 'image' %]

Auch abrufbar als: Unified diff