2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-30 12:36:45 +00:00

refactor for better readabilty

This commit is contained in:
Matthias 2021-06-25 07:40:01 +02:00
parent b99af16bfd
commit 4921cd47f9
2 changed files with 25 additions and 13 deletions

View File

@ -340,7 +340,7 @@
borderWidth: 1 borderWidth: 1
}] }]
} }
var StockPriceChart = loadStockPricingChart(document.getElementById('StockPriceChart'), pricedata) var StockPriceChart = loadStockPricingChart($('#StockPriceChart'), pricedata)
var bom_colors = randomColor({hue: 'green', count: {{ bom_parts|length }} }) var bom_colors = randomColor({hue: 'green', count: {{ bom_parts|length }} })
var bomdata = { var bomdata = {
labels: [{% for line in bom_parts %}'{{ line.name }}',{% endfor %}], labels: [{% for line in bom_parts %}'{{ line.name }}',{% endfor %}],
@ -369,12 +369,14 @@
{% if show_internal_price and roles.sales_order.view %} {% if show_internal_price and roles.sales_order.view %}
initPriceBreakSet( initPriceBreakSet(
$('#internal-price-break-table'), $('#internal-price-break-table'),
{{part.id}}, {
'internal price break', part_id: {{part.id}},
'internal-price', pb_human_name: 'internal price break',
"{% url 'api-part-internal-price-list' %}", pb_url_slug: 'internal-price',
$('#new-internal-price-break'), pb_url: '{% url 'api-part-internal-price-list' %}',
'{% url 'internal-price-break-create' %}' pb_new_btn: $('#new-internal-price-break'),
pb_new_url: '{% url 'internal-price-break-create' %}',
},
); );
{% endif %} {% endif %}
@ -393,12 +395,14 @@
{% if part.salable and roles.sales_order.view %} {% if part.salable and roles.sales_order.view %}
initPriceBreakSet( initPriceBreakSet(
$('#price-break-table'), $('#price-break-table'),
{{part.id}}, {
'sale price break', part_id: {{part.id}},
'sale-price', pb_human_name: 'sale price break',
"{% url 'api-part-sale-price-list' %}", pb_url_slug: 'sale-price',
$('#new-price-break'), pb_url: "{% url 'api-part-sale-price-list' %}",
'{% url 'sale-price-break-create' %}' pb_new_btn: $('#new-price-break'),
pb_new_url: '{% url 'sale-price-break-create' %}',
},
); );
{% endif %} {% endif %}

View File

@ -817,6 +817,14 @@ function loadPriceBreakTable(table, options) {
}); });
} }
function initPriceBreakSet(table, options) {
var part_id = options.part_id;
var pb_human_name = options.pb_human_name;
var pb_url_slug = options.pb_url_slug;
var pb_url = options.pb_url;
var pb_new_btn = options.pb_new_btn;
var pb_new_url = options.pb_new_url;
function initPriceBreakSet(table, part_id, pb_human_name, pb_url_slug, pb_url, pb_new_btn, pb_new_url) { function initPriceBreakSet(table, part_id, pb_human_name, pb_url_slug, pb_url, pb_new_btn, pb_new_url) {