Fixes for 'order parts' form

- Sometimes the part pk was not being retrieved properly
This commit is contained in:
Oliver Walters 2020-11-27 11:18:45 +11:00
parent 607cc90ce0
commit 7068f70811
2 changed files with 16 additions and 9 deletions

View File

@ -11,11 +11,11 @@
{% if parts|length > 0 %} {% if parts|length > 0 %}
<div class='alert alert-info alert-block' role='alert'> <div class='alert alert-info alert-block' role='alert'>
{% trans "Select suppliers." %} {% trans "Select suppliers" %}
</div> </div>
{% else %} {% else %}
<div class='alert alert-warning alert-block' role='alert'> <div class='alert alert-warning alert-block' role='alert'>
{% trans "No purchaseable parts selected." %} {% trans "No purchaseable parts selected" %}
</div> </div>
{% endif %} {% endif %}
@ -39,8 +39,8 @@
{{ part.full_name }} <small><i>{{ part.description }}</i></small> {{ part.full_name }} <small><i>{{ part.description }}</i></small>
</td> </td>
<td> <td>
<button class='btn btn-default btn-create' onClick='newSupplierPartFromOrderWizard()' id='new_supplier_part_{{ part.id }}' title='Create new supplier part for {{ part }}' type='button'> <button class='btn btn-default btn-create' onClick='newSupplierPartFromOrderWizard()' id='new_supplier_part_{{ part.id }}' part='{{ part.pk }}' title='{% trans "Create new supplier part" $}' type='button'>
<span part-id='{{ part.id }}' class='fas fa-plus-circle'></span> <span part='{{ part.pk }}' class='fas fa-plus-circle'></span>
</button> </button>
</td> </td>
<td> <td>

View File

@ -21,9 +21,16 @@ function newSupplierPartFromOrderWizard(e) {
e = e || window.event; e = e || window.event;
var src = e.target || e.srcElement; var src = e.srcElement || e.target;
var part = $(src).attr('part-id'); var part = $(src).attr('part');
console.log('part: ' + part);
if (!part) {
part = $(src).closest('button').attr('part');
console.log('parent: ' + part);
}
launchModalForm("/supplier-part/new/", { launchModalForm("/supplier-part/new/", {
modal: '#modal-form-secondary', modal: '#modal-form-secondary',
@ -125,7 +132,7 @@ function loadPurchaseOrderTable(table, options) {
name: 'purchaseorder', name: 'purchaseorder',
groupBy: false, groupBy: false,
original: options.params, original: options.params,
formatNoMatches: function() { return "{% trans "No purchase orders found" %}"; }, formatNoMatches: function() { return '{% trans "No purchase orders found" %}'; },
columns: [ columns: [
{ {
field: 'pk', field: 'pk',
@ -208,7 +215,7 @@ function loadSalesOrderTable(table, options) {
name: 'salesorder', name: 'salesorder',
groupBy: false, groupBy: false,
original: options.params, original: options.params,
formatNoMatches: function() { return "{% trans "No sales orders found" %}"; }, formatNoMatches: function() { return '{% trans "No sales orders found" %}'; },
columns: [ columns: [
{ {
field: 'pk', field: 'pk',
@ -265,7 +272,7 @@ function loadSalesOrderTable(table, options) {
{ {
sortable: true, sortable: true,
field: 'shipment_date', field: 'shipment_date',
title: "{% trans "Shipment Date" %}", title: '{% trans "Shipment Date" %}',
}, },
{ {
sortable: true, sortable: true,