[%- SET can_rename = 0 %]
 [%- FOREACH source = SOURCES %]
  
   
    | [% source.title %] | 
    
     [%- SET checkname = source.chk_action %]
     [%- IF is_global %]
      [%- SET checkname = object_type _ '_' _ source.chk_action %]
     [%- END %]
     [%- IF edit_attachments %]
      
      | [% L.checkbox_tag(checkname _ '_checkall') %] | 
      [% source.chkall_title %] | 
     [%- END %]
     [%  LxERP.t8('Date') %] | 
     [%  source.file_title %] | 
     [%- IF file_type == 'image' %]
      [%  LxERP.t8('Title') %] | 
      
       [%  LxERP.t8('ImagePreview') %]
       | 
      [%  LxERP.t8('Description') %] | 
     [%- ELSE %]
      [%  LxERP.t8('ImagePreview') %] | 
     [%- END %]
    
   
   
    [%- FOREACH file = source.files %]
     
      [%- 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) %] | 
      
       
        [% file.file_name %]
       
       | 
      [%- IF file_type == 'image' %]
       [% file.title %] | 
       
         
        | 
       [% file.description %] | 
      [%- ELSE %]
       
        [%- IF file.thumbnail %]
         
        [%- ELSE %]
         -
        [%- END %]
        | 
      [%- END %]
     
    [%- END # FOREACH file %]
   
  
  
   [%- IF edit_attachments %]
    [%- IF source.can_import %]
     [% L.button_tag("kivi.File.unimport(" _ object_id _ ",'" _ object_type _ "','" _ file_type _ "','" _ checkname _ "');",source.chk_title) %]
    [%- ELSE %]
     [%- IF source.can_delete %]
      [% L.button_tag("kivi.File.delete("   _ object_id _ ",'" _ object_type _ "','" _ file_type _ "','" _ checkname _ "'," _ is_global _ ");",  source.chk_title) %]
     [%- END %]
    [%- END %]
   [%- END %]
   [%- IF source.can_rename %]
    [%- can_rename = 1 %]
    [% L.button_tag("kivi.File.rename(" _ object_id _ ",'" _ object_type _ "','" _ file_type _ "','" _ checkname _ "'," _ is_global _ ");",  source.rename_title ) %]
   [%- END %]
   [%- IF source.can_import %]
    [% L.button_tag("kivi.File.import("   _ object_id _ ",'" _ object_type _ "','" _ file_type _ "','" _ source.name _ "','" _ source.path _"');",  source.import_title ) %]
   [%- END %]
   [%- IF source.can_upload %]
    [% L.button_tag("kivi.File.upload(" _ object_id _ ",'" _ object_type _ "','" _ file_type _ "','" _ source.upload_title _ "'," _ is_global _ ");", source.upload_title ) %]
    
      [% 'Drag and drop files here' | $T8 %]
    
   [%- END %]
  
 [%- END # FOREACH source %]
 
 
  [% L.button_tag("kivi.File.update(" _ object_id _ ",'" _ object_type _ "','" _ file_type _ "'," _ is_global _ ");", LxERP.t8('Update')) %]