Commit 4188ea9f08f05a1dd96051d349800302389ead83
1 parent
1fb05418
wyświetlanie numerów homonimów i poprawka do wybierania homonimu w odsyłaczach
Showing
4 changed files
with
41 additions
and
17 deletions
dictionary/ajax_lexeme_view.py
... | ... | @@ -164,6 +164,7 @@ def lexeme_edit_form(request, id): |
164 | 164 | lip.qualifiers.filter(vocabulary=owner) if ro_owner else []) |
165 | 165 | for lip in lips] |
166 | 166 | to_return['cross_references'] = l.cross_references(request.user) |
167 | + to_return['homonym'] = l.homonym_number | |
167 | 168 | return to_return |
168 | 169 | |
169 | 170 | |
... | ... | @@ -490,14 +491,28 @@ def homonym_count(request, entry, lexeme_id): |
490 | 491 | @ajax(method='get', login_required=True) |
491 | 492 | def cr_homonyms(request, entry, cr_type): |
492 | 493 | cr_type = CrossReferenceType.objects.get(pk=cr_type) |
493 | - lexemes = Lexeme.objects.filter(entry=entry, part_of_speech=cr_type.to_pos) | |
494 | + pos = cr_type.to_pos | |
495 | + lexemes = Lexeme.objects.filter(entry=entry, part_of_speech=pos) | |
496 | + if pos.symbol == 'subst': | |
497 | + labels = (u'Nr hom.', u'Rodzaj', u'Wzór') | |
498 | + make_row = lambda lexeme, lip_data: ( | |
499 | + lexeme.homonym_number, lip_data['genders'], lip_data['patterns']) | |
500 | + elif pos.lexical_class_id == 'v': | |
501 | + labels = (u'Nr hom.', u'Aspekt', u'Wzór') | |
502 | + aspect = LexemeAttribute.objects.get(name=u'aspekt') | |
503 | + make_row = lambda lexeme, lip_data: ( | |
504 | + lexeme.homonym_number, | |
505 | + lexeme.attribute_value(aspect).value | |
506 | + if lexeme.attribute_value(aspect) else '', | |
507 | + lip_data['patterns']) | |
508 | + else: | |
509 | + labels = (u'Nr hom.', u'Wzór') | |
510 | + make_row = lambda lexeme, lip_data: ( | |
511 | + lexeme.homonym_number, lip_data['patterns']) | |
494 | 512 | lexemes_data = [ |
495 | - { | |
496 | - 'homonym_number': l.homonym_number, | |
497 | - 'lip_data': l.lip_data(), | |
498 | - } for l in lexemes.order_by('homonym_number') | |
513 | + make_row(l, l.lip_data()) for l in lexemes.order_by('homonym_number') | |
499 | 514 | ] |
500 | - return {'lexemes': lexemes_data} | |
515 | + return {'labels': labels, 'lexemes': lexemes_data} | |
501 | 516 | |
502 | 517 | |
503 | 518 | @ajax(template='new_action_row.html', method='get', login_required=True) |
... | ... |
dictionary/templates/lexeme_edit_form.html
... | ... | @@ -35,6 +35,7 @@ |
35 | 35 | </p> |
36 | 36 | <p class="main-field"> |
37 | 37 | {{ form.entry.label_tag }} {{ form.entry.as_widget }} |
38 | + {% if homonym %}#{{ homonym }}{% endif %} | |
38 | 39 | </p> |
39 | 40 | <p class="main-field"> |
40 | 41 | {{ form.pronunciation.label_tag }} {{ form.pronunciation.as_widget }} |
... | ... | @@ -132,8 +133,8 @@ |
132 | 133 | <span class="remove ui-icon ui-icon-closethick"></span> |
133 | 134 | {% endif %} |
134 | 135 | <span class="type">{{ cr.type.desc }}</span> |
135 | - <span class="id">{{ cr.to_lexeme.pk }}</span> | |
136 | 136 | <span class="entry">{{ cr.to_lexeme.entry }}</span> |
137 | + <span class="hom">#{{ cr.to_lexeme.homonym_number }}</span> | |
137 | 138 | <span class="gender">{{ cr.to_lexeme.lip_data.genders }}</span> |
138 | 139 | </li> |
139 | 140 | {% endfor %} |
... | ... |
media/css/lexeme_view.css
media/js/lexeme-edit.js
... | ... | @@ -864,22 +864,29 @@ function show_homonym_count() { |
864 | 864 | |
865 | 865 | // odsyłacze |
866 | 866 | |
867 | -function homonym_choice(lexemes, hom_field) { | |
868 | - "use strict"; | |
869 | - var table = $('#homonym-list').find('tbody'); | |
870 | - table.html(''); | |
867 | +function homonym_choice(labels, lexemes, hom_field) { | |
868 | + "use strict"; | |
869 | + var table = $('#homonym-list'); | |
870 | + var thead = table.find('thead'); | |
871 | + var tbody = table.find('tbody'); | |
872 | + thead.html(''); | |
873 | + $.each(labels, function(i, label) { | |
874 | + var item = $('<th/>').text(label); | |
875 | + thead.append(item); | |
876 | + }); | |
877 | + tbody.html(''); | |
871 | 878 | // napakować okienko na podstawie wyniku z ajaxa |
872 | 879 | $.each(lexemes, function (i, data) { |
873 | 880 | var item = $('<tr/>').addClass('ui-state-default') |
874 | 881 | .attr('id', 'hom' + data.homonym_number); |
875 | - item.append($('<td/>').text(data.homonym_number)); | |
876 | - item.append($('<td/>').text(data.lip_data.genders)); | |
877 | - item.append($('<td/>').text(data.lip_data.patterns)); | |
882 | + $.each(data, function(i, data_item) { | |
883 | + item.append($('<td/>').text(data_item)); | |
884 | + }); | |
878 | 885 | item.click(function () { |
879 | 886 | hom_field.val($(this).children().first().text()); |
880 | 887 | $("#choose-homonym-dialog").dialog('close'); |
881 | 888 | }); |
882 | - table.append(item); | |
889 | + tbody.append(item); | |
883 | 890 | }); |
884 | 891 | $("#choose-homonym-dialog").dialog('open'); |
885 | 892 | } |
... | ... | @@ -900,7 +907,8 @@ var set_cr_homonym_number = function () { |
900 | 907 | if (lexemes.length === 1) |
901 | 908 | $t.find('.homonym-number').val(lexemes[0].homonym_number); |
902 | 909 | else if (lexemes.length > 1) { |
903 | - homonym_choice(lexemes, $t.find('.homonym-number')); | |
910 | + homonym_choice( | |
911 | + data.labels, lexemes, $t.find('.homonym-number')); | |
904 | 912 | } else { // nie ma żadnego |
905 | 913 | window.alert('Brak pasujących leksemów.'); |
906 | 914 | $t.find('.entry').val(''); |
... | ... |