mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #974 from SchrodingersGat/toggle-fix
Fix for weird button toggles (it was a doozy!)
This commit is contained in:
commit
eaf87294ce
@ -218,14 +218,13 @@
|
|||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
|
||||||
$(".slidey").change(function() {
|
$(".slidey").change(function() {
|
||||||
var field = $(this).attr('field');
|
var field = $(this).attr('fieldname');
|
||||||
|
|
||||||
var checked = $(this).prop('checked');
|
var checked = $(this).prop('checked');
|
||||||
|
|
||||||
var data = {};
|
var data = {};
|
||||||
|
|
||||||
data[field] = checked;
|
data[field] = checked;
|
||||||
|
|
||||||
// Update the particular field
|
// Update the particular field
|
||||||
inventreePut("{% url 'api-part-detail' part.id %}",
|
inventreePut("{% url 'api-part-detail' part.id %}",
|
||||||
data,
|
data,
|
||||||
@ -235,50 +234,5 @@
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#activate-part').click(function() {
|
|
||||||
showQuestionDialog(
|
|
||||||
'Activate Part?',
|
|
||||||
'Are you sure you wish to reactivate {{ part.full_name }}?',
|
|
||||||
{
|
|
||||||
accept_text: 'Activate',
|
|
||||||
accept: function() {
|
|
||||||
inventreePut(
|
|
||||||
"{% url 'api-part-detail' part.id %}",
|
|
||||||
{
|
|
||||||
active: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
method: 'PATCH',
|
|
||||||
reloadOnSuccess: true,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#deactivate-part').click(function() {
|
|
||||||
showQuestionDialog(
|
|
||||||
'Deactivate Part?',
|
|
||||||
`Are you sure you wish to deactivate {{ part.full_name }}?<br>
|
|
||||||
`,
|
|
||||||
{
|
|
||||||
accept_text: 'Deactivate',
|
|
||||||
accept: function() {
|
|
||||||
inventreePut(
|
|
||||||
"{% url 'api-part-detail' part.id %}",
|
|
||||||
{
|
|
||||||
active: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
method: 'PATCH',
|
|
||||||
reloadOnSuccess: true,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
<div>
|
<div>
|
||||||
<input field='{{ field }}' class='slidey' type="checkbox" data-offstyle='warning' data-onstyle="success" data-size='small' data-toggle="toggle" {% if disabled %}disabled="disabled" {% endif %}{% if state %}checked="checked"{% endif %}>
|
<input fieldname='{{ field }}' class='slidey' type="checkbox" data-offstyle='warning' data-onstyle="success" data-size='small' data-toggle="toggle" {% if disabled %}disabled {% endif %}{% if state %}checked=""{% endif %} autocomplete="off">
|
||||||
</div>
|
</div>
|
Loading…
Reference in New Issue
Block a user