mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Initialize related field for "part" selection
This commit is contained in:
parent
8a8d718534
commit
8a86932c7b
@ -50,6 +50,13 @@ function constructBomUploadTable(data, options={}) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
var buttons = `<div class='btn-group float-right' role='group'>`;
|
||||||
|
|
||||||
|
buttons += makeIconButton('fa-file-alt', 'button-row-data', idx, '{% trans "Display row data" %}');
|
||||||
|
buttons += makeIconButton('fa-times icon-red', 'button-row-remove', idx, '{% trans "Remove row" %}');
|
||||||
|
|
||||||
|
buttons += `</div>`;
|
||||||
|
|
||||||
var html = `
|
var html = `
|
||||||
<tr id='bom_import_row_${idx}' class='bom-import-row'>
|
<tr id='bom_import_row_${idx}' class='bom-import-row'>
|
||||||
<td id='col_part_${idx}'>${part_input}</td>
|
<td id='col_part_${idx}'>${part_input}</td>
|
||||||
@ -60,6 +67,7 @@ function constructBomUploadTable(data, options={}) {
|
|||||||
<td id='col_inherited_${idx}'>inherited</td>
|
<td id='col_inherited_${idx}'>inherited</td>
|
||||||
<td id='col_optional_${idx}'>optional</td>
|
<td id='col_optional_${idx}'>optional</td>
|
||||||
<td id='col_note_${idx}'>note</td>
|
<td id='col_note_${idx}'>note</td>
|
||||||
|
<td id='col_buttons_${idx}'>${buttons}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
|
|
||||||
$('#bom-import-table tbody').append(html);
|
$('#bom-import-table tbody').append(html);
|
||||||
@ -68,6 +76,7 @@ function constructBomUploadTable(data, options={}) {
|
|||||||
initializeRelatedField(
|
initializeRelatedField(
|
||||||
{
|
{
|
||||||
name: `part_${idx}`,
|
name: `part_${idx}`,
|
||||||
|
value: row.part,
|
||||||
api_url: '{% url "api-part-list" %}',
|
api_url: '{% url "api-part-list" %}',
|
||||||
filters: {
|
filters: {
|
||||||
component: true,
|
component: true,
|
||||||
|
@ -1484,10 +1484,19 @@ function initializeRelatedField(field, fields, options={}) {
|
|||||||
// limit size for AJAX requests
|
// limit size for AJAX requests
|
||||||
var pageSize = options.pageSize || 25;
|
var pageSize = options.pageSize || 25;
|
||||||
|
|
||||||
|
var parent = null;
|
||||||
|
var auto_width = true;
|
||||||
|
|
||||||
|
// Special considerations if the select2 input is a child of a modal
|
||||||
|
if (options && options.modal) {
|
||||||
|
parent = $(options.modal);
|
||||||
|
auto_width = true;
|
||||||
|
}
|
||||||
|
|
||||||
select.select2({
|
select.select2({
|
||||||
placeholder: '',
|
placeholder: '',
|
||||||
dropdownParent: $(options.modal),
|
dropdownParent: parent,
|
||||||
dropdownAutoWidth: false,
|
dropdownAutoWidth: auto_width,
|
||||||
language: {
|
language: {
|
||||||
noResults: function(query) {
|
noResults: function(query) {
|
||||||
if (field.noResults) {
|
if (field.noResults) {
|
||||||
|
Loading…
Reference in New Issue
Block a user