Refactor BomItemDelete form

This commit is contained in:
Oliver 2021-07-03 16:10:41 +10:00
parent 359e92cd8e
commit 83256b1014
4 changed files with 9 additions and 34 deletions

View File

@ -1,16 +0,0 @@
{% extends "modal_delete_form.html" %}
{% load i18n %}
{% block pre_form_content %}
{% trans "Are you sure you want to delete this BOM item?" %}
<br>
{% trans "Deleting this entry will remove the BOM row from the following part" %}:
<ul class='list-group'>
<li class='list-group-item'>
<b>{{ item.part.full_name }}</b> - <i>{{ item.part.description }}</i>
</li>
</ul>
{% endblock %}

View File

@ -109,7 +109,6 @@ category_urls = [
part_bom_urls = [ part_bom_urls = [
url(r'^edit/?', views.BomItemEdit.as_view(), name='bom-item-edit'), url(r'^edit/?', views.BomItemEdit.as_view(), name='bom-item-edit'),
url('^delete/?', views.BomItemDelete.as_view(), name='bom-item-delete'),
] ]
# URL list for part web interface # URL list for part web interface

View File

@ -2778,17 +2778,10 @@ class BomItemEdit(AjaxUpdateView):
return form return form
class BomItemDelete(AjaxDeleteView):
""" Delete view for removing BomItem """
model = BomItem
ajax_template_name = 'part/bom-delete.html'
context_object_name = 'item'
ajax_form_title = _('Confim BOM item deletion')
class PartSalePriceBreakCreate(AjaxCreateView): class PartSalePriceBreakCreate(AjaxCreateView):
""" View for creating a sale price break for a part """ """
View for creating a sale price break for a part
"""
model = PartSellPriceBreak model = PartSellPriceBreak
form_class = part_forms.EditPartSalePriceBreakForm form_class = part_forms.EditPartSalePriceBreakForm

View File

@ -514,14 +514,13 @@ function loadBomTable(table, options) {
var pk = $(this).attr('pk'); var pk = $(this).attr('pk');
var url = `/part/bom/${pk}/delete/`; var url = `/part/bom/${pk}/delete/`;
launchModalForm( constructForm(`/api/bom/${pk}/`, {
url, method: 'DELETE',
{ title: '{% trans "Delete BOM Item" %}',
success: function() { onSuccess: function() {
reloadBomTable(table); reloadBomTable(table);
} }
} });
);
}); });
table.on('click', '.bom-edit-button', function() { table.on('click', '.bom-edit-button', function() {