incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g..@apache.org
Subject svn commit: r1308056 - in /incubator/bloodhound/trunk/bloodhound_theme/bhtheme: htdocs/scripts/dashboard.js htdocs/scripts/theme.js templates/bloodhound_theme.html theme.py
Date Sun, 01 Apr 2012 09:26:31 GMT
Author: gjm
Date: Sun Apr  1 09:26:31 2012
New Revision: 1308056

URL: http://svn.apache.org/viewvc?rev=1308056&view=rev
Log:
Theme code import: Ticket fields inserted in quick create ticket menu

Removed:
    incubator/bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/scripts/dashboard.js
Modified:
    incubator/bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/scripts/theme.js
    incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html
    incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py

Modified: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/scripts/theme.js
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/scripts/theme.js?rev=1308056&r1=1308055&r2=1308056&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/scripts/theme.js (original)
+++ incubator/bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/scripts/theme.js Sun Apr  1
09:26:31 2012
@@ -2,7 +2,7 @@
 
 $( function () {
     // Do not close dropdown menu if user clicks on form controls
-    $('.dropdown-menu input, .dropdown-menu label')
+    $('.dropdown-menu input, .dropdown-menu label, .dropdown-menu select')
         .click(function (e) { e.stopPropagation(); });
     
     // Install quick create box click handlers

Modified: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html?rev=1308056&r1=1308055&r2=1308056&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html (original)
+++ incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html Sun
Apr  1 09:26:31 2012
@@ -73,6 +73,22 @@
           </form>
         </div>
         <div class="span4">
+          <py:def function="field_select(field, value)">
+            <select id="field-${field.name}" name="field_${field.name}"
+                class="input-mini" 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}"
+                      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}"
+                        py:content="option"></option>
+              </optgroup>
+            </select>
+          </py:def>
           <py:def function="qct_box()">
             <label for="qct_summary">Summary</label>
             <input class="input-medium" type="text" id="qct_summary"
@@ -83,20 +99,23 @@
             <div class="form-horizontal">
               <label class="control-label" for="qct_version">Version</label>
               <div class="controls">
-                <input name="qct_version" class="input-mini" type="text" 
-                    placeholder="Version" />
+                <!-- input name="qct_version" class="input-mini" type="text" 
+                    placeholder="Version" / -->
+                ${field_select(qct.fields.version, None)}
                 <p class="help-block">Most recent by default</p>
               </div>
               <label class="control-label" for="qct_type">Type</label>
               <div class="controls">
-                <input name="qct_type" class="input-mini" type="text" 
-                    placeholder="Type" />
+                <!-- input name="qct_type" class="input-mini" type="text" 
+                    placeholder="Type" / -->
+                ${field_select(qct.fields.type, None)}
                 <p class="help-block">Select ticket type</p>
               </div>
               <label class="control-label" for="qct_component">Component</label>
               <div class="controls">
-                <input name="qct_component" class="input-mini" type="text" 
-                    placeholder="Component" />
+                <!-- input name="qct_component" class="input-mini" type="text" 
+                    placeholder="Component" / -->
+                ${field_select(qct.fields.component, None)}
                 <p class="help-block">Select component</p>
               </div>
             </div>
@@ -113,39 +132,37 @@
               </div>
             </div>
           </py:def>
-          <div class="btn-group">
-            <a href="${href.newticket()}" class="btn btn-inverse">
-              Create Ticket
-            </a>
-            <a href="#" class="btn btn-inverse dropdown-toggle"
-                data-toggle="dropdown">
-              <i class="caret"></i>
-            </a>
-            <div id="qct-box" class="dropdown-menu">
-              <style>
-                #qct-box .help-block { white-space: nowrap; }
-                #qct-box .form-horizontal .controls .help-block { 
-                  margin-left: -20px;
-                }
-                #qct-box .form-horizontal .controls { margin-left: 90px; }
-                #qct-box .form-horizontal .control-label { width : 70px; }
-              </style>
-              <div class="popover-title"><h3>Create Ticket</h3></div>
-              <div class="popover-content">
-              ${qct_box()}
+          <py:choose test="">
+            <py:when test="qct">
+              <div class="btn-group">
+                <a href="${href.newticket()}" class="btn btn-inverse">
+                  Create Ticket
+                </a>
+                <a href="#" class="btn btn-inverse dropdown-toggle"
+                    data-toggle="dropdown">
+                  <i class="caret"></i>
+                </a>
+                <div id="qct-box" class="dropdown-menu">
+                  <style>
+                    #qct-box .help-block { white-space: nowrap; }
+                    #qct-box .form-horizontal .controls .help-block { 
+                      margin-left: -20px;
+                    }
+                    #qct-box .form-horizontal .controls { margin-left: 90px; }
+                    #qct-box .form-horizontal .control-label { width : 70px; }
+                    #qct-box .input-mini { width : 100px; }
+                  </style>
+                  <div class="popover-title"><h3>Create Ticket</h3></div>
+                  <div class="popover-content">
+                  ${qct_box()}
+                  </div>
+                </div>
               </div>
