You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by as...@apache.org on 2014/02/21 17:11:21 UTC

svn commit: r1570616 - in /bloodhound/trunk: bloodhound_multiproduct/multiproduct/ticket/ bloodhound_theme/bhtheme/ bloodhound_theme/bhtheme/htdocs/ bloodhound_theme/bhtheme/htdocs/js/ bloodhound_theme/bhtheme/templates/

Author: asemonella
Date: Fri Feb 21 16:11:20 2014
New Revision: 1570616

URL: http://svn.apache.org/r1570616
Log:
#727 Post QCT fields to preview new ticket.
Disables "more" link if no product selected.
Remove hidden fields not required for QCT 'more'.

Modified:
    bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/web_ui.py
    bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/bloodhound.css
    bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/js/theme.js
    bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html
    bloodhound/trunk/bloodhound_theme/bhtheme/theme.py

Modified: bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/web_ui.py
URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/web_ui.py?rev=1570616&r1=1570615&r2=1570616&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/web_ui.py (original)
+++ bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/web_ui.py Fri Feb 21 16:11:20 2014
@@ -50,16 +50,11 @@ class ProductTicketModule(TicketModule):
         """Override for TicketModule process_request"""
         ticketid = req.args.get('id')
         productid = req.args.get('productid', '')
-        qct_product = req.args.get('product')  # From QCT form
+
         if not ticketid:
             # if /newticket is executed in global scope (from QCT), redirect
             # the request to /products/<first_product_in_DB>/newticket
-            #
-            # If here from "More fields" link then pass along QCT form fields.
-            # If product arg present then redirect to
-            # /products/<qct_product>/newticket .
-
-            if not productid and not qct_product and \
+            if not productid and \
                     not isinstance(self.env, ProductEnvironment):
                 default_product = self.env.config.get('ticket',
                                                       'default_product')
@@ -67,16 +62,8 @@ class ProductTicketModule(TicketModule):
                 prefixes = [prod.prefix for prod in products]
                 if not default_product or default_product not in prefixes:
                     default_product = products[0].prefix
-                req.redirect(req.href.products(default_product, 'newticket',
-                                               req.args))
-            elif qct_product:
-                # Most likely arrived here via the QCT "More fields" link.
-                # Use <qct_product> to redirect to the appropriate product
-                # scope
-
-                req.args.pop('product')  # don't reenter block on redirect.
-                req.redirect(req.href.products(qct_product, 'newticket',
-                                               req.args))
+                req.redirect(req.href.products(default_product, 'newticket'))
+
             return self._process_newticket_request(req)
 
         if req.path_info in ('/newticket', '/products'):

Modified: bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/bloodhound.css
URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/bloodhound.css?rev=1570616&r1=1570615&r2=1570616&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/bloodhound.css (original)
+++ bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/bloodhound.css Fri Feb 21 16:11:20 2014
@@ -342,6 +342,9 @@ ol.arabic     { list-style-type: decimal
  margin-top: 5px;
  margin-bottom: 5px;
 }
+#qct-more {
+    visibility: hidden;
+}
 
 /*
   workaround for -hidden/-visible buttons in a btn-group, which don't

Modified: bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/js/theme.js
URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/js/theme.js?rev=1570616&r1=1570615&r2=1570616&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/js/theme.js (original)
+++ bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/js/theme.js Fri Feb 21 16:11:20 2014
@@ -94,16 +94,36 @@ $( function () {
       });
 
     /** 
-     * Pass QCT form fields to full ticket form when "More fields" is clicked
+     * POST QCT form fields to full ticket form when "More fields" is clicked
      */
     $('#qct-more').click(function(e) {
+        // As we're not creating the ticket, we'll remove hidden fields
+        // that result in unnecessary validation messages.
         e.preventDefault();
-        var href = $(this).attr('href');
-        var params = $('#qct-form').serialize();
-        params = params.replace(/field_/g, ''); // map to newticket querystring
-        window.location = href + '?' + params;
+        $qct_form = $('#qct-form');
+        $qct_form.unbind('submit');
+        new_ticket_url = $qct_form.find(':selected').attr('data-product-new-ticket-url');
+        $qct_form.attr('action', new_ticket_url);
+        $('.qct-product-scope-extra').remove();
+        $qct_form.append('<input type="hidden" value="1" name="preview" />');
+        $qct_form.submit();
+
     });
 
