mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Sliders now update the part options via AJAX
This commit is contained in:
parent
65a8a30f87
commit
1d67b4cdaa
@ -100,8 +100,10 @@ class PartSerializer(InvenTreeModelSerializer):
|
||||
'assembly',
|
||||
'component',
|
||||
'trackable',
|
||||
'purchaseable',
|
||||
'salable',
|
||||
'active',
|
||||
'virtual',
|
||||
]
|
||||
|
||||
|
||||
|
@ -13,16 +13,16 @@
|
||||
<span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
{% if part.active %}
|
||||
<li><a href="#" id='edit-part' title='Edit part'>Edit</a></li>
|
||||
<li><a href="#" field='edit-part' title='Edit part'>Edit</a></li>
|
||||
{% if part.purchaseable %}
|
||||
<li><a href='#' id='order-part' title='Order part'>Order</a></li>
|
||||
<li><a href='#' field='order-part' title='Order part'>Order</a></li>
|
||||
{% endif %}
|
||||
<li><a href='#' id='duplicate-part' title='Duplicate Part'>Duplicate</a></li>
|
||||
<li><a href='#' field='duplicate-part' title='Duplicate Part'>Duplicate</a></li>
|
||||
<hr>
|
||||
<li><a href="#" id='deactivate-part' title='Deactivate part'>Deactivate</a></li>
|
||||
<li><a href="#" field='deactivate-part' title='Deactivate part'>Deactivate</a></li>
|
||||
{% else %}
|
||||
<li><a href="#" id='activate-part' title='Activate part'>Activate</a></li>
|
||||
<li><a href='#' id='delete-part' title='Delete part'>Delete</a></li>
|
||||
<li><a href="#" field='activate-part' title='Activate part'>Activate</a></li>
|
||||
<li><a href='#' field='delete-part' title='Delete part'>Delete</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
@ -102,40 +102,59 @@
|
||||
<div class='col-sm-6'>
|
||||
<h4>Part Type</h4>
|
||||
<table class='table table-striped'>
|
||||
<tr>
|
||||
<td><b>Template</b></td>
|
||||
<td>{% include "slide.html" with state=part.is_template %}</td>
|
||||
<td><i>Part is used as a template for other parts</i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Virtual</b></td>
|
||||
<td>{% include "slide.html" with state=part.virtual %}</td>
|
||||
<td><i>Part is virtual (not a physical part)</i></td>
|
||||
<td>{% include "slide.html" with state=part.virtual field='virtual' %}</td>
|
||||
{% if part.virtual %}
|
||||
<td>Part is virtual (not a physical part)</td>
|
||||
{% else %}
|
||||
<td><i>Part is not a virtual part</i></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Assembly</b></td>
|
||||
<td>{% include "slide.html" with state=part.assembly %}</td>
|
||||
<td><i>Part can be assembled from other parts</i></td>
|
||||
<td>{% include "slide.html" with state=part.assembly field='assembly' %}</td>
|
||||
{% if part.assembly %}
|
||||
<td>Part can be assembled from other parts</td>
|
||||
{% else %}
|
||||
<td><i>Part cannot be assembled from other parts</i></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Component</b></td>
|
||||
<td>{% include "slide.html" with state=part.component %}</td>
|
||||
<td><i>Part can be used in assemblies</i></td>
|
||||
<td>{% include "slide.html" with state=part.component field='component' %}</td>
|
||||
{% if part.component %}
|
||||
<td>Part can be used in assemblies</td>
|
||||
{% else %}
|
||||
<td><i>Part cannot be used in assemblies</i></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Trackable</b></td>
|
||||
<td>{% include "slide.html" with state=part.trackable %}</td>
|
||||
<td><i>Part stock will be tracked by (serial or batch)</i></td>
|
||||
<td>{% include "slide.html" with state=part.trackable field='trackable' %}</td>
|
||||
{% if part.trackable %}
|
||||
<td>Part stock will be tracked by (serial or batch)</td>
|
||||
{% else %}
|
||||
<td><i>Part stock will not be tracked by</i></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Purchaseable</b></td>
|
||||
<td>{% include "slide.html" with state=part.purchaseable %}</td>
|
||||
<td>{% include "slide.html" with state=part.purchaseable field='purchaseable' %}</td>
|
||||
{% if part.purchaseable %}
|
||||
<td><Part can be purchased from external suppliers></td>
|
||||
{% else %}
|
||||
<td><i>Part can be purchased from external suppliers</i></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Sellable</b></td>
|
||||
<td>{% include "slide.html" with state=part.salable %}</td>
|
||||
<td><i>Part can be sold to customers</i></td>
|
||||
<td>{% include "slide.html" with state=part.salable field='salable' %}</td>
|
||||
{% if part.salable %}
|
||||
<td>Part can be sold to customers</td>
|
||||
{% else %}
|
||||
<td><i>Part cannot be sold to customers</i></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@ -156,6 +175,24 @@
|
||||
|
||||
{% block js_ready %}
|
||||
{{ block.super }}
|
||||
|
||||
$(".slidey").change(function() {
|
||||
var field = $(this).attr('field');
|
||||
|
||||
var checked = $(this).prop('checked');
|
||||
|
||||
var data = {};
|
||||
|
||||
data[field] = checked;
|
||||
|
||||
// Update the particular field
|
||||
inventreePut('/api/part/{{ part.id }}/',
|
||||
data,
|
||||
{
|
||||
method: 'PATCH',
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
$("#duplicate-part").click(function() {
|
||||
launchModalForm(
|
||||
|
@ -1,3 +1,3 @@
|
||||
<div>
|
||||
<input type="checkbox" data-onstyle="success" data-size='small' data-toggle="toggle" {% if disabled %}disabled="disabled" {% endif %}{% if state %}checked="checked"{% endif %}>
|
||||
<input field='{{ field }}' class='slidey' type="checkbox" data-onstyle="success" data-size='small' data-toggle="toggle" {% if disabled %}disabled="disabled" {% endif %}{% if state %}checked="checked"{% endif %}>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user