From 154069d34ae1c16f0e79bf968eb7881d02b6fa46 Mon Sep 17 00:00:00 2001 From: susanodd Date: Tue, 2 Jul 2024 13:59:26 +0200 Subject: [PATCH] #1268: Show gloss field values in similar glosses buttons. --- media/js/glosses_toggle_edit.js | 25 +++++++++++++++++++ .../dictionary/admin_batch_edit_view.html | 13 ++++++---- .../dictionary/templatetags/field_choice.py | 9 +++++++ 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/media/js/glosses_toggle_edit.js b/media/js/glosses_toggle_edit.js index 9526c58a4..7dc49ef9a 100644 --- a/media/js/glosses_toggle_edit.js +++ b/media/js/glosses_toggle_edit.js @@ -75,6 +75,11 @@ function toggle_handedness(data) { $(hCell).empty(); var cell = ""+handedness+""; hCell.html(cell); + + var button_lookup = '#button_' + glossid + '_handedness'; + var buttonCell = $(button_lookup); + var button_contents = similar_gloss_fields_labels['handedness'] + ': ' + handedness; + buttonCell.attr('value', button_contents); } function toggle_domhndsh(data) { @@ -87,6 +92,11 @@ function toggle_domhndsh(data) { $(hCell).empty(); var cell = ""+domhndsh+""; hCell.html(cell); + + var button_lookup = '#button_' + glossid + '_domhndsh'; + var buttonCell = $(button_lookup); + var button_contents = similar_gloss_fields_labels['domhndsh'] + ': ' + domhndsh; + buttonCell.attr('value', button_contents); } function toggle_subhndsh(data) { @@ -99,6 +109,11 @@ function toggle_subhndsh(data) { $(hCell).empty(); var cell = ""+subhndsh+""; hCell.html(cell); + + var button_lookup = '#button_' + glossid + '_subhndsh'; + var buttonCell = $(button_lookup); + var button_contents = similar_gloss_fields_labels['subhndsh'] + ': ' + subhndsh; + buttonCell.attr('value', button_contents); } function toggle_locprim(data) { @@ -111,6 +126,11 @@ function toggle_locprim(data) { $(hCell).empty(); var cell = ""+locprim+""; hCell.html(cell); + + var button_lookup = '#button_' + glossid + '_locprim'; + var buttonCell = $(button_lookup); + var button_contents = similar_gloss_fields_labels['locprim'] + ': ' + locprim; + buttonCell.attr('value', button_contents); } function toggle_movSh(data) { @@ -123,6 +143,11 @@ function toggle_movSh(data) { $(hCell).empty(); var cell = ""+movSh+""; hCell.html(cell); + + var button_lookup = '#button_' + glossid + '_movSh'; + var buttonCell = $(button_lookup); + var button_contents = similar_gloss_fields_labels['movSh'] + ': ' + movSh; + buttonCell.attr('value', button_contents); } function toggle_create_sense(data) { diff --git a/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html b/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html index 6b5975b91..f6042785e 100644 --- a/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html +++ b/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html @@ -25,6 +25,7 @@ var query_parameters_dict = {{query_parameters|safe}}; var language_2chars = {{language_2chars|safe}}; var similar_gloss_fields = {{similar_gloss_fields|safe}}; +var similar_gloss_fields_labels = {{similar_gloss_fields_labels|safe}}; var number_of_matches_found = '{% trans "Number of Similar Videos" %}'; @@ -657,13 +658,15 @@

{% trans "On initial view, the most recent query results are shown." %}

@@ -672,8 +675,8 @@

{% trans "On initial view, the most recent query results are shown." %}

diff --git a/signbank/dictionary/templatetags/field_choice.py b/signbank/dictionary/templatetags/field_choice.py index df1083740..2ad0fd56c 100644 --- a/signbank/dictionary/templatetags/field_choice.py +++ b/signbank/dictionary/templatetags/field_choice.py @@ -34,3 +34,12 @@ def normalise_empty(machine_value): def translated_frequency_list(dataset): generated_dict = dataset.generate_frequency_dict() return generated_dict + + +@register.filter +def get_gloss_field(gloss, field): + field_value = getattr(gloss, field) + if field_value: + return field_value.name + else: + return '-'
+ {% load field_choice %} {% for fieldname, label in similar_gloss_fields_labels.items %} - + {% with gloss|get_gloss_field:fieldname as fieldvalue %} + value="{{label}}: {{fieldvalue}}"> + {% endwith %} {% endfor %}