Author: rjollos
Date: Sun Dec 29 07:52:41 2013
New Revision: 1553998

URL: http://svn.apache.org/r1553998
Log:
0.8dev: When at global scope, use the `[ticket] default product` as the default 
value. Refs #304.

Before this change, the product select would be set to the empty value and the 
//Create// button would be disabled until a product is selected. That behavior 
is preserved when `[ticket] default product` has not been set.

Modified:
    bloodhound/trunk/bloodhound_multiproduct/multiproduct/api.py
    bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html
    bloodhound/trunk/bloodhound_theme/bhtheme/theme.py
    bloodhound/trunk/trac/trac/ticket/api.py

Modified: bloodhound/trunk/bloodhound_multiproduct/multiproduct/api.py
URL: 
http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_multiproduct/multiproduct/api.py?rev=1553998&r1=1553997&r2=1553998&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_multiproduct/multiproduct/api.py (original)
+++ bloodhound/trunk/bloodhound_multiproduct/multiproduct/api.py Sun Dec 29 
07:52:41 2013
@@ -86,6 +86,9 @@ class MultiProductSystem(Component):
         doc="""Prefix used for default product when migrating single-product
         installations to multi-product.""")
 
+    default_product = Option('ticket', 'default_product', '',
+        """Default product for newly created tickets.""")
+
     product_base_url = Option('multiproduct', 'product_base_url', '',
         """A pattern used to generate the base URL of product environments,
         e.g. the use cases listed in bh:wiki:/Proposals/BEP-0003#url-mapping .
@@ -623,7 +626,8 @@ class MultiProductSystem(Component):
     def get_select_fields(self):
         """Product select fields"""
         return [(35, {'name': 'product', 'label': N_('Product'),
-                      'cls': Product, 'pk': 'prefix', 'optional': False})]
+                      'cls': Product, 'pk': 'prefix', 'optional': False,
+                      'value': self.default_product})]
 
     def get_radio_fields(self):
         """Product radio fields"""

Modified: 
bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html
URL: 
http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html?rev=1553998&r1=1553997&r2=1553998&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html 
(original)
+++ bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html 
Sun Dec 29 07:52:41 2013
@@ -115,10 +115,11 @@
               <!--! create ticket button + dropdown -->
               <py:def function="field_select(field)">
                 <select id="field-${field.name}" name="field_${field.name}"
-                    class="input-block-level" data-empty="true" 
data-field="${field.name}" data-optional="${'true' if field.optional else 
'false'}">
-                  <option selected="selected" value="">${'' if field.optional 
else 'Choose...'}</option>
+                    class="input-block-level" data-field="${field.name}" 
data-optional="${'true' if field.optional else 'false'}">
+                  <option value="">${'' if field.optional else 
'Choose...'}</option>
                   <option py:for="idx,option in enumerate(field.options)"
                           py:with="description = field.options_desc[idx] if 
field.options_desc else option"
+                          selected="${field.value == option or None}"
                           value = "$option"
                           py:content="description"></option>
                   <optgroup py:for="optgroup in field.optgroups"

Modified: bloodhound/trunk/bloodhound_theme/bhtheme/theme.py
URL: 
http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py?rev=1553998&r1=1553997&r2=1553998&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_theme/bhtheme/theme.py (original)
+++ bloodhound/trunk/bloodhound_theme/bhtheme/theme.py Sun Dec 29 07:52:41 2013
@@ -549,8 +549,6 @@ class QuickCreateTicketDialog(Component)
             if product_field:
                 if self.env.product:
                     product_field['value'] = self.env.product.prefix
-                else:
-                    product_field['value'] = product_field['options'][0]
                 product_field['options_desc'] = [
                     ProductEnvironment.lookup_env(self.env, p).product.name
                         for p in product_field['options']

Modified: bloodhound/trunk/trac/trac/ticket/api.py
URL: 
http://svn.apache.org/viewvc/bloodhound/trunk/trac/trac/ticket/api.py?rev=1553998&r1=1553997&r2=1553998&view=diff
==============================================================================
--- bloodhound/trunk/trac/trac/ticket/api.py (original)
+++ bloodhound/trunk/trac/trac/ticket/api.py Sun Dec 29 07:52:41 2013
@@ -364,8 +364,9 @@ class TicketSystem(Component):
                 # Fields without possible values are treated as if they didn't
                 # exist
                 continue
-            field.update({'value': getattr(self, 'default_' + name, ''),
-                          'options': options})
+            if 'value' not in field:
+                field['value'] = getattr(self, 'default_' + name, '')
+            field['options'] = options
             fields.append(field)
 
         # Advanced text fields


Reply via email to