Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 38c29d92

Von Werner Hahn vor mehr als 6 Jahren hinzugefügt

  • ID 38c29d92af5f9a5a8ad8b39b9d47a9f0137f9c41
  • Vorgänger 8bd7bbaf
  • Nachfolger 75db0490

Shopmodul: ShopPart Bilder und Kategorien

Bilder werden als Tabelle angezeigt

Conflicts:
templates/webpages/ic/tabs/_shop.html

Shopparts: Bilder werden angezeigt TODO Bilder löschen
Shopkategorien werden aus der Api/Shop geholt und angezeigt zum markieren

Conflicts:
SL/Controller/ShopPart.pm
SL/ShopConnector/Shopware.pm
js/kivi.shop_part.js

Unterschiede anzeigen:

SL/Controller/FileUploader.pm
29 29

  
30 30
sub action_show_files {
31 31
  my ($self) = @_;
32
$main::lxdebug->dump(0, 'WH: Show_Files',\$::form);
33
  my $images = SL::DB::Manager::File->get_all( query => [ trans_id => $::form->{id}, modul => $::form->{modul} ] );
34
  $main::lxdebug->dump(0, 'WH: ',\$images);
32 35

  
33 36

  
34 37
}
SL/Controller/ShopPart.pm
8 8
use Data::Dumper;
9 9
use SL::Locale::String qw(t8);
10 10
use SL::DB::ShopPart;
11
use SL::DB::Default;
11 12
use SL::Helper::Flash;
12 13

  
13 14
use Rose::Object::MakeMethods::Generic
......
53 54

  
54 55
};
55 56

  
57
sub action_show_files {
58
  my ($self) = @_;
59
$main::lxdebug->dump(0, 'WH: Show_Files',\$::form);
60
  require SL::DB::File;
61
  my $images = SL::DB::Manager::File->get_all_sorted( where => [ trans_id => $::form->{id}, modul => $::form->{modul}, file_content_type => { like => 'image/%' } ], sort_by => 'position' );
62
  $main::lxdebug->dump(0, 'WH: ',\$images);
63
  #my $html = $self->render('shop_part/_list_images', { output => 0 }, IMAGES => $images);
64
  $self->render('shop_part/_list_images', { header => 0 }, IMAGES => $images);
65
  #$main::lxdebug->dump(0, 'WH: ',\$html);
66

  
67
  #$self->js->html('#shop_images', $html);
68
  #$self->js->render;
69

  
70
  # $self->render('customer_vendor_turnover/count_open_items_by_year', { layout => 0 });
71

  
72

  
73
}
74

  
75
sub action_get_categories {
76
  my ($self) = @_;
77

  
78
  my $shop_part = SL::DB::Manager::ShopPart->find_by(id => $::form->{shop_part_id});
79
  die unless $shop_part;
80
  require SL::Shop;
81
  my $shop = SL::Shop->new( config => $shop_part->shop );
82
  my $categories = $shop->connector->get_categories;
83
  $main::lxdebug->dump(0, 'WH: GET',\$categories);
56 84

  
85
  $self->js
86
    ->run(
87
      'kivi.shop_part.shop_part_dialog',
88
      t8('Shopcategories'),
89
      $self->render('shop_part/categories', { output => 0 }, CATEGORIES => $categories ) #, shop_part => $self->shop_part)
90
    )
91
    ->reinit_widgets;
92

  
93
  $self->js->render;
94
}
57 95

  
58 96
# old:
59 97
# sub action_edit {
......
107 145
  $self->js->render;
