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
});
};
+ 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("⏶ ");
+ }
+ };
+
});
<th class="listheading" width="3%">[% L.checkbox_tag(checkname _ '_checkall') %]</th>
<th class="listheading" width="7%">[% source.chkall_title %]</th>
[%- END %]
+ <th class="listheading" width="2%"><b>[% LxERP.t8('Version') %]</b></th>
<th class="listheading" width="15%"><b>[% LxERP.t8('Date') %]</b></th>
<th class="listheading" width="20%"><b>[% source.file_title %]</b></th>
[%- IF file_type == 'image' %]
<tbody>
[%- FOREACH file = source.files %]
- <tr class="listrow[% loop.count % 2 %]">
+ [%- is_other_version = 1 IF last_id == file.id %]
+ [%- last_id = file.id %]
+ [%- IF !is_other_version %]
+ [%- row_cnt = row_cnt + 1 %]
+ <tr class="listrow[% row_cnt % 2 %]">
+ [%- ELSE %]
+ <tr class="[% 'version_row_' _ file.id %] listrow[% row_cnt % 2 %] hidden">
+ [%- END %]
[%- IF edit_attachments %]
<td>[%- L.checkbox_tag(checkname _ '[]', 'value'=file.id _ '_' _ file.version, 'class'=checkname) %]</td>
<td></td>
[%- END %]
- <td>[% file.mtime_as_timestamp_s %][% L.hidden_tag("version[]", file.version) %]</td>
+ <td align="right" [%- IF file.version_count > 1 && !is_other_version %] class="cursor-pointer" onclick="kivi.File.toggle_versions('[% file.id %]')"[%- END %]>
+ [%- IF file.version_count > 1 && !is_other_version %]<span id="[% 'version_toggle_' _ file.id %]">⏷ </span>[% END %]
+ [% file.version _ '/' _ file.version_count %]
+ [% L.hidden_tag("version[]", file.version) %]
+ </td>
+ <td>[% file.mtime_as_timestamp_s %]</td>
<td>
<a href="controller.pl?action=File/download&id=[% file.id %][%- IF file.version %]&version=[%- file.version %][%- END %]">
<span id="[% "filename_" _ file.id %][%- IF file.version %]_[% file.version %][%- END %]">[% file.file_name %]</span>