mirror of
https://github.com/inventree/InvenTree.git
synced 2025-08-14 15:41:10 +00:00
Select existing image and upload successfully
This commit is contained in:
@@ -218,14 +218,22 @@
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
function onSelectImage(response) {
|
||||
// Callback when the image-selection modal form is displayed
|
||||
// Populate the form with image data (requested via AJAX)
|
||||
|
||||
$("#modal-form").find("#image-select-table").bootstrapTable({
|
||||
pagination: true,
|
||||
pageSize: 25,
|
||||
url: "{% url 'api-part-thumbs' %}",
|
||||
showHeader: false,
|
||||
clickToSelect: true,
|
||||
singleSelect: true,
|
||||
columns: [
|
||||
{
|
||||
checkbox: true,
|
||||
},
|
||||
{
|
||||
field: 'image',
|
||||
title: 'Image',
|
||||
@@ -234,6 +242,13 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
onCheck: function(row, element) {
|
||||
|
||||
// Update the selected image in the form
|
||||
var ipt = $("#modal-form").find("#image-input");
|
||||
ipt.val(row.image);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -4,14 +4,15 @@
|
||||
|
||||
{{ block.super }}
|
||||
|
||||
Select from existing images.
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block form %}
|
||||
<form method='post' action='' class='js-modal-form' enctype='multipart/form-data'>
|
||||
{% csrf_token %}
|
||||
{% load crispy_forms_tags %}
|
||||
{% csrf_token %}
|
||||
{% load crispy_forms_tags %}
|
||||
|
||||
<input id='image-input' name='image' type='hidden' value="{{ part.image }}">
|
||||
|
||||
<table id='image-select-table' class='table table-striped table-condensed table-img-grid'>
|
||||
</table>
|
||||
|
Reference in New Issue
Block a user