blob: eb575a6400d00351cdb874ddcec9a9f27480ed11 [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001[if-any fields.values fields.derived_values]
2
3 [# TODO(jrobbins): a better UX for undesired values would be to replace the current
4 --/value slect widget with a plain-text display of the value followed by an _X_
5 link to delete it. There would be a hidden field with the value. Validation would
6 fail in JS and on the server if each such _X_ had not already been clicked.]
7
8 [# There could be more than one if this field used to be multi-valued.]
9 [for fields.values]
10 <select name="custom_[fields.field_id][is arg2 ""][else]_[arg2][end]" id="[arg0]_custom_[fields.field_id]"
11 class="custom_field_value_menu" aria-labelledby="[fields.field_id]_label">
12 [define show_no_value_choice]No[end]
13 [# Non-required fields can have any value removed.]
14 [if-any fields.field_def.is_required_bool][else]
15 [define show_no_value_choice]Yes[end]
16 [end]
17 [# Formerly multi-valued fields need -- to narrow down to being singled valued.]
18 [if-index fields.values first][else]
19 [define show_no_value_choice]Yes[end]
20 [end]
21 [is show_no_value_choice "Yes"]
22 <option value="--"
23 [is fields.values.val ""]selected="selected"[end]
24 title="No value">--</option>
25 [end]
26
27 [define value_is_shown]No[end]
28 [for fields.field_def.choices]
29 [define show_choice]No[end]
30 [# Always show the current value]
31 [is fields.values.val fields.field_def.choices.name]
32 [define value_is_shown]Yes[end]
33 [define show_choice]Yes[end]
34 [end]
35 [# Formerly multi-valued fields extra values can ONLY be removed.]
36 [if-index fields.values first]
37 [define show_choice]Yes[end]
38 [end]
39 [is show_choice "Yes"]
40 <option value="[fields.field_def.choices.name]"
41 [is fields.values.val fields.field_def.choices.name]selected="selected"[end]>
42 [fields.field_def.choices.name]
43 [if-any fields.field_def.choices.docstring]= [fields.field_def.choices.docstring][end]
44 </option>
45 [end]
46 [end]
47
48 [is value_is_shown "No"]
49 [# This is an oddball label, force the user to explicitly remove it.]
50 <option value="[fields.values.val]" selected="selected"
51 title="This value is not a defined choice for this field">
52 [fields.values.val]
53 </option>
54 [end]
55 </select><br>
56 [end]
57
58 [for fields.derived_values]
59 <div title="Derived: [fields.derived_values.docstring]" class="rolloverzone">
60 <i>[fields.derived_values.val]</i>
61 </div>
62 [end]
63
64[else][# No current values, just give all choices.]
65
66 <select name="custom_[fields.field_id][is arg2 ""][else]_arg2[end]" id="[arg0]_custom_[fields.field_id]"
67 class="custom_field_value_menu" aria-labelledby="[fields.field_id]_label">
68 [if-any fields.field_def.is_required_bool]
69 <option value="" disabled="disabled" selected="selected">Select value&hellip;</option>
70 [else]
71 <option value="--" selected="selected" title="No value">--</option>
72 [end]
73 [for fields.field_def.choices]
74 <option value="[fields.field_def.choices.name]">
75 [fields.field_def.choices.name]
76 [if-any fields.field_def.choices.docstring]= [fields.field_def.choices.docstring][end]
77 </option>
78 [end]
79 </select><br>
80
81[end]