From 024fe04e0e38fcc70bb6da2124939738f6a73dc7 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 2 May 2018 22:18:58 +1000 Subject: [PATCH] Implemented bootstrap-table for parts list --- .../part/templates/part/category_detail.html | 13 ++- .../part/templates/part/category_parts.html | 80 +++++++++++++------ InvenTree/part/templates/part/index.html | 5 +- InvenTree/static/script/tables.js | 14 ++++ InvenTree/templates/base.html | 2 + 5 files changed, 86 insertions(+), 28 deletions(-) create mode 100644 InvenTree/static/script/tables.js diff --git a/InvenTree/part/templates/part/category_detail.html b/InvenTree/part/templates/part/category_detail.html index d7897f8ac8..13b2eadac9 100644 --- a/InvenTree/part/templates/part/category_detail.html +++ b/InvenTree/part/templates/part/category_detail.html @@ -17,8 +17,8 @@ {% endif %} {% if category.has_parts %} -

Parts

-{% include "part/category_parts.html" with parts=category.parts.all %} + +
{% endif %}
@@ -29,6 +29,7 @@ +
{% include 'modals.html' %} @@ -40,7 +41,6 @@ {% endblock %} {% block js_ready %} - $('#part-list').footable(); $("#edit-category").click(function () { launchModalForm("#modal-form", @@ -84,4 +84,11 @@ follow: true }); }); + + {% include "part/category_parts.html" with category=category %} + + $("#get-rows").click( function() { + alert($("#part-table").bootstrapTable('getSelections')); + }); + {% endblock %} \ No newline at end of file diff --git a/InvenTree/part/templates/part/category_parts.html b/InvenTree/part/templates/part/category_parts.html index 94d8af8676..ed87b275ee 100644 --- a/InvenTree/part/templates/part/category_parts.html +++ b/InvenTree/part/templates/part/category_parts.html @@ -1,24 +1,58 @@ - - - - - - - - - - -{% for part in parts %} - - - - - - -{% endfor %} - -
PartDescriptionCategoryStock
{{ part.name }}{{ part.description }} - {% if part.category %} - {{ part.category_path }} + $("#part-table").bootstrapTable({ + sortable: true, + search: true, + sortName: 'description', + idField: 'pk', + method: 'get', + pagination: true, + rememberOrder: true, + {% if category %} + queryParams: function(p) { + return { + category: {{ category.id }}, + } + }, {% endif %} - {{ part.total_stock }}
+ columns: [ + { + checkbox: true, + title: 'Select', + searchable: false, + }, + { + field: 'pk', + title: 'ID', + visible: false, + }, + { + field: 'name', + title: 'Part', + sortable: true, + formatter: function(value, row, index, field) { + return renderLink(value, row.url); + } + }, + { + sortable: true, + field: 'description', + title: 'Description', + }, + {% if category == None %} + { + sortable: true, + field: 'category_name', + title: 'Category', + formatter: function(value, row, index, field) { + return renderLink(value, row.category_url) + } + }, + {% endif %} + { + field: 'total_stock', + title: 'Stock', + searchable: false, + sortable: true, + } + ], + url: 'http://127.0.0.1:8000/api/part/', + }); \ No newline at end of file diff --git a/InvenTree/part/templates/part/index.html b/InvenTree/part/templates/part/index.html index 9265ef52ac..65c4ac0ded 100644 --- a/InvenTree/part/templates/part/index.html +++ b/InvenTree/part/templates/part/index.html @@ -16,8 +16,7 @@ {% include "part/category_subcategories.html" with children=children %} {% endif %} -

Parts

-{% include "part/category_parts.html" with parts=parts %} +