2
0
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:
Oliver Walters
2020-02-10 23:48:45 +11:00
parent 534b60d4b8
commit d4fe83170f
5 changed files with 50 additions and 13 deletions

View File

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

View File

@@ -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>