diff --git a/entries/static/entries/js/entries.js b/entries/static/entries/js/entries.js index 417618aebb387294bb24c4f81ac925f458d845e2..8a4f4db47c34349ad08dc7fe2e3cb1913f3f2a07 100644 --- a/entries/static/entries/js/entries.js +++ b/entries/static/entries/js/entries.js @@ -2,6 +2,7 @@ //TODO clear those to null on new entry to make sure var curr_entry = null; +var curr_no_filters = null; var curr_alternations = null; var curr_realisation_phrases = null; var curr_realisation_descriptions = null; @@ -798,6 +799,7 @@ function get_entry(entry_id, related) { timeout : 60000, success : function(response) { curr_entry = entry_id; + curr_no_filters = related; clear_info(); curr_alternations = response.alternations; curr_realisation_phrases = response.realisation_phrases; @@ -843,7 +845,8 @@ function bind_last_visited() { var selected_entry = $(this).data('entry'); if (selected_entry !== curr_entry) { $('.entry[data-entry="' + curr_entry + '"]').removeClass('table-primary'); - get_entry(selected_entry); + // TODO? don’t apply current filters to last visited + get_entry(selected_entry, true); } }); } @@ -1000,6 +1003,13 @@ function clear_results() { } function clear_entry() { + curr_entry = null; + curr_no_filters = null; + curr_alternations = null; + curr_realisation_phrases = null; + curr_realisation_descriptions = null; + curr_examples = null; + curr_examples_by_id = null; $('#syntax-schemata').empty(); $('#syntax-examples-list').empty(); $('#syntax-examples').hide(); @@ -1097,11 +1107,11 @@ $(document).ready(function() { initialize_entries_list(); $('#id_filter_schema_').change(function() { - get_entry(curr_entry); + get_entry(curr_entry, curr_no_filters); }); $('#id_filter_frame_').change(function() { - get_entry(curr_entry); + get_entry(curr_entry, curr_no_filters); }); initialize_main_form(); diff --git a/entries/static/entries/js/forms.js b/entries/static/entries/js/forms.js index 76fd651389c67383e206cbea6ea70ccc8979045f..81b8a7e49821e0de7dd26a8956a1ae25dc2b8e94 100644 --- a/entries/static/entries/js/forms.js +++ b/entries/static/entries/js/forms.js @@ -476,7 +476,7 @@ function initialize_local_form(selector, url) { if (response.errors) { show_form_errors(form, response.errors); } else if (response.success) { - get_entry(curr_entry); + get_entry(curr_entry, curr_no_filters); selector.modal('hide'); } submit.prop('disabled', false); diff --git a/entries/views.py b/entries/views.py index 18875ca688c1c81353c3e432adced1141ec3b292..fa20fa6e88807248aa3b06a9514ce1a135e10c6a 100644 --- a/entries/views.py +++ b/entries/views.py @@ -684,9 +684,9 @@ def get_entry(request): assert(not errors_dict) # dont’ do schema/frame filtering for related entries - FILTERING_OK = not simplejson.loads(request.POST['no_filters']) - filter_schemata = FILTERING_OK and entry_form.cleaned_data['filter_schemata'] - filter_frames = FILTERING_OK and entry_form.cleaned_data['filter_frames'] + apply_filters = not simplejson.loads(request.POST['no_filters']) + filter_schemata = apply_filters and entry_form.cleaned_data['filter_schemata'] + filter_frames = apply_filters and entry_form.cleaned_data['filter_frames'] if filter_schemata: schema_forms = [] # e.g. entry has schema that satisfies X & entry has schema that satisfies Y @@ -727,14 +727,14 @@ def get_entry(request): local_schema_form = None - if FILTERING_OK and 'schema_form' in request.session: + if apply_filters and 'schema_form' in request.session: errors_dict = dict() local_schema_form = collect_forms(request.session['schema_form'], errors_dict) print(local_schema_form) assert(not errors_dict) local_frame_form = None - if FILTERING_OK and 'frame_form' in request.session: + if apply_filters and 'frame_form' in request.session: errors_dict = dict() local_frame_form = collect_forms(request.session['frame_form'], errors_dict) assert(not errors_dict)