When a user can't access any sites, or no orders are returned, show "no orders found" message

This commit is contained in:
Chris Marslender 2017-11-06 10:44:55 -07:00
parent 68e42ab6a2
commit 77721a1637
No known key found for this signature in database
GPG Key ID: 5A3FF8E135EABA2C
6 changed files with 35 additions and 23 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -5977,7 +5977,9 @@ table.bar_chart {
}
#woocommerce_network_orders {
#woocommerce-network-order-table-loading {
.woocommerce-network-orders-no-orders,
.woocommerce-network-order-table-loading,
.woocommerce-network-order-table {
display: none;
&.is-active {
@ -5986,19 +5988,12 @@ table.bar_chart {
p {
margin: 0;
}
.spinner {
margin-top: 0;
float: none;
text-align: center;
}
}
.wp-list-table {
display: none;
&.is-active {
display: block;
}
.spinner {
margin-top: 0;
float: none;
}
}

View File

@ -11,10 +11,14 @@
$tbody = $( document.getElementById( 'network-orders-tbody' ) ),
template = _.template( $( document.getElementById( 'network-orders-row-template') ).text() ),
$loadingIndicator = $( document.getElementById( 'woocommerce-network-order-table-loading' ) ),
$orderTable = $( document.getElementById( 'woocommerce-network-order-table' ) );
$orderTable = $( document.getElementById( 'woocommerce-network-order-table' ) ),
$noneFound = $( document.getElementById( 'woocommerce-network-orders-no-orders' ) );
// No sites, so bail
if ( ! woocommerce_network_orders.sites.length ) {
$loadingIndicator.removeClass( 'is-active' );
$orderTable.removeClass( 'is-active' );
$noneFound.addClass( 'is-active' );
return;
}
@ -64,14 +68,22 @@
}
});
for ( orderindex in orders ) {
currentOrder = orders[ orderindex ];
if ( orders.length > 0 ) {
for ( orderindex in orders ) {
currentOrder = orders[ orderindex ];
$tbody.append( template( currentOrder ) );
$tbody.append( template( currentOrder ) );
}
$noneFound.removeClass( 'is-active' );
$loadingIndicator.removeClass( 'is-active' );
$orderTable.addClass( 'is-active' );
} else {
$noneFound.addClass( 'is-active' );
$loadingIndicator.removeClass( 'is-active' );
$orderTable.removeClass( 'is-active' );
}
$loadingIndicator.removeClass( 'is-active' );
$orderTable.addClass( 'is-active' );
} );
}

View File

@ -1 +1 @@
!function(e,o,r){if("undefined"!=typeof woocommerce_network_orders){var t=[],n=[],d=[],c=e(document.getElementById("network-orders-tbody")),a=o.template(e(document.getElementById("network-orders-row-template")).text()),s=e(document.getElementById("woocommerce-network-order-table-loading")),m=e(document.getElementById("woocommerce-network-order-table"));woocommerce_network_orders.sites.length&&(e.each(woocommerce_network_orders.sites,function(o,r){n[o]=e.Deferred(),d.push(e.ajax({url:woocommerce_network_orders.order_endpoint,data:{_wpnonce:woocommerce_network_orders.nonce,network_orders:!0,blog_id:r},type:"GET"}).success(function(e){var r;for(r in e)t.push(e[r]);n[o].resolve()}).fail(function(){n[o].resolve()}))}),n.length>0&&e.when.apply(e,n).done(function(){var e,o;t.sort(function(e,o){var r,t;return r=Date.parse(e.date_created_gmt),t=Date.parse(o.date_created_gmt),r===t?0:r<t?1:-1});for(e in t)o=t[e],c.append(a(o));s.removeClass("is-active"),m.addClass("is-active")}))}}(jQuery,_);
!function(e,o,r){if("undefined"!=typeof woocommerce_network_orders){var t=[],n=[],s=[],a=e(document.getElementById("network-orders-tbody")),d=o.template(e(document.getElementById("network-orders-row-template")).text()),c=e(document.getElementById("woocommerce-network-order-table-loading")),i=e(document.getElementById("woocommerce-network-order-table")),m=e(document.getElementById("woocommerce-network-orders-no-orders"));if(!woocommerce_network_orders.sites.length)return c.removeClass("is-active"),i.removeClass("is-active"),void m.addClass("is-active");e.each(woocommerce_network_orders.sites,function(o,r){n[o]=e.Deferred(),s.push(e.ajax({url:woocommerce_network_orders.order_endpoint,data:{_wpnonce:woocommerce_network_orders.nonce,network_orders:!0,blog_id:r},type:"GET"}).success(function(e){var r;for(r in e)t.push(e[r]);n[o].resolve()}).fail(function(){n[o].resolve()}))}),n.length>0&&e.when.apply(e,n).done(function(){var e,o;if(t.sort(function(e,o){var r,t;return r=Date.parse(e.date_created_gmt),t=Date.parse(o.date_created_gmt),r===t?0:r<t?1:-1}),t.length>0){for(e in t)o=t[e],a.append(d(o));m.removeClass("is-active"),c.removeClass("is-active"),i.addClass("is-active")}else m.addClass("is-active"),c.removeClass("is-active"),i.removeClass("is-active")})}}(jQuery,_);

View File

@ -311,13 +311,13 @@ class WC_Admin_Dashboard {
) );
?>
<div class="post-type-shop_order">
<div id="woocommerce-network-order-table-loading" class="is-active">
<div id="woocommerce-network-order-table-loading" class="woocommerce-network-order-table-loading is-active">
<p>
<span class="spinner is-active"></span> <?php esc_html_e( 'Loading Network Orders', 'woocommerce' ); ?>
</p>
</div>
<table id="woocommerce-network-order-table" class="wp-list-table">
<table id="woocommerce-network-order-table" class="woocommerce-network-order-table wp-list-table">
<thead>
<tr>
<td>Order</td>
@ -329,6 +329,11 @@ class WC_Admin_Dashboard {
</tbody>
</table>
<div id="woocommerce-network-orders-no-orders" class="woocommerce-network-orders-no-orders">
<p>
<?php esc_html_e( "No orders found", 'woocommerce' ); ?>
</p>
</div>
<script type="text/template" id="network-orders-row-template">
<tr>
<td>