Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added smarter template logic for dashboard order detail page.

Correct tab now remains open when an invalid form is submitted.
  • Loading branch information...
commit b3c576da75296c57319cd39bdf00a1b8e1b2cba4 1 parent 145a9d9
@codeinthehole codeinthehole authored
View
3  oscar/apps/dashboard/orders/views.py
@@ -269,6 +269,7 @@ def get_object(self):
def get_context_data(self, **kwargs):
ctx = super(OrderDetailView, self).get_context_data(**kwargs)
+ ctx['active_tab'] = kwargs.get('active_tab', 'lines')
ctx['note_form'] = self.get_order_note_form()
ctx['line_statuses'] = Line.all_statuses()
ctx['shipping_event_types'] = ShippingEventType.objects.all()
@@ -334,7 +335,7 @@ def save_note(self, request, order):
note.save()
messages.success(self.request, success_msg)
return self.reload_page_response(fragment='notes')
- ctx = self.get_context_data(note_form=form)
+ ctx = self.get_context_data(note_form=form, active_tab='notes')
return self.render_to_response(ctx)
def delete_note(self, request, order):
View
25 oscar/templates/oscar/dashboard/orders/order_detail.html
@@ -87,18 +87,17 @@
<div class="tabbable dashboard">
<ul class="nav nav-tabs">
{% block nav_tabs %}
- <li class="active"><a href="#lines" data-toggle="tab">{% trans "Order contents" %}</a></li>
- <li><a href="#shipping" data-toggle="tab">{% trans "Shipping" %}</a></li>
- <li><a href="#payment" data-toggle="tab">{% trans "Payment" %}</a></li>
- <li><a href="#discounts" data-toggle="tab">{% trans "Discounts" %}</a></li>
- <li><a href="#emails" data-toggle="tab">{% trans "Emails" %}</a></li>
- <li><a href="#notes" data-toggle="tab">{% trans "Notes" %}</a></li>
+ <li class="{% if active_tab == 'lines' %}active{% endif %}"><a href="#lines" data-toggle="tab">{% trans "Order contents" %}</a></li>
+ <li class="{% if active_tab == 'shipping' %}active{% endif %}"><a href="#shipping" data-toggle="tab">{% trans "Shipping" %}</a></li>
+ <li class="{% if active_tab == 'payment' %}active{% endif %}"><a href="#payment" data-toggle="tab">{% trans "Payment" %}</a></li>
+ <li class="{% if active_tab == 'discounts' %}active{% endif %}"><a href="#discounts" data-toggle="tab">{% trans "Discounts" %}</a></li>
+ <li class="{% if active_tab == 'emails' %}active{% endif %}"><a href="#emails" data-toggle="tab">{% trans "Emails" %}</a></li>
+ <li class="{% if active_tab == 'notes' %}active{% endif %}"><a href="#notes" data-toggle="tab">{% trans "Notes" %}</a></li>
{% endblock nav_tabs %}
</ul>
<div class="tab-content">
-
- <div class="tab-pane active" id="lines">
+ <div class="tab-pane {% if active_tab == 'lines' %}active{% endif %}" id="lines">
<div class="sub-header">
<h3 class="app-ico ico_shop_bag icon">{% trans "Items ordered" %}</h3>
</div>
@@ -295,7 +294,7 @@ <h3 class="app-ico ico_favourite icon">{% trans "Payment Events" %}</h3>
</div>
- <div class="tab-pane" id="shipping">
+ <div class="tab-pane {% if active_tab == 'shipping' %}active{% endif %}" id="shipping">
{% block tab_shipping %}
<table class="table">
<tbody>
@@ -324,7 +323,7 @@ <h3 class="app-ico ico_favourite icon">{% trans "Payment Events" %}</h3>
{% endblock %}
</div>
- <div class="tab-pane" id="payment">
+ <div class="tab-pane {% if active_tab == 'payment' %}active{% endif %}" id="payment">
{% if order.billing_address %}
<div class="sub-header">
<h3 class="app-ico ico_mapmarker icon">{% trans "Billing address" %}</h3>
@@ -375,7 +374,7 @@ <h3 class="app-ico ico_mapmarker icon">{% trans "Transactions" %}</h3>
</div>
- <div class="tab-pane" id="discounts">
+ <div class="tab-pane {% if active_tab == 'discounts' %}active{% endif %}" id="discounts">
{% block tab_discounts %}
<div class="sub-header">
<h3 class="app-ico ico_settings icon">{% trans "Discounts" %}</h3>
@@ -407,7 +406,7 @@ <h3 class="app-ico ico_settings icon">{% trans "Discounts" %}</h3>
{% endblock %}
</div>
- <div class="tab-pane" id="emails">
+ <div class="tab-pane {% if active_tab == 'emails' %}active{% endif %}" id="emails">
{% block tab_emails %}
<div class="sub-header">
<h3 class="app-ico ico_email icon">{% trans "Emails" %}</h3>
@@ -416,7 +415,7 @@ <h3 class="app-ico ico_email icon">{% trans "Emails" %}</h3>
{% endblock %}
</div>
- <div class="tab-pane" id="notes">
+ <div class="tab-pane {% if active_tab == 'notes' %}active{% endif %}" id="notes">
{% block tab_notes %}
<div class="sub-header">
<h3 class="app-ico ico_comment icon">{% trans "Notes" %}</h3>

0 comments on commit b3c576d

Please sign in to comment.
Something went wrong with that request. Please try again.