mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-20 13:56:30 +00:00
331 lines
11 KiB
HTML
331 lines
11 KiB
HTML
{% extends "part/part_app_base.html" %}
|
|
{% load static %}
|
|
{% load i18n %}
|
|
|
|
{% block menubar %}
|
|
{% include 'part/category_navbar.html' with tab='parts' %}
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
|
|
{% if messages %}
|
|
{% for message in messages %}
|
|
<div class='{{ message.tags }}'>
|
|
{{ message|safe }}
|
|
</div>
|
|
{% endfor %}
|
|
{% endif %}
|
|
|
|
|
|
<div class='panel panel-default panel-inventree'>
|
|
<div class='row'>
|
|
<div class='col-sm-6'>
|
|
{% if category %}
|
|
<h3>
|
|
{{ category.name }}
|
|
{% if user.is_staff and roles.part_category.change %}
|
|
<a href="{% url 'admin:part_partcategory_change' category.pk %}"><span title="{% trans 'Admin view' %}" class='fas fa-user-shield'></span></a>
|
|
{% endif %}
|
|
</h3>
|
|
<p>{{ category.description }}</p>
|
|
{% else %}
|
|
<h3>{% trans "Part Categories" %}</h3>
|
|
<p>{% trans "All parts" %}</p>
|
|
{% endif %}
|
|
<p>
|
|
<div class='btn-group action-buttons'>
|
|
{% if roles.part_category.add %}
|
|
<button class='btn btn-default' id='cat-create' title='{% trans "Create new part category" %}'>
|
|
<span class='fas fa-plus-circle icon-green'/>
|
|
</button>
|
|
{% endif %}
|
|
{% if category %}
|
|
{% if roles.part_category.change %}
|
|
<button class='btn btn-default' id='cat-edit' title='{% trans "Edit part category" %}'>
|
|
<span class='fas fa-edit icon-blue'/>
|
|
</button>
|
|
{% endif %}
|
|
{% if roles.part_category.delete %}
|
|
<button class='btn btn-default' id='cat-delete' title='{% trans "Delete part category" %}'>
|
|
<span class='fas fa-trash-alt icon-red'/>
|
|
</button>
|
|
{% endif %}
|
|
{% endif %}
|
|
</div>
|
|
</p>
|
|
</div>
|
|
<div class='col-sm-6'>
|
|
{% if category %}
|
|
<h3>{% trans "Category Details" %}</h3>
|
|
<table class='table table-condensed table-striped'>
|
|
<col width='25'>
|
|
<tr>
|
|
<td><span class='fas fa-sitemap'></span></td>
|
|
<td>{% trans "Category Path" %}</td>
|
|
<td>{{ category.pathstring }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td><span class='fas fa-info-circle'></span></td>
|
|
<td>{% trans "Category Description" %}</td>
|
|
<td>{{ category.description }}</td>
|
|
</tr>
|
|
{% if category.default_location %}
|
|
<tr>
|
|
<td><span class='fas fa-map-marker-alt'></span></td>
|
|
<td>{% trans "Default Location" %}</td>
|
|
<td><a href="{% url 'stock-location-detail' category.default_location.pk %}">{{ category.default_location.pathstring }}</a></td>
|
|
</tr>
|
|
{% endif %}
|
|
{% if category.default_keywords %}
|
|
<tr>
|
|
<td><span class='fas fa-key'></span></td>
|
|
<td>{% trans "Keywords" %}</td>
|
|
<td>{{ category.default_keywords }}</td>
|
|
</tr>
|
|
{% endif %}
|
|
<tr>
|
|
<td><span class='fas fa-sitemap'></span></td>
|
|
<td>{% trans "Subcategories" %}</td>
|
|
<td>{{ category.children.count }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td><span class='fas fa-shapes'></span></td>
|
|
<td>{% trans "Parts (Including subcategories)" %}</td>
|
|
<td>{{ category.partcount }}</td>
|
|
</tr>
|
|
</table>
|
|
{% else %}
|
|
<h3>{% trans "Category Details" %}</h3>
|
|
<table class='table table-striped table-condensed'>
|
|
<col width='25'>
|
|
<tr>
|
|
<td><span class='fas fa-sitemap'></span></td>
|
|
<td>{% trans "Part Categories" %}</td>
|
|
<td>{{ category_count }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td><span class='fas fa-shapes'></span></td>
|
|
<td>{% trans "Parts" %}</td>
|
|
<td>{{ part_count }}</td>
|
|
</tr>
|
|
</table>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{% block category_content %}
|
|
|
|
<div id='button-toolbar'>
|
|
<div class='btn-group'>
|
|
<button class='btn btn-default' id='part-export' title='{% trans "Export Part Data" %}'>
|
|
<span class='fas fa-file-download'></span> {% trans "Export" %}
|
|
</button>
|
|
{% if roles.part.add %}
|
|
<button class='btn btn-success' id='part-create' title='{% trans "Create new part" %}'>
|
|
<span class='fas fa-plus-circle'></span> {% trans "New Part" %}
|
|
</button>
|
|
{% endif %}
|
|
<div class='btn-group'>
|
|
<button id='part-options' class='btn btn-primary dropdown-toggle' type='button' data-toggle="dropdown">{% trans "Options" %}<span class='caret'></span></button>
|
|
<ul class='dropdown-menu'>
|
|
{% if roles.part.change %}
|
|
<li><a href='#' id='multi-part-category' title='{% trans "Set category" %}'>{% trans "Set Category" %}</a></li>
|
|
{% endif %}
|
|
<li><a href='#' id='multi-part-order' title='{% trans "Order parts" %}'>{% trans "Order Parts" %}</a></li>
|
|
<li><a href='#' id='multi-part-export' title='{% trans "Export" %}'>{% trans "Export Data" %}</a></li>
|
|
</ul>
|
|
</div>
|
|
<!-- Buttons to toggle between grid and table view -->
|
|
<button id='view-list' class='btn btn-default' type='button' title='{% trans "View list display" %}'>
|
|
<span class='fas fa-th-list'></span>
|
|
</button>
|
|
<button id='view-grid' class='btn btn-default' type='button' title='{% trans "View grid display" %}'>
|
|
<span class='fas fa-th'></span>
|
|
</button>
|
|
<div class='filter-list' id='filter-list-parts'>
|
|
<!-- Empty div -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class='panel panel-default panel-inventree'>
|
|
<div class='panel-heading'>
|
|
<h4>
|
|
{% block heading %}
|
|
{% trans "Parts" %}
|
|
{% endblock %}
|
|
</h4>
|
|
</div>
|
|
<div class='panel-content'>
|
|
{% block details %}
|
|
<table class='table table-striped table-condensed' data-toolbar='#button-toolbar' id='part-table'>
|
|
</table>
|
|
{% endblock %}
|
|
</div>
|
|
</div>
|
|
|
|
{% endblock %}
|
|
|
|
|
|
{% block category_tables %}
|
|
{% endblock category_tables %}
|
|
|
|
{% endblock %}
|
|
{% block js_load %}
|
|
{{ block.super }}
|
|
{% endblock %}
|
|
|
|
{% block js_ready %}
|
|
{{ block.super }}
|
|
|
|
enableNavbar({
|
|
label: 'category',
|
|
toggleId: '#category-menu-toggle',
|
|
});
|
|
|
|
$('#view-list').click(function() {
|
|
$('#view-list').hide();
|
|
$('#view-grid').show();
|
|
|
|
$('#part-table').bootstrapTable('toggleCustomView');
|
|
inventreeSave('part-grid-view', '');
|
|
});
|
|
|
|
$('#view-grid').click(function() {
|
|
$('#view-grid').hide();
|
|
$('#view-list').show();
|
|
|
|
$('#part-table').bootstrapTable('toggleCustomView');
|
|
inventreeSave('part-grid-view', 1);
|
|
});
|
|
|
|
$("#cat-create").click(function() {
|
|
launchModalForm(
|
|
"{% url 'category-create' %}",
|
|
{
|
|
follow: true,
|
|
{% if category %}
|
|
data: {
|
|
category: {{ category.id }}
|
|
},
|
|
{% endif %}
|
|
secondary: [
|
|
{
|
|
field: 'default_location',
|
|
label: '{% trans "New Location" %}',
|
|
title: '{% trans "Create new location" %}',
|
|
url: "{% url 'stock-location-create' %}",
|
|
},
|
|
{
|
|
field: 'parent',
|
|
label: '{% trans "New Category" %}',
|
|
title: '{% trans "Create new category" %}',
|
|
url: "{% url 'category-create' %}",
|
|
},
|
|
]
|
|
}
|
|
);
|
|
})
|
|
|
|
$("#part-export").click(function() {
|
|
|
|
var url = "{% url 'part-export' %}?category={{ category.id }}";
|
|
|
|
location.href = url;
|
|
});
|
|
|
|
{% if roles.part.add %}
|
|
$("#part-create").click(function() {
|
|
launchModalForm(
|
|
"{% url 'part-create' %}",
|
|
{
|
|
follow: true,
|
|
data: {
|
|
{% if category %}
|
|
category: {{ category.id }}
|
|
{% endif %}
|
|
},
|
|
secondary: [
|
|
{
|
|
field: 'category',
|
|
label: '{% trans "New Category" %}',
|
|
title: '{% trans "Create new Part Category" %}',
|
|
url: "{% url 'category-create' %}",
|
|
},
|
|
{
|
|
field: 'default_location',
|
|
label: '{% trans "New Location" %}',
|
|
title: '{% trans "Create new Stock Location" %}',
|
|
url: "{% url 'stock-location-create' %}",
|
|
}
|
|
]
|
|
}
|
|
);
|
|
});
|
|
{% endif %}
|
|
|
|
{% if category %}
|
|
$("#cat-edit").click(function () {
|
|
|
|
constructForm(
|
|
'{% url "api-part-category-detail" category.pk %}',
|
|
{
|
|
fields: {
|
|
name: {},
|
|
description: {},
|
|
parent: {
|
|
help_text: '{% trans "Select parent category" %}',
|
|
},
|
|
default_location: {},
|
|
default_keywords: {
|
|
icon: 'fa-key',
|
|
}
|
|
},
|
|
title: '{% trans "Edit Part Category" %}',
|
|
reload: true
|
|
}
|
|
);
|
|
});
|
|
|
|
{% if category.parent %}
|
|
var redirect = "{% url 'category-detail' category.parent.id %}";
|
|
{% else %}
|
|
var redirect = "{% url 'part-index' %}";
|
|
{% endif %}
|
|
|
|
$('#cat-delete').click(function() {
|
|
launchModalForm(
|
|
"{% url 'category-delete' category.id %}",
|
|
{
|
|
redirect: redirect
|
|
}
|
|
);
|
|
});
|
|
|
|
{% endif %}
|
|
|
|
loadPartTable(
|
|
"#part-table",
|
|
"{% url 'api-part-list' %}",
|
|
{
|
|
params: {
|
|
{% if category %}category: {{ category.id }},
|
|
{% else %}category: "null",
|
|
{% endif %}
|
|
},
|
|
buttons: ['#part-options'],
|
|
checkbox: true,
|
|
gridView: true,
|
|
},
|
|
);
|
|
|
|
if (inventreeLoad("part-grid-view")) {
|
|
$('#view-grid').hide();
|
|
$('#part-table').bootstrapTable('toggleCustomView');
|
|
} else {
|
|
$('#view-list').hide();
|
|
}
|
|
|
|
{% endblock %} |