BuildAttachmentDelete form

This commit is contained in:
Oliver 2021-06-30 12:48:14 +10:00
parent 653e3cd135
commit 4d8e88c779
4 changed files with 23 additions and 21 deletions

View File

@ -70,6 +70,15 @@ $("#attachment-table").on('click', '.attachment-edit-button', function() {
$("#attachment-table").on('click', '.attachment-delete-button', function() { $("#attachment-table").on('click', '.attachment-delete-button', function() {
var pk = $(this).attr('pk'); 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/`; var url = `/build/attachment/${pk}/delete/`;
launchModalForm( launchModalForm(

View File

@ -36,10 +36,6 @@ build_urls = [
url('^new/', views.BuildItemCreate.as_view(), name='build-item-create'), 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'new/', views.BuildCreate.as_view(), name='build-create'),
url(r'^(?P<pk>\d+)/', include(build_detail_urls)), url(r'^(?P<pk>\d+)/', include(build_detail_urls)),

View File

@ -1058,18 +1058,3 @@ class BuildItemEdit(AjaxUpdateView):
form.fields['install_into'].widget = HiddenInput() form.fields['install_into'].widget = HiddenInput()
return form 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')
}

View File

@ -438,13 +438,25 @@ function constructFormBody(fields, options) {
// The "submit" button will be disabled unless "confirm" is checked // The "submit" button will be disabled unless "confirm" is checked
function insertConfirmButton(options) { function insertConfirmButton(options) {
var message = options.confirmMessage || '{% trans "Confirm" %}';
var confirm = ` var confirm = `
<span style='float: left;'> <span style='float: left;'>
Confirm ${message}
<input name='confirm' type='checkbox'> <input id='modal-confirm' name='confirm' type='checkbox'>
</span>`; </span>`;
$(options.modal).find('#modal-footer-buttons').append(confirm); $(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);
});
} }