From f85b20a14c8aeb90e4594d826cdf653751f0972e Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Thu, 19 Oct 2017 12:40:35 -0400 Subject: Remove a lot of the duplicate code for rendering a load listing --- .../templates/dispatch/companies/detail.html | 35 +----------- .../templates/dispatch/drivers/detail.html | 40 +------------ .../templates/dispatch/generic_load_listing.html | 66 ++++++++++++++++++++++ app/dispatch/templates/dispatch/loads/list.html | 46 ++------------- 4 files changed, 76 insertions(+), 111 deletions(-) create mode 100644 app/dispatch/templates/dispatch/generic_load_listing.html (limited to 'app/dispatch') diff --git a/app/dispatch/templates/dispatch/companies/detail.html b/app/dispatch/templates/dispatch/companies/detail.html index b889055..5c643da 100644 --- a/app/dispatch/templates/dispatch/companies/detail.html +++ b/app/dispatch/templates/dispatch/companies/detail.html @@ -19,38 +19,9 @@ -{% load dynamic_key %} -{% for date in loads %} -
-
-
- {{date}} - - - - - - - - - {% for load in loads|keyvalue:date %} - - - - - - {% empty %} - - {% endfor %} - -
DriverAmount
{{ load.user.first_name }} {{ load.user.last_name }}{{ load.amount }} - Edit - View -
No load.
-
-
-
-{% endfor %} +{% load custom_tags %} +{% listForCommaString "Driver,Amount,Description" as load_headers %} +{% include "dispatch/generic_load_listing.html" %}
diff --git a/app/dispatch/templates/dispatch/drivers/detail.html b/app/dispatch/templates/dispatch/drivers/detail.html index d6e194b..7655470 100644 --- a/app/dispatch/templates/dispatch/drivers/detail.html +++ b/app/dispatch/templates/dispatch/drivers/detail.html @@ -53,43 +53,9 @@
{% endif %} - - -{% load dynamic_key %} -{% for date in loads %} -
-
-
- {{date|date:"l F d"}} - - - - - - - - - {% for load in loads|keyvalue:date %} - - - {% if load.amount == 0 %} - - {% else %} - - {% endif %} - - - {% empty %} - - {% endfor %} - -
CompanyAmount
{{ load.company.name }}{{ load.amount }}{{ load.amount }} - View -
No load.
-
-
-
-{% endfor %} +{% load custom_tags %} +{% listForCommaString "Company,Amount,Load Number,Description" as load_headers %} +{% include "dispatch/generic_load_listing.html" %}
diff --git a/app/dispatch/templates/dispatch/generic_load_listing.html b/app/dispatch/templates/dispatch/generic_load_listing.html new file mode 100644 index 0000000..ed4399b --- /dev/null +++ b/app/dispatch/templates/dispatch/generic_load_listing.html @@ -0,0 +1,66 @@ + +{% load dynamic_key %} +{% for date in loads %} +
+
+
+ {{date|date:"l F d"}} + + + + {% for heading in load_headers %} + + {% endfor %} + + + + + + {% for load in loads|keyvalue:date %} + + {% if "Company" in load_headers %} + + {% endif %} + {% if "Driver" in load_headers %} + + {% endif %} + + {% if "Amount" in load_headers %} + {% if load.amount == 0 %} + + {% else %} + + {% endif %} + {% endif %} + {% if "Load Number" in load_headers %} + + {% endif %} + {% if "Description" in load_headers %} + + {% endif %} + + + {% empty %} + + {% endfor %} + +
{{heading}}
{{ load.company.name }}{{ load.user.first_name }} {{ load.user.last_name }}{{ load.amount }}{{ load.amount }}{{ load.load_number }}{{ load.description }} + + View +
No load.
+
+
+
+{% endfor %} diff --git a/app/dispatch/templates/dispatch/loads/list.html b/app/dispatch/templates/dispatch/loads/list.html index 0620fba..78cb476 100644 --- a/app/dispatch/templates/dispatch/loads/list.html +++ b/app/dispatch/templates/dispatch/loads/list.html @@ -13,6 +13,7 @@ Add Load
+
arrow_back Prev @@ -22,48 +23,9 @@
-{% load dynamic_key %} -{% for date in loads %} -
-
-
- {{date|date:"l F d"}} - - - - - - - - - - - - {% for load in loads|keyvalue:date %} - - - - {% if load.amount == 0 %} - - {% else %} - - {% endif %} - - - - - {% empty %} - - {% endfor %} - -
CompanyDriverAmountLoad NumberDescription
{{ load.company.name }}{{ load.user.first_name }} {{ load.user.last_name }}{{ load.amount }}{{ load.amount }}{{ load.load_number }}{{ load.description }} - - View -
No load.
-
-
-
-{% endfor %} +{% load custom_tags %} +{% listForCommaString "Company,Driver,Amount,Description" as load_headers %} +{% include "dispatch/generic_load_listing.html" %}
-- cgit v1.2.3