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 = `
|
||||
<tr id='bom_import_row_${idx}' class='bom-import-row'>
|
||||
<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_optional_${idx}'>optional</td>
|
||||
<td id='col_note_${idx}'>note</td>
|
||||
<td id='col_buttons_${idx}'>${buttons}</td>
|
||||
</tr>`;
|
||||
|
||||
$('#bom-import-table tbody').append(html);
|
||||
@ -68,6 +76,7 @@ function constructBomUploadTable(data, options={}) {
|
||||
initializeRelatedField(
|
||||
{
|
||||
name: `part_${idx}`,
|
||||
value: row.part,
|
||||
api_url: '{% url "api-part-list" %}',
|
||||
filters: {
|
||||
component: true,
|
||||
|
@ -1484,10 +1484,19 @@ function initializeRelatedField(field, fields, options={}) {
|
||||
// limit size for AJAX requests
|
||||
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({
|
||||
placeholder: '',
|
||||
dropdownParent: $(options.modal),
|
||||
dropdownAutoWidth: false,
|
||||
dropdownParent: parent,
|
||||
dropdownAutoWidth: auto_width,
|
||||
language: {
|
||||
noResults: function(query) {
|
||||
if (field.noResults) {
|
||||
|
Loading…
Reference in New Issue
Block a user