From 60a8ef723b80b8ceb83fb0271f44d9bbb1fec10f Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 28 Oct 2020 23:48:35 +1100 Subject: [PATCH 1/6] Simplify display of possible conflicting parts - Round to single digit - Only show 5 closest matches (cherry picked from commit ed8be5225d85cebc231193da2806cac7845fb884) --- .../static/script/inventree/modals.js | 3 +++ InvenTree/part/models.py | 2 +- .../part/templates/part/create_part.html | 20 +++++++++++-------- InvenTree/part/views.py | 3 ++- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/modals.js b/InvenTree/InvenTree/static/script/inventree/modals.js index 49de96468f..e620489ee2 100644 --- a/InvenTree/InvenTree/static/script/inventree/modals.js +++ b/InvenTree/InvenTree/static/script/inventree/modals.js @@ -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) { diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 25d53c7496..2d654de129 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -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) diff --git a/InvenTree/part/templates/part/create_part.html b/InvenTree/part/templates/part/create_part.html index 4f1fcfb03a..d0e322d887 100644 --- a/InvenTree/part/templates/part/create_part.html +++ b/InvenTree/part/templates/part/create_part.html @@ -1,19 +1,23 @@ {% extends "modal_form.html" %} +{% load inventree_extras %} +{% load i18n %} {% block pre_form_content %} {{ block.super }} {% if matches %} -Possible Matching Parts -

The new part may be a duplicate of these existing parts:

-