mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-27 06:05:19 +00:00
Add loading splash to BOM
This commit is contained in:
@@ -98,8 +98,10 @@ orderManagementModule.controller "AdminOrderMgmtCtrl", [
|
||||
api_error_msg = "You don't have an API key yet. An attempt was made to generate one, but you are currently not authorised, please contact your site administrator for access."
|
||||
|
||||
$scope.fetchOrders = ->
|
||||
$scope.loading = true
|
||||
dataFetcher("/api/orders?template=bulk_index&q[completed_at_not_null]=true&q[completed_at_gt]=#{$scope.startDate}&q[completed_at_lt]=#{$scope.endDate}").then (data) ->
|
||||
$scope.resetOrders data
|
||||
$scope.loading = false
|
||||
|
||||
$scope.resetOrders = (data) ->
|
||||
$scope.orders = data
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
= render :partial => 'spree/admin/shared/order_sub_menu'
|
||||
|
||||
%div{ 'ng-app' => 'ofn.bulk_order_management', 'ng-controller' => 'AdminOrderMgmtCtrl', 'ng-init' => "initialise('#{@spree_api_key}');" }
|
||||
%div{ 'ng-app' => 'ofn.bulk_order_management', 'ng-controller' => 'AdminOrderMgmtCtrl', 'ng-init' => "initialise('#{@spree_api_key}');loading=true;" }
|
||||
%div{ 'ng-show' => '!spree_api_key_ok' }
|
||||
{{ api_error_msg }}
|
||||
.filter_selects{ :class => "four columns alpha" }
|
||||
@@ -29,9 +29,11 @@
|
||||
.spacer{ :class => "seven columns alpha" }
|
||||
|
||||
%hr{ :class => "sixteen columns alpha", :style => "margin-bottom: 15px" }
|
||||
%div{ :class => "sixteen columns alpha", 'ng-show' => 'lineItems.length == 0'}
|
||||
%h4{ :style => 'color:red;' } No matching orders found.
|
||||
%div{ 'ng-hide' => 'lineItems.length == 0' }
|
||||
%div.loading{ :class => "sixteen columns alpha", 'ng-show' => 'loading' }
|
||||
%h4 Loading Line Items...
|
||||
%div{ :class => "sixteen columns alpha", 'ng-show' => '!loading && lineItems.length == 0'}
|
||||
%h4{ :style => 'color:red;' } No matching line items found.
|
||||
%div{ 'ng-hide' => 'loading || lineItems.length == 0' }
|
||||
%table.index#listing_orders.bulk
|
||||
%thead
|
||||
%tr
|
||||
|
||||
@@ -29,9 +29,9 @@ feature %q{
|
||||
page.should have_selector "h1.page-title", text: "Bulk Order Management"
|
||||
end
|
||||
|
||||
it "displays a message when number of products is zero" do
|
||||
it "displays a message when number of line items is zero" do
|
||||
visit '/admin/orders/bulk_management'
|
||||
page.should have_text "No matching orders found."
|
||||
page.should have_text "No matching line items found."
|
||||
end
|
||||
|
||||
context "displaying the list of line items " do
|
||||
@@ -46,6 +46,10 @@ feature %q{
|
||||
visit '/admin/orders/bulk_management'
|
||||
end
|
||||
|
||||
it "displays a 'loading' splash for line items" do
|
||||
page.should have_selector "div.loading", :text => "Loading Line Items..."
|
||||
end
|
||||
|
||||
it "displays a list of line items" do
|
||||
page.should have_selector "th.id", text: "ID", :visible => true
|
||||
page.should have_selector "td.id", text: li1.id.to_s
|
||||
|
||||
@@ -44,6 +44,14 @@ describe "AdminOrderMgmtCtrl", ->
|
||||
httpBackend.flush()
|
||||
expect(scope.resetOrders).toHaveBeenCalledWith "list of orders"
|
||||
|
||||
it "sets the loading property to true before fetching orders and unsets it when loading is complete", ->
|
||||
spyOn scope, "resetOrders"
|
||||
scope.fetchOrders()
|
||||
expect(scope.loading).toEqual true
|
||||
httpBackend.flush()
|
||||
expect(scope.loading).toEqual false
|
||||
|
||||
|
||||
describe "resetting orders", ->
|
||||
beforeEach ->
|
||||
spyOn(scope, "matchDistributor").andReturn "nothing"
|
||||
|
||||
Reference in New Issue
Block a user