mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-07 07:48:50 +00:00
Refactor ManufacturerPart pages
This commit is contained in:
parent
52da678636
commit
676cca89a1
330
InvenTree/company/templates/company/manufacturer_part.html
Normal file
330
InvenTree/company/templates/company/manufacturer_part.html
Normal file
@ -0,0 +1,330 @@
|
|||||||
|
{% extends "two_column.html" %}
|
||||||
|
{% load static %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block page_title %}
|
||||||
|
InvenTree | {% trans "Manufacturer Part" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block menubar %}
|
||||||
|
{% include "company/manufacturer_part_navbar.html" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block thumbnail %}
|
||||||
|
<img class='part-thumb'
|
||||||
|
{% if part.part.image %}
|
||||||
|
src='{{ part.part.image.url }}'
|
||||||
|
{% else %}
|
||||||
|
src="{% static 'img/blank_image.png' %}"
|
||||||
|
{% endif %}/>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block page_data %}
|
||||||
|
<h3>{% trans "Manufacturer Part" %}</h3>
|
||||||
|
<hr>
|
||||||
|
<h4>
|
||||||
|
{{ part.part.full_name }}
|
||||||
|
{% if user.is_staff and perms.company.change_company %}
|
||||||
|
<a href="{% url 'admin:company_supplierpart_change' part.pk %}">
|
||||||
|
<span title='{% trans "Admin view" %}' class='fas fa-user-shield'></span>
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</h4>
|
||||||
|
<p>{{ part.manufacturer.name }} - {{ part.MPN }}</p>
|
||||||
|
|
||||||
|
{% if roles.purchase_order.change %}
|
||||||
|
<div class='btn-row'>
|
||||||
|
<div class='btn-group action-buttons' role='group'>
|
||||||
|
{% comment "for later" %}
|
||||||
|
{% if roles.purchase_order.add %}
|
||||||
|
<button type='button' class='btn btn-default btn-glyph' id='order-part' title='{% trans "Order part" %}'>
|
||||||
|
<span class='fas fa-shopping-cart'></span>
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
{% endcomment %}
|
||||||
|
<button type='button' class='btn btn-default btn-glyph' id='edit-part' title='{% trans "Edit manufacturer part" %}'>
|
||||||
|
<span class='fas fa-edit icon-green'/>
|
||||||
|
</button>
|
||||||
|
{% if roles.purchase_order.delete %}
|
||||||
|
<button type='button' class='btn btn-default btn-glyph' id='delete-part' title='{% trans "Delete manufacturer part" %}'>
|
||||||
|
<span class='fas fa-trash-alt icon-red'/>
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block page_details %}
|
||||||
|
|
||||||
|
<h4>{% trans "Manufacturer Part Details" %}</h4>
|
||||||
|
<table class="table table-striped table-condensed">
|
||||||
|
<col width='25'>
|
||||||
|
<tr>
|
||||||
|
<td><span class='fas fa-shapes'></span></td>
|
||||||
|
<td>{% trans "Internal Part" %}</td>
|
||||||
|
<td>
|
||||||
|
{% if part.part %}
|
||||||
|
<a href="{% url 'part-detail' part.part.id %}?display=part-suppliers">{{ part.part.full_name }}</a>{% include "clip.html"%}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% if part.description %}
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>{% trans "Description" %}</td>
|
||||||
|
<td>{{ part.description }}{% include "clip.html"%}</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
{% if part.link %}
|
||||||
|
<tr>
|
||||||
|
<td><span class='fas fa-link'></span></td>
|
||||||
|
<td>{% trans "External Link" %}</td>
|
||||||
|
<td><a href="{{ part.link }}">{{ part.link }}</a>{% include "clip.html"%}</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
<tr>
|
||||||
|
<td><span class='fas fa-industry'></span></td>
|
||||||
|
<td>{% trans "Manufacturer" %}</td>
|
||||||
|
<td><a href="{% url 'company-detail' part.manufacturer.id %}">{{ part.manufacturer.name }}</a>{% include "clip.html"%}</td></tr>
|
||||||
|
<tr>
|
||||||
|
<td><span class='fas fa-hashtag'></span></td>
|
||||||
|
<td>{% trans "MPN" %}</td>
|
||||||
|
<td>{{ part.MPN }}{% include "clip.html"%}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block page_content %}
|
||||||
|
|
||||||
|
<div class='panel panel-default panel-inventree panel-hidden' id='panel-supplier-parts'>
|
||||||
|
<div class='panel-heading'>
|
||||||
|
<h4>{% trans "Suppliers" %}</h4>
|
||||||
|
</div>
|
||||||
|
<div class='panel-content'>
|
||||||
|
<div id='supplier-button-toolbar'>
|
||||||
|
<div class='btn-group'>
|
||||||
|
<button class="btn btn-success" id='supplier-create'>
|
||||||
|
<span class='fas fa-plus-circle'></span> {% trans "New Supplier Part" %}
|
||||||
|
</button>
|
||||||
|
<div id='opt-dropdown' class="btn-group">
|
||||||
|
<button id='supplier-part-options' class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">{% trans "Options" %}<span class="caret"></span></button>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a href='#' id='supplier-part-delete' title='{% trans "Delete supplier parts" %}'>{% trans "Delete" %}</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table class="table table-striped table-condensed" id='supplier-table' data-toolbar='#supplier-button-toolbar'>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class='panel panel-default panel-inventree panel-hidden' id='panel-parameters'>
|
||||||
|
<div class='panel-heading'>
|
||||||
|
<h4>{% trans "Parameters" %}</h4>
|
||||||
|
</div>
|
||||||
|
<div class='panel-content'>
|
||||||
|
<div id='parameter-toolbar'>
|
||||||
|
<div class='btn-group'>
|
||||||
|
<button class='btn btn-success' id='parameter-create'>
|
||||||
|
<span class='fas fa-plus-circle'></span> {% trans "New Parameter" %}
|
||||||
|
</button>
|
||||||
|
<div id='opt-dropdown' class="btn-group">
|
||||||
|
<button id='parameter-options' class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">{% trans "Options" %}<span class="caret"></span></button>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a href='#' id='multi-parameter-delete' title='{% trans "Delete parameters" %}'>{% trans "Delete" %}</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table class='table table-striped table-condensed' id='parameter-table' data-toolbar='#parameter-toolbar'></table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block js_ready %}
|
||||||
|
{{ block.super }}
|
||||||
|
|
||||||
|
enableNavbar({
|
||||||
|
label: 'manufacturer-part',
|
||||||
|
toggleId: '#manufacturer-part-menu-toggle'
|
||||||
|
});
|
||||||
|
|
||||||
|
function reloadParameters() {
|
||||||
|
$("#parameter-table").bootstrapTable("refresh");
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#parameter-create').click(function() {
|
||||||
|
|
||||||
|
constructForm('{% url "api-manufacturer-part-parameter-list" %}', {
|
||||||
|
method: 'POST',
|
||||||
|
fields: {
|
||||||
|
name: {},
|
||||||
|
value: {},
|
||||||
|
units: {},
|
||||||
|
manufacturer_part: {
|
||||||
|
value: {{ part.pk }},
|
||||||
|
hidden: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
title: '{% trans "Add Parameter" %}',
|
||||||
|
onSuccess: reloadParameters
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#supplier-create').click(function () {
|
||||||
|
launchModalForm(
|
||||||
|
"{% url 'supplier-part-create' %}",
|
||||||
|
{
|
||||||
|
reload: true,
|
||||||
|
data: {
|
||||||
|
manufacturer_part: {{ part.id }}
|
||||||
|
},
|
||||||
|
secondary: [
|
||||||
|
{
|
||||||
|
field: 'supplier',
|
||||||
|
label: '{% trans "New Supplier" %}',
|
||||||
|
title: '{% trans "Create new supplier" %}',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#supplier-part-delete").click(function() {
|
||||||
|
|
||||||
|
var selections = $("#supplier-table").bootstrapTable("getSelections");
|
||||||
|
|
||||||
|
var parts = [];
|
||||||
|
|
||||||
|
selections.forEach(function(item) {
|
||||||
|
parts.push(item.pk);
|
||||||
|
});
|
||||||
|
|
||||||
|
launchModalForm("{% url 'supplier-part-delete' %}", {
|
||||||
|
data: {
|
||||||
|
parts: parts,
|
||||||
|
},
|
||||||
|
reload: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#multi-parameter-delete").click(function() {
|
||||||
|
|
||||||
|
var selections = $("#parameter-table").bootstrapTable("getSelections");
|
||||||
|
|
||||||
|
var text = `
|
||||||
|
<div class ='alert alert-block alert-danger'>
|
||||||
|
<p>{% trans "Selected parameters will be deleted" %}:</p>
|
||||||
|
<ul>`;
|
||||||
|
|
||||||
|
selections.forEach(function(item) {
|
||||||
|
text += `<li>${item.name} - <i>${item.value}</i></li>`;
|
||||||
|
});
|
||||||
|
|
||||||
|
text += `
|
||||||
|
</ul>
|
||||||
|
</div>`;
|
||||||
|
|
||||||
|
showQuestionDialog(
|
||||||
|
'{% trans "Delete Parameters" %}',
|
||||||
|
text,
|
||||||
|
{
|
||||||
|
accept_text: '{% trans "Delete" %}',
|
||||||
|
accept: function() {
|
||||||
|
// Delete each parameter via the API
|
||||||
|
var requests = [];
|
||||||
|
|
||||||
|
selections.forEach(function(item) {
|
||||||
|
var url = `/api/company/part/manufacturer/parameter/${item.pk}/`;
|
||||||
|
|
||||||
|
requests.push(inventreeDelete(url));
|
||||||
|
});
|
||||||
|
|
||||||
|
$.when.apply($, requests).then(function() {
|
||||||
|
$('#parameter-table').bootstrapTable('refresh');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
loadSupplierPartTable(
|
||||||
|
"#supplier-table",
|
||||||
|
"{% url 'api-supplier-part-list' %}",
|
||||||
|
{
|
||||||
|
params: {
|
||||||
|
part: {{ part.part.id }},
|
||||||
|
manufacturer_part: {{ part.id }},
|
||||||
|
part_detail: false,
|
||||||
|
supplier_detail: true,
|
||||||
|
manufacturer_detail: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
loadManufacturerPartParameterTable(
|
||||||
|
"#parameter-table",
|
||||||
|
"{% url 'api-manufacturer-part-parameter-list' %}",
|
||||||
|
{
|
||||||
|
params: {
|
||||||
|
manufacturer_part: {{ part.id }},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
linkButtonsToSelection($("#supplier-table"), ['#supplier-part-options']);
|
||||||
|
|
||||||
|
linkButtonsToSelection($("#parameter-table"), ['#parameter-options']);
|
||||||
|
|
||||||
|
$('#order-part, #order-part2').click(function() {
|
||||||
|
launchModalForm(
|
||||||
|
"{% url 'order-parts' %}",
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
part: {{ part.part.id }},
|
||||||
|
},
|
||||||
|
reload: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#edit-part').click(function () {
|
||||||
|
|
||||||
|
constructForm('{% url "api-manufacturer-part-detail" part.pk %}', {
|
||||||
|
fields: {
|
||||||
|
part: {},
|
||||||
|
manufacturer: {},
|
||||||
|
MPN: {
|
||||||
|
icon: 'fa-hashtag',
|
||||||
|
},
|
||||||
|
description: {},
|
||||||
|
link: {
|
||||||
|
icon: 'fa-link',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
title: '{% trans "Edit Manufacturer Part" %}',
|
||||||
|
reload: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#delete-part').click(function() {
|
||||||
|
|
||||||
|
constructForm('{% url "api-manufacturer-part-detail" part.pk %}', {
|
||||||
|
method: 'DELETE',
|
||||||
|
title: '{% trans "Delete Manufacturer Part" %}',
|
||||||
|
redirect: "{% url 'company-detail' part.manufacturer.id %}",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
attachNavCallbacks({
|
||||||
|
name: 'manufacturerpart',
|
||||||
|
default: 'parameters'
|
||||||
|
});
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -1,143 +0,0 @@
|
|||||||
{% extends "two_column.html" %}
|
|
||||||
{% load static %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block page_title %}
|
|
||||||
InvenTree | {% trans "Manufacturer Part" %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block thumbnail %}
|
|
||||||
<img class='part-thumb'
|
|
||||||
{% if part.part.image %}
|
|
||||||
src='{{ part.part.image.url }}'
|
|
||||||
{% else %}
|
|
||||||
src="{% static 'img/blank_image.png' %}"
|
|
||||||
{% endif %}/>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block page_data %}
|
|
||||||
<h3>{% trans "Manufacturer Part" %}</h3>
|
|
||||||
<hr>
|
|
||||||
<h4>
|
|
||||||
{{ part.part.full_name }}
|
|
||||||
{% if user.is_staff and perms.company.change_company %}
|
|
||||||
<a href="{% url 'admin:company_supplierpart_change' part.pk %}">
|
|
||||||
<span title='{% trans "Admin view" %}' class='fas fa-user-shield'></span>
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
</h4>
|
|
||||||
<p>{{ part.manufacturer.name }} - {{ part.MPN }}</p>
|
|
||||||
|
|
||||||
{% if roles.purchase_order.change %}
|
|
||||||
<div class='btn-row'>
|
|
||||||
<div class='btn-group action-buttons' role='group'>
|
|
||||||
{% comment "for later" %}
|
|
||||||
{% if roles.purchase_order.add %}
|
|
||||||
<button type='button' class='btn btn-default btn-glyph' id='order-part' title='{% trans "Order part" %}'>
|
|
||||||
<span class='fas fa-shopping-cart'></span>
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
|
||||||
{% endcomment %}
|
|
||||||
<button type='button' class='btn btn-default btn-glyph' id='edit-part' title='{% trans "Edit manufacturer part" %}'>
|
|
||||||
<span class='fas fa-edit icon-green'/>
|
|
||||||
</button>
|
|
||||||
{% if roles.purchase_order.delete %}
|
|
||||||
<button type='button' class='btn btn-default btn-glyph' id='delete-part' title='{% trans "Delete manufacturer part" %}'>
|
|
||||||
<span class='fas fa-trash-alt icon-red'/>
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block page_details %}
|
|
||||||
|
|
||||||
<h4>{% trans "Manufacturer Part Details" %}</h4>
|
|
||||||
<table class="table table-striped table-condensed">
|
|
||||||
<col width='25'>
|
|
||||||
<tr>
|
|
||||||
<td><span class='fas fa-shapes'></span></td>
|
|
||||||
<td>{% trans "Internal Part" %}</td>
|
|
||||||
<td>
|
|
||||||
{% if part.part %}
|
|
||||||
<a href="{% url 'part-detail' part.part.id %}?display=part-suppliers">{{ part.part.full_name }}</a>{% include "clip.html"%}
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% if part.description %}
|
|
||||||
<tr>
|
|
||||||
<td></td>
|
|
||||||
<td>{% trans "Description" %}</td>
|
|
||||||
<td>{{ part.description }}{% include "clip.html"%}</td>
|
|
||||||
</tr>
|
|
||||||
{% endif %}
|
|
||||||
{% if part.link %}
|
|
||||||
<tr>
|
|
||||||
<td><span class='fas fa-link'></span></td>
|
|
||||||
<td>{% trans "External Link" %}</td>
|
|
||||||
<td><a href="{{ part.link }}">{{ part.link }}</a>{% include "clip.html"%}</td>
|
|
||||||
</tr>
|
|
||||||
{% endif %}
|
|
||||||
<tr>
|
|
||||||
<td><span class='fas fa-industry'></span></td>
|
|
||||||
<td>{% trans "Manufacturer" %}</td>
|
|
||||||
<td><a href="{% url 'company-detail' part.manufacturer.id %}">{{ part.manufacturer.name }}</a>{% include "clip.html"%}</td></tr>
|
|
||||||
<tr>
|
|
||||||
<td><span class='fas fa-hashtag'></span></td>
|
|
||||||
<td>{% trans "MPN" %}</td>
|
|
||||||
<td>{{ part.MPN }}{% include "clip.html"%}</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block js_ready %}
|
|
||||||
{{ block.super }}
|
|
||||||
|
|
||||||
enableNavbar({
|
|
||||||
label: 'manufacturer-part',
|
|
||||||
toggleId: '#manufacturer-part-menu-toggle'
|
|
||||||
})
|
|
||||||
|
|
||||||
$('#order-part, #order-part2').click(function() {
|
|
||||||
launchModalForm(
|
|
||||||
"{% url 'order-parts' %}",
|
|
||||||
{
|
|
||||||
data: {
|
|
||||||
part: {{ part.part.id }},
|
|
||||||
},
|
|
||||||
reload: true,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#edit-part').click(function () {
|
|
||||||
|
|
||||||
constructForm('{% url "api-manufacturer-part-detail" part.pk %}', {
|
|
||||||
fields: {
|
|
||||||
part: {},
|
|
||||||
manufacturer: {},
|
|
||||||
MPN: {
|
|
||||||
icon: 'fa-hashtag',
|
|
||||||
},
|
|
||||||
description: {},
|
|
||||||
link: {
|
|
||||||
icon: 'fa-link',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
title: '{% trans "Edit Manufacturer Part" %}',
|
|
||||||
reload: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#delete-part').click(function() {
|
|
||||||
|
|
||||||
constructForm('{% url "api-manufacturer-part-detail" part.pk %}', {
|
|
||||||
method: 'DELETE',
|
|
||||||
title: '{% trans "Delete Manufacturer Part" %}',
|
|
||||||
redirect: "{% url 'company-detail' part.manufacturer.id %}",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
{% endblock %}
|
|
@ -1,38 +0,0 @@
|
|||||||
{% extends "company/manufacturer_part_base.html" %}
|
|
||||||
{% load static %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block menubar %}
|
|
||||||
{% include "company/manufacturer_part_navbar.html" with tab='details' %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block heading %}
|
|
||||||
{% trans "Manufacturer Part Details" %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
|
|
||||||
{% block details %}
|
|
||||||
|
|
||||||
<table class="table table-striped table-condensed">
|
|
||||||
<tr>
|
|
||||||
<td>{% trans "Internal Part" %}</td>
|
|
||||||
<td>
|
|
||||||
{% if part.part %}
|
|
||||||
<a href="{% url 'part-detail' part.part.id %}?display=part-manufacturers">{{ part.part.full_name }}</a>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr><td>{% trans "Manufacturer" %}</td><td><a href="{% url 'company-detail' part.manufacturer.id %}?display=supplier-parts">{{ part.manufacturer.name }}</a></td></tr>
|
|
||||||
<tr><td>{% trans "MPN" %}</td><td>{{ part.MPN }}</tr></tr>
|
|
||||||
{% if part.link %}
|
|
||||||
<tr><td>{% trans "External Link" %}</td><td><a href="{{ part.link }}">{{ part.link }}</a></td></tr>
|
|
||||||
{% endif %}
|
|
||||||
</table>
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block js_ready %}
|
|
||||||
{{ block.super }}
|
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
|
@ -8,8 +8,15 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class='list-group-item {% if tab == "suppliers" %}active{% endif %}' title='{% trans "Supplier Parts" %}'>
|
<li class='list-group-item' title='{% trans "Parameters" %}'>
|
||||||
<a href='{% url "manufacturer-part-suppliers" part.id %}'>
|
<a href='#' id='select-parameters' class='nav-toggle'>
|
||||||
|
<span class='fas fa-th-list sidebar-icon'></span>
|
||||||
|
{% trans "Parameters" %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class='list-group-item' title='{% trans "Supplier Parts" %}'>
|
||||||
|
<a href='#' id='select-supplier-parts' class='nav-toggle'>
|
||||||
<span class='fas fa-building sidebar-icon'></span>
|
<span class='fas fa-building sidebar-icon'></span>
|
||||||
{% trans "Suppliers" %}
|
{% trans "Suppliers" %}
|
||||||
</a>
|
</a>
|
||||||
|
@ -1,187 +0,0 @@
|
|||||||
{% extends "company/manufacturer_part_base.html" %}
|
|
||||||
{% load static %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block menubar %}
|
|
||||||
{% include "company/manufacturer_part_navbar.html" with tab='suppliers' %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block heading %}
|
|
||||||
{% trans "Suppliers" %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block details %}
|
|
||||||
<div id='button-toolbar'>
|
|
||||||
<div class='btn-group'>
|
|
||||||
<button class="btn btn-success" id='supplier-create'>
|
|
||||||
<span class='fas fa-plus-circle'></span> {% trans "New Supplier Part" %}
|
|
||||||
</button>
|
|
||||||
<div id='opt-dropdown' class="btn-group">
|
|
||||||
<button id='supplier-part-options' class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">{% trans "Options" %}<span class="caret"></span></button>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li><a href='#' id='supplier-part-delete' title='{% trans "Delete supplier parts" %}'>{% trans "Delete" %}</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<table class="table table-striped table-condensed" id='supplier-table' data-toolbar='#button-toolbar'>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block post_content_panels %}
|
|
||||||
|
|
||||||
<div class='panel panel-default panel-inventree'>
|
|
||||||
<div class='panel-heading'>
|
|
||||||
<h4>{% trans "Parameters" %}</h4>
|
|
||||||
</div>
|
|
||||||
<div class='panel-content'>
|
|
||||||
<div id='parameter-toolbar'>
|
|
||||||
<div class='btn-group'>
|
|
||||||
<button class='btn btn-success' id='parameter-create'>
|
|
||||||
<span class='fas fa-plus-circle'></span> {% trans "New Parameter" %}
|
|
||||||
</button>
|
|
||||||
<div id='opt-dropdown' class="btn-group">
|
|
||||||
<button id='parameter-options' class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">{% trans "Options" %}<span class="caret"></span></button>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li><a href='#' id='multi-parameter-delete' title='{% trans "Delete parameters" %}'>{% trans "Delete" %}</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<table class='table table-striped table-condensed' id='parameter-table' data-toolbar='#parameter-toolbar'></table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block js_ready %}
|
|
||||||
{{ block.super }}
|
|
||||||
|
|
||||||
function reloadParameters() {
|
|
||||||
$("#parameter-table").bootstrapTable("refresh");
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#parameter-create').click(function() {
|
|
||||||
|
|
||||||
constructForm('{% url "api-manufacturer-part-parameter-list" %}', {
|
|
||||||
method: 'POST',
|
|
||||||
fields: {
|
|
||||||
name: {},
|
|
||||||
value: {},
|
|
||||||
units: {},
|
|
||||||
manufacturer_part: {
|
|
||||||
value: {{ part.pk }},
|
|
||||||
hidden: true,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
title: '{% trans "Add Parameter" %}',
|
|
||||||
onSuccess: reloadParameters
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#supplier-create').click(function () {
|
|
||||||
launchModalForm(
|
|
||||||
"{% url 'supplier-part-create' %}",
|
|
||||||
{
|
|
||||||
reload: true,
|
|
||||||
data: {
|
|
||||||
manufacturer_part: {{ part.id }}
|
|
||||||
},
|
|
||||||
secondary: [
|
|
||||||
{
|
|
||||||
field: 'supplier',
|
|
||||||
label: '{% trans "New Supplier" %}',
|
|
||||||
title: '{% trans "Create new supplier" %}',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#supplier-part-delete").click(function() {
|
|
||||||
|
|
||||||
var selections = $("#supplier-table").bootstrapTable("getSelections");
|
|
||||||
|
|
||||||
var parts = [];
|
|
||||||
|
|
||||||
selections.forEach(function(item) {
|
|
||||||
parts.push(item.pk);
|
|
||||||
});
|
|
||||||
|
|
||||||
launchModalForm("{% url 'supplier-part-delete' %}", {
|
|
||||||
data: {
|
|
||||||
parts: parts,
|
|
||||||
},
|
|
||||||
reload: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#multi-parameter-delete").click(function() {
|
|
||||||
|
|
||||||
var selections = $("#parameter-table").bootstrapTable("getSelections");
|
|
||||||
|
|
||||||
var text = `
|
|
||||||
<div class ='alert alert-block alert-danger'>
|
|
||||||
<p>{% trans "Selected parameters will be deleted" %}:</p>
|
|
||||||
<ul>`;
|
|
||||||
|
|
||||||
selections.forEach(function(item) {
|
|
||||||
text += `<li>${item.name} - <i>${item.value}</i></li>`;
|
|
||||||
});
|
|
||||||
|
|
||||||
text += `
|
|
||||||
</ul>
|
|
||||||
</div>`;
|
|
||||||
|
|
||||||
showQuestionDialog(
|
|
||||||
'{% trans "Delete Parameters" %}',
|
|
||||||
text,
|
|
||||||
{
|
|
||||||
accept_text: '{% trans "Delete" %}',
|
|
||||||
accept: function() {
|
|
||||||
// Delete each parameter via the API
|
|
||||||
var requests = [];
|
|
||||||
|
|
||||||
selections.forEach(function(item) {
|
|
||||||
var url = `/api/company/part/manufacturer/parameter/${item.pk}/`;
|
|
||||||
|
|
||||||
requests.push(inventreeDelete(url));
|
|
||||||
});
|
|
||||||
|
|
||||||
$.when.apply($, requests).then(function() {
|
|
||||||
$('#parameter-table').bootstrapTable('refresh');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
loadSupplierPartTable(
|
|
||||||
"#supplier-table",
|
|
||||||
"{% url 'api-supplier-part-list' %}",
|
|
||||||
{
|
|
||||||
params: {
|
|
||||||
part: {{ part.part.id }},
|
|
||||||
manufacturer_part: {{ part.id }},
|
|
||||||
part_detail: false,
|
|
||||||
supplier_detail: true,
|
|
||||||
manufacturer_detail: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
loadManufacturerPartParameterTable(
|
|
||||||
"#parameter-table",
|
|
||||||
"{% url 'api-manufacturer-part-parameter-list' %}",
|
|
||||||
{
|
|
||||||
params: {
|
|
||||||
manufacturer_part: {{ part.id }},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
linkButtonsToSelection($("#supplier-table"), ['#supplier-part-options'])
|
|
||||||
linkButtonsToSelection($("#parameter-table"), ['#parameter-options'])
|
|
||||||
{% endblock %}
|
|
@ -31,8 +31,7 @@ company_urls = [
|
|||||||
manufacturer_part_urls = [
|
manufacturer_part_urls = [
|
||||||
|
|
||||||
url(r'^(?P<pk>\d+)/', include([
|
url(r'^(?P<pk>\d+)/', include([
|
||||||
url(r'^suppliers/', views.ManufacturerPartDetail.as_view(template_name='company/manufacturer_part_suppliers.html'), name='manufacturer-part-suppliers'),
|
url('^.*$', views.ManufacturerPartDetail.as_view(template_name='company/manufacturer_part.html'), name='manufacturer-part-detail'),
|
||||||
url('^.*$', views.ManufacturerPartDetail.as_view(template_name='company/manufacturer_part_suppliers.html'), name='manufacturer-part-detail'),
|
|
||||||
])),
|
])),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user