moksha/api/widgets/containers/tabbedcontainer.py | 1
moksha/api/widgets/containers/templates/tabbedcontainer_tabs.mak | 2
moksha/lib/helpers.py | 54 +++++++++-
moksha/public/javascript/ui/moksha.ui.grid.js | 6 -
moksha/public/javascript/ui/moksha.ui.tabs.js | 4
5 files changed, 56 insertions(+), 11 deletions(-)
New commits:
commit c948ee1ab299f539f78aae763eeb5078506db506
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Fri Apr 3 17:20:20 2009 -0400
various fixes and enhansments to the UI behviour
* tabbed containers now don't get confused when tabs with similar names (e.g. tab and tab_2)
are present
* query strings are now url escaped
* add the ability to clone ConfigWrappers so an app can define them once and use them in
more than one container
* take out some of the FIXME's and TODO's which no longer apply
diff --git a/moksha/api/widgets/containers/tabbedcontainer.py b/moksha/api/widgets/containers/tabbedcontainer.py
index 67d0b39..4615864 100644
--- a/moksha/api/widgets/containers/tabbedcontainer.py
+++ b/moksha/api/widgets/containers/tabbedcontainer.py
@@ -76,6 +76,7 @@ class TabbedContainer(FormField):
# Filter out any None's in the list which signify apps which are
# not allowed to run with the current session's authorization level
tabs = ConfigWrapper.process_wrappers(tabs, d)
+
d['tabs'] = tabs
d['tabwidget'] = tabwidget
d['panewidget'] = panewidget
diff --git a/moksha/api/widgets/containers/templates/tabbedcontainer_tabs.mak b/moksha/api/widgets/containers/templates/tabbedcontainer_tabs.mak
index a31202f..74e2927 100644
--- a/moksha/api/widgets/containers/templates/tabbedcontainer_tabs.mak
+++ b/moksha/api/widgets/containers/templates/tabbedcontainer_tabs.mak
@@ -5,7 +5,7 @@
% for t in tabgroup:
<li>
% if t['type'] == 'Category':
- <H3>${t['label']}</H3>
+ <H4>${t['label']}</H4>
${display_tabs(t['apps'])}
% else:
<a href="${t['url']}${t['query_string']}" title="${t['content_id']}">
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py
index 71ae5b8..fdbb0a5 100644
--- a/moksha/lib/helpers.py
+++ b/moksha/lib/helpers.py
@@ -72,6 +72,16 @@ class ConfigWrapper(object):
super(ConfigWrapper, self).__init__()
self.uuid = 'uuid' + str(uuid.uuid4())
+ def _update_nested_dicts(self, dest, source):
+ """Recursive helper which updates nested dicts"""
+
+ for key, value in source.iteritems():
+ if key in dest:
+ if isinstance(dest[key], dict):
+ self._update_nested_dicts(dest[key], value)
+ else:
+ dest[key] = value
+
@staticmethod
def _validate_predicates(predicates):
if not isinstance(predicates, (list, tuple)):
@@ -223,7 +233,6 @@ class App(ConfigWrapper):
self._validate_predicates(self.auth)
-
if isinstance(css_class, list) or isinstance(css_class, tuple):
css_class = ' '.join(css_class)
self.css_class = css_class
@@ -231,6 +240,25 @@ class App(ConfigWrapper):
if self.label and not self.content_id:
self.content_id = scrub_filter.sub('_', self.label.lower())
+ def clone(self, update_params={}, auth=None, content_id=None):
+ params = {}
+ params.update(self.params)
+
+ self._update_nested_dicts(params, update_params)
+
+ if auth == None:
+ auth = self.auth;
+
+ if content_id == None:
+ content_id == self.content_id
+
+ return App(label=self.label,
+ url=self.url,
+ params=params,
+ auth=auth,
+ content_id=content_id,
+ css_class=self.css_class)
+
def set_default_css(self, css):
""" If we already have css defined ignore, otherwise set our css_class
"""
@@ -240,12 +268,14 @@ class App(ConfigWrapper):
def _create_query_string(self, params):
qlist = []
for k, i in params.iteritems():
- qlist.append("%s=%s" % (k, str(i)))
+ s = str(i)
+ s = urllib.quote_plus(s)
+
+ qlist.append("%s=%s" % (k, s))
result = ""
if qlist:
result = '?' + '&'.join(qlist)
-
return result
def process(self, d=None):
@@ -379,6 +409,24 @@ class Widget(ConfigWrapper):
if self.label and not content_id:
self.content_id = scrub_filter.sub('_', self.label.lower())
+ def clone(self, update_params={}, auth=None, content_id=None):
+ params = {}
+ params.update(self.params)
+ self._update_nested_dicts(params, update_params)
+
+ if auth == None:
+ auth = self.auth;
+
+ if content_id == None:
+ content_id = self.content_id
+
+ return Widget(label=self.label,
+ widget=self.widget,
+ params=params,
+ auth=auth,
+ content_id=content_id,
+ css_class=self.css_class)
+
def set_default_css(self, css):
""" If we already have css defined ignore, otherwise set our css_class
"""
diff --git a/moksha/public/javascript/ui/moksha.ui.grid.js b/moksha/public/javascript/ui/moksha.ui.grid.js
index d38ec9e..156749e 100644
--- a/moksha/public/javascript/ui/moksha.ui.grid.js
+++ b/moksha/public/javascript/ui/moksha.ui.grid.js
@@ -118,14 +118,10 @@
$rows[i].replaceWith('');
//FIXME: We need to relabel rows if this is not the
- // end of the rows and if it is we need to add a
- // blank row
+ // end of the rows
},
get_json: function(path, args, callback) {
- //TODO: implement a json loading method
- // which starts and stops a loading
- // throbber
var self = this;
if (typeof(moksha_csrf_token)!='undefined' && moksha_csrf_token)
diff --git a/moksha/public/javascript/ui/moksha.ui.tabs.js b/moksha/public/javascript/ui/moksha.ui.tabs.js
index 1ffbbac..e6797e4 100644
--- a/moksha/public/javascript/ui/moksha.ui.tabs.js
+++ b/moksha/public/javascript/ui/moksha.ui.tabs.js
@@ -513,8 +513,8 @@ $.widget("ui.mokshatabs", {
var l = id.length;
for(var i=0; i < this.$tabs.length; i++) {
var h = $(this.$tabs[i]).attr('href');
- // FIXME: you can't have two tabs where one is a substring of another
- if (h.substr(0, l) == id) {
+ h = h.split('-uuid')[0]
+ if (h == id) {
index = i;
break;
}