Skip to content

Commit

Permalink
Added smarter template logic for dashboard order detail page.
Browse files Browse the repository at this point in the history
Correct tab now remains open when an invalid form is submitted.
  • Loading branch information
codeinthehole committed Aug 2, 2012
1 parent 145a9d9 commit b3c576d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
3 changes: 2 additions & 1 deletion oscar/apps/dashboard/orders/views.py
Expand Up @@ -269,6 +269,7 @@ def get_object(self):


def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
ctx = super(OrderDetailView, self).get_context_data(**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['note_form'] = self.get_order_note_form()
ctx['line_statuses'] = Line.all_statuses() ctx['line_statuses'] = Line.all_statuses()
ctx['shipping_event_types'] = ShippingEventType.objects.all() ctx['shipping_event_types'] = ShippingEventType.objects.all()
Expand Down Expand Up @@ -334,7 +335,7 @@ def save_note(self, request, order):
note.save() note.save()
messages.success(self.request, success_msg) messages.success(self.request, success_msg)
return self.reload_page_response(fragment='notes') 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) return self.render_to_response(ctx)


def delete_note(self, request, order): def delete_note(self, request, order):
Expand Down
25 changes: 12 additions & 13 deletions oscar/templates/oscar/dashboard/orders/order_detail.html
Expand Up @@ -87,18 +87,17 @@ <h2>{% trans "Order Details" %}</h2>
<div class="tabbable dashboard"> <div class="tabbable dashboard">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
{% block nav_tabs %} {% block nav_tabs %}
<li class="active"><a href="#lines" data-toggle="tab">{% trans "Order contents" %}</a></li> <li class="{% if active_tab == 'lines' %}active{% endif %}"><a href="#lines" data-toggle="tab">{% trans "Order contents" %}</a></li>
<li><a href="#shipping" data-toggle="tab">{% trans "Shipping" %}</a></li> <li class="{% if active_tab == 'shipping' %}active{% endif %}"><a href="#shipping" data-toggle="tab">{% trans "Shipping" %}</a></li>
<li><a href="#payment" data-toggle="tab">{% trans "Payment" %}</a></li> <li class="{% if active_tab == 'payment' %}active{% endif %}"><a href="#payment" data-toggle="tab">{% trans "Payment" %}</a></li>
<li><a href="#discounts" data-toggle="tab">{% trans "Discounts" %}</a></li> <li class="{% if active_tab == 'discounts' %}active{% endif %}"><a href="#discounts" data-toggle="tab">{% trans "Discounts" %}</a></li>
<li><a href="#emails" data-toggle="tab">{% trans "Emails" %}</a></li> <li class="{% if active_tab == 'emails' %}active{% endif %}"><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 == 'notes' %}active{% endif %}"><a href="#notes" data-toggle="tab">{% trans "Notes" %}</a></li>
{% endblock nav_tabs %} {% endblock nav_tabs %}
</ul> </ul>


<div class="tab-content"> <div class="tab-content">

<div class="tab-pane {% if active_tab == 'lines' %}active{% endif %}" id="lines">
<div class="tab-pane active" id="lines">
<div class="sub-header"> <div class="sub-header">
<h3 class="app-ico ico_shop_bag icon">{% trans "Items ordered" %}</h3> <h3 class="app-ico ico_shop_bag icon">{% trans "Items ordered" %}</h3>
</div> </div>
Expand Down Expand Up @@ -295,7 +294,7 @@ <h3 class="app-ico ico_favourite icon">{% trans "Payment Events" %}</h3>


</div> </div>


<div class="tab-pane" id="shipping"> <div class="tab-pane {% if active_tab == 'shipping' %}active{% endif %}" id="shipping">
{% block tab_shipping %} {% block tab_shipping %}
<table class="table"> <table class="table">
<tbody> <tbody>
Expand Down Expand Up @@ -324,7 +323,7 @@ <h3 class="app-ico ico_favourite icon">{% trans "Payment Events" %}</h3>
{% endblock %} {% endblock %}
</div> </div>


<div class="tab-pane" id="payment"> <div class="tab-pane {% if active_tab == 'payment' %}active{% endif %}" id="payment">
{% if order.billing_address %} {% if order.billing_address %}
<div class="sub-header"> <div class="sub-header">
<h3 class="app-ico ico_mapmarker icon">{% trans "Billing address" %}</h3> <h3 class="app-ico ico_mapmarker icon">{% trans "Billing address" %}</h3>
Expand Down Expand Up @@ -375,7 +374,7 @@ <h3 class="app-ico ico_mapmarker icon">{% trans "Transactions" %}</h3>


</div> </div>


<div class="tab-pane" id="discounts"> <div class="tab-pane {% if active_tab == 'discounts' %}active{% endif %}" id="discounts">
{% block tab_discounts %} {% block tab_discounts %}
<div class="sub-header"> <div class="sub-header">
<h3 class="app-ico ico_settings icon">{% trans "Discounts" %}</h3> <h3 class="app-ico ico_settings icon">{% trans "Discounts" %}</h3>
Expand Down Expand Up @@ -407,7 +406,7 @@ <h3 class="app-ico ico_settings icon">{% trans "Discounts" %}</h3>
{% endblock %} {% endblock %}
</div> </div>


<div class="tab-pane" id="emails"> <div class="tab-pane {% if active_tab == 'emails' %}active{% endif %}" id="emails">
{% block tab_emails %} {% block tab_emails %}
<div class="sub-header"> <div class="sub-header">
<h3 class="app-ico ico_email icon">{% trans "Emails" %}</h3> <h3 class="app-ico ico_email icon">{% trans "Emails" %}</h3>
Expand All @@ -416,7 +415,7 @@ <h3 class="app-ico ico_email icon">{% trans "Emails" %}</h3>
{% endblock %} {% endblock %}
</div> </div>


<div class="tab-pane" id="notes"> <div class="tab-pane {% if active_tab == 'notes' %}active{% endif %}" id="notes">
{% block tab_notes %} {% block tab_notes %}
<div class="sub-header"> <div class="sub-header">
<h3 class="app-ico ico_comment icon">{% trans "Notes" %}</h3> <h3 class="app-ico ico_comment icon">{% trans "Notes" %}</h3>
Expand Down

0 comments on commit b3c576d

Please sign in to comment.