Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7dd8ee36

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

  • ID 7dd8ee369c041cbcd772bb27de8fdacb21166626
  • Vorgänger 567c0d7c
  • Nachfolger 18c88aa1

CVar Inputfelder auf Templateblöcke umgeschrieben.

Bei großen Belegen, sprich 50 Zeilen steigt der Aufwand für die CVars im Moment
in der dritten Potenz. Das führt dazu dass selbst auf schnellen Servern die
Requests unhaltbar langsam sind.

Ab jetzt werden für Belege die CVars nicht mehr vorgrendert, sondern zur
Laufzeit gerendert, und dann mit einem vorkompilierten Template, dass im
Speicher eingebunden wird.

Die anderen beiden Templates sind davon nicht betroffen.

Unterschiede anzeigen:

bin/mozilla/io.pl
2094 2094
    return;
2095 2095
  }
2096 2096

  
2097
  foreach my $cvar (@{ $form->{CVAR_CONFIGS}->{IC} }) {
2098
    $cvar->{valid} = $params{part_id}
2099
      ? CVar->get_custom_variables_validity(config_id => $cvar->{id}, trans_id => $params{part_id})
2100
      : 0;
2101

  
2102
    $cvar->{value} = $form->{"ic_cvar_" . $cvar->{name} . "_$params{row}"};
2103
  }
2104

  
2105
  CVar->render_inputs(hide_non_editable => 1,
2106
                      variables         => $form->{CVAR_CONFIGS}->{IC},
2107
                      name_prefix       => 'ic_',
2108
                      name_postfix      => "_$params{row}");
2109

  
2110 2097
  my $num_visible_cvars = 0;
2111 2098
  foreach my $cvar (@{ $form->{CVAR_CONFIGS}->{IC} }) {
2099
    $cvar->{valid} = $params{part_id} &&
2100
       CVar->get_custom_variables_validity(config_id => $cvar->{id}, trans_id => $params{part_id});
2101

  
2112 2102
    my $description = '';
2113 2103
    if ($cvar->{flag_editable} && $cvar->{valid}) {
2114 2104
      $num_visible_cvars++;
2115 2105
      $description = $cvar->{description} . ' ';
2116 2106
    }
2117 2107

  
2118
    push @{ $params{ROW2} }, { line_break => $num_visible_cvars == 1,
2119
                               value      => $description . $cvar->{HTML_CODE},
2120
                             };
2108
    push @{ $params{ROW2} }, {
2109
      line_break     => $num_visible_cvars == 1,
2110
      description    => $description,
2111
      cvar           => 1,
2112
      render_options => {
2113
         hide_non_editable => 1,
2114
         var               => $cvar,
2115
         name_prefix       => 'ic_',
2116
         name_postfix      => "_$params{row}",
2117
         valid             => $cvar->{valid},
2118
         value             => $form->{"ic_cvar_" . $cvar->{name} . "_$params{row}"},
2119
      }
2120
    };
2121 2121
  }
2122 2122

  
2123 2123
  $main::lxdebug->leave_sub(2);
templates/webpages/amcvar/render_inputs_block.html
1
[%- USE T8 %]
2
[%- USE HTML %]
3
[%- BLOCK cvar_inputs %]
4
[%- var               = cvar.var  %]
5
[%- hide_non_editable = cvar.hide_non_editable, %]
6
[%- name_prefix       = cvar.name_prefix, %]
7
[%- name_postfix      = cvar.name_postfix, %]
8
[%- valid             = cvar.valid, %]
9
[%- value             = cvar.value, %]
10
[%- var_name          = HTML.escape(name_prefix) _ "cvar_" _ HTML.escape(var.name) _ HTML.escape(name_postfix) -%]
11
[%- %]
12
[%- IF hide_non_editable && !var.flag_editable %]
13
<input type="hidden" name="[% var_name %]" value="[% HTML.escape(var.value) %]">
14
[%- ELSIF !valid %]
15
  [%- IF show_disabled_message %]
16
<i>[% 'Element disabled' | $T8 %]</i>
17
  [%- END %]
18
[%- ELSIF var.type == 'bool' %]
19
<input type="checkbox" name="[% var_name %]" value="1"[% IF value %] checked[% END %]>
20
[%- ELSIF var.type == 'textfield' %]
21
<textarea name="[% var_name %]" cols="[% HTML.escape(var.width) %]" rows="[% HTML.escape(var.height) %]">[% HTML.escape(value) %]</textarea>
22
[%- ELSIF var.type == 'date' %]
23
<input name="[% var_name %]" id="[% var_name %]" size="12" value="[% HTML.escape(value) %]">
24
<input name="[% var_name %]_button" id="[% var_name %]_trigger" type="button" value="?">
25
<script type="text/javascript">
26
 <!--
