mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Refactor PartCategory views
This commit is contained in:
parent
d5bf108fef
commit
72337dab49
@ -3,7 +3,7 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block menubar %}
|
{% block menubar %}
|
||||||
{% include 'part/category_navbar.html' with tab='parts' %}
|
{% include 'part/category_navbar.html' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
@ -115,9 +115,13 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% block category_content %}
|
{% block page_content %}
|
||||||
|
|
||||||
<div id='button-toolbar'>
|
<div class='panel panel-default panel-inventree panel-hidden' id='panel-parts'>
|
||||||
|
<div class='panel-heading'>
|
||||||
|
<h4>{% trans "Parts" %}</h4>
|
||||||
|
</div>
|
||||||
|
<div id='part-button-toolbar'>
|
||||||
<div class='btn-group'>
|
<div class='btn-group'>
|
||||||
<button class='btn btn-default' id='part-export' title='{% trans "Export Part Data" %}'>
|
<button class='btn btn-default' id='part-export' title='{% trans "Export Part Data" %}'>
|
||||||
<span class='fas fa-file-download'></span> {% trans "Export" %}
|
<span class='fas fa-file-download'></span> {% trans "Export" %}
|
||||||
@ -149,29 +153,43 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class='panel-content'>
|
||||||
|
<table class='table table-striped table-condensed' data-toolbar='#part-button-toolbar' id='part-table'>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class='panel panel-default panel-inventree'>
|
<div class='panel panel-default panel-inventree panel-hidden' id='panel-parameters'>
|
||||||
<div class='panel-heading'>
|
<div class='panel-heading'>
|
||||||
<h4>
|
<h4>{% trans "Part Parameters" %}</h4>
|
||||||
{% block heading %}
|
|
||||||
{% trans "Parts" %}
|
|
||||||
{% endblock %}
|
|
||||||
</h4>
|
|
||||||
</div>
|
</div>
|
||||||
<div class='panel-content'>
|
<div class='panel-content'>
|
||||||
{% block details %}
|
<table class='table table-striped table-condensed' data-toolbar='#param-button-toolbar' id='parametric-part-table'>
|
||||||
<table class='table table-striped table-condensed' data-toolbar='#button-toolbar' id='part-table'>
|
|
||||||
</table>
|
</table>
|
||||||
{% endblock %}
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class='panel panel-default panel-inventree panel-hidden' id='panel-subcategories'>
|
||||||
|
<div class='panel-heading'>
|
||||||
|
<h4>{% trans "Subcategories" %}</h4>
|
||||||
|
</div>
|
||||||
|
<div class='panel-content'>
|
||||||
|
<div id='subcategory-button-toolbar'>
|
||||||
|
<div class='button-toolbar container-fluid' style='float: right;'>
|
||||||
|
|
||||||
|
<div class='filter-list' id='filter-list-category'>
|
||||||
|
<!-- An empty div in which the filter list will be constructed -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table class='table table-striped table-condensed' id='subcategory-table' data-toolbar='#subcategory-button-toolbar'></table>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
{% block category_tables %}
|
|
||||||
{% endblock category_tables %}
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block js_load %}
|
{% block js_load %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
@ -180,6 +198,26 @@
|
|||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
|
||||||
|
loadPartCategoryTable($('#subcategory-table'), {
|
||||||
|
params: {
|
||||||
|
{% if category %}
|
||||||
|
parent: {{ category.pk }}
|
||||||
|
{% else %}
|
||||||
|
parent: 'null'
|
||||||
|
{% endif %}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
{% if category %}
|
||||||
|
loadParametricPartTable(
|
||||||
|
"#parametric-part-table",
|
||||||
|
{
|
||||||
|
headers: {{ headers|safe }},
|
||||||
|
data: {{ parameters|safe }},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
enableNavbar({
|
enableNavbar({
|
||||||
label: 'category',
|
label: 'category',
|
||||||
toggleId: '#category-menu-toggle',
|
toggleId: '#category-menu-toggle',
|
||||||
@ -328,4 +366,9 @@
|
|||||||
$('#view-list').hide();
|
$('#view-list').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
attachNavCallbacks({
|
||||||
|
name: 'partcategory',
|
||||||
|
default: 'part-stock'
|
||||||
|
});
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -11,31 +11,23 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class='list-group-item {% if tab == "subcategories" %}active{% endif %}' title='{% trans "Subcategories" %}'>
|
<li class='list-group-item' title='{% trans "Subcategories" %}'>
|
||||||
{% if category %}
|
<a href='#' id='select-subcategories' class='nav-toggle'>
|
||||||
<a href='{% url "category-subcategory" category.id %}'>
|
|
||||||
{% else %}
|
|
||||||
<a href='{% url "category-index-subcategory" %}'>
|
|
||||||
{% endif %}
|
|
||||||
<span class='fas fa-sitemap sidebar-icon'></span>
|
<span class='fas fa-sitemap sidebar-icon'></span>
|
||||||
{% trans "Subcategories" %}
|
{% trans "Subcategories" %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class='list-group-item {% if tab == "parts" %}active{% endif %}' title='{% trans "Parts" %}'>
|
<li class='list-group-item' title='{% trans "Parts" %}'>
|
||||||
{% if category %}
|
<a href='#' id='select-parts' class='nav-toggle'>
|
||||||
<a href='{% url "category-detail" category.id %}'>
|
|
||||||
{% else %}
|
|
||||||
<a href='{% url "part-index" %}'>
|
|
||||||
{% endif %}
|
|
||||||
<span class='fas fa-shapes sidebar-icon'></span>
|
<span class='fas fa-shapes sidebar-icon'></span>
|
||||||
{% trans "Parts" %}
|
{% trans "Parts" %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
{% if show_import and user.is_staff and roles.part.add %}
|
{% if show_import and user.is_staff and roles.part.add %}
|
||||||
<li class='list-group-item {% if tab == "import" %}active{% endif %}' title='{% trans "Import Parts" %}'>
|
<li class='list-group-item' title='{% trans "Import Parts" %}'>
|
||||||
<a href='{% url "part-import" %}'>
|
<a href='#' id='select-part-import' class='nav-toggle'>
|
||||||
<span class='fas fa-file-upload sidebar-icon'></span>
|
<span class='fas fa-file-upload sidebar-icon'></span>
|
||||||
{% trans "Import Parts" %}
|
{% trans "Import Parts" %}
|
||||||
</a>
|
</a>
|
||||||
@ -43,8 +35,8 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if category %}
|
{% if category %}
|
||||||
<li class='list-group-item {% if tab == "parameters" %}active{% endif %}' title='{% trans "Parameters" %}'>
|
<li class='list-group-item' title='{% trans "Parameters" %}'>
|
||||||
<a href='{% url "category-parametric" category.id %}'>
|
<a href='#' id='select-parameters' class='nav-toggle'>
|
||||||
<span class='fas fa-tasks sidebar-icon'></span>
|
<span class='fas fa-tasks sidebar-icon'></span>
|
||||||
{% trans "Parameters" %}
|
{% trans "Parameters" %}
|
||||||
</a>
|
</a>
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
{% extends "part/category.html" %}
|
|
||||||
{% load static %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block menubar %}
|
|
||||||
{% include 'part/category_navbar.html' with tab='parameters' %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block heading %}
|
|
||||||
{% trans "Part Parameters" %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block details %}
|
|
||||||
|
|
||||||
<table class='table table-striped table-condensed' data-toolbar='#button-toolbar' id='parametric-part-table'>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block js_ready %}
|
|
||||||
{{ block.super }}
|
|
||||||
|
|
||||||
/* Hide Button Toolbar */
|
|
||||||
window.onload = function hideButtonToolbar() {
|
|
||||||
var toolbar = document.getElementById("button-toolbar");
|
|
||||||
toolbar.style.display = "none";
|
|
||||||
};
|
|
||||||
|
|
||||||
loadParametricPartTable(
|
|
||||||
"#parametric-part-table",
|
|
||||||
{
|
|
||||||
headers: {{ headers|safe }},
|
|
||||||
data: {{ parameters|safe }},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
{% endblock %}
|
|
@ -1,16 +0,0 @@
|
|||||||
{% extends "part/category.html" %}
|
|
||||||
{% load static %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block menubar %}
|
|
||||||
{% include 'part/category_navbar.html' with tab='parts' %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block heading %}
|
|
||||||
{% trans "Parts" %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block details %}
|
|
||||||
<table class='table table-striped table-condensed' data-toolbar='#button-toolbar' id='part-table'>
|
|
||||||
</table>
|
|
||||||
{% endblock %}
|
|
@ -3,7 +3,6 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load markdownify %}
|
{% load markdownify %}
|
||||||
|
|
||||||
|
|
||||||
{% block menubar %}
|
{% block menubar %}
|
||||||
{% include 'part/navbar.html' %}
|
{% include 'part/navbar.html' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@ -116,6 +115,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class='panel panel-default panel-inventree panel-hidden' id='panel-pricing'>
|
||||||
|
<!-- TODO -->
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class='panel panel-default panel-inventree panel-hidden' id='panel-variants'>
|
<div class='panel panel-default panel-inventree panel-hidden' id='panel-variants'>
|
||||||
<div class='panel-heading'>
|
<div class='panel-heading'>
|
||||||
<h4>{% trans "Part Variants" %}</h4>
|
<h4>{% trans "Part Variants" %}</h4>
|
||||||
@ -788,11 +791,6 @@
|
|||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
attachNavCallbacks({
|
|
||||||
name: 'part',
|
|
||||||
default: 'part-stock'
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#supplier-create').click(function () {
|
$('#supplier-create').click(function () {
|
||||||
launchModalForm(
|
launchModalForm(
|
||||||
"{% url 'supplier-part-create' %}",
|
"{% url 'supplier-part-create' %}",
|
||||||
@ -895,4 +893,9 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
attachNavCallbacks({
|
||||||
|
name: 'part',
|
||||||
|
default: 'part-stock'
|
||||||
|
});
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
{% extends "part/category.html" %}
|
|
||||||
|
|
||||||
{% load i18n %}
|
|
||||||
{% load inventree_extras %}
|
|
||||||
{% load static %}
|
|
||||||
|
|
||||||
{% block menubar %}
|
|
||||||
{% include 'part/category_navbar.html' with tab='subcategories' %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block category_content %}
|
|
||||||
|
|
||||||
<div class='panel panel-default panel-inventree'>
|
|
||||||
|
|
||||||
<div class='panel-heading'>
|
|
||||||
<h4>{% trans "Subcategories" %}</h4>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id='button-toolbar'>
|
|
||||||
<div class='button-toolbar container-fluid' style='float: right;'>
|
|
||||||
|
|
||||||
<div class='filter-list' id='filter-list-category'>
|
|
||||||
<!-- An empty div in which the filter list will be constructed -->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<table class='table table-striped table-condensed' id='subcategory-table' data-toolbar='#button-toolbar'></table>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block js_ready %}
|
|
||||||
{{ block.super }}
|
|
||||||
|
|
||||||
enableNavbar({
|
|
||||||
label: 'category',
|
|
||||||
toggleId: '#category-menu-toggle',
|
|
||||||
});
|
|
||||||
|
|
||||||
loadPartCategoryTable($('#subcategory-table'), {
|
|
||||||
params: {
|
|
||||||
{% if category %}
|
|
||||||
parent: {{ category.pk }}
|
|
||||||
{% else %}
|
|
||||||
parent: 'null'
|
|
||||||
{% endif %}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
{% endblock %}
|
|
@ -78,9 +78,6 @@ category_urls = [
|
|||||||
url(r'^delete/', views.CategoryDelete.as_view(), name='category-delete'),
|
url(r'^delete/', views.CategoryDelete.as_view(), name='category-delete'),
|
||||||
url(r'^parameters/', include(category_parameter_urls)),
|
url(r'^parameters/', include(category_parameter_urls)),
|
||||||
|
|
||||||
url(r'^subcategory/', views.CategoryDetail.as_view(template_name='part/subcategory.html'), name='category-subcategory'),
|
|
||||||
url(r'^parametric/', views.CategoryParametric.as_view(), name='category-parametric'),
|
|
||||||
|
|
||||||
# Anything else
|
# Anything else
|
||||||
url(r'^.*$', views.CategoryDetail.as_view(), name='category-detail'),
|
url(r'^.*$', views.CategoryDetail.as_view(), name='category-detail'),
|
||||||
]))
|
]))
|
||||||
|
@ -1818,7 +1818,7 @@ class CategoryDetail(InvenTreeRoleMixin, DetailView):
|
|||||||
model = PartCategory
|
model = PartCategory
|
||||||
context_object_name = 'category'
|
context_object_name = 'category'
|
||||||
queryset = PartCategory.objects.all().prefetch_related('children')
|
queryset = PartCategory.objects.all().prefetch_related('children')
|
||||||
template_name = 'part/category_partlist.html'
|
template_name = 'part/category.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
|
|
||||||
@ -1829,18 +1829,6 @@ class CategoryDetail(InvenTreeRoleMixin, DetailView):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
context['part_count'] = 0
|
context['part_count'] = 0
|
||||||
|
|
||||||
return context
|
|
||||||
|
|
||||||
|
|
||||||
class CategoryParametric(CategoryDetail):
|
|
||||||
""" Parametric view for PartCategory """
|
|
||||||
|
|
||||||
template_name = 'part/category_parametric.html'
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
|
|
||||||
context = super(CategoryParametric, self).get_context_data(**kwargs).copy()
|
|
||||||
|
|
||||||
# Get current category
|
# Get current category
|
||||||
category = kwargs.get('object', None)
|
category = kwargs.get('object', None)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user