From cf2abb413017d47b31f009e95ec4d5c2beb7e2c2 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 19 Sep 2019 23:20:42 +1000 Subject: [PATCH 01/11] Add option to display ALL results in a paginated table - Commonize the number of pages allowed --- InvenTree/InvenTree/static/script/inventree/part.js | 3 ++- InvenTree/InvenTree/static/script/inventree/stock.js | 3 ++- InvenTree/company/templates/company/detail_part.html | 1 + InvenTree/company/templates/company/index.html | 1 + InvenTree/part/templates/part/build.html | 1 + InvenTree/templates/InvenTree/search.html | 6 ++++-- InvenTree/templates/InvenTree/settings/currency.html | 3 ++- InvenTree/templates/InvenTree/settings/part.html | 3 ++- 8 files changed, 15 insertions(+), 6 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/part.js b/InvenTree/InvenTree/static/script/inventree/part.js index 1056a7706b..16eec9e293 100644 --- a/InvenTree/InvenTree/static/script/inventree/part.js +++ b/InvenTree/InvenTree/static/script/inventree/part.js @@ -198,7 +198,8 @@ function loadPartTable(table, url, options={}) { sortName: 'name', method: 'get', pagination: true, - pageSize: 25, + pageSize: 50, + pageList: [25, 50, 100, 'all'], rememberOrder: true, formatNoMatches: function() { return "No parts found"; }, queryParams: function(p) { diff --git a/InvenTree/InvenTree/static/script/inventree/stock.js b/InvenTree/InvenTree/static/script/inventree/stock.js index ae07be1dd3..589969faaf 100644 --- a/InvenTree/InvenTree/static/script/inventree/stock.js +++ b/InvenTree/InvenTree/static/script/inventree/stock.js @@ -47,7 +47,8 @@ function loadStockTable(table, options) { search: true, method: 'get', pagination: true, - pageSize: 25, + pageSize: 50, + pageList: [25, 50, 100, 'all'], rememberOrder: true, formatNoMatches: function() { return 'No stock items matching query'; diff --git a/InvenTree/company/templates/company/detail_part.html b/InvenTree/company/templates/company/detail_part.html index 2cc100390b..3a24140464 100644 --- a/InvenTree/company/templates/company/detail_part.html +++ b/InvenTree/company/templates/company/detail_part.html @@ -50,6 +50,7 @@ search: true, pagination: true, pageSize: 50, + pageList: [25, 50, 100, 'all'], formatNoMatches: function() { return "No supplier parts found for {{ company.name }}"; }, queryParams: function(p) { return { diff --git a/InvenTree/company/templates/company/index.html b/InvenTree/company/templates/company/index.html index 17b737b670..c77c705ad5 100644 --- a/InvenTree/company/templates/company/index.html +++ b/InvenTree/company/templates/company/index.html @@ -37,6 +37,7 @@ InvenTree | Supplier List search: true, pagination: true, pageSize: 50, + pageList: [25, 50, 100, 'all'], formatNoMatches: function() { return "No company information found"; }, columns: [ { diff --git a/InvenTree/part/templates/part/build.html b/InvenTree/part/templates/part/build.html index 958a057409..d6510e5123 100644 --- a/InvenTree/part/templates/part/build.html +++ b/InvenTree/part/templates/part/build.html @@ -36,6 +36,7 @@ search: true, pagination: true, pageSize: 50, + pageList: [25, 50, 100, 'all'], queryParams: function(p) { return { part: {{ part.id }}, diff --git a/InvenTree/templates/InvenTree/search.html b/InvenTree/templates/InvenTree/search.html index a31e4ed1a8..97285ddfd5 100644 --- a/InvenTree/templates/InvenTree/search.html +++ b/InvenTree/templates/InvenTree/search.html @@ -140,7 +140,8 @@ InvenTree | Search Results search: "{{ query }}", }, pagination: true, - pageSize: 25, + pageSize: 50, + pageList: [25, 50, 100, 'all'], search: true, columns: [ { @@ -163,7 +164,8 @@ InvenTree | Search Results search: "{{ query }}", }, pagination: true, - pageSize: 25, + pageSize: 50, + pageList: [25, 50, 100, 'all'], search: true, columns: [ { diff --git a/InvenTree/templates/InvenTree/settings/currency.html b/InvenTree/templates/InvenTree/settings/currency.html index 712cd1700c..dcdafb72ac 100644 --- a/InvenTree/templates/InvenTree/settings/currency.html +++ b/InvenTree/templates/InvenTree/settings/currency.html @@ -27,7 +27,8 @@ sortable: true, search: true, pagination: true, - pageSize: 25, + pageSize: 50, + pageList: [25, 50, 100, 'all'], formatNoMatches: function() { return "No currencies found"; }, rowStyle: function(row, index) { if (row.base) { diff --git a/InvenTree/templates/InvenTree/settings/part.html b/InvenTree/templates/InvenTree/settings/part.html index 87535c7db1..5f624063c1 100644 --- a/InvenTree/templates/InvenTree/settings/part.html +++ b/InvenTree/templates/InvenTree/settings/part.html @@ -27,7 +27,8 @@ sortable: true, search: true, pagination: true, - pageSize: 25, + pageSize: 50, + pageList: [25, 50, 100, 'all'], formatNoMatches: function() { return "No part parameter templates found"; }, columns: [ { From 3c98cd87a75bd16257d433644990be573710188e Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 19 Sep 2019 23:29:03 +1000 Subject: [PATCH 02/11] Use localStorage rather than sessionStorage for storing user prefs - Also create some helper functions --- .../static/script/inventree/inventree.js | 43 +++++++++++++++++++ InvenTree/part/templates/part/category.html | 6 +-- InvenTree/stock/templates/stock/location.html | 6 +-- 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/inventree.js b/InvenTree/InvenTree/static/script/inventree/inventree.js index 703c49218b..390aba92ab 100644 --- a/InvenTree/InvenTree/static/script/inventree/inventree.js +++ b/InvenTree/InvenTree/static/script/inventree/inventree.js @@ -136,4 +136,47 @@ function imageHoverIcon(url) { `; return html; +} + +function inventreeSave(name, value) { + /* + * Save a key:value pair to local storage + */ + + var key = "inventree-" + name; + localStorage.setItem(key, value); +} + +function inventreeLoad(name) { + /* + * Retrieve a key:value pair from local storage + */ + + var key = "inventree-" + name; + + return localStorage.getItem(key); +} + +function inventreeLoadInt(name) { + /* + * Retrieve a value from local storage, and attempt to cast to integer + */ + + var data = inventreeLoad(name); + + return parseInt(data, 10); +} + +function inventreeLoadFloat(name) { + + var data = inventreeLoad(name); + + return parseFloat(data); +} + +function inventreeDel(name) { + + var key = 'inventree-' + name; + + localStorage.removeItem(key); } \ No newline at end of file diff --git a/InvenTree/part/templates/part/category.html b/InvenTree/part/templates/part/category.html index d9913482fd..f48e06e6d7 100644 --- a/InvenTree/part/templates/part/category.html +++ b/InvenTree/part/templates/part/category.html @@ -67,16 +67,16 @@ {% block js_ready %} {{ block.super }} - if (sessionStorage.getItem("inventree-show-part-categories")) { + if (inventreeLoadInt("show-part-cats") == 1) { $("#collapse-item-categories").collapse('show'); } $("#collapse-item-categories").on('shown.bs.collapse', function() { - sessionStorage.setItem('inventree-show-part-categories', 1); + inventreeSave('show-part-cats', 1); }); $("#collapse-item-categories").on('hidden.bs.collapse', function() { - sessionStorage.removeItem('inventree-show-part-categories'); + inventreeDel('show-part-cats'); }); $("#cat-create").click(function() { diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html index 6a0d05cfcc..929dd7baf8 100644 --- a/InvenTree/stock/templates/stock/location.html +++ b/InvenTree/stock/templates/stock/location.html @@ -55,16 +55,16 @@ {% block js_ready %} {{ block.super }} - if (sessionStorage.getItem("inventree-show-part-locations")) { + if (inventreeLoadInt("show-part-locs") == 1) { $("#collapse-item-locations").collapse('show'); } $("#collapse-item-locations").on('shown.bs.collapse', function() { - sessionStorage.setItem('inventree-show-part-locations', 1); + inventreeSave('show-part-locs', 1); }); $("#collapse-item-locations").on('hidden.bs.collapse', function() { - sessionStorage.removeItem('inventree-show-part-locations'); + inventreeDel('show-part-locs'); }); $("#stock-export").click(function() { From b3ea2bfb9a24b3b86c9544b587ece6d78e70baae Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 19 Sep 2019 23:38:15 +1000 Subject: [PATCH 03/11] Update badges --- InvenTree/part/templates/part/subcategories.html | 4 +++- InvenTree/stock/templates/stock/location_list.html | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/InvenTree/part/templates/part/subcategories.html b/InvenTree/part/templates/part/subcategories.html index abf61d743e..c503d5504c 100644 --- a/InvenTree/part/templates/part/subcategories.html +++ b/InvenTree/part/templates/part/subcategories.html @@ -12,7 +12,9 @@ {% if child.description %} - {{ child.description }} {% endif %} - {{ child.partcount }} + {% if child.partcount > 0 %} + {{ child.partcount }} Part{% if child.partcount > 1 %}s{% endif %} + {% endif %} {% endfor %} diff --git a/InvenTree/stock/templates/stock/location_list.html b/InvenTree/stock/templates/stock/location_list.html index 9ce7a1814c..a6e1811f46 100644 --- a/InvenTree/stock/templates/stock/location_list.html +++ b/InvenTree/stock/templates/stock/location_list.html @@ -8,7 +8,9 @@ Sub-Locations{{ children|length }}
    {% for child in children %}
  • {{ child.name }} - {{ child.description }} - {{ child.item_count }} + {% if child.item_count > 0 %} + {{ child.item_count }} Item{% if child.item_count > 1 %}s{% endif %} + {% endif %}
  • {% endfor %}
From 508a3fc35c057ac822722cfbabda51e37b301329 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 19 Sep 2019 23:59:01 +1000 Subject: [PATCH 04/11] Improve display of part category page --- InvenTree/part/templates/part/category.html | 28 ++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/InvenTree/part/templates/part/category.html b/InvenTree/part/templates/part/category.html index f48e06e6d7..c3477f47c2 100644 --- a/InvenTree/part/templates/part/category.html +++ b/InvenTree/part/templates/part/category.html @@ -8,9 +8,6 @@ {% if category %}

{{ category.name }}

{{ category.description }}

- {% if category.default_location %} -

Default Location: {{ category.default_location }}

- {% endif %} {% else %}

Part Categories

All parts

@@ -32,6 +29,31 @@

+ {% if category %} +

Category Details

+ + + + + + + + + + {% if category.default_location %} + + + + + {% endif %} + {% if category.default_keywords %} + + + + + {% endif %} +
Category Path{{ category.pathstring }}
Category Description{{ category.description }}
Default Location{{ category.default_location.pathstring }}
Keywords{{ category.default_keywords }}
+ {% endif %}
From 5a9e5dea20e4d1d5440e2e0732c15c5217d7e940 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 20 Sep 2019 00:00:34 +1000 Subject: [PATCH 05/11] Add sub-category and part count --- InvenTree/part/templates/part/category.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/InvenTree/part/templates/part/category.html b/InvenTree/part/templates/part/category.html index c3477f47c2..f6c49b2094 100644 --- a/InvenTree/part/templates/part/category.html +++ b/InvenTree/part/templates/part/category.html @@ -52,6 +52,14 @@ {{ category.default_keywords }} {% endif %} + + Subcategories + {{ category.children.count }} + + + Parts (Including subcategories) + {{ category.partcount }} + {% endif %} From 6f540913547978e30d6e68333e1003a58e7c9b5d Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 20 Sep 2019 00:03:59 +1000 Subject: [PATCH 06/11] Improve display of stock location --- InvenTree/stock/templates/stock/location.html | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html index 929dd7baf8..45743bbd5d 100644 --- a/InvenTree/stock/templates/stock/location.html +++ b/InvenTree/stock/templates/stock/location.html @@ -32,6 +32,27 @@

+ {% if location %} +

Location Details

+ + + + + + + + + + + + + + + + + +
Location Path{{ location.pathstring }}
Location Description{{ location.description }}
Sublocations{{ location.children.count }}
Stock Items{{ location.item_count }}
+ {% endif %}
From fcbf0e6e93027ed4ab64141e69e65ffdcbc1485f Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 20 Sep 2019 11:52:38 +1000 Subject: [PATCH 07/11] Create UI elements to cancel an order - View - Form - Template - Button - Javascript --- InvenTree/order/forms.py | 14 +++++++- InvenTree/order/models.py | 7 ++++ .../order/templates/order/order_cancel.html | 7 ++++ .../order/purchase_order_detail.html | 11 +++++++ InvenTree/order/urls.py | 1 + InvenTree/order/views.py | 33 +++++++++++++++++++ 6 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 InvenTree/order/templates/order/order_cancel.html diff --git a/InvenTree/order/forms.py b/InvenTree/order/forms.py index c7942e3549..4844ef4344 100644 --- a/InvenTree/order/forms.py +++ b/InvenTree/order/forms.py @@ -6,6 +6,7 @@ Django Forms for interacting with Order objects from __future__ import unicode_literals from django import forms +from django.utils.translation import ugettext as _ from InvenTree.forms import HelperForm @@ -14,7 +15,7 @@ from .models import PurchaseOrder, PurchaseOrderLineItem class IssuePurchaseOrderForm(HelperForm): - confirm = forms.BooleanField(required=False, help_text='Place order') + confirm = forms.BooleanField(required=False, help_text=_('Place order')) class Meta: model = PurchaseOrder @@ -23,6 +24,17 @@ class IssuePurchaseOrderForm(HelperForm): ] +class CancelPurchaseOrderForm(HelperForm): + + confirm = forms.BooleanField(required=False, help_text=_('Cancel order')) + + class Meta: + model = PurchaseOrder + fields = [ + 'confirm', + ] + + class EditPurchaseOrderForm(HelperForm): """ Form for editing a PurchaseOrder object """ diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index 9eff4d11c3..de0ac86bad 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -98,6 +98,13 @@ class Order(models.Model): self.complete_date = datetime.now().date() self.save() + def cancel_order(self): + """ Marks the order as CANCELLED. """ + + if self.status in [OrderStatus.PLACED, OrderStatus.PENDING]: + self.status = OrderStatus.CANCELLED + self.save() + class PurchaseOrder(Order): """ A PurchaseOrder represents goods shipped inwards from an external supplier. diff --git a/InvenTree/order/templates/order/order_cancel.html b/InvenTree/order/templates/order/order_cancel.html new file mode 100644 index 0000000000..3c71028b06 --- /dev/null +++ b/InvenTree/order/templates/order/order_cancel.html @@ -0,0 +1,7 @@ +{% extends "modal_form.html" %} + +{% block pre_form_content %} + +Cancelling this order means that the order will no longer be editable. + +{% endblock %} \ No newline at end of file diff --git a/InvenTree/order/templates/order/purchase_order_detail.html b/InvenTree/order/templates/order/purchase_order_detail.html index 2ddbdc3052..29336b18db 100644 --- a/InvenTree/order/templates/order/purchase_order_detail.html +++ b/InvenTree/order/templates/order/purchase_order_detail.html @@ -43,6 +43,11 @@ InvenTree | {{ order }} {% endif %} + {% if order.status == OrderStatus.PENDING or order.status == OrderStatus.PLACED %} + + {% endif %}

@@ -176,6 +181,12 @@ $("#edit-order").click(function() { ); }); +$("#cancel-order").click(function() { + launchModalForm("{% url 'purchase-order-cancel' order.id %}", { + reload: true, + }); +}); + $("#receive-order").click(function() { launchModalForm("{% url 'purchase-order-receive' order.id %}", { reload: true, diff --git a/InvenTree/order/urls.py b/InvenTree/order/urls.py index 38687342c2..994e6b054d 100644 --- a/InvenTree/order/urls.py +++ b/InvenTree/order/urls.py @@ -11,6 +11,7 @@ from . import views purchase_order_detail_urls = [ + url(r'^cancel/?', views.PurchaseOrderCancel.as_view(), name='purchase-order-cancel'), url(r'^edit/?', views.PurchaseOrderEdit.as_view(), name='purchase-order-edit'), url(r'^issue/?', views.PurchaseOrderIssue.as_view(), name='purchase-order-issue'), url(r'^receive/?', views.PurchaseOrderReceive.as_view(), name='purchase-order-receive'), diff --git a/InvenTree/order/views.py b/InvenTree/order/views.py index 86a231075e..49d2ed01ed 100644 --- a/InvenTree/order/views.py +++ b/InvenTree/order/views.py @@ -112,6 +112,39 @@ class PurchaseOrderEdit(AjaxUpdateView): return form +class PurchaseOrderCancel(AjaxUpdateView): + """ View for cancelling a purchase order """ + + model = PurchaseOrder + ajax_form_title = 'Cancel Order' + ajax_template_name = 'order/order_cancel.html' + form_class = order_forms.CancelPurchaseOrderForm + + def post(self, request, *args, **kwargs): + """ Mark the PO as 'CANCELLED' """ + + order = self.get_object() + form = self.get_form() + + confirm = str2bool(request.POST.get('confirm', False)) + + valid = False + + if not confirm: + form.errors['confirm'] = [_('Confirm order cancellation')] + else: + valid = True + + data = { + 'form_valid': valid + } + + if valid: + order.cancel_order() + + return self.renderJsonResponse(request, form, data) + + class PurchaseOrderIssue(AjaxUpdateView): """ View for changing a purchase order from 'PENDING' to 'ISSUED' """ From 8eaff6a353000222dfbfc1224050f308eb82af50 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 22 Sep 2019 21:37:04 +1000 Subject: [PATCH 08/11] Add wrapper function around bootstrapTable --- .../static/script/inventree/inventree.js | 10 ++++++-- .../static/script/inventree/tables.js | 25 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/inventree.js b/InvenTree/InvenTree/static/script/inventree/inventree.js index 390aba92ab..90dbacbe35 100644 --- a/InvenTree/InvenTree/static/script/inventree/inventree.js +++ b/InvenTree/InvenTree/static/script/inventree/inventree.js @@ -147,14 +147,20 @@ function inventreeSave(name, value) { localStorage.setItem(key, value); } -function inventreeLoad(name) { +function inventreeLoad(name, defaultValue) { /* * Retrieve a key:value pair from local storage */ var key = "inventree-" + name; - return localStorage.getItem(key); + var value = localStorage.getItem(key); + + if (value == null) { + return defaultValue; + } else { + return value; + } } function inventreeLoadInt(name) { diff --git a/InvenTree/InvenTree/static/script/inventree/tables.js b/InvenTree/InvenTree/static/script/inventree/tables.js index 59bc446d5e..8e9d3ccf84 100644 --- a/InvenTree/InvenTree/static/script/inventree/tables.js +++ b/InvenTree/InvenTree/static/script/inventree/tables.js @@ -44,6 +44,31 @@ function isNumeric(n) { } +/* Wrapper function for bootstrapTable. + * Sets some useful defaults, and manage persistent settings. + */ + +function inventreeTable(table, options) { + + var tableName = options.name || 'table'; + + var varName = tableName + '-pagesize'; + + options.pagination = true; + options.pageSize = inventreeLoad(varName, 25); + options.pageList = [25, 50, 100, 250, 'all']; + options.rememberOrder = true; + options.sortable = true; + options.search = true; + + options.onPageChange = function(number, size) { + inventreeSave(varName, size); + }; + + // Standard options for all tables + $(table).bootstrapTable(options); +} + function customGroupSorter(sortName, sortOrder, sortData) { console.log('got here'); From df41fafefb7839278f6ebdea7a0504876154e077 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 22 Sep 2019 21:42:51 +1000 Subject: [PATCH 09/11] Update page table --- InvenTree/InvenTree/static/script/inventree/part.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/part.js b/InvenTree/InvenTree/static/script/inventree/part.js index 16eec9e293..ec4b77eead 100644 --- a/InvenTree/InvenTree/static/script/inventree/part.js +++ b/InvenTree/InvenTree/static/script/inventree/part.js @@ -191,16 +191,10 @@ function loadPartTable(table, url, options={}) { } }); - $(table).bootstrapTable({ + inventreeTable(table, { url: url, - sortable: true, - search: true, sortName: 'name', method: 'get', - pagination: true, - pageSize: 50, - pageList: [25, 50, 100, 'all'], - rememberOrder: true, formatNoMatches: function() { return "No parts found"; }, queryParams: function(p) { return query; From 2046c126008bebc72f5df141e7321798da1757f9 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 22 Sep 2019 21:56:57 +1000 Subject: [PATCH 10/11] Use a jQuerified function --- InvenTree/InvenTree/static/script/inventree/part.js | 2 +- InvenTree/InvenTree/static/script/inventree/tables.js | 5 ++--- InvenTree/build/templates/build/index.html | 4 +--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/part.js b/InvenTree/InvenTree/static/script/inventree/part.js index ec4b77eead..0904c22a0d 100644 --- a/InvenTree/InvenTree/static/script/inventree/part.js +++ b/InvenTree/InvenTree/static/script/inventree/part.js @@ -191,7 +191,7 @@ function loadPartTable(table, url, options={}) { } }); - inventreeTable(table, { + $(table).inventreeTable({ url: url, sortName: 'name', method: 'get', diff --git a/InvenTree/InvenTree/static/script/inventree/tables.js b/InvenTree/InvenTree/static/script/inventree/tables.js index 8e9d3ccf84..4a129132e0 100644 --- a/InvenTree/InvenTree/static/script/inventree/tables.js +++ b/InvenTree/InvenTree/static/script/inventree/tables.js @@ -47,8 +47,7 @@ function isNumeric(n) { /* Wrapper function for bootstrapTable. * Sets some useful defaults, and manage persistent settings. */ - -function inventreeTable(table, options) { +$.fn.inventreeTable = function(options) { var tableName = options.name || 'table'; @@ -66,7 +65,7 @@ function inventreeTable(table, options) { }; // Standard options for all tables - $(table).bootstrapTable(options); + this.bootstrapTable(options); } function customGroupSorter(sortName, sortOrder, sortData) { diff --git a/InvenTree/build/templates/build/index.html b/InvenTree/build/templates/build/index.html index 3c9eda3544..fb75d0586a 100644 --- a/InvenTree/build/templates/build/index.html +++ b/InvenTree/build/templates/build/index.html @@ -44,9 +44,7 @@ InvenTree | Build List }); }); - $(".build-table").bootstrapTable({ - sortable: true, - search: true, + $(".build-table").inventreeTable({ formatNoMatches: function() { return 'No builds found'; }, columns: [ { From ae2e2f36e4615d5b528e6b25220af73f26ef6f42 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 22 Sep 2019 22:18:53 +1000 Subject: [PATCH 11/11] Update a bunch more tables --- .../InvenTree/static/script/inventree/stock.js | 17 ++++------------- .../InvenTree/static/script/inventree/tables.js | 1 + InvenTree/build/templates/build/allocate.html | 4 +--- .../company/templates/company/detail_part.html | 7 +------ .../company/detail_purchase_orders.html | 4 +--- InvenTree/company/templates/company/index.html | 7 +------ InvenTree/order/templates/order/po_table.html | 2 +- .../templates/order/purchase_order_detail.html | 4 +--- .../order/templates/order/purchase_orders.html | 3 +-- InvenTree/part/templates/part/allocation.html | 4 +--- InvenTree/part/templates/part/attachments.html | 4 +--- InvenTree/part/templates/part/build.html | 7 +------ InvenTree/part/templates/part/orders.html | 4 +--- InvenTree/part/templates/part/params.html | 4 +--- InvenTree/part/templates/part/supplier.html | 4 +--- InvenTree/part/templates/part/used_in.html | 4 +--- InvenTree/part/templates/part/variants.html | 4 +--- InvenTree/templates/InvenTree/search.html | 16 ++++------------ .../templates/InvenTree/settings/currency.html | 7 +------ .../templates/InvenTree/settings/part.html | 7 +------ 20 files changed, 26 insertions(+), 88 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/stock.js b/InvenTree/InvenTree/static/script/inventree/stock.js index 589969faaf..e4582e879e 100644 --- a/InvenTree/InvenTree/static/script/inventree/stock.js +++ b/InvenTree/InvenTree/static/script/inventree/stock.js @@ -42,14 +42,10 @@ function loadStockTable(table, options) { var params = options.params || {}; - table.bootstrapTable({ - sortable: true, - search: true, + console.log('load stock table'); + + table.inventreeTable({ method: 'get', - pagination: true, - pageSize: 50, - pageList: [25, 50, 100, 'all'], - rememberOrder: true, formatNoMatches: function() { return 'No stock items matching query'; }, @@ -387,15 +383,10 @@ function loadStockTrackingTable(table, options) { } }); - table.bootstrapTable({ - sortable: true, - search: true, + table.inventreeTable({ method: 'get', - rememberOrder: true, queryParams: options.params, columns: cols, - pagination: true, - pageSize: 50, url: options.url, }); diff --git a/InvenTree/InvenTree/static/script/inventree/tables.js b/InvenTree/InvenTree/static/script/inventree/tables.js index 4a129132e0..3b2279e18e 100644 --- a/InvenTree/InvenTree/static/script/inventree/tables.js +++ b/InvenTree/InvenTree/static/script/inventree/tables.js @@ -60,6 +60,7 @@ $.fn.inventreeTable = function(options) { options.sortable = true; options.search = true; + // Callback to save pagination data options.onPageChange = function(number, size) { inventreeSave(varName, size); }; diff --git a/InvenTree/build/templates/build/allocate.html b/InvenTree/build/templates/build/allocate.html index 3471b1283a..3e67c65145 100644 --- a/InvenTree/build/templates/build/allocate.html +++ b/InvenTree/build/templates/build/allocate.html @@ -62,9 +62,7 @@ InvenTree | Allocate Parts {% else %} - $("#build-list").bootstrapTable({ - search: true, - sortable: true, + $("#build-list").inventreeTable({ }); $("#btn-allocate").click(function() { diff --git a/InvenTree/company/templates/company/detail_part.html b/InvenTree/company/templates/company/detail_part.html index 3a24140464..16d564a9db 100644 --- a/InvenTree/company/templates/company/detail_part.html +++ b/InvenTree/company/templates/company/detail_part.html @@ -45,12 +45,7 @@ }); }); - $("#part-table").bootstrapTable({ - sortable: true, - search: true, - pagination: true, - pageSize: 50, - pageList: [25, 50, 100, 'all'], + $("#part-table").inventreeTable({ formatNoMatches: function() { return "No supplier parts found for {{ company.name }}"; }, queryParams: function(p) { return { diff --git a/InvenTree/company/templates/company/detail_purchase_orders.html b/InvenTree/company/templates/company/detail_purchase_orders.html index 077a107848..8c299cbd4e 100644 --- a/InvenTree/company/templates/company/detail_purchase_orders.html +++ b/InvenTree/company/templates/company/detail_purchase_orders.html @@ -42,9 +42,7 @@ newOrder(); }); - $("#po-table").bootstrapTable({ - search: true, - sortable: true, + $(".po-table").inventreeTable({ }); {% endblock %} diff --git a/InvenTree/company/templates/company/index.html b/InvenTree/company/templates/company/index.html index c77c705ad5..711ed8eb37 100644 --- a/InvenTree/company/templates/company/index.html +++ b/InvenTree/company/templates/company/index.html @@ -32,12 +32,7 @@ InvenTree | Supplier List }); }); - $("#company-table").bootstrapTable({ - sortable: true, - search: true, - pagination: true, - pageSize: 50, - pageList: [25, 50, 100, 'all'], + $("#company-table").inventreeTable({ formatNoMatches: function() { return "No company information found"; }, columns: [ { diff --git a/InvenTree/order/templates/order/po_table.html b/InvenTree/order/templates/order/po_table.html index 16fa462951..0fe41e8efa 100644 --- a/InvenTree/order/templates/order/po_table.html +++ b/InvenTree/order/templates/order/po_table.html @@ -1,4 +1,4 @@ - +
diff --git a/InvenTree/order/templates/order/purchase_order_detail.html b/InvenTree/order/templates/order/purchase_order_detail.html index 29336b18db..83bd526a96 100644 --- a/InvenTree/order/templates/order/purchase_order_detail.html +++ b/InvenTree/order/templates/order/purchase_order_detail.html @@ -221,9 +221,7 @@ $('#new-po-line').click(function() { }); {% endif %} -$("#po-lines-table").bootstrapTable({ - search: true, - sortable: true, +$("#po-lines-table").inventreeTable({ }); diff --git a/InvenTree/order/templates/order/purchase_orders.html b/InvenTree/order/templates/order/purchase_orders.html index 0e93c6d900..6e6e45cdfd 100644 --- a/InvenTree/order/templates/order/purchase_orders.html +++ b/InvenTree/order/templates/order/purchase_orders.html @@ -32,8 +32,7 @@ $("#po-create").click(function() { ); }); -$("#po-table").bootstrapTable({ - search: true, +$("#po-table").inventreeTable({ }); {% endblock %} \ No newline at end of file diff --git a/InvenTree/part/templates/part/allocation.html b/InvenTree/part/templates/part/allocation.html index 807251a0d1..21c3413ea0 100644 --- a/InvenTree/part/templates/part/allocation.html +++ b/InvenTree/part/templates/part/allocation.html @@ -29,9 +29,7 @@ {% block js_ready %} - $("#build-table").bootstrapTable({ - search: true, - sortable: true, + $("#build-table").inventreeTable({ columns: [ { title: 'Build', diff --git a/InvenTree/part/templates/part/attachments.html b/InvenTree/part/templates/part/attachments.html index c31db94c3e..1f35535fcd 100644 --- a/InvenTree/part/templates/part/attachments.html +++ b/InvenTree/part/templates/part/attachments.html @@ -89,9 +89,7 @@ }); }); - $("#attachment-table").bootstrapTable({ - search: true, - sortable: true, + $("#attachment-table").inventreeTable({ }); {% endblock %} \ No newline at end of file diff --git a/InvenTree/part/templates/part/build.html b/InvenTree/part/templates/part/build.html index d6510e5123..6f44aded08 100644 --- a/InvenTree/part/templates/part/build.html +++ b/InvenTree/part/templates/part/build.html @@ -31,12 +31,7 @@ }); }); - $("#build-table").bootstrapTable({ - sortable: true, - search: true, - pagination: true, - pageSize: 50, - pageList: [25, 50, 100, 'all'], + $("#build-table").inventreeTable({ queryParams: function(p) { return { part: {{ part.id }}, diff --git a/InvenTree/part/templates/part/orders.html b/InvenTree/part/templates/part/orders.html index d3488bea2d..b3f84735f3 100644 --- a/InvenTree/part/templates/part/orders.html +++ b/InvenTree/part/templates/part/orders.html @@ -26,9 +26,7 @@ {% block js_ready %} {{ block.super }} -$("#po-table").bootstrapTable({ - search: true, - sortable: true, +$("#po-table").inventreeTable({ }); $("#part-order2").click(function() { diff --git a/InvenTree/part/templates/part/params.html b/InvenTree/part/templates/part/params.html index 1ccb9d4da6..f1d575d2b7 100644 --- a/InvenTree/part/templates/part/params.html +++ b/InvenTree/part/templates/part/params.html @@ -44,9 +44,7 @@ {% block js_ready %} {{ block.super }} - $('#param-table').bootstrapTable({ - search: true, - sortable: true, + $('#param-table').inventreeTable({ }); $('#param-create').click(function() { diff --git a/InvenTree/part/templates/part/supplier.html b/InvenTree/part/templates/part/supplier.html index 35593f3fdc..8d21f6417c 100644 --- a/InvenTree/part/templates/part/supplier.html +++ b/InvenTree/part/templates/part/supplier.html @@ -50,9 +50,7 @@ }); }); - $("#supplier-table").bootstrapTable({ - sortable: true, - search: true, + $("#supplier-table").inventreeTable({ formatNoMatches: function() { return "No supplier parts available for {{ part.full_name }}"; }, queryParams: function(p) { return { diff --git a/InvenTree/part/templates/part/used_in.html b/InvenTree/part/templates/part/used_in.html index 665d7ed58f..872288723e 100644 --- a/InvenTree/part/templates/part/used_in.html +++ b/InvenTree/part/templates/part/used_in.html @@ -16,9 +16,7 @@ {% block js_ready %} {{ block.super }} - $("#used-table").bootstrapTable({ - sortable: true, - search: true, + $("#used-table").inventreeTable({ formatNoMatches: function() { return "{{ part.full_name }} is not used to make any other parts"; }, queryParams: function(p) { return { diff --git a/InvenTree/part/templates/part/variants.html b/InvenTree/part/templates/part/variants.html index fd55029ba5..725a7ba9b4 100644 --- a/InvenTree/part/templates/part/variants.html +++ b/InvenTree/part/templates/part/variants.html @@ -53,9 +53,7 @@ {{ block.super }} - $('#variant-table').bootstrapTable({ - search: true, - sortable: true, + $('#variant-table').inventreeTable({ }); $('#new-variant').click(function() { diff --git a/InvenTree/templates/InvenTree/search.html b/InvenTree/templates/InvenTree/search.html index 97285ddfd5..fef14b6712 100644 --- a/InvenTree/templates/InvenTree/search.html +++ b/InvenTree/templates/InvenTree/search.html @@ -83,7 +83,7 @@ InvenTree | Search Results onSearchResults('#supplier-part-results-table', '#supplier-part-result-count'); - $("#category-results-table").bootstrapTable({ + $("#category-results-table").inventreeTable({ url: "{% url 'api-part-category-list' %}", queryParams: { search: "{{ query }}", @@ -103,7 +103,7 @@ InvenTree | Search Results ], }); - $("#location-results-table").bootstrapTable({ + $("#location-results-table").inventreeTable({ url: "{% url 'api-location-list' %}", queryParams: { search: "{{ query }}", @@ -134,15 +134,11 @@ InvenTree | Search Results } ); - $("#company-results-table").bootstrapTable({ + $("#company-results-table").inventreeTable({ url: "{% url 'api-company-list' %}", queryParams: { search: "{{ query }}", }, - pagination: true, - pageSize: 50, - pageList: [25, 50, 100, 'all'], - search: true, columns: [ { field: 'name', @@ -158,15 +154,11 @@ InvenTree | Search Results ] }); - $("#supplier-part-results-table").bootstrapTable({ + $("#supplier-part-results-table").inventreeTable({ url: "{% url 'api-part-supplier-list' %}", queryParams: { search: "{{ query }}", }, - pagination: true, - pageSize: 50, - pageList: [25, 50, 100, 'all'], - search: true, columns: [ { field: 'supplier_name', diff --git a/InvenTree/templates/InvenTree/settings/currency.html b/InvenTree/templates/InvenTree/settings/currency.html index dcdafb72ac..4eb9420f05 100644 --- a/InvenTree/templates/InvenTree/settings/currency.html +++ b/InvenTree/templates/InvenTree/settings/currency.html @@ -19,16 +19,11 @@ {% block js_ready %} {{ block.super }} - $("#currency-table").bootstrapTable({ + $("#currency-table").inventreeTable({ url: "{% url 'api-currency-list' %}", queryParams: { ordering: 'suffix' }, - sortable: true, - search: true, - pagination: true, - pageSize: 50, - pageList: [25, 50, 100, 'all'], formatNoMatches: function() { return "No currencies found"; }, rowStyle: function(row, index) { if (row.base) { diff --git a/InvenTree/templates/InvenTree/settings/part.html b/InvenTree/templates/InvenTree/settings/part.html index 5f624063c1..2bbfaf2b03 100644 --- a/InvenTree/templates/InvenTree/settings/part.html +++ b/InvenTree/templates/InvenTree/settings/part.html @@ -19,16 +19,11 @@ {% block js_ready %} {{ block.super }} - $("#param-table").bootstrapTable({ + $("#param-table").inventreeTable({ url: "{% url 'api-part-param-template-list' %}", queryParams: { ordering: 'name', }, - sortable: true, - search: true, - pagination: true, - pageSize: 50, - pageList: [25, 50, 100, 'all'], formatNoMatches: function() { return "No part parameter templates found"; }, columns: [ {
Company