From be0797c6e61b48d3b977f6646c348646a9897bb1 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 2 May 2018 23:17:24 +1000 Subject: [PATCH] Bootstrap table to company list --- InvenTree/company/serializers.py | 2 + .../company/templates/company/index.html | 57 ++++++++++++------- .../part/templates/part/category_parts.html | 2 +- 3 files changed, 40 insertions(+), 21 deletions(-) diff --git a/InvenTree/company/serializers.py b/InvenTree/company/serializers.py index f2f06c607f..bb99f18e75 100644 --- a/InvenTree/company/serializers.py +++ b/InvenTree/company/serializers.py @@ -5,6 +5,8 @@ from .models import Company class CompanySerializer(serializers.HyperlinkedModelSerializer): + url = serializers.CharField(source='get_absolute_url', read_only=True) + class Meta: model = Company fields = '__all__' diff --git a/InvenTree/company/templates/company/index.html b/InvenTree/company/templates/company/index.html index 607c4f1cee..cec745cd20 100644 --- a/InvenTree/company/templates/company/index.html +++ b/InvenTree/company/templates/company/index.html @@ -6,26 +6,7 @@

Companies

- - - - - - - - - - {% for company in companies %} - - - - - {% endfor %} - +
NameDescription
- - {{ company.name }} - - {{ company.description }}
@@ -48,4 +29,40 @@ follow: true }); }); + + $("#company-table").bootstrapTable({ + sortable: true, + search: true, + columns: [ + { + field: 'pk', + title: 'ID', + visible: false, + }, + { + field: 'name', + title: 'Company', + sortable: true, + formatter: function(value, row, index, field) { + return renderLink(value, row.url); + } + }, + { + field: 'description', + title: 'Description', + }, + { + field: 'website', + title: 'Website', + formatter: function(value, row, index, field) { + if (value) { + return renderLink(value, value); + } + return ''; + } + } + ], + url: "{% url 'api-company-list' %}" + }); + {% 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 3a8c272463..f389fee83a 100644 --- a/InvenTree/part/templates/part/category_parts.html +++ b/InvenTree/part/templates/part/category_parts.html @@ -59,5 +59,5 @@ sortable: true, } ], - url: 'http://127.0.0.1:8000/api/part/', + url: "{% url 'api-part-list' %}", }); \ No newline at end of file