2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-14 23:51:08 +00:00

Ability to toggle part category "star" status via the API

This commit is contained in:
Oliver
2021-11-04 00:01:52 +11:00
parent 193d6b334c
commit 1c6eb41341
8 changed files with 88 additions and 26 deletions

View File

@@ -20,15 +20,37 @@
{% include "admin_button.html" with url=url %}
{% endif %}
{% if category %}
{% if roles.part_category.change %}
<button class='btn btn-outline-secondary' id='cat-edit' title='{% trans "Edit part category" %}'>
<span class='fas fa-edit'/>
{% if starred_directly %}
<button type='button' class='btn btn-outline-secondary' id='toggle-starred' title='{% trans "You are subscribed to notifications for this category" %}'>
<span id='category-star-icon' class='fas fa-bell icon-green'></span>
</button>
{% elif starred %}
<button type='button' class='btn btn-outline-secondary' title='{% trans "You are subscribed to notifications for this category" %}' disabled='true'>
<span class='fas fa-bell icon-green'></span>
</button>
{% else %}
<button type='button' class='btn btn-outline-secondary' id='toggle-starred' title='{% trans "Subscribe to nofications for this category" %}'>
<span id='category-star-icon' class='fa fa-bell-slash'/>
</button>
{% endif %}
{% if roles.part_category.delete %}
<button class='btn btn-outline-secondary' id='cat-delete' title='{% trans "Delete part category" %}'>
<span class='fas fa-trash-alt icon-red'/>
</button>
{% if roles.part_category.change or roles.part_category.delete %}
<div class='btn-group' role='group'>
<button id='category-options' class='btn btn-outline-secondary dropdown-toggle' type='button' data-bs-toggle='dropdown' title='{% trans "Category Actions" %}'>
<span class='fas fa-tools'></span> <span class='caret'></span>
</button>
<ul class='dropdown-menu'>
{% if roles.part_category.change %}
<li><a class='dropdown-item' href='#' id='cat-edit' title='{% trans "Edit category" %}'>
<span class='fas fa-edit icon-green'></span> {% trans "Edit Category" %}
</a></li>
{% endif %}
{% if roles.part_category.delete %}
<li><a class='dropdown-item' href='#' id='cat-delete' title='{% trans "Delete category" %}'>
<span class='fas fa-trash-alt icon-red'></span> {% trans "Delete Category" %}
</a></li>
{% endif %}
</ul>
</div>
{% endif %}
{% endif %}
{% if roles.part_category.add %}
@@ -198,6 +220,14 @@
data: {{ parameters|safe }},
}
);
$("#toggle-starred").click(function() {
toggleStar({
url: '{% url "api-part-category-detail" category.pk %}',
button: '#category-star-icon'
});
});
{% endif %}
enableSidebar('category');

View File

@@ -320,7 +320,7 @@
$("#toggle-starred").click(function() {
toggleStar({
part: {{ part.id }},
url: '{% url "api-part-detail" part.pk %}',
button: '#part-star-icon',
});
});