diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-01-02 15:33:56 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-01-02 15:33:56 +0100 |
commit | cd6fd329f22241a6a3dd14a14c579bdf1831677d (patch) | |
tree | 6e8ffab7918d9a8519d2c45bb95dea18cdd9bf99 /ishtar_common | |
parent | 535a71c99f4961113821ae60327edc44b01fdf9e (diff) | |
download | Ishtar-cd6fd329f22241a6a3dd14a14c579bdf1831677d.tar.bz2 Ishtar-cd6fd329f22241a6a3dd14a14c579bdf1831677d.zip |
Manage multiple condition for cascading shortcut menu - Manage shortcut menu for treatment and treatment files (refs #3384)
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/models.py | 2 | ||||
-rw-r--r-- | ishtar_common/static/js/ishtar.js | 12 | ||||
-rw-r--r-- | ishtar_common/views.py | 18 |
3 files changed, 28 insertions, 4 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index fcb367ae5..ccb817adc 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -257,7 +257,7 @@ class OwnPerms: if query: q = cls.objects.filter(query) if replace_query: - q = cls.objects.filter(**replace_query) + q = cls.objects.filter(replace_query) if limit: items += list(q.order_by('-pk')[:limit]) else: diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index 8abf23289..b5f4f1a79 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -102,6 +102,18 @@ function init_shortcut_fields(){ load_shortcut_menu ); }); + $("#current_treatment").change(function(){ + $.post('/' + url_path + 'update-current-item/', + {item:'treatment', value:$("#current_treatment").val()}, + load_shortcut_menu + ); + }); + $("#current_treatmentfile").change(function(){ + $.post('/' + url_path + 'update-current-item/', + {item:'treatmentfile', value:$("#current_treatmentfile").val()}, + load_shortcut_menu + ); + }); } function init_advanced_shortcut_fields(){ diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 783c6badb..cf3f968b1 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -264,7 +264,7 @@ def shortcut_menu(request): 'ishtar/blocks/advanced_shortcut_menu.html', dct, context_instance=RequestContext(request)) dct = {'current_menu': []} - current_selected_item = None + current_selected_item = {} for lbl, model in CURRENT_ITEMS: new_selected_item = None model_name = model.SLUG @@ -294,7 +294,8 @@ def shortcut_menu(request): pass if items: dct['current_menu'].append((lbl, model_name, cls, items)) - current_selected_item = new_selected_item + if new_selected_item: + current_selected_item[model_name] = new_selected_item return render_to_response('ishtar/blocks/shortcut_menu.html', dct, context_instance=RequestContext(request)) @@ -317,6 +318,16 @@ def get_current_items(request): def unpin(request, item_type): + if item_type not in ('find', 'contextrecord', 'operation', 'file', + 'treatment', 'treatmentfile'): + logger.warning("unpin unknow type: {}".format(item_type)) + return HttpResponse('nok') + request.session['treatment'] = '' + if item_type == 'treatment': + return HttpResponse('ok') + request.session['treatmentfile'] = '' + if item_type == 'treatmentfile': + return HttpResponse('ok') request.session['find'] = '' if item_type == 'find': return HttpResponse('ok') @@ -327,7 +338,8 @@ def unpin(request, item_type): if item_type == 'operation': return HttpResponse('ok') request.session['file'] = '' - return HttpResponse('ok') + if item_type == 'file': + return HttpResponse('ok') def update_current_item(request, item_type=None, pk=None): |