Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 1004e229

Von Sven Schöling vor mehr als 3 Jahren hinzugefügt

  • ID 1004e229f325908710645008f17911de1d883803
  • Vorgänger 224d74b3
  • Nachfolger fe45b669

ImageUpload: erste Version

Unterschiede anzeigen:

SL/Controller/ImageUpload.pm
1
package SL::Controller::ImageUpload;
2

  
3
use strict;
4
use parent qw(SL::Controller::Base);
5

  
6
use SL::DB::Part;
7
use SL::DB::Order;
8
use SL::DB::DeliveryOrder;
9

  
10
use Rose::Object::MakeMethods::Generic
11
(
12
  scalar => [ qw() ],
13
  'scalar --get_set_init' => [ qw(object_type object) ],
14
);
15

  
16
my %object_loader = (
17
  part            => [ "SL::DB::Part" ],
18
  sales_order     => [ "SL::DB::Order", [ sales => 1, quotation => 0 ] ],
19
  sales_quotation => [ "SL::DB::Order", [ sales => 1, quotation => 1 ] ],
20
  purchase_order  => [ "SL::DB::Order", [ sales => 0, quotation => 1 ] ],
21
  sales_delivery_order => [ "SL::DB::DeliveryOrder", [ is_sales => 1 ] ],
22
);
23

  
24

  
25
################ actions #################
26

  
27
sub action_upload_image {
28
  my ($self) = @_;
29

  
30
  $::request->layout->add_javascripts('kivi.File.js');
31

  
32
  $self->render('image_upload/form');
33
}
34

  
35
################# internal ###############
36

  
37
sub init_object_type {
38
  $::form->{object_type} or die "need object type"
39
}
40

  
41
sub init_object {
42
  my ($self) = @_;
43

  
44
  return unless $self->object_type;
45

  
46
  my $loader = $object_loader{ $self->object_type } or die "unknown object type";
47
  my $manager = $loader->[0]->_get_manager_class;
48

  
49
  return $manager->find_by(id => $::form->{object_id}*1) if $::form->{object_id};
50

  
51
  return $manager->find_by(donumber => $::form->{object_number}, @{ $loader->[1] // [] }) if $::form->{object_number};
52
}
53

  
54

  
55
1;
56

  
57

  
menus/mobile/00-erp.yaml
8 8
  order: 100
9 9
  access: sales_delivery_order_edit
10 10
  params:
11
    action: ImageUpload/search_delivery_order
12
    sales: 1
11
    action: ImageUpload/upload_image
12
    object_type: sales_delivery_order
13 13
- id: component_test
14 14
  name: Component Test
15 15
  order: 200
templates/mobile_webpages/image_upload/form.html
1
[% USE HTML %]
2
[% USE T8 %]
3
[% USE P %]
4
[% USE LxERP %]
5

  
6
<h1>[% title | html %]</h1>
7

  
8
<form action="controller.pl">
9

  
10
[% IF !SELF.object.id %]
11

  
12
  <p>[% 'Input delivery order number (picker NYI)' | $T8 %]</p>
13

  
14
  [% P.M.input_tag("object_number", "", label=LxERP.t8("Number")) %]
15
  [% P.M.submit_tag("submit", LxERP.t8("Update")) %]
16
[% ELSE %]
17
  <h2>[% SELF.object.displayable_name | html %]</h2>
18

  
19
  [% P.hidden_tag("object_id", SELF.object.id) %]
20
[% END %]
21

  
22
[% P.hidden_tag("object_type", SELF.object_type) %]
23
[% P.hidden_tag("action", "ImageUpload/upload_image") %]
24
</form>
25

  
26
[%# IF SELF.object.id %]
27
  <div id="image_list_[% SELF.object_type | html %]"></div>
28
  <script>
29
    $(function() { $.get('controller.pl', { action: "File/list", "file_type": "image", "object_type": "[% SELF.object_type %]", "object_id": "[% SELF.object.id %]", "json": "1"}, kivi.eval_json_result) });
30
  </script>
31
[%# END %]

Auch abrufbar als: Unified diff