Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ea9af152

Von Werner Hahn vor mehr als 7 Jahren hinzugefügt

  • ID ea9af15288094d1bbf55e28c41bad85262528dac
  • Vorgänger 0f7f50f2
  • Nachfolger c8598827

Shopmodul: Fehlerbehandlung bei falsch konfigurierten Shop mit den
Shopartikel.
Button Shopbild bearbeiten entfernt, keine Funktion hierfür vorhanden
Layout edit Shopartikel angepasst, dass man nicht scrollen muss

Unterschiede anzeigen:

SL/Controller/ShopPart.pm
46 46
  require SL::Shop;
47 47
  my $shop = SL::Shop->new( config => $shop_part->shop );
48 48

  
49
  my $return    = $shop->connector->update_part($self->shop_part, 'all');
50

  
51
  # the connector deals with parsing/result verification, just needs to return success or failure
52
  if ( $return == 1 ) {
53
    my $now = DateTime->now;
54
    my $attributes->{last_update} = $now;
55
    $self->shop_part->assign_attributes(%{ $attributes });
56
    $self->shop_part->save;
57
    $self->js->html('#shop_part_last_update_' . $shop_part->id, $now->to_kivitendo('precision' => 'minute'))
58
           ->flash('info', t8("Updated part [#1] in shop [#2] at #3", $shop_part->part->displayable_name, $shop_part->shop->description, $now->to_kivitendo('precision' => 'minute') ) )
59
           ->render;
60
  } else {
61
    $self->js->flash('error', t8('The shop part wasn\'t updated.'))->render;
62
  };
49
  my $connect = $shop->check_connectivity;
50
  if($connect->{success}){
51
    my $return    = $shop->connector->update_part($self->shop_part, 'all');
52

  
53
    # the connector deals with parsing/result verification, just needs to return success or failure
54
    if ( $return == 1 ) {
55
      my $now = DateTime->now;
56
      my $attributes->{last_update} = $now;
57
      $self->shop_part->assign_attributes(%{ $attributes });
58
      $self->shop_part->save;
59
      $self->js->html('#shop_part_last_update_' . $shop_part->id, $now->to_kivitendo('precision' => 'minute'))
60
             ->flash('info', t8("Updated part [#1] in shop [#2] at #3", $shop_part->part->displayable_name, $shop_part->shop->description, $now->to_kivitendo('precision' => 'minute') ) )
61
             ->render;
62
    } else {
63
      $self->js->flash('error', t8('The shop part wasn\'t updated.'))->render;
64
    }
65
  }else{
66
    $self->js->flash('error', t8('The shop part wasn\'t updated. #1', $connect->{data}->{version}))->render;
67
  }
68

  
63 69

  
64 70
}
65 71

  
......
86 92
  require SL::Shop;
87 93
  my $shop = SL::Shop->new( config => $self->shop_part->shop );
88 94

  
89
  my $categories = $shop->connector->get_categories;
90

  
91
  $self->js
92
    ->run(
93
      'kivi.ShopPart.shop_part_dialog',
94
      t8('Shopcategories'),
95
      $self->render('shop_part/categories', { output => 0 }, CATEGORIES => $categories )
96
    )
97
    ->reinit_widgets;
98
    $self->js->render;
95
  my $connect = $shop->check_connectivity;
96
  if($connect->{success}){
97
    my $categories = $shop->connector->get_categories;
98

  
99
    $self->js
100
      ->run(
101
        'kivi.ShopPart.shop_part_dialog',
102
        t8('Shopcategories'),
103
        $self->render('shop_part/categories', { output => 0 }, CATEGORIES => $categories )
104
      )
105
      ->reinit_widgets;
106
      $self->js->render;
107
  }else{
108
    $self->js->flash('error', t8('Can\'t connect to shop. #1', $connect->{data}->{version}))->render;
109
  }
99 110

  
100 111
}
101 112

  
......
278 289
  $self->shop_part->save;
279 290

  
280 291
  my ( $price, $price_src_str ) = $self->get_price_n_pricesource($self->shop_part->active_price_source);
281

  
292
if(!$is_new){
282 293
  flash('info', $is_new ? t8('The shop part has been created.') : t8('The shop part has been saved.'));
283 294
  $self->js->html('#shop_part_description_' . $self->shop_part->id, $self->shop_part->shop_description)
284 295
           ->html('#shop_part_active_' . $self->shop_part->id, $self->shop_part->active)
......
287 298
           ->run('kivi.ShopPart.close_dialog')
288 299
           ->flash('info', t8("Updated shop part"))
289 300
           ->render;
301
         }else{
302
    $self->redirect_to(controller => 'Part', action => 'edit', 'part.id' => $self->shop_part->part_id);
303
  }
290 304
}
291 305

  
292 306
#
templates/webpages/part/form.html
41 41
    [%- IF CUSTOM_VARIABLES.size %]
42 42
    <li><a href="#custom_variables">[% 'Custom Variables' | $T8 %]</a></li>
43 43
    [%- END %]
44
    [% IF AUTH.assert('shop_part_edit', 1) %]
44
    [% IF AUTH.assert('shop_part_edit', 1) && SELF.part.id %]
45 45
    <li><a href="#shop_variables">[% 'Shop variables' | $T8 %]</a></li>
46 46
    [% END %]
