mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Homepage Improvements (#5057)
* remove STOCK_RECENT_COUNT parameter - Now "recent" is set by date - Tables are paginated by the server * Display total row count * remove PART_RECENT_COUNT - Replace with date filter - Update Part.api * Bump API version
This commit is contained in:
parent
31ff3599eb
commit
61d2f452b2
@ -2,11 +2,14 @@
|
|||||||
|
|
||||||
|
|
||||||
# InvenTree API version
|
# InvenTree API version
|
||||||
INVENTREE_API_VERSION = 123
|
INVENTREE_API_VERSION = 124
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Increment this API version number whenever there is a significant change to the API that any clients need to know about
|
Increment this API version number whenever there is a significant change to the API that any clients need to know about
|
||||||
|
|
||||||
|
v124 -> 2023-06-17 : https://github.com/inventree/InvenTree/pull/5057
|
||||||
|
- Add "created_before" and "created_after" filters to the Part API
|
||||||
|
|
||||||
v123 -> 2023-06-15 : https://github.com/inventree/InvenTree/pull/5019
|
v123 -> 2023-06-15 : https://github.com/inventree/InvenTree/pull/5019
|
||||||
- Add Metadata to: Plugin Config
|
- Add Metadata to: Plugin Config
|
||||||
|
|
||||||
|
@ -1775,13 +1775,6 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
|
|||||||
'validator': bool,
|
'validator': bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
'PART_RECENT_COUNT': {
|
|
||||||
'name': _('Recent Part Count'),
|
|
||||||
'description': _('Number of recent parts to display on index page'),
|
|
||||||
'default': 10,
|
|
||||||
'validator': [int, MinValueValidator(1)]
|
|
||||||
},
|
|
||||||
|
|
||||||
'HOMEPAGE_BOM_REQUIRES_VALIDATION': {
|
'HOMEPAGE_BOM_REQUIRES_VALIDATION': {
|
||||||
'name': _('Show unvalidated BOMs'),
|
'name': _('Show unvalidated BOMs'),
|
||||||
'description': _('Show BOMs that await validation on the homepage'),
|
'description': _('Show BOMs that await validation on the homepage'),
|
||||||
@ -1796,13 +1789,6 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
|
|||||||
'validator': bool,
|
'validator': bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
'STOCK_RECENT_COUNT': {
|
|
||||||
'name': _('Recent Stock Count'),
|
|
||||||
'description': _('Number of recent stock items to display on index page'),
|
|
||||||
'default': 10,
|
|
||||||
'validator': [int, MinValueValidator(1)]
|
|
||||||
},
|
|
||||||
|
|
||||||
'HOMEPAGE_STOCK_LOW': {
|
'HOMEPAGE_STOCK_LOW': {
|
||||||
'name': _('Show low stock'),
|
'name': _('Show low stock'),
|
||||||
'description': _('Show low stock items on the homepage'),
|
'description': _('Show low stock items on the homepage'),
|
||||||
|
@ -990,6 +990,10 @@ class PartFilter(rest_filters.FilterSet):
|
|||||||
|
|
||||||
tags_slug = rest_filters.CharFilter(field_name='tags__slug', lookup_expr='iexact')
|
tags_slug = rest_filters.CharFilter(field_name='tags__slug', lookup_expr='iexact')
|
||||||
|
|
||||||
|
# Created date filters
|
||||||
|
created_before = rest_filters.DateFilter(label='Updated before', field_name='creation_date', lookup_expr='lte')
|
||||||
|
created_after = rest_filters.DateFilter(label='Updated after', field_name='creation_date', lookup_expr='gte')
|
||||||
|
|
||||||
|
|
||||||
class PartMixin:
|
class PartMixin:
|
||||||
"""Mixin class for Part API endpoints"""
|
"""Mixin class for Part API endpoints"""
|
||||||
|
@ -60,11 +60,16 @@ function addHeaderAction(label, title, icon, options) {
|
|||||||
</div>`
|
</div>`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Connect a callback to the table
|
let table_name = `#table-${label}`;
|
||||||
$(`#table-${label}`).on('load-success.bs.table', function() {
|
|
||||||
var count = $(`#table-${label}`).bootstrapTable('getData').length;
|
|
||||||
|
|
||||||
var badge = $(`#sidebar-badge-${label}`);
|
// Connect a callback to the table
|
||||||
|
$(table_name).on('load-success.bs.table', function(data) {
|
||||||
|
|
||||||
|
let options = $(table_name).bootstrapTable('getOptions');
|
||||||
|
|
||||||
|
let count = options.totalRows;
|
||||||
|
|
||||||
|
let badge = $(`#sidebar-badge-${label}`);
|
||||||
|
|
||||||
badge.html(count);
|
badge.html(count);
|
||||||
|
|
||||||
@ -113,7 +118,7 @@ addHeaderAction('latest-parts', '{% trans "Latest Parts" %}', 'fa-newspaper');
|
|||||||
loadSimplePartTable("#table-latest-parts", "{% url 'api-part-list' %}", {
|
loadSimplePartTable("#table-latest-parts", "{% url 'api-part-list' %}", {
|
||||||
params: {
|
params: {
|
||||||
ordering: "-creation_date",
|
ordering: "-creation_date",
|
||||||
limit: {% settings_value "PART_RECENT_COUNT" user=request.user %},
|
created_after: moment().subtract(1, 'months').format('YYYY-MM-DD'),
|
||||||
{% if hide_inactive %}
|
{% if hide_inactive %}
|
||||||
active: true,
|
active: true,
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -150,14 +155,13 @@ loadSimplePartTable("#table-bom-validation", "{% url 'api-part-list' %}", {
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if roles.stock.view %}
|
{% if roles.stock.view %}
|
||||||
|
|
||||||
{% if setting_stock_recent %}
|
{% if setting_stock_recent %}
|
||||||
addHeaderAction('recently-updated-stock', '{% trans "Recently Updated" %}', 'fa-clock');
|
addHeaderAction('recently-updated-stock', '{% trans "Recently Updated" %}', 'fa-clock');
|
||||||
loadStockTable($('#table-recently-updated-stock'), {
|
loadStockTable($('#table-recently-updated-stock'), {
|
||||||
params: {
|
params: {
|
||||||
part_detail: true,
|
part_detail: true,
|
||||||
ordering: "-updated",
|
ordering: "-updated",
|
||||||
limit: {% settings_value "STOCK_RECENT_COUNT" user=request.user %},
|
updated_after: moment().subtract(1, 'months').format('YYYY-MM-DD'),
|
||||||
},
|
},
|
||||||
name: 'recently-updated-stock',
|
name: 'recently-updated-stock',
|
||||||
});
|
});
|
||||||
|
@ -18,11 +18,9 @@
|
|||||||
{% include "InvenTree/settings/setting.html" with key="HOMEPAGE_PART_STARRED" icon='fa-bell' 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_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="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_REQUIRES_VALIDATION" user_setting=True %}
|
{% include "InvenTree/settings/setting.html" with key="HOMEPAGE_BOM_REQUIRES_VALIDATION" user_setting=True %}
|
||||||
<tr><td colspan='5'></td></tr>
|
<tr><td colspan='5'></td></tr>
|
||||||
{% include "InvenTree/settings/setting.html" with key="HOMEPAGE_STOCK_RECENT" icon='fa-history' user_setting=True %}
|
{% include "InvenTree/settings/setting.html" with key="HOMEPAGE_STOCK_RECENT" icon='fa-history' user_setting=True %}
|
||||||
{% include "InvenTree/settings/setting.html" with key="STOCK_RECENT_COUNT" icon="fa-clock" user_setting=True %}
|
|
||||||
{% include "InvenTree/settings/setting.html" with key="HOMEPAGE_STOCK_LOW" user_setting=True %}
|
{% include "InvenTree/settings/setting.html" with key="HOMEPAGE_STOCK_LOW" user_setting=True %}
|
||||||
{% include "InvenTree/settings/setting.html" with key="HOMEPAGE_SHOW_STOCK_DEPLETED" user_setting=True %}
|
{% include "InvenTree/settings/setting.html" with key="HOMEPAGE_SHOW_STOCK_DEPLETED" user_setting=True %}
|
||||||
{% include "InvenTree/settings/setting.html" with key="HOMEPAGE_BUILD_STOCK_NEEDED" user_setting=True %}
|
{% include "InvenTree/settings/setting.html" with key="HOMEPAGE_BUILD_STOCK_NEEDED" user_setting=True %}
|
||||||
|
Loading…
Reference in New Issue
Block a user