mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Updates to build forms / etc
This commit is contained in:
parent
2df0f03a9a
commit
2e4613e702
@ -134,6 +134,32 @@ function reloadFieldOptions(fieldName, options) {
|
||||
}
|
||||
|
||||
|
||||
function enableField(fieldName, enabled, options={}) {
|
||||
/* Enable (or disable) a particular field in a modal.
|
||||
*
|
||||
* Args:
|
||||
* - fieldName: The name of the field
|
||||
* - enabled: boolean enabled / disabled status
|
||||
* - options:
|
||||
*/
|
||||
|
||||
var modal = options.modal || '#modal-form';
|
||||
|
||||
var field = getFieldByName(modal, fieldName);
|
||||
|
||||
field.prop("disabled", !enabled);
|
||||
}
|
||||
|
||||
function clearField(fieldName, options={}) {
|
||||
|
||||
var modal = options.modal || '#modal-form';
|
||||
|
||||
var field = getFieldByName(modal, fieldName);
|
||||
|
||||
field.val("");
|
||||
}
|
||||
|
||||
|
||||
function partialMatcher(params, data) {
|
||||
/* Replacement function for the 'matcher' parameter for a select2 dropdown.
|
||||
|
||||
|
@ -40,12 +40,7 @@ InvenTree | {% trans "Build Orders" %}
|
||||
$("#collapse-item-active").collapse().show();
|
||||
|
||||
$("#new-build").click(function() {
|
||||
launchModalForm(
|
||||
"{% url 'build-create' %}",
|
||||
{
|
||||
follow: true,
|
||||
}
|
||||
);
|
||||
newBuildOrder();
|
||||
});
|
||||
|
||||
loadBuildTable($("#build-table"), {
|
||||
|
@ -29,12 +29,9 @@
|
||||
{% block js_ready %}
|
||||
{{ block.super }}
|
||||
$("#start-build").click(function() {
|
||||
launchModalForm(
|
||||
"{% url 'build-create' %}",
|
||||
{
|
||||
follow: true,
|
||||
newBuildOrder({
|
||||
data: {
|
||||
part: {{ part.id }}
|
||||
part: {{ part.id }},
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,37 @@
|
||||
{% load i18n %}
|
||||
{% load inventree_extras %}
|
||||
|
||||
function newBuildOrder(options={}) {
|
||||
/* Launch modal form to create a new BuildOrder.
|
||||
*/
|
||||
|
||||
launchModalForm(
|
||||
"{% url 'build-create' %}",
|
||||
{
|
||||
follow: true,
|
||||
data: options.data || {},
|
||||
callback: [
|
||||
{
|
||||
field: 'part',
|
||||
action: function(value) {
|
||||
inventreeGet(
|
||||
`/api/part/${value}/`, {},
|
||||
{
|
||||
success: function(response) {
|
||||
|
||||
//enableField('serial_numbers', response.trackable);
|
||||
//clearField('serial_numbers');
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
function loadBuildTable(table, options) {
|
||||
// Display a table of Build objects
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user