From: Bernd Bleßmann Date: Mon, 25 Apr 2022 15:37:59 +0000 (+0200) Subject: Dateimanagement: erst nur letzte Version anzeigen / alle Versionen ausklappbar. X-Git-Tag: kivitendo-mebil_0.1-0~10^2~2^2~37 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=a6e0a7f493d24aec0eebede85eeaa5e724bd2e11;p=kivitendo-erp.git Dateimanagement: erst nur letzte Version anzeigen / alle Versionen ausklappbar. Und auch alle Versionen von Anhängen und Bildern anzeigen. Vorher wurde hier nur die letzte Version gezeigt. --- diff --git a/SL/Controller/File.pm b/SL/Controller/File.pm index dcf790e5b..8dacec241 100644 --- a/SL/Controller/File.pm +++ b/SL/Controller/File.pm @@ -404,26 +404,21 @@ sub _delete_all { sub _do_list { my ($self, $json) = @_; + my @files; + my @object_types = ($self->object_type); if ( $self->file_type eq 'document' ) { - my @object_types; - push @object_types, $self->object_type; push @object_types, qw(dunning1 dunning2 dunning3 dunning_invoice dunning_orig_invoice) if $self->object_type eq 'invoice'; # hardcoded object types? - @files = SL::File->get_all_versions(object_id => $self->object_id, - object_type => \@object_types, - file_type => $self->file_type, - ); - - } - elsif ( $self->file_type eq 'attachment' || $self->file_type eq 'image' ) { - @files = SL::File->get_all(object_id => $self->object_id, - object_type => $self->object_type, - file_type => $self->file_type, - ); } + @files = SL::File->get_all_versions(object_id => $self->object_id, + object_type => \@object_types, + file_type => $self->file_type, + ); + $self->files(\@files); - $_->{thumbnail} = _create_thumbnail($_) for @files; + $_->{thumbnail} = _create_thumbnail($_) for @files; + $_->{version_count} = SL::File->get_version_count(id => $_->id) for @files; if($self->object_type eq 'shop_image'){ $self->js diff --git a/js/kivi.File.js b/js/kivi.File.js index 63a85346c..55aa4eab8 100644 --- a/js/kivi.File.js +++ b/js/kivi.File.js @@ -409,4 +409,16 @@ namespace('kivi.File', function(ns) { }); }; + ns.toggle_versions = function(file_id) { + if ($('#version_toggle_' + file_id).data('versions_expanded')) { + $('.version_row_' + file_id).hide(); + $('#version_toggle_' + file_id).data('versions_expanded', 0); + $('#version_toggle_' + file_id).html("⏷ "); + } else { + $('.version_row_' + file_id).show(); + $('#version_toggle_' + file_id).data('versions_expanded', 1); + $('#version_toggle_' + file_id).html("⏶ "); + } + }; + }); diff --git a/templates/webpages/file/list.html b/templates/webpages/file/list.html index 66a3d33ad..2868d4f47 100644 --- a/templates/webpages/file/list.html +++ b/templates/webpages/file/list.html @@ -29,6 +29,7 @@ [% L.checkbox_tag(checkname _ '_checkall') %] [% source.chkall_title %] [%- END %] + [% LxERP.t8('Version') %] [% LxERP.t8('Date') %] [% source.file_title %] [%- IF file_type == 'image' %] @@ -45,12 +46,24 @@ [%- FOREACH file = source.files %] - + [%- is_other_version = 1 IF last_id == file.id %] + [%- last_id = file.id %] + [%- IF !is_other_version %] + [%- row_cnt = row_cnt + 1 %] + + [%- ELSE %] + + [%- END %] [%- IF edit_attachments %] [%- L.checkbox_tag(checkname _ '[]', 'value'=file.id _ '_' _ file.version, 'class'=checkname) %] [%- END %] - [% file.mtime_as_timestamp_s %][% L.hidden_tag("version[]", file.version) %] + 1 && !is_other_version %] class="cursor-pointer" onclick="kivi.File.toggle_versions('[% file.id %]')"[%- END %]> + [%- IF file.version_count > 1 && !is_other_version %]⏷ [% END %] + [% file.version _ '/' _ file.version_count %] + [% L.hidden_tag("version[]", file.version) %] + + [% file.mtime_as_timestamp_s %] [% file.file_name %]