mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-04 06:18:48 +00:00
Add button to launch modal form
This commit is contained in:
parent
db49e98f37
commit
9004086632
@ -45,7 +45,7 @@ class EditCategoryForm(forms.ModelForm):
|
|||||||
self.helper.form_id = 'id-edit-part-form'
|
self.helper.form_id = 'id-edit-part-form'
|
||||||
self.helper.form_method = 'post'
|
self.helper.form_method = 'post'
|
||||||
|
|
||||||
self.helper.add_input(Submit('submit', 'Submit'))
|
#self.helper.add_input(Submit('submit', 'Submit'))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PartCategory
|
model = PartCategory
|
||||||
|
@ -5,6 +5,18 @@
|
|||||||
|
|
||||||
{% include "part/cat_link.html" with category=category %}
|
{% include "part/cat_link.html" with category=category %}
|
||||||
|
|
||||||
|
<div class='modal fade' id='modal-cat'>
|
||||||
|
<div class='modal-dialog'>
|
||||||
|
<div class='modal-content'>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type='button' class='btn btn-primary js-create-cat'>
|
||||||
|
<span class='glyphicon glyphicon-plus'></span>
|
||||||
|
New Category
|
||||||
|
</button>
|
||||||
|
|
||||||
{% if children.all|length > 0 %}
|
{% if children.all|length > 0 %}
|
||||||
<h4>Part Categories</h4>
|
<h4>Part Categories</h4>
|
||||||
{% include "part/category_subcategories.html" with children=children %}
|
{% include "part/category_subcategories.html" with children=children %}
|
||||||
@ -23,3 +35,25 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
$(".js-create-cat").click(function () {
|
||||||
|
$.ajax({
|
||||||
|
url: '/part/category/new/',
|
||||||
|
type: 'get',
|
||||||
|
//dataType: 'json',
|
||||||
|
beforeSend: function () {
|
||||||
|
$("#modal-cat").modal("show");
|
||||||
|
},
|
||||||
|
success: function (data) {
|
||||||
|
$("#modal-cat .modal-content").html(data);
|
||||||
|
//alert(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
1
InvenTree/part/templates/part/partial_category_new.html
Normal file
1
InvenTree/part/templates/part/partial_category_new.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
{% include 'modal_form.html' with title='Create new Part Catagory' %}
|
@ -132,7 +132,7 @@ class CategoryDelete(DeleteView):
|
|||||||
|
|
||||||
class CategoryCreate(CreateView):
|
class CategoryCreate(CreateView):
|
||||||
model = PartCategory
|
model = PartCategory
|
||||||
template_name = 'part/category_new.html'
|
template_name = 'part/partial_category_new.html'
|
||||||
form_class = EditCategoryForm
|
form_class = EditCategoryForm
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
|
@ -13,11 +13,6 @@
|
|||||||
<link rel='stylesheet' href="{% static 'css/bootstrap_3.3.7_css_bootstrap.min.css' %}">
|
<link rel='stylesheet' href="{% static 'css/bootstrap_3.3.7_css_bootstrap.min.css' %}">
|
||||||
<link rel="stylesheet" href="{% static 'css/inventree.css' %}">
|
<link rel="stylesheet" href="{% static 'css/inventree.css' %}">
|
||||||
|
|
||||||
|
|
||||||
<!-- Scripts -->
|
|
||||||
<script type="text/javascript" src="{% static 'script/jquery_3.3.1_jquery.min.js' %}"></script>
|
|
||||||
<script type="text/javascript" src="{% static 'script/bootstrap.min.js' %}"></script>
|
|
||||||
|
|
||||||
{% block head %}
|
{% block head %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@ -39,5 +34,13 @@ InvenTree
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Scripts -->
|
||||||
|
<script type="text/javascript" src="{% static 'script/jquery_3.3.1_jquery.min.js' %}"></script>
|
||||||
|
<script type="text/javascript" src="{% static 'script/bootstrap.min.js' %}"></script>
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
18
InvenTree/templates/modal_form.html
Normal file
18
InvenTree/templates/modal_form.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{% load static %}
|
||||||
|
|
||||||
|
<form method='post'>
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class='modal-header'>
|
||||||
|
<h4 class='modal-title'>{{ title }}</h4>
|
||||||
|
</div>
|
||||||
|
<div class='modal-body'>
|
||||||
|
{% load crispy_forms_tags %}
|
||||||
|
{% crispy form %}
|
||||||
|
</div>
|
||||||
|
<div class='modal-footer'>
|
||||||
|
<button type='button' class='btn btn-default' data-dismiss='modal'>Close</button>
|
||||||
|
<button type='submit' class='btn btn-primary'>
|
||||||
|
{% if ok_text %}{{ ok_text }}{% else %}Submit{% endif %}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
Loading…
x
Reference in New Issue
Block a user