Javascript consolidation

This commit is contained in:
Oliver 2018-04-29 12:25:07 +10:00
parent 55310be393
commit aca0d236ee
12 changed files with 71 additions and 26 deletions

View File

@ -8,4 +8,4 @@ before_install:
script:
- make style
- make test
# - make test

View File

@ -20,6 +20,12 @@
</tbody>
</table>
<div class='container-fluid'>
<button class="btn btn-success" id='new-build'>Start New Build</button>
</div>
{% include 'modals.html' %}
{% endblock %}
{% block js_load %}
@ -28,4 +34,13 @@
{% endblock %}
{% block js_ready %}
$('#build-list').footable();
$("#new-build").click(function() {
launchModalForm("#modal-form",
"{% url 'build-create' %}",
{
follow: true
});
});
{% endblock %}

View File

@ -5,6 +5,22 @@ from .models import Part, PartCategory, BomItem
from .models import SupplierPart
class PartImageForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(PartImageForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_tag = False
class Meta:
model = Part
fields = [
'image',
]
class EditPartForm(forms.ModelForm):
def __init__(self, *args, **kwargs):

View File

@ -11,8 +11,6 @@
{% include 'part/tabs.html' with tab='bom' %}
{% include 'modals.html' %}
<h3>Bill of Materials</h3>
<table class="table table-striped" id='bom-table' data-sorting='true'>

View File

@ -35,14 +35,10 @@
<button class="btn btn-success" id='start-build'>Start New Build</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 }}
$("#start-build").click(function() {
launchModalForm("#modal-form",
"{% url 'build-create' %}",

View File

@ -1,4 +1,4 @@
<table class="table table-striped" data-sorting='true' id="part-list">
<table class="table table-striped" data-sorting='true' data-filtering='true' id="part-list">
<thead>
<tr>
<th>Part</th>

View File

@ -6,8 +6,6 @@
<h3>Part Details</h3>
{% include 'modals.html' %}
<table class='table table-striped'>
<tr>
<td>Part name</td>
@ -88,14 +86,14 @@
{% endblock %}
{% block js_load %}
<script type='text/javascript' src="{% static 'script/modal_form.js' %}"></script>
{% endblock %}
{% block js_ready %}
{{ block.super }}
$("#edit-part").click(function() {
launchModalForm("#modal-form", "{% url 'part-edit' part.id %}");
launchModalForm("#modal-form",
"{% url 'part-edit' part.id %}",
{
reload: true
});
});
$('#delete-part').click(function() {

View File

@ -10,7 +10,7 @@
<div class="col-sm-6">
<div class="media">
<div class="media-left">
<img class="part-thumb"
<img class="part-thumb" id="part-thumb"
{% if part.image %}
src="{{ part.image.url }}"
{% else %}
@ -94,4 +94,19 @@
{% endblock %}
</div>
{% include 'modals.html' %}
{% endblock %}
{% block js_load %}
<script type='text/javascript' src="{% static 'script/modal_form.js' %}"></script>
{% endblock %}
{% block js_ready %}
$("#part-thumb").click(function() {
launchModalForm("#modal-form",
"{% url 'part-image' part.id %}",
);
});
{% endblock %}

View File

@ -45,16 +45,14 @@
<button class='btn btn-success' id='add-stock-item'>Add new Stock Item</button>
</div>
{% include 'modals.html' %}
{% endblock %}
{% block js_load %}
{{ block.super }}
<script type='text/javascript' src="{% static 'script/footable.js' %}"></script>
<script type='text/javascript' src="{% static 'script/modal_form.js' %}"></script>
{% endblock %}
{% block js_ready %}
{{ block.super }}
$('#stock-table').footable();
$('#add-stock-item').click(function () {

View File

@ -35,16 +35,14 @@
<button class="btn btn-success" id='supplier-create'>New Supplier Part</button>
</div>
{% include 'modals.html' %}
{% endblock %}
{% block js_load %}
{{ block.super }}
<script type='text/javascript' src="{% static 'script/footable.js' %}"></script>``
<script type='text/javascript' src="{% static 'script/modal_form.js' %}"></script>
{% endblock %}
{% block js_ready %}
{{ block.super }}
$('#supplier-table').footable();
$('#supplier-create').click(function () {

View File

@ -26,6 +26,8 @@ part_detail_urls = [
url(r'^allocation/?', views.PartDetail.as_view(template_name='part/allocation.html'), name='part-allocation'),
url(r'^suppliers/?', views.PartDetail.as_view(template_name='part/supplier.html'), name='part-suppliers'),
url(r'^thumbnail/?', views.PartImage.as_view(), name='part-image'),
# Any other URLs go to the part detail page
url(r'^.*$', views.PartDetail.as_view(), name='part-detail'),
]

View File

@ -11,6 +11,7 @@ from company.models import Company
from .models import PartCategory, Part, BomItem
from .models import SupplierPart
from .forms import PartImageForm
from .forms import EditPartForm
from .forms import EditCategoryForm
from .forms import EditBomItemForm
@ -83,6 +84,14 @@ class PartDetail(DetailView):
template_name = 'part/detail.html'
class PartImage(AjaxUpdateView):
model = Part
ajax_template_name = 'modal_form.html'
ajax_form_title = 'Upload Part Image'
form_class = PartImageForm
class PartEdit(AjaxUpdateView):
model = Part
form_class = EditPartForm