Use the part detail API for uploading a new image

This commit is contained in:
Oliver 2021-06-23 08:34:45 +10:00
parent b8e4b58df0
commit f199feb8d9
3 changed files with 6 additions and 3 deletions

View File

@ -58,7 +58,7 @@ function inventreeFormDataUpload(url, data, options={}) {
xhr.setRequestHeader('X-CSRFToken', csrftoken);
},
url: url,
method: 'POST',
method: options.method || 'POST',
data: data,
processData: false,
contentType: false,

View File

@ -219,6 +219,7 @@ function enableDragAndDrop(element, url, options) {
data - Other form data to upload
success - Callback function in case of success
error - Callback function in case of error
method - HTTP method
*/
data = options.data || {};
@ -254,7 +255,8 @@ function enableDragAndDrop(element, url, options) {
if (options.error) {
options.error(xhr, status, error);
}
}
},
method: options.method || 'POST',
}
);
} else {

View File

@ -239,9 +239,10 @@
enableDragAndDrop(
'#part-thumb',
"{% url 'part-image-upload' part.id %}",
"{% url 'api-part-detail' part.id %}",
{
label: 'image',
method: 'PATCH',
success: function(data, status, xhr) {
location.reload();
}