+    function set_qct_more_visibility(is_visible) {
+        if (is_visible) {
+            $('#qct-more').css('visibility', 'visible');
+        } else {
+            $('#qct-more').css('visibility', 'hidden');
+        }
+    }
+
+    $('#field-product').change(function(e) {
+        set_qct_more_visibility($(this).val());
+    });
+
+    set_qct_more_visibility($('#field-product').val());
+
     $('body').on('click.close', '#qct-alert-close', 
         function (e) { qct_alert_close() });
 

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=1570616&r1=1570615&r2=1570616&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html (original)
+++ bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html Fri Feb 21 16:11:20 2014
@@ -122,7 +122,8 @@
                   <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"
+                          value = "${option.value}"
+                          data-product-new-ticket-url = "${option.product_new_ticket_url}"
                           py:content="description"></option>
                   <optgroup py:for="optgroup in field.optgroups"
                             py:if="optgroup.options"
@@ -176,7 +177,7 @@
                             </div>
 
                             <py:for each="field in qct.hidden_fields">
-                              <input type="hidden" name="field_${field.name}" value="${field.value}" />
+                              <input class="qct-product-scope-extra" type="hidden" name="field_${field.name}" value="${field.value}" />
                             </py:for>
                           </form>
 

Modified: bloodhound/trunk/bloodhound_theme/bhtheme/theme.py
URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py?rev=1570616&r1=1570615&r2=1570616&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_theme/bhtheme/theme.py (original)
+++ bloodhound/trunk/bloodhound_theme/bhtheme/theme.py Fri Feb 21 16:11:20 2014
@@ -47,6 +47,7 @@ from bhdashboard.web_ui import Dashboard
 from bhdashboard import wiki
 
 from multiproduct.env import ProductEnvironment
+from multiproduct.model import Product
 from multiproduct.web_ui import PRODUCT_RE, ProductModule
 from bhtheme.translation import _, add_domain
 
@@ -555,7 +556,7 @@ class QuickCreateTicketDialog(Component)
             dum_req.perm = req.perm
             ticket = Ticket(self.env)
             tm._populate(dum_req, ticket, False)
-            all_fields = dict([f['name'], f]
+            all_fields = dict([f['name'], self.add_prod_new_ticket_url(dum_req, f)]
                               for f in tm._prepare_fields(dum_req, ticket)
                               if f['type'] == 'select')
 
@@ -565,13 +566,14 @@ class QuickCreateTicketDialog(Component)
                 product_field['options'] = \
                     [prefix for prefix in product_field['options']
                      if req.perm.has_permission('TICKET_CREATE',
-                                                Neighborhood('product', prefix)
+                                                Neighborhood('product', prefix['value'])
                                                     .child(None, None))]
+
                 if self.env.product and \
                         self.env.product.prefix in product_field['options']:
                     product_field['value'] = self.env.product.prefix
                 product_field['options_desc'] = [
-                    ProductEnvironment.lookup_env(self.env, p).product.name
+                    ProductEnvironment.lookup_env(self.env, p['value']).product.name
                         for p in product_field['options']
                 ]
             else:
@@ -587,8 +589,7 @@ class QuickCreateTicketDialog(Component)
                 'fields': [all_fields[k] for k in self.qct_fields
                            if k in all_fields],
                 'hidden_fields': [all_fields[k] for k in all_fields.keys()
-                                  if k not in self.qct_fields]
-            }
+                                  if k not in self.qct_fields] }
         return template, data, content_type
 
     # IRequestHandler methods
@@ -665,5 +666,17 @@ class QuickCreateTicketDialog(Component)
                                    "of ticket #%s: %s" % (t.id, e))
         return t['product'], t.id
 
+    def add_prod_new_ticket_url(self, req, fields):
+        if fields.get('name') == 'product':
+            options_with_attrs = []
+            for option in fields.get('options', []):
+                options_with_attrs.append({
+                    'value': option,
+                    'product_new_ticket_url': \
+                            req.href.products(option, 'newticket')
+                })
+            fields['options'] = options_with_attrs
+        return fields
+
 from pkg_resources import get_distribution
 application_version = get_distribution('BloodhoundTheme').version