2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 21:45:39 +00:00

Merge branch 'master' into stock-item-forms

This commit is contained in:
Oliver
2021-11-04 10:34:49 +11:00
33 changed files with 826 additions and 199 deletions

View File

@ -76,6 +76,7 @@ function addHeaderAction(label, title, icon, options) {
}
{% settings_value 'HOMEPAGE_PART_STARRED' user=request.user as setting_part_starred %}
{% settings_value 'HOMEPAGE_CATEGORY_STARRED' user=request.user as setting_category_starred %}
{% settings_value 'HOMEPAGE_PART_LATEST' user=request.user as setting_part_latest %}
{% settings_value 'HOMEPAGE_BOM_VALIDATION' user=request.user as setting_bom_validation %}
{% to_list setting_part_starred setting_part_latest setting_bom_validation as settings_list_part %}
@ -84,15 +85,25 @@ function addHeaderAction(label, title, icon, options) {
addHeaderTitle('{% trans "Parts" %}');
{% if setting_part_starred %}
addHeaderAction('starred-parts', '{% trans "Starred Parts" %}', 'fa-star');
addHeaderAction('starred-parts', '{% trans "Subscribed Parts" %}', 'fa-bell');
loadSimplePartTable("#table-starred-parts", "{% url 'api-part-list' %}", {
params: {
"starred": true,
starred: true,
},
name: 'starred_parts',
});
{% endif %}
{% if setting_category_starred %}
addHeaderAction('starred-categories', '{% trans "Subscribed Categories" %}', 'fa-bell');
loadPartCategoryTable($('#table-starred-categories'), {
params: {
starred: true,
},
name: 'starred_categories'
});
{% endif %}
{% if setting_part_latest %}
addHeaderAction('latest-parts', '{% trans "Latest Parts" %}', 'fa-newspaper');
loadSimplePartTable("#table-latest-parts", "{% url 'api-part-list' %}", {
@ -128,8 +139,7 @@ loadSimplePartTable("#table-bom-validation", "{% url 'api-part-list' %}", {
{% to_list setting_stock_recent setting_stock_low setting_stock_depleted setting_stock_needed as settings_list_stock %}
{% endif %}
{% if roles.stock.view and True in settings_list_stock %}
addHeaderTitle('{% trans "Stock" %}');
{% if roles.stock.view %}
{% if setting_stock_recent %}
addHeaderAction('recently-updated-stock', '{% trans "Recently Updated" %}', 'fa-clock');
@ -145,7 +155,7 @@ loadStockTable($('#table-recently-updated-stock'), {
{% endif %}
{% if setting_stock_low %}
addHeaderAction('low-stock', '{% trans "Low Stock" %}', 'fa-shopping-cart');
addHeaderAction('low-stock', '{% trans "Low Stock" %}', 'fa-flag');
loadSimplePartTable("#table-low-stock", "{% url 'api-part-list' %}", {
params: {
low_stock: true,

View File

@ -14,7 +14,8 @@
<div class='row'>
<table class='table table-striped table-condensed'>
<tbody>
{% include "InvenTree/settings/setting.html" with key="HOMEPAGE_PART_STARRED" icon='fa-star' user_setting=True %}
{% include "InvenTree/settings/setting.html" with key="HOMEPAGE_PART_STARRED" icon='fa-bell' user_setting=True %}
{% include "InvenTree/settings/setting.html" with key="HOMEPAGE_CATEGORY_STARRED" icon='fa-bell' user_setting=True %}
{% include "InvenTree/settings/setting.html" with key="HOMEPAGE_PART_LATEST" icon='fa-history' user_setting=True %}
{% include "InvenTree/settings/setting.html" with key="PART_RECENT_COUNT" icon="fa-clock" user_setting=True %}
{% include "InvenTree/settings/setting.html" with key="HOMEPAGE_BOM_VALIDATION" user_setting=True %}

View File

@ -84,6 +84,13 @@
</div>
</div>
<main class='col ps-md-2 pt-2'>
{% block alerts %}
<div class='notification-area' id='alerts'>
<!-- Div for displayed alerts -->
</div>
{% endblock %}
{% block breadcrumb_list %}
<div class='container-fluid navigation'>
<nav aria-label='breadcrumb'>
@ -102,7 +109,6 @@
</div>
{% include 'modals.html' %}
{% include 'about.html' %}
{% include 'notification.html' %}
</div>
<!-- Scripts -->

View File

@ -17,13 +17,15 @@
{% block body %}
<tr style="height: 3rem; border-bottom: 1px solid">
<th>{% trans "Part Name" %}</th>
<th>{% trans "Available Quantity" %}</th>
<th>{% trans "Total Stock" %}</th>
<th>{% trans "Available" %}</th>
<th>{% trans "Minimum Quantity" %}</th>
</tr>
<tr style="height: 3rem">
<td style="text-align: center;">{{ part.full_name }}</td>
<td style="text-align: center;">{{ part.total_stock }}</td>
<td style="text-align: center;">{{ part.available_stock }}</td>
<td style="text-align: center;">{{ part.minimum_stock }}</td>
</tr>
{% endblock %}

View File

@ -169,7 +169,12 @@ function inventreeDocReady() {
html += '</span>';
if (user_settings.SEARCH_SHOW_STOCK_LEVELS) {
html += partStockLabel(item.data);
html += partStockLabel(
item.data,
{
classes: 'badge-right',
}
);
}
html += '</a>';

View File

@ -373,24 +373,23 @@ function duplicatePart(pk, options={}) {
}
/* Toggle the 'starred' status of a part.
* Performs AJAX queries and updates the display on the button.
*
* options:
* - button: ID of the button (default = '#part-star-icon')
* - URL: API url of the object
* - user: pk of the user
*/
function toggleStar(options) {
/* Toggle the 'starred' status of a part.
* Performs AJAX queries and updates the display on the button.
*
* options:
* - button: ID of the button (default = '#part-star-icon')
* - part: pk of the part object
* - user: pk of the user
*/
var url = `/api/part/${options.part}/`;
inventreeGet(url, {}, {
inventreeGet(options.url, {}, {
success: function(response) {
var starred = response.starred;
inventreePut(
url,
options.url,
{
starred: !starred,
},
@ -398,9 +397,19 @@ function toggleStar(options) {
method: 'PATCH',
success: function(response) {
if (response.starred) {
$(options.button).addClass('icon-yellow');
$(options.button).removeClass('fa fa-bell-slash').addClass('fas fa-bell icon-green');
$(options.button).attr('title', '{% trans "You are subscribed to notifications for this item" %}');
showMessage('{% trans "You have subscribed to notifications for this item" %}', {
style: 'success',
});
} else {
$(options.button).removeClass('icon-yellow');
$(options.button).removeClass('fas fa-bell icon-green').addClass('fa fa-bell-slash');
$(options.button).attr('title', '{% trans "Subscribe to notifications for this item" %}');
showMessage('{% trans "You have unsubscribed to notifications for this item" %}', {
style: 'warning',
});
}
}
}
@ -410,12 +419,12 @@ function toggleStar(options) {
}
function partStockLabel(part) {
function partStockLabel(part, options={}) {
if (part.in_stock) {
return `<span class='badge rounded-pill bg-success'>{% trans "Stock" %}: ${part.in_stock}</span>`;
return `<span class='badge rounded-pill bg-success ${options.classes}'>{% trans "Stock" %}: ${part.in_stock}</span>`;
} else {
return `<span class='badge rounded-pill bg-danger'>{% trans "No Stock" %}</span>`;
return `<span class='badge rounded-pill bg-danger ${options.classes}'>{% trans "No Stock" %}</span>`;
}
}
@ -443,7 +452,7 @@ function makePartIcons(part) {
}
if (part.starred) {
html += makeIconBadge('fa-star', '{% trans "Starred part" %}');
html += makeIconBadge('fa-bell icon-green', '{% trans "Subscribed part" %}');
}
if (part.salable) {
@ -451,7 +460,7 @@ function makePartIcons(part) {
}
if (!part.active) {
html += `<span class='badge badge-right rounded-pill bg-warning'>{% trans "Inactive" %}</span>`;
html += `<span class='badge badge-right rounded-pill bg-warning'>{% trans "Inactive" %}</span> `;
}
return html;
@ -1258,10 +1267,17 @@ function loadPartCategoryTable(table, options) {
switchable: true,
sortable: true,
formatter: function(value, row) {
return renderLink(
var html = renderLink(
value,
`/part/category/${row.pk}/`
);
if (row.starred) {
html += makeIconBadge('fa-bell icon-green', '{% trans "Subscribed category" %}');
}
return html;
}
},
{

View File

@ -103,6 +103,10 @@ function getAvailableTableFilters(tableKey) {
title: '{% trans "Include subcategories" %}',
description: '{% trans "Include subcategories" %}',
},
starred: {
type: 'bool',
title: '{% trans "Subscribed" %}',
},
};
}
@ -368,7 +372,7 @@ function getAvailableTableFilters(tableKey) {
},
starred: {
type: 'bool',
title: '{% trans "Starred" %}',
title: '{% trans "Subscribed" %}',
},
salable: {
type: 'bool',

View File

@ -1,18 +0,0 @@
<div class='notification-area'>
<div class="alert alert-success alert-dismissable" id="alert-success">
<a href="#" class="close" data-bs-dismiss="alert" aria-label="close">&times;</a>
<div class='alert-msg'>Success alert</div>
</div>
<div class='alert alert-info alert-dismissable' id='alert-info'>
<a href="#" class="close" data-bs-dismiss="alert" aria-label="close">&times;</a>
<div class='alert-msg'>Info alert</div>
</div>
<div class='alert alert-warning alert-dismissable' id='alert-warning'>
<a href="#" class="close" data-bs-dismiss="alert" aria-label="close">&times;</a>
<div class='alert-msg'>Warning alert</div>
</div>
<div class='alert alert-danger alert-dismissable' id='alert-danger'>
<a href="#" class="close" data-bs-dismiss="alert" aria-label="close">&times;</a>
<div class='alert-msg'>Danger alert</div>
</div>
</div>