mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Simplify display of possible conflicting parts
- Round to single digit
- Only show 5 closest matches
(cherry picked from commit ed8be5225d
)
This commit is contained in:
parent
6dc5ef0cdc
commit
60a8ef723b
@ -467,6 +467,9 @@ function openModal(options) {
|
||||
|
||||
var modal = options.modal || '#modal-form';
|
||||
|
||||
// Ensure that the 'warning' div is hidden
|
||||
$(modal).find('#form-validation-warning').css('display', 'none');
|
||||
|
||||
$(modal).on('shown.bs.modal', function() {
|
||||
$(modal + ' .modal-form-content').scrollTop(0);
|
||||
if (options.focus) {
|
||||
|
@ -245,7 +245,7 @@ def match_part_names(match, threshold=80, reverse=True, compare_length=False):
|
||||
if ratio >= threshold:
|
||||
matches.append({
|
||||
'part': part,
|
||||
'ratio': ratio
|
||||
'ratio': round(ratio, 1)
|
||||
})
|
||||
|
||||
matches = sorted(matches, key=lambda item: item['ratio'], reverse=reverse)
|
||||
|
@ -1,19 +1,23 @@
|
||||
{% extends "modal_form.html" %}
|
||||
{% load inventree_extras %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block pre_form_content %}
|
||||
|
||||
{{ block.super }}
|
||||
|
||||
{% if matches %}
|
||||
<b>Possible Matching Parts</b>
|
||||
<p>The new part may be a duplicate of these existing parts:</p>
|
||||
<div class='alert alert-block alert-warning'>
|
||||
<b>{% trans "Possible Matching Parts" %}</b>
|
||||
<p>{% trans "The new part may be a duplicate of these existing parts" %}:</p>
|
||||
<ul class='list-group'>
|
||||
{% for match in matches %}
|
||||
<li class='list-group-item list-group-item-condensed'>
|
||||
{{ match.part.full_name }} - <i>{{ match.part.description }}</i> ({{ match.ratio }}%)
|
||||
{{ match.part.full_name }} - <i>{{ match.part.description }}</i> ({% decimal match.ratio %}% {% trans "match" %})
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
@ -436,7 +436,8 @@ class PartDuplicate(AjaxCreateView):
|
||||
matches = match_part_names(name)
|
||||
|
||||
if len(matches) > 0:
|
||||
context['matches'] = matches
|
||||
# Display the first five closest matches
|
||||
context['matches'] = matches[:5]
|
||||
|
||||
# Enforce display of the checkbox
|
||||
form.fields['confirm_creation'].widget = CheckboxInput()
|
||||
|
Loading…
Reference in New Issue
Block a user