Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f0e61977

Von Werner Hahn vor mehr als 8 Jahren hinzugefügt

  • ID f0e619775dbc66b8e9f921c9dda5e4448dd337bf
  • Vorgänger 3c407887
  • Nachfolger a2a746b0

Fileuploader: löschen und ändern anfang

Unterschiede anzeigen:

SL/Controller/FileUploader.pm
26 26
# this action renders the popup dialog to upload the file
27 27
sub action_ajax_add_file{
28 28
  my ($self) = @_;
29
  $self->file(SL::DB::File->new);
29
  $self->file( $::form->{id} ? SL::DB::File->new(id => $::form->{id})->load : SL::DB::File->new );
30 30
  $self->render('common/file_upload', { layout => 0}, data => $::form);
31 31
}
32 32

  
js/kivi.FileUploader.js
1 1
namespace('kivi.FileUploader', function(ns) {
2 2
  //opens a popupdialog for fileupload
3
  //controller_action is passed to the popup_dialog fileupload form and can/will be called from the form to deal with the uploaded file
4
  ns.add_file = function(id,modul,controller_action,allowed_filetypes) {
3

  
4
  //id                  = id of the id in the table files
5
  //trans_id            = id of the object (part_id, shoppart_id, project_id,...) where the file belongs to
6
  //modul               = name where the file belongs to like IC, shop_part, CV ....
7
  //controller_action   = Controller/Action wich will be called by button save in popupdialog the todo whatever you want to to with the file(save it to db, save it to webdav)
8
  //                      controller_action is passed to the popup_dialog fileupload form and can/will be called from the form to deal with the uploaded file
9
  //allowed_filetypes   = must be seperated by | like jpg|gif|pdf
10
  ns.add_file = function(id,trans_id,modul,controller_action,allowed_filetypes) {
5 11
    kivi.popup_dialog({
6 12
        url :           'controller.pl?action=FileUploader/ajax_add_file',
7
        data:           'id=' + id + '&modul=' + modul + '&ca=' + controller_action + '&aft=' + allowed_filetypes,
13
        data:           'id=' + id + '&trans_id=' + trans_id + '&modul=' + modul + '&ca=' + controller_action + '&aft=' + allowed_filetypes,
8 14
        dialog:         { title: kivi.t8('File upload') }
9 15
    } );
10 16
    return true;
11 17
  };
18

  
19
  ns.delete_file = function(id) {
20
    alert ("ID: "+id);
21
  };
12 22
});
js/kivi.shop_part.js
101 101
    if (discount_str) $('#discount_' + row).val(discount_str);
102 102
    $('#update_button').click();
103 103
  }
104

  
105
  ns.show_images = function(id) {
106
    var url = 'controller.pl?action=ShopPart/show_files&modul=shop_part&id='+id;
107
    $('#shop_images').load(url);
108
  }
109

  
104 110
});
templates/webpages/common/file_upload.html
4 4
[%  L.dump(data) %]
5 5
<form method="post" id="fileupload_form" method="POST" enctype="multipart/form-data">
6 6
 [% L.hidden_tag('form_prefix',                    id_base,         id=id_base _ '_form_prefix') %]
7
 [% L.hidden_tag('trans_id',                       data.id, no_id=1) %]
7
 [% L.hidden_tag('id',                             data.id, no_id=1) %]
8
 [% L.hidden_tag('trans_id',                       data.trans_id) %]
8 9
 [% L.hidden_tag('modul',                          data.modul) %]
9 10
 [% L.hidden_tag('aft',                            data.aft) %]
10 11

  
......
17 18
 </h2>
18 19

  
19 20
 <table>
20
[% IF SELF.file.number %]
21
[% IF SELF.file.id %]
21 22
  <tr>
22 23
   <th align="right">[%- LxERP.t8("Number") %]:</th>
23 24
   <td>[% HTML.escape(SELF.file.number) %]</td>
templates/webpages/ic/tabs/_shop.html
61 61
  </div>
62 62
  [%- END %]
63 63
  <script type="text/javascript">
64
    function show_images() {
65
      var url = 'controller.pl?action=ShopPart/show_files&modul=shop_part&id=[% shop_part.part_id %]';
66
      $('#shop_images').load(url);
67
    }
68
<!-- TODO -->
69
$(window).load(function() {
70
        show_images();
71
});
64
    $(function() {
65
            kivi.shop_part.show_images([% shop_part.part_id %]);
66
    });
72 67
  </script>
73 68
  <div id="shop_images" border=1 >
74 69
  </div>
templates/webpages/shop_part/_list_images.html
1 1
[%- USE HTML %][%- USE L -%][%- USE P -%][%- USE LxERP -%]
2 2
[%- USE T8 %][% USE Base64 %]
3 3
[%- USE Dumper %]
4
[% Dumper.dump(FORM) %]
4 5
<table width="100%" id="images_list">
5 6
  <thead>
6 7
    <tr class="listheading">
......
10 11
      <th>[% 'Description' | $T8 %]</th>
11 12
      <th>[% 'Filename' | $T8 %]</th>
12 13
      <th>[% 'Orig. Size w/h' | $T8 %]</th>
14
      <th>[% 'Action' | $T8 %]</th>
13 15
    </tr>
14 16
  </thead>
15 17
  <tbody>
......
17 19
    <tr class="listrow" id="image_id_[%  img.id %]">
18 20
      <td><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]" class="dragdrop"></td>
19 21
      <td width="70px"><img src="data:[%  img.thumbnail_img_content_type %];base64,[%  img.thumbnail_img_content.encode_base64 %]" alt="[%  img.title %]"></td>
20
      <td>[%  HTML.escape(img.title) %]</td>
21
      <td>[%  HTML.escape(img.description) %]</td>
22
      <td>[%  HTML.escape(img.filename) %]</td>
23
      <td>[%  HTML.escape(img.files_img_width) _  ' x ' _ HTML.escape(img.files_img_height) %]</td>
22
      <td>[% HTML.escape(img.title) %]</td>
23
      <td>[% HTML.escape(img.description) %]</td>
24
      <td>[% HTML.escape(img.filename) %]</td>
25
      <td>[% HTML.escape(img.files_img_width) _  ' x ' _ HTML.escape(img.files_img_height) %]</td>
26
      <td>[% L.button_tag("kivi.FileUploader.delete_file(" _ img.id _ ")", LxERP.t8('Delete')) %] [% L.button_tag("kivi.FileUploader.add_file(" _ img.id _ "," _ FORM.id _ ",'shop_part','ShopPart/ajax_upload_file','jpg|png|tif|gif')", LxERP.t8('Edit')) %] </td>
24 27
    </tr>
25 28
   [%  END %]
26 29
  </tbody>
......
28 31

  
29 32
[% L.sortable_element('#images_list tbody', url=SELF.url_for(action='reorder'), with='image_id') %]
30 33
<p>
31
[% L.button_tag("kivi.FileUploader.add_file(this.form.id.value,'shop_part','ShopPart/ajax_upload_file','jpg|png|tif|gif')", 'Fileupload') %]
34
[% L.button_tag("kivi.FileUploader.add_file(''," _ FORM.id _ ",'shop_part','ShopPart/ajax_upload_file','jpg|png|tif|gif')", LxERP.t8('Fileupload')) %]
32 35
</p>

Auch abrufbar als: Unified diff