mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 13:05:42 +00:00
Modal for company create
- Ajax modals now return the URL of the item they are operating on - passing {follow: true} to the modal caller will go to that URL on success - footable'd company list
This commit is contained in:
@ -34,12 +34,7 @@ class EditCompanyForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EditCompanyForm, self).__init__(*args, **kwargs)
|
||||
self.helper = FormHelper()
|
||||
|
||||
self.helper.form_id = 'id-edit-part-form'
|
||||
self.helper.form_class = 'blueForms'
|
||||
self.helper.form_method = 'post'
|
||||
|
||||
self.helper.add_input(Submit('submit', 'Submit'))
|
||||
self.helper.form_tag = False
|
||||
|
||||
class Meta:
|
||||
model = Company
|
||||
|
@ -6,23 +6,30 @@
|
||||
|
||||
<h3>Companies</h3>
|
||||
|
||||
<div class="container">
|
||||
<div class='input-group'>
|
||||
<input class="form-control" id="company-filter" type="text" placeholder="Search...">
|
||||
<span class='input-group-btn'>
|
||||
<button type='button' class='btn' id='clear-filter'>Clear</button>
|
||||
</span>
|
||||
</div>
|
||||
<hr>
|
||||
<ul class='list-group' id="company-list">
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<table class='table table-striped' id='company-table' data-sorting='true' data-filtering='true'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for company in companies %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{% url 'company-detail' company.id %}">
|
||||
{{ company.name }}
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ company.description }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class='container-fluid'>
|
||||
<a href="{% url 'company-create' %}">
|
||||
<button class="btn btn-success">New Company</button>
|
||||
</a>
|
||||
<button class="btn btn-success" id='new-company'>New Company</button>
|
||||
</div>
|
||||
|
||||
{% include 'modals.html' %}
|
||||
@ -31,8 +38,19 @@
|
||||
|
||||
{% block javascript %}
|
||||
|
||||
<script type="text/javascript" src="{% static 'script/delay.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'script/filter_company.js' %}">
|
||||
<script type='text/javascript' src="{% static 'script/footable.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/modal_form.js' %}"></script>
|
||||
|
||||
<script type='text/javascript'>
|
||||
$('#company-table').footable();
|
||||
|
||||
$('#new-company').click(function () {
|
||||
launchModalForm('#modal-form',
|
||||
"{% url 'company-create' %}",
|
||||
{
|
||||
follow: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
@ -6,6 +6,8 @@ from django.http import HttpResponseRedirect
|
||||
from django.views.generic import DetailView, ListView
|
||||
from django.views.generic.edit import UpdateView, DeleteView, CreateView
|
||||
|
||||
from InvenTree.views import AjaxCreateView, AjaxUpdateView, AjaxDeleteView
|
||||
|
||||
from .models import Company
|
||||
|
||||
from .forms import EditCompanyForm
|
||||
@ -43,11 +45,13 @@ class CompanyEdit(UpdateView):
|
||||
context_object_name = 'company'
|
||||
|
||||
|
||||
class CompanyCreate(CreateView):
|
||||
class CompanyCreate(AjaxCreateView):
|
||||
model = Company
|
||||
context_object_name = 'company'
|
||||
form_class = EditCompanyForm
|
||||
template_name = "company/create.html"
|
||||
ajax_template_name = 'modal_form.html'
|
||||
ajax_form_title = "Create new Company"
|
||||
|
||||
|
||||
class CompanyDelete(DeleteView):
|
||||
|
Reference in New Issue
Block a user