mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 04:26:44 +00:00
Use the part detail API for uploading a new image
This commit is contained in:
parent
b8e4b58df0
commit
f199feb8d9
@ -58,7 +58,7 @@ function inventreeFormDataUpload(url, data, options={}) {
|
|||||||
xhr.setRequestHeader('X-CSRFToken', csrftoken);
|
xhr.setRequestHeader('X-CSRFToken', csrftoken);
|
||||||
},
|
},
|
||||||
url: url,
|
url: url,
|
||||||
method: 'POST',
|
method: options.method || 'POST',
|
||||||
data: data,
|
data: data,
|
||||||
processData: false,
|
processData: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
|
@ -219,6 +219,7 @@ function enableDragAndDrop(element, url, options) {
|
|||||||
data - Other form data to upload
|
data - Other form data to upload
|
||||||
success - Callback function in case of success
|
success - Callback function in case of success
|
||||||
error - Callback function in case of error
|
error - Callback function in case of error
|
||||||
|
method - HTTP method
|
||||||
*/
|
*/
|
||||||
|
|
||||||
data = options.data || {};
|
data = options.data || {};
|
||||||
@ -254,7 +255,8 @@ function enableDragAndDrop(element, url, options) {
|
|||||||
if (options.error) {
|
if (options.error) {
|
||||||
options.error(xhr, status, error);
|
options.error(xhr, status, error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
method: options.method || 'POST',
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -239,9 +239,10 @@
|
|||||||
|
|
||||||
enableDragAndDrop(
|
enableDragAndDrop(
|
||||||
'#part-thumb',
|
'#part-thumb',
|
||||||
"{% url 'part-image-upload' part.id %}",
|
"{% url 'api-part-detail' part.id %}",
|
||||||
{
|
{
|
||||||
label: 'image',
|
label: 'image',
|
||||||
|
method: 'PATCH',
|
||||||
success: function(data, status, xhr) {
|
success: function(data, status, xhr) {
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user