From 2e0198e7cd177ffc833b6d0157c57d47c458554b Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 21 Jan 2022 01:20:32 +0100 Subject: [PATCH] refactor field matching --- .../order/order_wizard/match_fields.html | 99 +------------------ .../part/bom_upload/match_fields.html | 99 +------------------ .../part/import_wizard/match_fields.html | 99 +------------------ .../patterns/wizard/match_fields.html | 98 ++++++++++++++++++ 4 files changed, 101 insertions(+), 294 deletions(-) create mode 100644 InvenTree/templates/patterns/wizard/match_fields.html diff --git a/InvenTree/order/templates/order/order_wizard/match_fields.html b/InvenTree/order/templates/order/order_wizard/match_fields.html index c7a9b02fd2..d4c91efeb3 100644 --- a/InvenTree/order/templates/order/order_wizard/match_fields.html +++ b/InvenTree/order/templates/order/order_wizard/match_fields.html @@ -1,99 +1,2 @@ {% extends "order/order_wizard/po_upload.html" %} -{% load inventree_extras %} -{% load i18n %} -{% load static %} - -{% block form_alert %} -{% if missing_columns and missing_columns|length > 0 %} - -{% endif %} -{% if duplicates and duplicates|length > 0 %} - -{% endif %} -{% endblock form_alert %} - -{% block form_buttons_top %} - {% if wizard.steps.prev %} - - {% endif %} - -{% endblock form_buttons_top %} - -{% block form_content %} - - - {% trans "File Fields" %} - - {% for col in form %} - -
- - {{ col.name }} - -
- - {% endfor %} - - - - - {% trans "Match Fields" %} - - {% for col in form %} - - {{ col }} - {% for duplicate in duplicates %} - {% if duplicate == col.value %} - - {% endif %} - {% endfor %} - - {% endfor %} - - {% for row in rows %} - {% with forloop.counter as row_index %} - - - - - {{ row_index }} - {% for item in row.data %} - - - {{ item }} - - {% endfor %} - - {% endwith %} - {% endfor %} - -{% endblock form_content %} - -{% block form_buttons_bottom %} -{% endblock form_buttons_bottom %} - -{% block js_ready %} -{{ block.super }} - -$('.fieldselect').select2({ - width: '100%', - matcher: partialMatcher, -}); - -{% endblock %} \ No newline at end of file +{% include "patterns/wizard/match_fields.html" %} \ No newline at end of file diff --git a/InvenTree/part/templates/part/bom_upload/match_fields.html b/InvenTree/part/templates/part/bom_upload/match_fields.html index b09260cf46..1336bfc9eb 100644 --- a/InvenTree/part/templates/part/bom_upload/match_fields.html +++ b/InvenTree/part/templates/part/bom_upload/match_fields.html @@ -1,99 +1,2 @@ {% extends "part/bom_upload/upload_file.html" %} -{% load inventree_extras %} -{% load i18n %} -{% load static %} - -{% block form_alert %} -{% if missing_columns and missing_columns|length > 0 %} - -{% endif %} -{% if duplicates and duplicates|length > 0 %} - -{% endif %} -{% endblock form_alert %} - -{% block form_buttons_top %} - {% if wizard.steps.prev %} - - {% endif %} - -{% endblock form_buttons_top %} - -{% block form_content %} - - - {% trans "File Fields" %} - - {% for col in form %} - -
- - {{ col.name }} - -
- - {% endfor %} - - - - - {% trans "Match Fields" %} - - {% for col in form %} - - {{ col }} - {% for duplicate in duplicates %} - {% if duplicate == col.value %} - - {% endif %} - {% endfor %} - - {% endfor %} - - {% for row in rows %} - {% with forloop.counter as row_index %} - - - - - {{ row_index }} - {% for item in row.data %} - - - {{ item }} - - {% endfor %} - - {% endwith %} - {% endfor %} - -{% endblock form_content %} - -{% block form_buttons_bottom %} -{% endblock form_buttons_bottom %} - -{% block js_ready %} -{{ block.super }} - -$('.fieldselect').select2({ - width: '100%', - matcher: partialMatcher, -}); - -{% endblock %} \ No newline at end of file +{% include "patterns/wizard/match_fields.html" %} \ No newline at end of file diff --git a/InvenTree/part/templates/part/import_wizard/match_fields.html b/InvenTree/part/templates/part/import_wizard/match_fields.html index 9c33717772..8bde89a175 100644 --- a/InvenTree/part/templates/part/import_wizard/match_fields.html +++ b/InvenTree/part/templates/part/import_wizard/match_fields.html @@ -1,99 +1,2 @@ {% extends "part/import_wizard/part_upload.html" %} -{% load inventree_extras %} -{% load i18n %} -{% load static %} - -{% block form_alert %} -{% if missing_columns and missing_columns|length > 0 %} - -{% endif %} -{% if duplicates and duplicates|length > 0 %} - -{% endif %} -{% endblock form_alert %} - -{% block form_buttons_top %} - {% if wizard.steps.prev %} - - {% endif %} - -{% endblock form_buttons_top %} - -{% block form_content %} - - - {% trans "File Fields" %} - - {% for col in form %} - -
- - {{ col.name }} - -
- - {% endfor %} - - - - - {% trans "Match Fields" %} - - {% for col in form %} - - {{ col }} - {% for duplicate in duplicates %} - {% if duplicate == col.value %} - - {% endif %} - {% endfor %} - - {% endfor %} - - {% for row in rows %} - {% with forloop.counter as row_index %} - - - - - {{ row_index }} - {% for item in row.data %} - - - {{ item }} - - {% endfor %} - - {% endwith %} - {% endfor %} - -{% endblock form_content %} - -{% block form_buttons_bottom %} -{% endblock form_buttons_bottom %} - -{% block js_ready %} -{{ block.super }} - -$('.fieldselect').select2({ - width: '100%', - matcher: partialMatcher, -}); - -{% endblock %} \ No newline at end of file +{% include "patterns/wizard/match_fields.html" %} \ No newline at end of file diff --git a/InvenTree/templates/patterns/wizard/match_fields.html b/InvenTree/templates/patterns/wizard/match_fields.html new file mode 100644 index 0000000000..bb119d39a5 --- /dev/null +++ b/InvenTree/templates/patterns/wizard/match_fields.html @@ -0,0 +1,98 @@ +{% load inventree_extras %} +{% load i18n %} +{% load static %} + +{% block form_alert %} +{% if missing_columns and missing_columns|length > 0 %} + +{% endif %} +{% if duplicates and duplicates|length > 0 %} + +{% endif %} +{% endblock form_alert %} + +{% block form_buttons_top %} + {% if wizard.steps.prev %} + + {% endif %} + +{% endblock form_buttons_top %} + +{% block form_content %} + + + {% trans "File Fields" %} + + {% for col in form %} + +
+ + {{ col.name }} + +
+ + {% endfor %} + + + + + {% trans "Match Fields" %} + + {% for col in form %} + + {{ col }} + {% for duplicate in duplicates %} + {% if duplicate == col.value %} + + {% endif %} + {% endfor %} + + {% endfor %} + + {% for row in rows %} + {% with forloop.counter as row_index %} + + + + + {{ row_index }} + {% for item in row.data %} + + + {{ item }} + + {% endfor %} + + {% endwith %} + {% endfor %} + +{% endblock form_content %} + +{% block form_buttons_bottom %} +{% endblock form_buttons_bottom %} + +{% block js_ready %} +{{ block.super }} + +$('.fieldselect').select2({ + width: '100%', + matcher: partialMatcher, +}); + +{% endblock %}