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',
|
'assembly',
|
||||||
'component',
|
'component',
|
||||||
'trackable',
|
'trackable',
|
||||||
|
'purchaseable',
|
||||||
'salable',
|
'salable',
|
||||||
'active',
|
'active',
|
||||||
|
'virtual',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,16 +13,16 @@
|
|||||||
<span class="caret"></span></button>
|
<span class="caret"></span></button>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
{% if part.active %}
|
{% 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 %}
|
{% 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 %}
|
{% 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>
|
<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 %}
|
{% else %}
|
||||||
<li><a href="#" id='activate-part' title='Activate part'>Activate</a></li>
|
<li><a href="#" field='activate-part' title='Activate part'>Activate</a></li>
|
||||||
<li><a href='#' id='delete-part' title='Delete part'>Delete</a></li>
|
<li><a href='#' field='delete-part' title='Delete part'>Delete</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@ -102,40 +102,59 @@
|
|||||||
<div class='col-sm-6'>
|
<div class='col-sm-6'>
|
||||||
<h4>Part Type</h4>
|
<h4>Part Type</h4>
|
||||||
<table class='table table-striped'>
|
<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>
|
<tr>
|
||||||
<td><b>Virtual</b></td>
|
<td><b>Virtual</b></td>
|
||||||
<td>{% include "slide.html" with state=part.virtual %}</td>
|
<td>{% include "slide.html" with state=part.virtual field='virtual' %}</td>
|
||||||
<td><i>Part is virtual (not a physical part)</i></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>
|
||||||
<tr>
|
<tr>
|
||||||
<td><b>Assembly</b></td>
|
<td><b>Assembly</b></td>
|
||||||
<td>{% include "slide.html" with state=part.assembly %}</td>
|
<td>{% include "slide.html" with state=part.assembly field='assembly' %}</td>
|
||||||
<td><i>Part can be assembled from other parts</i></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>
|
||||||
<tr>
|
<tr>
|
||||||
<td><b>Component</b></td>
|
<td><b>Component</b></td>
|
||||||
<td>{% include "slide.html" with state=part.component %}</td>
|
<td>{% include "slide.html" with state=part.component field='component' %}</td>
|
||||||
<td><i>Part can be used in assemblies</i></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>
|
||||||
<tr>
|
<tr>
|
||||||
<td><b>Trackable</b></td>
|
<td><b>Trackable</b></td>
|
||||||
<td>{% include "slide.html" with state=part.trackable %}</td>
|
<td>{% include "slide.html" with state=part.trackable field='trackable' %}</td>
|
||||||
<td><i>Part stock will be tracked by (serial or batch)</i></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>
|
||||||
<tr>
|
<tr>
|
||||||
<td><b>Purchaseable</b></td>
|
<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>
|
<td><i>Part can be purchased from external suppliers</i></td>
|
||||||
|
{% endif %}
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><b>Sellable</b></td>
|
<td><b>Sellable</b></td>
|
||||||
<td>{% include "slide.html" with state=part.salable %}</td>
|
<td>{% include "slide.html" with state=part.salable field='salable' %}</td>
|
||||||
<td><i>Part can be sold to customers</i></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>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -157,6 +176,24 @@
|
|||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
{{ block.super }}
|
{{ 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() {
|
$("#duplicate-part").click(function() {
|
||||||
launchModalForm(
|
launchModalForm(
|
||||||
"{% url 'part-duplicate' part.id %}",
|
"{% url 'part-duplicate' part.id %}",
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
<div>
|
<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>
|
</div>
|
Loading…
Reference in New Issue
Block a user