Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 70672226

Von Werner Hahn vor mehr als 8 Jahren hinzugefügt

  • ID 70672226afd7f3f424b796d69ea04f1111c2fbdf
  • Vorgänger 237d9e65
  • Nachfolger 959ec023

Shopparts: Kategorien werden in die DB geschrieben

Unterschiede anzeigen:

SL/Controller/ShopPart.pm
79 79
  require SL::Shop;
80 80
  my $shop = SL::Shop->new( config => $shop_part->shop );
81 81
  my $categories = $shop->connector->get_categories;
82
  $main::lxdebug->dump(0, 'WH: GET',\$categories);
83 82

  
84 83
  $self->js
85 84
    ->run(
......
144 143
  $self->js->render;
145 144
}
146 145

  
147
sub render_shop_categories_edit_dialog {
146
sub action_save_categories {
148 147
  my ($self) = @_;
149 148

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

  
160
  $self->js->render;
152
  my $params = delete($::form->{shop_part}) || { };
153

  
154
  $self->shop_part->assign_attributes(%{ $params });
155
  $self->shop_part->assign_attributes(%{ $categories });
156

  
157
  $self->shop_part->save;
158

  
159
  flash('info', t8('The categories has been saved.'));
160

  
161
  $self->js->run('kivi.shop_part.close_dialog')
162
           ->flash('info', t8("Updated categories"))
163
           ->render;
161 164
}
165

  
162 166
sub action_reorder {
163 167
  my ($self) = @_;
164 168
$main::lxdebug->message(0, "WH:REORDER ");
SL/DB/MetaSetup/ShopPart.pm
17 17
  meta_tags        => { type => 'text' },
18 18
  mtime            => { type => 'timestamp' },
19 19
  part_id          => { type => 'integer', not_null => 1 },
20
  shop_category    => { type => 'text' },
20
  shop_category    => { type => 'array' },
21 21
  shop_description => { type => 'text' },
22 22
  shop_id          => { type => 'integer', not_null => 1 },
23 23
  show_date        => { type => 'date' },
SL/DB/ShopPart.pm
8 8
use SL::DB::MetaSetup::ShopPart;
9 9
use SL::DB::Manager::ShopPart;
10 10
use SL::DB::Helper::AttrHTML;
11
use SL::DB::Helper::ActsAsList;
11
#use SL::DB::Helper::ActsAsList;
12 12

  
13 13
__PACKAGE__->meta->initialize;
14 14
__PACKAGE__->attr_html('shop_description');
js/kivi.shop_part.js
78 78
    });
79 79
  }
80 80
  // write categories in kivi DB not in the shops DB TODO: create new categories in the shops db
81
  ns.set_categorie = function(shop_id, shop_part_id) {
81
  ns.save_categories = function(shop_part_id, shop_id) {
82 82
    var form = $('form').serializeArray();
83
    form.push( { name: 'action', value: 'ShopPart/set_categorie' }
83
    form.push( { name: 'action', value: 'ShopPart/save_categories' }
84 84
             , { name: 'shop_id', value: shop_id }
85
             , { name: 'shop_part_id', value: shop_part_id }
85 86
    );
86 87

  
87 88
    $.post('controller.pl', form, function(data) {
sql/Pg-upgrade2/shop_parts_2.sql
1
-- @tag: shop_parts_2
2
-- @description: Add tables for part information for shop
3
-- @charset: UTF-8
4
-- @depends: release_3_3_0 shops
5
-- @ignore: 0
6
ALTER TABLE shop_parts ALTER COLUMN shop_category TYPE TEXT[] USING array[shop_category];
templates/webpages/shop_part/categories.html
1
[%- USE HTML %]
2
[%- USE T8 %]
3
[%- USE L -%]
4
[%- USE P -%]
5
[%- USE LxERP -%]
6
[%- USE Dumper -%]
7

  
8
[%  LxERP.t8("Part") %]: [% HTML.escape(SELF.shop_part.part.displayable_name) %]<br>
9
[%  LxERP.t8("Shop") %]: [% HTML.escape(SELF.shop_part.shop.description) %]
10

  
11
[% #  Dumper.dump_html(CATEGORIES) %]
12

  
13
<form action="controller.pl" method="post">
14
  [% BLOCK recurse %]
15
    [% FOREACH obj = data %]
16
      <ul>
17
        <li>[% L.checkbox_tag('categories[]',value=obj.name) %][% HTML.escape(obj.name) %]</li>
18
        [% IF obj.childrenCount >= 1 %]
19
          [% INCLUDE recurse data=obj.children %]
20
        [% END %]
21
      </ul>
22
    [% END %]
23
  [% END %]
24
  <div><h2>[% LxERP.t8("Shopcategories") %]</h2>
25
      [% FOREACH row = CATEGORIES %]
26
        [% IF row.name == 'Root' %]
27
          [% IF row.childrenCount >= 1 %]
28
            [% INCLUDE recurse data=row.children %]
29
          [% END %]
30
        [% END %]
31
      [% END %]
32
  </div>
33
    [% L.button_tag("kivi.shop_part.save_categories(" _ SELF.shop_part.id _", " _ SELF.shop_part.shop.id _")", LxERP.t8("Save"))  %]</td>
34
</form>
35

  

Auch abrufbar als: Unified diff