Skip to content

Commit 8d86d02

Browse files
committed
merge from upstream.
2 parents e934a68 + 0141b75 commit 8d86d02

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ Features:
156156
field. This allows onchange javascript to trigger to highlight
157157
changes, recalculate other form values etc. See ``upgrading.txt``
158158
for details on applying these changes to your tracker. (John Rouillard)
159+
- menu template function has a new parameter "showdef". When set to a
160+
string, the string is appended to the displayed option value. This
161+
allows the user to reset the value for the menu (select) to the
162+
original value. (John Rouillard)
159163

160164
Fixed:
161165

roundup/cgi/templating.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2053,7 +2053,7 @@ def field(self, showid=0, size=None, **kwargs):
20532053
**kwargs)
20542054

20552055
def menu(self, size=None, height=None, showid=0, additional=[], value=None,
2056-
sort_on=None, html_kwargs={}, translate=True, **conditions):
2056+
sort_on=None, html_kwargs={}, translate=True, showdef=None, **conditions):
20572057
""" Render a form select list for this property
20582058
20592059
"size" is used to limit the length of the list labels
@@ -2071,6 +2071,11 @@ def menu(self, size=None, height=None, showid=0, additional=[], value=None,
20712071
"translate" indicates if we should do translation of labels
20722072
using gettext -- this is often desired (e.g. for status
20732073
labels) but sometimes not.
2074+
"showdef" marks the default value with the string passed
2075+
as the showdef argument. It is appended to the selected
2076+
value so the user can reset the menu to the original value.
2077+
Note that the marker may be removed if the length of
2078+
the option label and the marker exceed the size.
20742079
20752080
The remaining keyword arguments are used as conditions for
20762081
filtering the items in the list - they're passed as the
@@ -2139,8 +2144,13 @@ def menu(self, size=None, height=None, showid=0, additional=[], value=None,
21392144

21402145
# figure if this option is selected
21412146
s = ''
2147+
# record the marker for the selected item if requested
2148+
selected_mark=''
2149+
21422150
if value in [optionid, option]:
21432151
s = 'selected="selected" '
2152+
if ( showdef ):
2153+
selected_mark = showdef
21442154

21452155
# figure the label
21462156
if showid:
@@ -2150,6 +2160,7 @@ def menu(self, size=None, height=None, showid=0, additional=[], value=None,
21502160
else:
21512161
lab = option
21522162

2163+
lab = lab + selected_mark
21532164
# truncate if it's too long
21542165
if size is not None and len(lab) > size:
21552166
lab = lab[:size-3] + '...'

0 commit comments

Comments
 (0)