47 47
   </ul>
......
70 70
   <div id="sales_price_information">
71 71
     [% PROCESS part/_sales_price_information.html id=SELF.part.id %]
72 72
   </div>
73
   [% IF AUTH.assert('shop_part_edit', 1) %]
73
   [% IF AUTH.assert('shop_part_edit', 1) && SELF.part.id %]
74 74
   <div id="shop_variables">
75 75
     [% PROCESS 'part/_shop.html' %]
76 76
   </div>
templates/webpages/shop_part/_list_images.html
23 23
      <td>[% HTML.escape(img.file.description) %]</td>
24 24
      <td>[% HTML.escape(img.file.file_name) %]</td>
25 25
      <td>[% HTML.escape(img.org_file_width) _  ' x ' _ HTML.escape(img.org_file_height) %]</td>
26
      <td>[% L.button_tag("kivi.File.delete_file(" _ img.file_id _ ", 'ShopPart/ajax_delete_file')", LxERP.t8('Delete'), confirm=LxERP.t8("Are you sure?")) %] [% L.button_tag("kivi.FileUploader.add_file(" _ img.id _ "," _ FORM.id _ ",'shop_part','ShopPart/ajax_update_file','jpg|png|tif|gif')", LxERP.t8('Edit')) %] </td>
26
      <td>[% L.button_tag("kivi.File.delete_file(" _ img.file_id _ ", 'ShopPart/ajax_delete_file')", LxERP.t8('Delete'), confirm=LxERP.t8("Are you sure?")) %]</td>
27 27
    </tr>
28 28
   [%  END %]
29 29
  </tbody>
templates/webpages/shop_part/edit.html
5 5
[%- USE LxERP -%]
6 6
[%- USE Dumper -%]
7 7

  
8
<p>
8 9
[% LxERP.t8("Part") %]: [% HTML.escape(SELF.shop_part.part.displayable_name) %]<br>
9 10
[% LxERP.t8("Shop") %]: [% HTML.escape(SELF.shop_part.shop.description) %]
11
<p>
10 12
[% # Dumper.dump_html(SELF) %]
11 13
<form action="controller.pl" method="post">
12 14
  <div>
......
21 23
    <table>
22 24
    <tr>
23 25
     <td>[% LxERP.t8("Description") %]</td>
24
     <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>
26
     <td colspan="3">[% L.textarea_tag('shop_part.shop_description', SELF.shop_part.shop_description, wrap="soft", style="width: 350px; height: 150px", class="texteditor") %]</td>
25 27
    </tr>
26 28
    <tr>
27 29
     <td>[% LxERP.t8("Active") %]</td>
28 30
     <td>[% L.yes_no_tag("shop_part.active", SELF.shop_part.active, default = "yes") %]</td>
31
     <td>[% LxERP.t8("Date") %]</td>
32
     <td>[% L.date_tag("shop_part.show_date", SELF.shop_part.show_date) %]</td>
29 33
    </tr>
30 34
    <tr>
31
      <th align="right">[% 'Price Source' | $T8 %]</th>
35
      <td>[% 'Price Source' | $T8 %]</th>
32 36
      [% IF SELF.shop_part.active_price_source %]
33 37
        [% SET price_source = SELF.shop_part.active_price_source %]
34 38
      [% ELSE %]
35 39
        [% SET price_source = SELF.shop_part.shop.price_source %]
36 40
      [% END %]
37 41
      <td>[% L.select_tag('shop_part.active_price_source', SELF.price_sources, value_key = 'id', title_key = 'name', with_empty = 0, default = price_source, default_value_key='id' ) %]</td>
38
    </tr>
39
    <tr>
40
     <td>[% LxERP.t8("Sort order") %]</td>
41
     <td>[% L.input_tag("shop_part.sortorder", SELF.shop_part.sortorder, size=2) %]</td>
42
    </tr>
43
    <tr>
44
     <td>[% LxERP.t8("Date") %]</td>
45
     <td>[% L.date_tag("shop_part.show_date", SELF.shop_part.show_date) %]</td>
46
    </tr>
47
    <tr>
48 42
     <td>[% LxERP.t8("Front page") %]</td>
49 43
     <td>[% L.yes_no_tag('shop_part.front_page', SELF.shop_part.front_page) %]</td>
50 44
    </tr>
51 45
    <tr>
46
     <td>[% LxERP.t8("Sort order") %]</td>
47
     <td>[% L.input_tag("shop_part.sortorder", SELF.shop_part.sortorder, size=2) %]</td>
52 48
     <td>[% LxERP.t8("Meta tag title") %]</td>
53 49
     <td>[% L.input_tag("shop_part.metatag_title", SELF.shop_part.metatag_title, size=12) %]</td>
54 50
    </tr>
55 51
    <tr>
56 52
     <td>[% LxERP.t8("Meta tag keywords") %]</td>
57 53
     <td>[% L.input_tag("shop_part.metatag_keywords", SELF.shop_part.metatag_keywords, size=22) %]</td>
58
    </tr>
59
    <tr>
60 54
     <td>[% LxERP.t8("Meta tag description") %]</td>
61 55
     <td>[% L.textarea_tag("shop_part.metatag_description", SELF.shop_part.metatag_description, rows=4) %]</td>
62 56
    </tr>

Auch abrufbar als: Unified diff