Created
January 10, 2012 21:24
-
-
Save ktusznio/1591289 to your computer and use it in GitHub Desktop.
Batman Filtering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Shopify.OrdersController extends Shopify.ApplicationController | |
index: (params) -> | |
@allOrders = Shopify.Order.get('all') | |
@_filterOrders() | |
addFilter: (type, value) -> | |
@set "#{type}Filter", value | |
@_filterOrders() | |
_filterOrders: -> | |
orders = @allOrders | |
for filterType in ['status', 'payment', 'fulfillment'] | |
if filterValue = @get("#{filterType}Filter") | |
orders = orders.indexedBy(filterType).get(filterValue) | |
@set 'orders', orders |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div>Showing status ( | |
<a data-event-click="addFilter | withArguments 'status', ''">any</a> | |
<a data-event-click="addFilter | withArguments 'status', 'open'">open</a> | |
<a data-event-click="addFilter | withArguments 'status', 'closed'">closed</a>) | |
payment status ( | |
<a data-event-click="addFilter | withArguments 'payment', ''">any</a> | |
<a data-event-click="addFilter | withArguments 'payment', 'paid'">paid</a> | |
<a data-event-click="addFilter | withArguments 'payment', 'pending'">pending</a> | |
<a data-event-click="addFilter | withArguments 'payment', 'authorized'">authorized</a> | |
<a data-event-click="addFilter | withArguments 'payment', 'abandoned'">abandoned</a> | |
<a data-event-click="addFilter | withArguments 'payment', 'refunded'">refunded</a> | |
<a data-event-click="addFilter | withArguments 'payment', 'voided'">voided</a>) | |
</div> | |
<div data-foreach-order="orders">...</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment