diff options
-rw-r--r-- | ishtar_common/static/js/ishtar.js | 3 | ||||
-rw-r--r-- | ishtar_common/static/media/style.css | 13 | ||||
-rw-r--r-- | ishtar_common/templates/blocks/JQueryJqGrid.html | 28 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/sheet.html | 30 | ||||
-rw-r--r-- | ishtar_common/views.py | 3 | ||||
-rw-r--r-- | ishtar_common/widgets.py | 6 |
6 files changed, 75 insertions, 8 deletions
diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index caa28089c..c26c8a7d9 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -56,7 +56,7 @@ $(".help_display").live("click", function(){ var last_window; -function load_window(url, speed){ +function load_window(url, speed, on_success){ $.ajax({ url: url, cache: false, @@ -64,6 +64,7 @@ function load_window(url, speed){ $("#window").append(html); $("#"+last_window).show(); $("a[rel^='prettyPhoto']").prettyPhoto({'social_tools':''}); + if (on_success) on_success(); }, error:function(XMLHttpRequest, textStatus, errorThrows){ } diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css index a957e0794..f622fcb0d 100644 --- a/ishtar_common/static/media/style.css +++ b/ishtar_common/static/media/style.css @@ -372,6 +372,19 @@ table.confirm tr.spacer td:last-child{ border-radius:8px; } +.previous_page, .next_page{ + position:absolute; + top:1px; +} + +.previous_page{ + left:135px; +} + +.next_page{ + right:135px; +} + .dashboard > div, .dashboard h3{ width:760px; diff --git a/ishtar_common/templates/blocks/JQueryJqGrid.html b/ishtar_common/templates/blocks/JQueryJqGrid.html index 26855f4ea..d21fa8276 100644 --- a/ishtar_common/templates/blocks/JQueryJqGrid.html +++ b/ishtar_common/templates/blocks/JQueryJqGrid.html @@ -29,7 +29,8 @@ <input type="hidden" id="hidden_{{name}}" name="{{name}}"/> -<script type="text/javascript"> +<script type="text/javascript" language='javascript'> + var query_vars = new Array({{col_idx|safe}}); var selItems_{{sname}} = new Array(); jQuery(document).ready(function(){ @@ -118,6 +119,31 @@ jQuery(document).ready(function(){ return true; }); {% endif %} + }); + + function get_next_table_id(c_id){ + var mygrid = jQuery("#grid_{{name}}"); + var has_current_id = false; + ids = mygrid.getDataIDs(); + for (idx in ids){ + if (has_current_id) return ids[idx]; + if (ids[idx] == c_id) has_current_id = true; + } + return false; + } + function get_previous_table_id(c_id){ + var mygrid = jQuery("#grid_{{name}}"); + var previous_id = 0; + ids = mygrid.getDataIDs(); + for (idx in ids){ + if (ids[idx] == c_id){ + if (previous_id) return previous_id; + return false; + } + previous_id = ids[idx]; + } + return false; + } </script> diff --git a/ishtar_common/templates/ishtar/sheet.html b/ishtar_common/templates/ishtar/sheet.html index 9ce038ae9..915376938 100644 --- a/ishtar_common/templates/ishtar/sheet.html +++ b/ishtar_common/templates/ishtar/sheet.html @@ -15,11 +15,35 @@ <div class="sheet" id='{{window_id}}'> {% block head_sheet %} <script type="text/javascript">var last_window='{{window_id}}';</script> + <div class="head"> + +<a href='#' class='previous_page ui-icon ui-icon-circle-arrow-w'>{% trans "Previous" %}</a> <a href='#' onclick='$("#{{window_id}}").hide("slow")'>{% trans "Close" %}</a> - -<a href='#' onclick='closeAllWindows();'> -{% trans "Close all windows" %} -</a></div>{% endblock %} +<a href='#' onclick='closeAllWindows();'>{% trans "Close all windows" %}</a> +<a href='#' class='next_page ui-icon ui-icon-circle-arrow-e'>{% trans "Next" %}</a> + +</div> + +<script type="text/javascript" language='javascript'> +jQuery(document).ready(function(){ + if (! get_next_table_id({{item.pk}})){ + jQuery('.next_page').hide(); + } + if (! get_previous_table_id({{item.pk}})){ + jQuery('.previous_page').hide(); + } + jQuery(".next_page").click(function() { + load_window("{{current_window_url}}" + get_next_table_id({{item.pk}}) + "/", + '', function(){$("#{{window_id}}").hide();}); + }); + jQuery(".previous_page").click(function() { + load_window("{{current_window_url}}" + get_previous_table_id({{item.pk}}) + "/", + '', function(){$("#{{window_id}}").hide();}); + }); +}); +</script> +{% endblock %} <div class="body"> {% block content %}{% endblock %} </div> diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 2278cf47a..3ebb20569 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -371,6 +371,9 @@ def show_item(model, name): except ObjectDoesNotExist: return HttpResponse(None) doc_type = 'type' in dct and dct.pop('type') + url_name = u"/".join(reverse('show-'+name, args=['0', ''] + ).split('/')[:-2]) + u"/" + dct['current_window_url'] = url_name date = 'date' in dct and dct.pop('date') dct['window_id'] = "%s-%d-%s" % (name, item.pk, datetime.datetime.now().strftime('%M%s')) diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index e94353ec7..c10bc7d34 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -238,9 +238,9 @@ class JQueryJqGrid(forms.RadioSelect): continue
col_names.append(u'"%s"' % field_verbose_name)
extra_cols.append(self.COL_TPL % {'idx':field_name})
- col_names = col_names and ",\n".join(col_names) or ""
- col_idx = col_idx and ",\n".join(col_idx) or ""
- extra_cols = extra_cols and ",\n".join(extra_cols) or ""
+ col_names = col_names and ", ".join(col_names) or ""
+ col_idx = col_idx and ", ".join(col_idx) or ""
+ extra_cols = extra_cols and ", ".join(extra_cols) or ""
dct['encoding'] = settings.ENCODING or 'utf-8'
dct['source'] = unicode(self.source)
if unicode(self.source_full) and unicode(self.source_full) != 'None':
|