From 2e7253ebc40b6cad8962b0a654c0b1c04927053d Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 28 Apr 2018 11:43:26 +1000 Subject: [PATCH] Tweak javascript for category detail pages --- InvenTree/build/templates/build/index.html | 40 ++++++++++--------- InvenTree/build/views.py | 2 + .../part/templates/part/category_detail.html | 26 +++++++++--- InvenTree/static/script/modal_form.js | 4 ++ InvenTree/templates/InvenTree/index.html | 10 +++++ 5 files changed, 58 insertions(+), 24 deletions(-) create mode 100644 InvenTree/templates/InvenTree/index.html diff --git a/InvenTree/build/templates/build/index.html b/InvenTree/build/templates/build/index.html index b96be4313e..329c2591af 100644 --- a/InvenTree/build/templates/build/index.html +++ b/InvenTree/build/templates/build/index.html @@ -1,34 +1,36 @@ {% extends "base.html" %} - +{% load static %} {% block content %}

Part Builds

- +
+ - + + + -{% if active|length > 0 %} - -{% include "build/build_list.html" with builds=active %} -{% endif %} - -{% if complete|length > 0 %} - - -{% include "build/build_list.html" with builds=complete %} -{% endif %} - -{% if cancelled|length > 0 %} - - -{% include "build/build_list.html" with builds=cancelled.all %} -{% endif %} +{% include "build/build_list.html" with builds=builds %} +
Build Part Quantity Status
Active Builds
Completed Builds
Cancelled Builds
{% endblock %} + +{% block javascript %} + + + + + + +{% endblock %} \ No newline at end of file diff --git a/InvenTree/build/views.py b/InvenTree/build/views.py index e02a4a5e42..5f61770617 100644 --- a/InvenTree/build/views.py +++ b/InvenTree/build/views.py @@ -25,10 +25,12 @@ class BuildIndex(ListView): context = super(BuildIndex, self).get_context_data(**kwargs).copy() + """ context['active'] = self.get_queryset().filter(status__in=[Build.PENDING, Build.HOLDING]) context['complete'] = self.get_queryset().filter(status=Build.COMPLETE) context['cancelled'] = self.get_queryset().filter(status=Build.CANCELLED) + """ return context diff --git a/InvenTree/part/templates/part/category_detail.html b/InvenTree/part/templates/part/category_detail.html index 9b12cab55f..1eff2e013a 100644 --- a/InvenTree/part/templates/part/category_detail.html +++ b/InvenTree/part/templates/part/category_detail.html @@ -50,24 +50,40 @@ $(document).ready(function (){ ); }); + {% if category.parent %} + var categoryRedirect = "{% url 'category-detail' category.parent.id %}"; + {% else %} + var categoryRedirect = "{% url 'part-index' %}"; + {% endif %} + $("#delete-category").click(function() { launchDeleteForm("#modal-delete", "{% url 'category-delete' category.id %}", - {redirect: "{% url 'part-index' %}"}); + { + redirect: categoryRedirect + }); }); $("#create-cat").click(function() { launchModalForm("#modal-form", "{% url 'category-create' %}", - {data: {category: {{ category.id }} - }}); + { + follow: true, + data: { + category: {{ category.id }} + } + }); }); $("#create-part").click( function() { launchModalForm("#modal-form", "{% url 'part-create' %}", - {data: {category: {{ category.id }} - }}); + { + data: { + category: {{ category.id }} + }, + reload: true + }); }); }); diff --git a/InvenTree/static/script/modal_form.js b/InvenTree/static/script/modal_form.js index efe4801f07..96e1fba6b0 100644 --- a/InvenTree/static/script/modal_form.js +++ b/InvenTree/static/script/modal_form.js @@ -54,6 +54,10 @@ function launchDeleteForm(modal, url, options = {}) { if (options.success) { options.success(); } + // Follow the URL returned by the JSON response + else if (options.follow && response.url) { + window.location.href = response.url; + } else if (options.redirect) { window.location.href = options.redirect; } diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html new file mode 100644 index 0000000000..79f5e50a5d --- /dev/null +++ b/InvenTree/templates/InvenTree/index.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} + +{% block content %} + +{% endblock %} + + +{% block javascript %} + +{% endblock %} \ No newline at end of file