27
     Calendar.setup({ inputField : "[% var_name %]",
28
                      ifFormat   : "[% myconfig_jsc_dateformat %]",
29
                      align      : "BR",
30
                      button     : "[% var_name %]_trigger" });
31
   -->
32
</script>
33
[%- ELSIF var.type == 'timestamp' %]
34
<input name="[% var_name %]" value="[% HTML.escape(value) %]">
35
[%- ELSIF var.type == 'select' %]
36
<select name="[% var_name %]">
37
 [%- FOREACH option = var.OPTIONS %]
38
 <option[% IF option.value == value %] selected[% END %]>[% HTML.escape(option.value) %]</option>
39
 [%- END %]
40
</select>
41
[%- ELSE %]
42
<input name="[% var_name %]" value="[% HTML.escape(value) %]" [%- IF var.maxlength %] maxlength="[% HTML.escape(var.maxlength) %]"[% END -%]>
43
[%- END %]
44
[%- END %]
templates/webpages/oe/sales_order.html
1 1
[%- USE T8 %]
2
[% USE HTML %]
2
[%- USE HTML %]
3
[%- PROCESS 'amcvar/render_inputs_block.html' %]
3 4
<tr>
4 5
 <td>
5 6
  <input type="button" id="cb_show_details" name="show_details" value='[% 'Show details' | $T8 %]'>
......
7 8
   $('#cb_show_details').click(function(){ $('[id$="row2"]').toggle() });
8 9
  </script>
9 10
  <table id='display_row' width="100%">
10
   <tr class="listheading">[% FOREACH header = HEADER %][% IF header.display %]
11
    <th align="left" nowrap width="[% header.width %]" class="listheading">[% header.value %]</th>[% END %][% END %]
11
   <tr class="listheading">
12
[%- FOREACH header = HEADER %]
13
 [%- IF header.display %]
14
    <th align="left" nowrap width="[% header.width %]" class="listheading">[% header.value %]</th>
15
 [%- END %]
16
[%- END %]
12 17
   </tr>
13

  
14
   [% FOREACH row = ROWS %]
15
     <tr valign="top" class="[% IF row.error %]error_message[% ELSE %]listrow[% loop.count % 2 %][% END %]">[% FOREACH row1 = row.ROW1 %]
16
      <td align="[% row1.align %]"[% IF row1.nowrap %] nowrap[% END %]>[% row1.value %]</td>[% END %]
18
[%- FOREACH row = ROWS %]
19
     <tr valign="top" class="[% IF row.error %]error_message[% ELSE %]listrow[% loop.count % 2 %][% END %]">
20
 [%- FOREACH row1 = row.ROW1 %]
21
      <td align="[% row1.align %]"[% IF row1.nowrap %] nowrap[% END %]>[% row1.value %]</td>
22
 [%- END %]
17 23
     </tr>
18

  
19
     [% FOREACH hidden = row.HIDDENS %][% hidden.value %]
20
     [% END %]
21

  
22
     <tr class="listrow[% loop.count % 2 %]" id="[% loop.count %].row2" [% UNLESS show_details %]style="display:none;"[% END %]><td colspan="[% row.colspan %]">[% FOREACH row2 = row.ROW2 %]
23
      [% IF row2.line_break %]<br/>[% END %]
24
      [% row2.value %][% END %]
25
     </td></tr>
26
   [% END %]
24
 [%- FOREACH hidden = row.HIDDENS %]
25
    [% hidden.value %]
26
 [%- END %]
27
     <tr class="listrow[% loop.count % 2 %]" id="[% loop.count %].row2" [% UNLESS show_details %]style="display:none;"[% END %]>
28
      <td colspan="[% row.colspan %]">
29
 [%- FOREACH row2 = row.ROW2 %]
30
   [%- IF row2.line_break %]<br/>[%- END %]
31
   [%- IF row2.cvar %]
32
     [% row2.description %]
33
     [% INCLUDE cvar_inputs cvar = row2.render_options %]
34
   [%- ELSE %]
35
     [% row2.value %]
36
   [%- END %]
37
 [%- END %]
38
      </td>
39
     </tr>
40
[%- END %]
27 41

  
28 42
  </table>
29 43
 </td>

Auch abrufbar als: Unified diff