2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 21:45:39 +00:00

Refactor display toggle for part list and part category list

This commit is contained in:
Oliver
2021-10-30 12:45:07 +11:00
parent 3bd59728db
commit be23634c5d
3 changed files with 142 additions and 103 deletions

View File

@ -146,13 +146,6 @@
<li><a class='dropdown-item' href='#' id='multi-part-export' title='{% trans "Export" %}'>{% trans "Export Data" %}</a></li>
</ul>
</div>
<!-- Buttons to toggle between grid and table view -->
<button id='view-list' class='btn btn-outline-secondary' type='button' title='{% trans "View list display" %}'>
<span class='fas fa-th-list'></span>
</button>
<button id='view-grid' class='btn btn-outline-secondary' type='button' title='{% trans "View grid display" %}'>
<span class='fas fa-th'></span>
</button>
<div class='filter-list' id='filter-list-parts'>
<!-- Empty div -->
</div>
@ -181,15 +174,6 @@
<div class='panel-content'>
<div id='subcategory-button-toolbar'>
<div class='btn-group' role='group'>
<!-- Buttons to toggle between tree and table view -->
<button id='view-cat-list' class='btn btn-outline-secondary' type='button' title='{% trans "View list display" %}'>
<span class='fas fa-th-list'></span>
</button>
<button id='view-cat-tree' class='btn btn-outline-secondary' type='button' title='{% trans "View tree display" %}'>
<span class='fas fa-sitemap'></span>
</button>
<div class='filter-list' id='filter-list-category'>
<!-- An empty div in which the filter list will be constructed -->
</div>
@ -222,65 +206,17 @@
enableSidebar('category');
// Callback to view the category table in "list" mode
$('#view-cat-list').click(function() {
$('#view-cat-list').hide();
$('#view-cat-tree').show();
inventreeSave('category-tree-view', '');
loadPartCategoryTable($('#subcategory-table'), {
loadPartCategoryTable(
$('#subcategory-table'), {
params: {
{% if category %}
parent: {{ category.pk }}
parent: {{ category.pk }},
{% else %}
parent: 'null'
parent: null,
{% endif %}
},
tree_view: false,
});
$('#subcategory-table').bootstrapTable('resetView');
});
// Callback to view the category table in "tree" mode
$('#view-cat-tree').click(function() {
$('#view-cat-list').show();
$('#view-cat-tree').hide();
inventreeSave('category-tree-view', 1);
loadPartCategoryTable($('#subcategory-table'), {
params: {
{% if category %}
parent: {{ category.pk }}
{% else %}
parent: 'null'
{% endif %}
},
tree_view: true,
});
$('#subcategory-table').bootstrapTable('resetView');
});
// Callback to view the part table in "list" mode
$('#view-list').click(function() {
$('#view-list').hide();
$('#view-grid').show();
$('#part-table').bootstrapTable('toggleCustomView');
inventreeSave('part-grid-view', '');
});
// Callback to view the part table in "grid" mode
$('#view-grid').click(function() {
$('#view-grid').hide();
$('#view-list').show();
$('#part-table').bootstrapTable('toggleCustomView');
inventreeSave('part-grid-view', 1);
});
}
}
);
$("#cat-create").click(function() {
@ -368,33 +304,4 @@
},
);
if (inventreeLoad("part-grid-view")) {
$('#view-grid').hide();
$('#part-table').bootstrapTable('toggleCustomView');
} else {
$('#view-list').hide();
}
var tree_view = false;
if (inventreeLoad('category-tree-view')) {
$('#view-cat-tree').hide();
tree_view = true;
} else {
$('#view-cat-list').hide();
}
loadPartCategoryTable($('#subcategory-table'), {
params: {
{% if category %}
parent: {{ category.pk }}
{% else %}
parent: 'null'
{% endif %}
},
tree_view: tree_view
});
{% endblock %}