2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-14 15:41:10 +00:00

Replace PartImageUpload form

This commit is contained in:
Oliver
2021-06-30 00:18:25 +10:00
parent 293b5d4c07
commit 26eafe242c
4 changed files with 33 additions and 38 deletions

View File

@@ -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);
}
}
);
)
});