108 146
}
109 147

  
110
sub action_save_categories {
148
sub render_shop_categories_edit_dialog {
111 149
  my ($self) = @_;
112 150

  
151
  # when self->shop_part is called in template, it will be an existing shop_part with id,
152
  # or a new shop_part with only part_id and shop_id set
153
  $self->js
154
    ->run(
155
      'kivi.shop_part.shop_part_dialog',
156
      t8('Shopcategories'),
157
      $self->render('shop_part/categories', { output => 0 }) #, shop_part => $self->shop_part)
158
    )
159
    ->reinit_widgets;
160

  
161
  $self->js->render;
162
}
163
sub action_reorder {
164
  my ($self) = @_;
165
$main::lxdebug->message(0, "WH:REORDER ");
166
  require SL::DB::File;
167
  SL::DB::File->reorder_list(@{ $::form->{image_id} || [] });
168
  $main::lxdebug->message(0, "WH:REORDER II ");
169

  
170
  $self->render(\'', { type => 'json' });
171
}
172

  
113 173
#
114 174
# internal stuff
115 175
#
SL/DB/ShopPart.pm
4 4
package SL::DB::ShopPart;
5 5
#package SL::DB::ShopPart;
6 6

  
7
use SL::DB::Helper::AttrHTML;
8 7
use strict;
9 8

  
10 9
use SL::DB::MetaSetup::ShopPart;
11 10
use SL::DB::Manager::ShopPart;
11
use SL::DB::Helper::AttrHTML;
12
use SL::DB::Helper::ActsAsList;
12 13

  
13 14
__PACKAGE__->meta->initialize;
14 15
__PACKAGE__->attr_html('shop_description');
SL/ShopConnector/Base.pm
13 13

  
14 14
sub update_part { die 'update_part needs to be implemented' }
15 15

  
16
sub get_categories { die 'get_order needs to be implemented' }
16 17
1;
17 18

  
18 19
__END__
SL/ShopConnector/Shopware.pm
150 150
  # return $import;
151 151
};
152 152

  
153
sub get_categories {
154
  my ($self) = @_;
155

  
156
  my $url = $self->url;
157

  
158
  my $data = $self->connector->get("http://$url/api/categories");
159
  my $data_json = $data->content;
160
  my $import = SL::JSON::decode_json($data_json);
161
  my @daten = @{$import->{data}};
162
  my %categories = map { ($_->{id} => $_) } @daten;
163

  
164
  for(@daten) {
165
    my $parent = $categories{$_->{parentId}};
166
    $parent->{children} ||= [];
167
    push @{$parent->{children}},$_;
168
  }
169

  
170
  return \@daten;
171
}
172

  
173
sub get_article {
174
}
175

  
176
sub get_articles {
177
}
178

  
179
sub set_article {
180
}
181

  
153 182
sub init_url {
154 183
  my ($self) = @_;
155 184
  # TODO: validate url and port
js/kivi.shop_part.js
2 2
namespace('kivi.shop_part', function(ns) {
3 3
  var $dialog;
4 4

  
5
  // this is called by sub render, with a certain prerendered html (edit.html)
5
  // this is called by sub render, with a certain prerendered html (edit.html,categories.html)
6 6
  ns.shop_part_dialog = function(title, html) {
7 7
    var id            = 'jqueryui_popup_dialog';
8 8
    var dialog_params = {
templates/webpages/ic/tabs/_shop.html
102 102
   <td>[% L.html_tag('span', shop_part.last_update.to_kivitendo('precision' => 'minute'), id => 'shop_part_last_update_' _ shop_part.id ) %]</td>
103 103
   <td>[% L.button_tag("kivi.shop_part.edit_shop_part(" _ shop_part.id _ ")", LxERP.t8("Edit"))  %]</td>
104 104
   <td>[% L.button_tag("kivi.shop_part.update_shop_part(" _ shop_part.id _ ")", LxERP.t8("Update"))  %]</td>
105
   <td>[% L.button_tag("kivi.shop_part.get_all_categories(" _ shop_part.id _ ")", LxERP.t8("Shopcategories"))  %]</td>
105 106
  </tr>
106 107
  [%- END %]
107 108
  [%- FOREACH shop = SHOPS_NOT_ASSIGNED %]
......
137 138
   </p>
138 139
  </div>
139 140
  [%- END %]
140
  <div id="shop_images">
141
  <script type="text/javascript">
142
    function show_images() {
143
      var url = 'controller.pl?action=ShopPart/show_files&modul=shop_part&id=[% shop_part.part_id %]';
144
      $('#shop_images').load(url);
145
    }
146

  
147
$(window).load(function() {
148
        show_images();
149
});
150
  </script>
151
  <div id="shop_images" border=1 >
141 152
  </div>
142 153
</div>
143 154

  
templates/webpages/shop_part/_list_images.html
1
[%- USE HTML %][%- USE L -%][%- USE P -%][%- USE LxERP -%]
2
[%- USE T8 %][% USE Base64 %]
3
[%- USE Dumper %]
4
<table width="100%" id="images_list">
5
  <thead>
6
    <tr class="listheading">
7
      <th width="10px"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]" class="dragdrop"></th>
8
      <th width="70px"></th>
9
      <th>[% 'Title' | $T8 %]</th>
10
      <th>[% 'Description' | $T8 %]</th>
11
      <th>[% 'Filename' | $T8 %]</th>
12
      <th>[% 'Orig. Size w/h' | $T8 %]</th>
13
    </tr>
14
  </thead>
15
  <tbody>
16
   [%-  FOREACH img = IMAGES %]
17
    <tr class="listrow" id="image_id_[%  img.id %]">
18
      <td><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]" class="dragdrop"></td>
19
      <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.thumbnail_img_width) _  ' x ' _ HTML.escape(img.thumbnail_img_height) %]</td>
24
    </tr>
25
   [%  END %]
26
  </tbody>
27
</table>
28

  
29
[% L.sortable_element('#images_list tbody', url=SELF.url_for(action='reorder'), with='image_id') %]
30
<p>
31
[% L.button_tag("add_file(this.form.id.value,'shop_part')", 'Fileupload') %]
32
</p>
33

  
34

  
35

  
36

  
37
<script type='text/javascript'>
38
<!--
39
function add_file(id,modul) {
40
  //var id = this.$('#part').val();
41
  kivi.popup_dialog({
42
        url :           'controller.pl?action=FileUploader/ajax_add_file',
43
        data:           'id=' + id + '&modul=' + modul,
44
        dialog:         { title: kivi.t8('File upload') }
45
  } );
46
   // var url = 'controller.pl?action=ShopPart/show_files?modul=shop_part&id=' + $('#id').val();
47
   // $('#images_list').load(url);
48
    //$('#jqueryui_popup_dialog').dialog('close');
49
  return true;
50
}
51
-->
52
</script>
templates/webpages/shop_part/edit.html
8 8
[% LxERP.t8("Shop") %]: [% HTML.escape(SELF.shop_part.shop.description) %]
9 9

  
10 10
<form action="controller.pl" method="post">
11
  <div>
12
    [% IF SELF.shop_part.id %]
13
    [%- L.hidden_tag("shop_part.id", SELF.shop_part.id) %]
14
    [%- L.hidden_tag("shop_part.shop_id", SELF.shop_part.shop_id) %]
15
    [% ELSE %]
16
    [%- L.hidden_tag("shop_part.shop_id", FORM.shop_id) %]
17
    [%- L.hidden_tag("shop_part.part_id", FORM.part_id) %]
18
    [% END %]
11 19

  
12
[% IF SELF.shop_part.id %]
13
[%- L.hidden_tag("shop_part.id", SELF.shop_part.id) %]
14
[% ELSE %]
15
[%- L.hidden_tag("shop_part.shop_id", FORM.shop_id) %]
16
[%- L.hidden_tag("shop_part.part_id", FORM.part_id) %]
17
[% END %]
20
    <table>
21
    <tr>
22
     <td>[% LxERP.t8("Description") %]</td>
23
     <td>[% L.textarea_tag('shop_part.shop_description_as_restricted_html', SELF.shop_part.shop_description_as_restricted_html, style='width:100%', rows=20, class="texteditor") %]</td>
24
    </tr>
25
    <tr>
26
     <td>[% LxERP.t8("Active") %]</td>
27
     <td>[% L.yes_no_tag("shop_part.active", SELF.shop_part.active) %]</td>
28
    </tr>
29
    <tr>
30
     <td>[% LxERP.t8("Sort order") %]</td>
31
     <td>[% L.input_tag("shop_part.sortorder", SELF.shop_part.sortorder, size=2) %]</td>
32
    </tr>
33
    <tr>
34
     <td>[% LxERP.t8("Date") %]</td>
35
     <td>[% L.date_tag("shop_part.show_date", SELF.shop_part.show_date) %]</td>
36
    </tr>
37
    <tr>
38
     <td>[% LxERP.t8("Front page") %]</td>
39
     <td>[% L.yes_no_tag('shop_part.front_page', SELF.shop_part.front_page) %]</td>
40
    </tr>
41
    <tr>
42
     <td>[% LxERP.t8("Meta Tags") %]</td>
43
     <td>[% L.input_tag("shop_part.meta_tags", SELF.shop_part.meta_tags, size=2) %]</td>
44
    </tr>
45
    <tr>
46
     <td>[% LxERP.t8("Shop Category") %]</td>
47
     <td>[% L.input_tag("shop_part.shop_category", SELF.shop_part.category, size=2) %]</td>
48
    </tr>
49
    </table>
50
    [% # L.dump(SELF.shop_part) %]
18 51

  
19
 <table>
20
  <tr>
21
   <td>[% LxERP.t8("Description") %]</td>
22
   <td>[% L.textarea_tag('shop_part.shop_description_as_restricted_html', SELF.shop_part.shop_description_as_restricted_html, style='width:100%', rows=20, class="texteditor") %]</td>
23
     <td>[% L.textarea_tag('letter.body_as_restricted_html', letter.body_as_restricted_html, style='width:100%', rows=20, class="texteditor") %]</td>
24
   <!--   <td>[% L.textarea_tag("shop_part.shop_description", SELF.shop_part.shop_description) %]</td> -->
25
  </tr>
26
  <tr>
27
   <td>[% LxERP.t8("Active") %]</td>
28
   <td>[% L.yes_no_tag("shop_part.active", SELF.shop_part.active) %]</td>
29
  </tr>
30
  <tr>
31
   <td>[% LxERP.t8("Sort order") %]</td>
32
   <td>[% L.input_tag("shop_part.sortorder", SELF.shop_part.sortorder, size=2) %]</td>
33
  </tr>
34
  <tr>
35
   <td>[% LxERP.t8("Date") %]</td>
36
   <td>[% L.date_tag("shop_part.show_date", SELF.shop_part.show_date) %]</td>
37
  </tr>
38
  <tr>
39
   <td>[% LxERP.t8("Front page") %]</td>
40
   <td>[% L.yes_no_tag('shop_part.front_page', SELF.shop_part.front_page) %]</td>
41
  </tr>
42
  <tr>
43
   <td>[% LxERP.t8("Meta Tags") %]</td>
44
   <td>[% L.input_tag("shop_part.meta_tags", SELF.shop_part.meta_tags, size=2) %]</td>
45
  </tr>
46
  <tr>
47
   <td>[% LxERP.t8("Shop Category") %]</td>
48
   <td>[% L.input_tag("shop_part.shop_category", SELF.shop_part.category, size=2) %]</td>
49
  </tr>
50
</table>
51
[% # L.dump(SELF.shop_part) %]
52
    [% IF SELF.shop_part.id %]
53
    [% L.button_tag("kivi.shop_part.save_shop_part(" _ SELF.shop_part.id _ ")", LxERP.t8("Save"))  %]</td>
54
    [% ELSE %]
55
    [% L.button_tag("kivi.shop_part.add_shop_part(" _ FORM.part_id _", " _ FORM.shop_id _")", LxERP.t8("Save"))  %]</td>
56
    [% END %]
57
    [% # L.button_tag("kivi.shop_part.update_partnumber()", LxERP.t8("Update Partnumber"))  %]</td>
52 58

  
53
[% IF SELF.shop_part.id %]
54
[% L.button_tag("kivi.shop_part.save_shop_part(" _ SELF.shop_part.id _ ")", LxERP.t8("Save"))  %]</td>
55
[% ELSE %]
56
[% L.button_tag("kivi.shop_part.add_shop_part(" _ FORM.part_id _", " _ FORM.shop_id _")", LxERP.t8("Save"))  %]</td>
57
[% END %]
58
[% # L.button_tag("kivi.shop_part.update_partnumber()", LxERP.t8("Update Partnumber"))  %]</td>
59
    [% # L.hidden_tag("action", "ShopPart/dispatch") %]
60
    [% # L.submit_tag('action_update', LxERP.t8('Save')) %]
59 61

  
60
[% # L.hidden_tag("action", "ShopPart/dispatch") %]
61
[% # L.submit_tag('action_update', LxERP.t8('Save')) %]
62 62

  
63
</div>
63
  </div>
64 64
</form>
65

  
66

  
67

  
65 68
[%- IF SELF.shop_part.part.image && INSTANCE_CONF.get_parts_show_image %]
66 69
         <a href="[% SELF.shop_part.part.image | html %]" target="_blank"><img style="[% INSTANCE_CONF.get_parts_image_css %]" src="[% SELF.shop_part.part.image | html %]"/></a>
67 70
[%- END %]

Auch abrufbar als: Unified diff