mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Replace PartImageUpload form
This commit is contained in:
parent
293b5d4c07
commit
26eafe242c
@ -133,6 +133,14 @@
|
||||
});
|
||||
});
|
||||
|
||||
function reloadImage(data) {
|
||||
if (data.image) {
|
||||
$('#company-image').attr('src', data.image);
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
enableDragAndDrop(
|
||||
"#company-thumb",
|
||||
"{% url 'api-company-detail' company.id %}",
|
||||
@ -140,12 +148,7 @@
|
||||
label: 'image',
|
||||
method: 'PATCH',
|
||||
success: function(data, status, xhr) {
|
||||
|
||||
if (data.image) {
|
||||
$('#company-image').attr('src', data.image);
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
reloadImage(data);
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -167,11 +170,7 @@
|
||||
},
|
||||
title: '{% trans "Upload Image" %}',
|
||||
onSuccess: function(data) {
|
||||
if (data.image) {
|
||||
$('#company-image').attr('src', data.image);
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
reloadImage(data);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -237,6 +237,16 @@
|
||||
});
|
||||
{% endif %}
|
||||
|
||||
function reloadImage(data) {
|
||||
// If image / thumbnail data present, live update
|
||||
if (data.image) {
|
||||
$('#part-image').attr('src', data.image);
|
||||
} else {
|
||||
// Otherwise, reload the page
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
enableDragAndDrop(
|
||||
'#part-thumb',
|
||||
"{% url 'api-part-detail' part.id %}",
|
||||
@ -244,14 +254,7 @@
|
||||
label: 'image',
|
||||
method: 'PATCH',
|
||||
success: function(data, status, xhr) {
|
||||
|
||||
// If image / thumbnail data present, live update
|
||||
if (data.image) {
|
||||
$('#part-image').attr('src', data.image);
|
||||
} else {
|
||||
// Otherwise, reload the page
|
||||
location.reload();
|
||||
}
|
||||
reloadImage(data);
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -293,11 +296,20 @@
|
||||
});
|
||||
|
||||
$("#part-image-upload").click(function() {
|
||||
launchModalForm("{% url 'part-image-upload' part.id %}",
|
||||
|
||||
constructForm(
|
||||
'{% url "api-part-detail" part.pk %}',
|
||||
{
|
||||
reload: true
|
||||
method: 'PATCH',
|
||||
fields: {
|
||||
image: {},
|
||||
},
|
||||
title: '{% trans "Upload Image" %}',
|
||||
onSuccess: function(data) {
|
||||
reloadImage(data);
|
||||
}
|
||||
}
|
||||
);
|
||||
)
|
||||
});
|
||||
|
||||
|
||||
|
@ -81,7 +81,6 @@ part_detail_urls = [
|
||||
url(r'^qr_code/?', views.PartQRCode.as_view(), name='part-qr'),
|
||||
|
||||
# Normal thumbnail with form
|
||||
url(r'^thumbnail/?', views.PartImageUpload.as_view(), name='part-image-upload'),
|
||||
url(r'^thumb-select/?', views.PartImageSelect.as_view(), name='part-image-select'),
|
||||
url(r'^thumb-download/', views.PartImageDownloadFromURL.as_view(), name='part-image-download'),
|
||||
|
||||
|
@ -1186,21 +1186,6 @@ class PartImageDownloadFromURL(AjaxUpdateView):
|
||||
)
|
||||
|
||||
|
||||
class PartImageUpload(AjaxUpdateView):
|
||||
""" View for uploading a new Part image """
|
||||
|
||||
model = Part
|
||||
ajax_template_name = 'modal_form.html'
|
||||
ajax_form_title = _('Upload Part Image')
|
||||
|
||||
form_class = part_forms.PartImageForm
|
||||
|
||||
def get_data(self):
|
||||
return {
|
||||
'success': _('Updated part image'),
|
||||
}
|
||||
|
||||
|
||||
class PartImageSelect(AjaxUpdateView):
|
||||
""" View for selecting Part image from existing images. """
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user