Skip to content

Commit

Permalink
Refine the implementation of the paginated inventory #3
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <[email protected]>
  • Loading branch information
tdruez committed May 30, 2024
1 parent d172064 commit 8a720b9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
4 changes: 3 additions & 1 deletion product_portfolio/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ class ProductPackageFilterSet(BaseProductRelationFilterSet):
label=_("Search"),
search_fields=[
"package__filename",
"package__type",
"package__namespace",
"package__name",
"package__version",
"license_expression",
Expand Down Expand Up @@ -241,7 +243,7 @@ def do_nothing(queryset, name, value):
return queryset

class Meta:
model = ProductComponent
model = ProductPackage
fields = [
"review_status",
"purpose",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,24 @@

{% if compliance_errors %}
<script>
$('.toggle-details')
.tooltip({container: 'body', placement: 'top'})
.on('click', function() {
$('.extra-details').toggle();
});
// Select all elements with the class 'toggle-details'
document.querySelectorAll('.toggle-details').forEach(function(toggleDetail) {
// Set the title attribute to add a tooltip
toggleDetail.setAttribute('title', 'Your Tooltip Text Here');

// Add event listener for 'click' event
toggleDetail.addEventListener('click', function() {
// Select all elements with the class 'extra-details'
document.querySelectorAll('.extra-details').forEach(function(extraDetail) {
// Toggle the display property
if (extraDetail.style.display === 'none' || extraDetail.style.display === '') {
extraDetail.style.display = 'table-row';
} else {
extraDetail.style.display = 'none';
}
});
});
});

const tabInventoryLabel = document.getElementById('tab_inventory-tab');
if (tabInventoryLabel) {
Expand Down
5 changes: 1 addition & 4 deletions product_portfolio/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,7 @@ def get_context_data(self, **kwargs):
user = self.request.user
dataspace = user.dataspace

productcomponents_count = self.object.productcomponents.count()
productpackages_count = self.object.productpackages.count()
context["inventory_count"] = productcomponents_count + productpackages_count
context["inventory_count"] = self.object.productinventoryitem_set.count()

filter_productpackage = ProductPackageFilterSet(
self.request.GET,
Expand All @@ -627,7 +625,6 @@ def get_context_data(self, **kwargs):

productcomponent_qs = filter_productcomponent.qs.order_by(
"feature",
"component",
"component__name",
"component__version",
"name",
Expand Down

0 comments on commit 8a720b9

Please sign in to comment.