Add audit button to inventory list view
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2024-07-28 13:46:46 +03:00
parent 1e0f81fbb3
commit a60a540408
3 changed files with 60 additions and 3 deletions

View File

@@ -12,6 +12,9 @@
<th>Type</th>
<th>Owner</th>
<th>User</th>
{% if can_audit %}
<th>Audit</th>
{% endif %}
</tr>
</thead>
<tbody>
@@ -30,6 +33,17 @@
<td>{{ item.type }}</td>
<td>{{ item | owner_link}}</td>
<td>{{ item | user_link}}</td>
{% if can_audit %}
<td>
<button
data-item-id="{{ item._id }}"
class="audit-button {{ item.inventory | audit_color }} waves-effect waves-light btn-small"
>
<i class="material-icons left">done</i>{{item.inventory | audit_text}}
</button>
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
@@ -38,4 +52,20 @@
<a class="waves-effect waves-light btn" href="/m/inventory/add">Add item</a>
</p>
</div>
<script>
$('button.audit-button').on('click', function() {
let button = $(this);
$.ajax({
method: 'POST',
url: "/m/inventory/" + button.data('itemId') + "/audit",
data: { noRedirect: true },
success: function() {
button.unbind('click');
button.removeClass(['orange', 'red', 'waves-effect', 'waves-light']);
button.addClass(['unclickable', 'green']);
button.text('Just now');
}
})
});
</script>
{% endblock %}