mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
BuildAttachmentDelete form
This commit is contained in:
parent
653e3cd135
commit
4d8e88c779
@ -70,6 +70,15 @@ $("#attachment-table").on('click', '.attachment-edit-button', function() {
|
||||
$("#attachment-table").on('click', '.attachment-delete-button', function() {
|
||||
var pk = $(this).attr('pk');
|
||||
|
||||
constructForm(`/api/build/attachment/${pk}/`, {
|
||||
method: 'DELETE',
|
||||
confirmMessage: '{% trans "Confirm Delete Operation" %}',
|
||||
title: '{% trans "Delete Attachment" %}',
|
||||
reload: true,
|
||||
});
|
||||
|
||||
return;
|
||||
|
||||
var url = `/build/attachment/${pk}/delete/`;
|
||||
|
||||
launchModalForm(
|
||||
|
@ -36,10 +36,6 @@ build_urls = [
|
||||
url('^new/', views.BuildItemCreate.as_view(), name='build-item-create'),
|
||||
])),
|
||||
|
||||
url('^attachment/', include([
|
||||
url(r'^(?P<pk>\d+)/delete/', views.BuildAttachmentDelete.as_view(), name='build-attachment-delete'),
|
||||
])),
|
||||
|
||||
url(r'new/', views.BuildCreate.as_view(), name='build-create'),
|
||||
|
||||
url(r'^(?P<pk>\d+)/', include(build_detail_urls)),
|
||||
|
@ -1058,18 +1058,3 @@ class BuildItemEdit(AjaxUpdateView):
|
||||
form.fields['install_into'].widget = HiddenInput()
|
||||
|
||||
return form
|
||||
|
||||
|
||||
class BuildAttachmentDelete(AjaxDeleteView):
|
||||
"""
|
||||
View for deleting a BuildAttachment
|
||||
"""
|
||||
|
||||
model = BuildOrderAttachment
|
||||
ajax_form_title = _('Delete Attachment')
|
||||
context_object_name = 'attachment'
|
||||
|
||||
def get_data(self):
|
||||
return {
|
||||
'danger': _('Deleted attachment')
|
||||
}
|
||||
|
@ -438,13 +438,25 @@ function constructFormBody(fields, options) {
|
||||
// The "submit" button will be disabled unless "confirm" is checked
|
||||
function insertConfirmButton(options) {
|
||||
|
||||
var message = options.confirmMessage || '{% trans "Confirm" %}';
|
||||
|
||||
var confirm = `
|
||||
<span style='float: left;'>
|
||||
Confirm
|
||||
<input name='confirm' type='checkbox'>
|
||||
${message}
|
||||
<input id='modal-confirm' name='confirm' type='checkbox'>
|
||||
</span>`;
|
||||
|
||||
$(options.modal).find('#modal-footer-buttons').append(confirm);
|
||||
|
||||
// Disable the 'submit' button
|
||||
$(options.modal).find('#modal-form-submit').prop('disabled', true);
|
||||
|
||||
// Trigger event
|
||||
$(options.modal).find('#modal-confirm').change(function() {
|
||||
var enabled = this.checked;
|
||||
|
||||
$(options.modal).find('#modal-form-submit').prop('disabled', !enabled);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user