mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Click on company image to edit it
This commit is contained in:
parent
e9be3e9e06
commit
17e6147c47
@ -23,3 +23,12 @@ class EditCompanyForm(HelperForm):
|
||||
'is_supplier',
|
||||
'notes'
|
||||
]
|
||||
|
||||
|
||||
class CompanyImageForm(HelperForm):
|
||||
|
||||
class Meta:
|
||||
model = Company
|
||||
fields = [
|
||||
'image'
|
||||
]
|
@ -8,7 +8,7 @@
|
||||
<div class="col-sm-6">
|
||||
<div class="media">
|
||||
<div class="media-left">
|
||||
<img class="part-thumb"
|
||||
<img class="part-thumb" id='company-thumb'
|
||||
{% if company.image %}
|
||||
src="{{ company.image.url }}"
|
||||
{% else %}
|
||||
@ -62,4 +62,19 @@
|
||||
|
||||
</div>
|
||||
|
||||
{% include 'modals.html' %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js_ready %}
|
||||
|
||||
$("#company-thumb").click(function() {
|
||||
launchModalForm("#modal-form",
|
||||
"{% url 'company-image' company.id %}",
|
||||
{
|
||||
reload: true
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
{% endblock %}
|
@ -29,14 +29,13 @@
|
||||
<button class="btn btn-danger" id='delete-company'>Delete Company</button>
|
||||
</div>
|
||||
|
||||
{% include 'modals.html' %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js_load %}
|
||||
<script type='text/javascript' src="{% static 'script/modal_form.js' %}"></script>
|
||||
{% endblock %}
|
||||
{% block js_ready %}
|
||||
{{ block.super }}
|
||||
$('#edit-company').click(function() {
|
||||
launchModalForm("#modal-form",
|
||||
"{% url 'company-edit' company.id %}",
|
||||
|
@ -13,8 +13,6 @@
|
||||
<button class="btn btn-success" id='part-create'>New Supplier Part</button>
|
||||
</div>
|
||||
|
||||
{% include 'modals.html' %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js_load %}
|
||||
@ -22,6 +20,8 @@
|
||||
{% endblock %}
|
||||
{% block js_ready %}
|
||||
|
||||
{{ block.super }}
|
||||
|
||||
$("#part-create").click(function () {
|
||||
launchModalForm("#modal-form",
|
||||
"{% url 'supplier-part-create' %}",
|
||||
|
@ -12,6 +12,8 @@ company_detail_urls = [
|
||||
|
||||
url(r'parts/?', views.CompanyDetail.as_view(template_name='company/detail_part.html'), name='company-detail-parts'),
|
||||
|
||||
url(r'thumbnail/?', views.CompanyImage.as_view(), name='company-image'),
|
||||
|
||||
# Any other URL
|
||||
url(r'^.*$', views.CompanyDetail.as_view(), name='company-detail'),
|
||||
]
|
||||
|
@ -8,6 +8,7 @@ from InvenTree.views import AjaxCreateView, AjaxUpdateView, AjaxDeleteView
|
||||
from .models import Company
|
||||
|
||||
from .forms import EditCompanyForm
|
||||
from .forms import CompanyImageForm
|
||||
|
||||
|
||||
class CompanyIndex(ListView):
|
||||
@ -35,6 +36,18 @@ class CompanyDetail(DetailView):
|
||||
model = Company
|
||||
|
||||
|
||||
class CompanyImage(AjaxUpdateView):
|
||||
model = Company
|
||||
ajax_template_name = 'modal_form.html'
|
||||
ajax_form_title = 'Update Company Image'
|
||||
form_class = CompanyImageForm
|
||||
|
||||
def get_data(self):
|
||||
return {
|
||||
'success': 'Updated company image',
|
||||
}
|
||||
|
||||
|
||||
class CompanyEdit(AjaxUpdateView):
|
||||
model = Company
|
||||
form_class = EditCompanyForm
|
||||
|
Loading…
Reference in New Issue
Block a user