summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ishtar/furnitures/forms.py2
-rw-r--r--ishtar/furnitures/views.py19
-rw-r--r--ishtar/furnitures/widgets.py19
-rw-r--r--static/media/style.css4
4 files changed, 33 insertions, 11 deletions
diff --git a/ishtar/furnitures/forms.py b/ishtar/furnitures/forms.py
index 2725815b4..a7f31999e 100644
--- a/ishtar/furnitures/forms.py
+++ b/ishtar/furnitures/forms.py
@@ -1079,7 +1079,7 @@ class OperationFormSelection(forms.Form):
form_label = _("Operation")
associated_models = {'pk':models.Operation}
currents = {'pk':models.Operation}
- pk = forms.IntegerField(label=_("Operation"), required=False,
+ pk = forms.IntegerField(label="", required=False,
widget=widgets.JQueryJqGrid(reverse_lazy('json-operation'),
OperationSelect(), ['operation_type', 'year']),
validators=[models.valid_id(models.Operation)])
diff --git a/ishtar/furnitures/views.py b/ishtar/furnitures/views.py
index 811618449..b266bed63 100644
--- a/ishtar/furnitures/views.py
+++ b/ishtar/furnitures/views.py
@@ -157,7 +157,14 @@ def json_operation(request, non_closed=True):
continue
dct[request_keys[k]] = q
if not dct:
- return HttpResponse(mimetype='text/plain')
+ if 'json_operation' in request.session:
+ dct = request.session['json_operation']
+ elif 'operation' in request.session:
+ dct = {"pk":request.session['operation']}
+ if not dct:
+ return HttpResponse(mimetype='text/plain')
+ else:
+ request.session['json_operation'] = dct
query = Q(**dct)
operations = models.Operation.objects.filter(query)
q = request.GET.get('sidx')
@@ -166,9 +173,13 @@ def json_operation(request, non_closed=True):
if k.endswith("__pk"):
k = k[:-len("__pk")] + "__label"
q = request.GET.get('sord')
- if q and q == u'desc':
- k = "-" + k
- operations.order_by(k)
+ sign = q and q == u'desc' and "-" or ''
+ if k == "name":
+ k = "operation_code"
+ operations = operations.order_by(sign + 'year').order_by(
+ sign + 'operation_code')
+ else:
+ operations = operations.order_by(sign + k)
data = json.dumps({
"records":len(operations),
"rows":[{"id":unicode(operation.pk),
diff --git a/ishtar/furnitures/widgets.py b/ishtar/furnitures/widgets.py
index b1d49f660..af22c7b3e 100644
--- a/ishtar/furnitures/widgets.py
+++ b/ishtar/furnitures/widgets.py
@@ -148,7 +148,8 @@ class JQueryJqGrid(forms.RadioSelect):
rendered += """
</table>
<button id='search_%s' class='submit'>%s</button>
-""" % (name, unicode(_("Search")))
+<h4>%s</h4>
+""" % (name, unicode(_("Search")), unicode(_("Search and select an item")))
extra_cols = []
col_names, col_idx = [], []
for k in self.form.fields:
@@ -160,8 +161,9 @@ class JQueryJqGrid(forms.RadioSelect):
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 ""
- rendered += """<table id="grid_%s"></table>
-<input type="hidden" id="hidden_%s" name="%s">""" % (name, name, name)
+ rendered += """<table id="grid_%s" class='jqgrid'></table>
+<div id="pager_%s"></div>
+<input type="hidden" id="hidden_%s" name="%s">""" % (name, name, name, name)
rendered += """
<script type="text/javascript">
var query_vars = new Array(%(col_idx)s);
@@ -188,6 +190,7 @@ jQuery("#search_%(name)s").click(function (){
mygrid.trigger("reloadGrid");
return false;
});
+
jQuery("#grid_%(name)s").jqGrid({
url:'%(source)s',
datatype: "json",
@@ -197,17 +200,21 @@ jQuery("#grid_%(name)s").jqGrid({
{name:'id', index:'id', hidden:true},
{name:'value', index:'value'}%(extra_cols)s
],
- jsonReader : {
- },
sortname: 'value',
viewrecords: true,
sortorder: "asc",
+ emptyrecords: "%(no_result)s",
+ loadtext: "%(loading)s",
+ pager: '#pager_%(name)s',
+ pgbuttons: false,
+ pginput: false,
width:500
});
});
</script>
""" % {'name':name, 'col_names':col_names, 'extra_cols':extra_cols,
'name_label':unicode(_("Name")), 'source':unicode(self.source),
- 'col_idx':col_idx}
+ 'col_idx':col_idx, 'no_result':unicode(_("No results")),
+ 'loading':unicode(_("Loading..."))}
return rendered
diff --git a/static/media/style.css b/static/media/style.css
index b9cfc18f6..25616ac69 100644
--- a/static/media/style.css
+++ b/static/media/style.css
@@ -224,3 +224,7 @@ div.form .errorlist{
table.confirm tr.spacer td:last-child{
border-bottom:1px solid #922;
}
+
+.jqgrid{
+ cursor:pointer;
+}