-            </div>
-          </div>
-          <!-- div class="btn-group">
-            <a href="${href.newticket()}" class="btn btn-inverse">
-              Create Ticket
-            </a>
-            <a href="#" class="btn btn-inverse popover-target" 
-                rel="popover" title="Create Ticket"
-                data-content="Here" data-placement="bottom">
-              <i class="caret"></i>
-            </a>
-          </div -->
+            </py:when>
+            <py:otherwise>
+              &nbsp;
+            </py:otherwise>
+          </py:choose>
         </div>
         <div class="span4">
           <ul py:if="chrome.nav.mainnav or chrome.nav.metanav"

Modified: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py?rev=1308056&r1=1308055&r2=1308056&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py (original)
+++ incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py Sun Apr  1 09:26:31 2012
@@ -16,13 +16,84 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-from genshi.core import Stream
+from genshi.builder import tag
+from genshi.core import Markup, Stream, TEXT
+from genshi.filters import Transformer
+from genshi.input import HTML
 from trac.core import *
+from trac.ticket.model import Ticket
+from trac.ticket.web_ui import TicketModule
+from trac.web.api import Request, IRequestFilter, ITemplateStreamFilter
+from trac.web.chrome import Chrome
+from trac.web.main import RequestDispatcher
 
-from themeengine.api import IThemeProvider, ThemeBase
+from themeengine.api import ThemeBase
 
-class BloodhoundTheme(ThemeBase):
-    """Look and feel of Bloodhound issue tracker."""
+from urlparse import urlparse
+from wsgiref.util import setup_testing_defaults
+
+def dummy_request(env, uname=None):
+    environ = {}
+    setup_testing_defaults(environ)
+    environ.update({
+                'REQUEST_METHOD' : 'GET',
+                'SCRIPT_NAME' : urlparse(str(env._abs_href())).path,
+                'trac.base_url' : str(env._abs_href()), 
+                })
+    req = Request(environ, lambda *args, **kwds: None)
+    # Intercept redirection
+    req.redirect = lambda *args, **kwds: None
+    # Setup user information
+    if uname is not None :
+      environ['REMOTE_USER'] = req.authname = uname
     
+    rd = RequestDispatcher(env)
+    chrome = Chrome(env)
+    req.callbacks.update({
+        'authname': rd.authenticate,
+        'chrome': chrome.prepare_request,
+        'hdf': getattr(rd, '_get_hdf', None),
+        'locale' : getattr(rd, '_get_locale', None),
+        'perm': rd._get_perm,
+        'session': rd._get_session,
+        'tz': rd._get_timezone,
+        'form_token': rd._get_form_token
+    })
+    return req
+
+class BloodhoundTheme(ThemeBase):
+    """Look and feel of Bloodhound issue tracker.
+    """
     template = htdocs = css = screenshot = True
-    
+
+    # Internal methods
+    def is_theme_active(self, req):
+        # TODO: Implement
+        return True
+
+class QuickCreateTicketDialog(Component):
+    implements(IRequestFilter)
+
+    # IRequestFilter(Interface):
+
+    def pre_process_request(self, req, handler):
+        """Nothing to do.
+        """
+        return handler
+
+    def post_process_request(self, req, template, data, content_type):
+        """Append necessary ticket data
+        """
+        if (template, data, content_type) != (None,) * 3: # TODO: Check !
+            if data is None:
+                data = {}
+            fakereq = dummy_request(self.env)
+            ticket = Ticket(self.env)
+            tm = TicketModule(self.env)
+            tm._populate(fakereq, ticket, False)
+            fields = dict([f['name'], f] \
+                        for f in tm._prepare_fields(fakereq, ticket))
+            data['qct'] = { 'fields' : fields }
+        return template, data, content_type
+
+



Mime
View raw message