Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 018e340a

Von Moritz Bunkus vor mehr als 16 Jahren hinzugefügt

  • ID 018e340ac9f0fc9c4b0bd180bd195e7c0fbd3c0e
  • Vorgänger 2b688418
  • Nachfolger 1967b595

Multibox: Einen weiteren Parameter ergänzt, mit dem gesteuert wird, ob überhaupt zugelassen werden soll, dass ein Textfeld anstelle einer Drop-Down-Box angezeigt wird, ohne dass man dafür explizit mit limit rumspielen muss.

Unterschiede anzeigen:

templates/webpages/generic/multibox.html
6 6
  decides wether it should be a text field or a drop down box,
7 7
  generates the HTML code, and fixes everything just right.
8 8

  
9
  call:  INCLUDE generic/multibox.html var = var, var2 = .... 
9
  call:  INCLUDE generic/multibox.html var = var, var2 = ....
10 10

  
11 11
  options and variables:
12
    name       : name of the select/textfield
13
    id         : id of the select/textfield, optional, defaults to name
14
    default    : entered/selected value. defaults to a dereference of name, since it is usually set to that for update mechanisms
15
    id_key     : key that holds the id in each row.
16
    id_sub     : name of a perl sub that calculates the id for each row. will be called with a hashref.
17
    label_key  : key that holds the label in each row.
18
    label_sub  : name of a perl sub that calculates the label for each row. will be called with a hashref.
19
    DATA       : the actual data, expected to be arrayref of hashrefs, usually what's returned by the all_vc routines.
20
    limit      : defines the limit of entries, after which a textbox is generated. defaults to vclimit, or, failing to find that, 50.
21
    show_empty : show an empty first line in select boxes. defaults to false
22
    style      : additional style information
23
    onChange   : java magic on change
24
    select     : java function call for a selection popup or other magic
12
    name          : name of the select/textfield
13
    id            : id of the select/textfield, optional, defaults to name
14
    default       : entered/selected value. defaults to a dereference of name, since it is usually set to that for update mechanisms
15
    id_key        : key that holds the id in each row.
16
    id_sub        : name of a perl sub that calculates the id for each row. will be called with a hashref.
17
    label_key     : key that holds the label in each row.
18
    label_sub     : name of a perl sub that calculates the label for each row. will be called with a hashref.
19
    DATA          : the actual data, expected to be arrayref of hashrefs, usually what's returned by the all_vc routines.
20
    show_empty    : show an empty first line in select boxes. defaults to false
21
    style         : additional style information
22
    onChange      : java magic on change
23
    select        : java function call for a selection popup or other magic
24
    allow_textbox : allow to display a textbox instead of a drop down box if there are more entries than 'limit' entries.
25
    limit         : defines the limit of entries, after which a textbox is generated. defaults to vclimit, or, failing to find that, 200.
25 26
-%]
26
[%- DEFAULT 
27
  limit      = limit != ''   ? limit   : 50
28
  id         = id    != ''   ? id      : name
27
[%- DEFAULT
28
  limit      = limit   != '' ? limit   : vclimit != '' ? vclimit : 200
29
  id         = id      != '' ? id      : name
29 30
  default    = default != '' ? default : $name
30 31
-%]
31 32
[%- FOREACH row = DATA %]
32 33
  [%-
33 34
       row.id       = row.$id_key     != ''  ? row.$id_key    : $id_sub(row)
34
       row.label    = row.$label_key  != ''  ? row.$label_key 
35
                    : $label_sub(row) != ''  ? $label_sub(row) 
35
       row.label    = row.$label_key  != ''  ? row.$label_key
36
                    : $label_sub(row) != ''  ? $label_sub(row)
36 37
                    :                          row.id
37 38
       row.selected = default == row.id
38 39
  -%]
39 40
[%- END -%]
40
[%- IF DATA.size and limit < DATA.size %]
41
<input type="text" 
41
[%- IF allow_textbox and DATA.size and limit < DATA.size %]
42
<input type="text"
42 43
 [%- IF name     %] name="[%     HTML.escape(name)     %]"[% END %]
43 44
 [%- IF id       %] id="[%       HTML.escape(id)       %]"[% END %]
44 45
 [%- IF default  %] value="[%    HTML.escape(default)  %]"[% END %]
......
48 49
  <input type="button" onclick="[% select %]" value="?">
49 50
[% END %]
50 51
[%- ELSE %]
51
<select 
52
<select
52 53
 [%- IF name     %] name="[%     HTML.escape(name)     %]"[% END %]
53 54
 [%- IF id       %] id="[%       HTML.escape(id)       %]"[% END %]
54 55
 [%- IF style    %] style="[%    HTML.escape(style)    %]"[% END %]

Auch abrufbar als: Unified diff