#304: Default product is not the default option in the ticket quick create or
newticket form
--------------------------+--------------------
Reporter: rjollos | Owner: nobody
Type: defect | Status: new
Priority: minor | Milestone:
Component: multiproduct | Version: 0.3.0
Keywords: |
--------------------------+--------------------
There are a few issues that result in the default product not being the
initial value for the select on either the newticket form or the quick
create ticket form.
1. It appears that we need to at least pass the default value to
`field_select`:
{{{
#!patch
Index: bloodhound_theme/bhtheme/templates/bloodhound_theme.html
===================================================================
--- bloodhound_theme/bhtheme/templates/bloodhound_theme.html (revision
1422215)
+++ bloodhound_theme/bhtheme/templates/bloodhound_theme.html (working
copy)
@@ -124,7 +124,7 @@
<py:if test="qct.fields.product">
<label class="control-label" for="field-
product">Product</label>
<div class="controls">
- ${field_select(qct.fields.product, None)}
+ ${field_select(qct.fields.product,
opt.fields.product.value)}
</div>
</py:if>
<py:if test="qct.fields.version">
}}}
I also wonder, however, if we should modify `field_select` so that the
default value doesn't need to be explicitly passed:
{{{
#!patch
Index: bloodhound_theme/bhtheme/templates/bloodhound_theme.html
===================================================================
--- bloodhound_theme/bhtheme/templates/bloodhound_theme.html (revision
1422215)
+++ bloodhound_theme/bhtheme/templates/bloodhound_theme.html (working
copy)
@@ -98,19 +98,19 @@
</form>
</div>
<div class="span2">
- <py:def function="field_select(field, value)">
+ <py:def function="field_select(field)">
<select id="field-${field.name}" name="field_${field.name}"
class="input-medium" data-empty="true" data-
field="${field.name}">
<option py:if="field.optional"></option>
<option py:for="option in field.options"
- selected="${value == option or None}"
+ selected="${field.value == option or None}"
value = "$option"
py:content="option"></option>
<optgroup py:for="optgroup in field.optgroups"
py:if="optgroup.options"
label="${optgroup.label}">
<option py:for="option in optgroup.options"
- selected="${value == option or None}"
+ selected="${field.value == option or None}"
value = "$option"
py:content="option"></option>
</optgroup>
@@ -124,25 +124,25 @@
<py:if test="qct.fields.product">
<label class="control-label" for="field-
product">Product</label>
<div class="controls">
- ${field_select(qct.fields.product, None)}
+ ${field_select(qct.fields.product)}
</div>
</py:if>
<py:if test="qct.fields.version">
<label class="control-label" for="field-
version">Version</label>
<div class="controls">
- ${field_select(qct.fields.version, None)}
+ ${field_select(qct.fields.version)}
</div>
</py:if>
<py:if test="qct.fields.type">
<label class="control-label" for="field-
type">Type</label>
<div class="controls">
- ${field_select(qct.fields.type, None)}
+ ${field_select(qct.fields.type)}
</div>
</py:if>
<py:if test="qct.fields.component">
<label class="control-label" for="field-
component">Component</label>
<div class="controls">
- ${field_select(qct.fields.component, None)}
+ ${field_select(qct.fields.component)}
</div>
</py:if>
</div>
}}}
2. The default values for selects are hard-coded in the `TicketSystem`
class, so we either need some way to set them through the
`ITicketFieldProvider` implementation, or hard code the product value as
in the following patch (not idea, just for demonstration):
{{{
#!patch
Index: trac/trac/ticket/api.py
===================================================================
--- trac/trac/ticket/api.py (revision 1422139)
+++ trac/trac/ticket/api.py (working copy)
@@ -252,6 +252,8 @@
"""Default resolution for resolving (closing) tickets
(''since 0.11'').""")
+ default_product = Option('ticket', 'default_product', '')
+
def __init__(self):
self.log.debug('action controllers for ticket workflow: %r' %
[c.__class__.__name__ for c in self.action_controllers])
}}}
3. The final issue I see is that value stored in `default_product` is the
product `name`, whereas values in the select are the product `prefix`es.
The `value` of the select element needs to be a product `prefix`. This is
related to #303.
Has anyone tried pushing `ITicketFieldProvider` to the Trac core?
--
Ticket URL: <https://issues.apache.org/bloodhound/ticket/304>
Apache Bloodhound <https://issues.apache.org/bloodhound/>
The Apache Bloodhound (incubating) issue tracker