User can update customer code from customer index page

This commit is contained in:
Rob Harrington
2015-05-08 12:46:37 +10:00
parent 734ad21e82
commit 9add073b17
3 changed files with 21 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
angular.module("admin.customers").controller "customersCtrl", ($scope, Customers, Columns, shops) ->
angular.module("admin.customers").controller "customersCtrl", ($scope, Customers, Columns, pendingChanges, shops) ->
$scope.shop = null
$scope.shops = shops
$scope.submitAll = pendingChanges.submitAll
$scope.columns = Columns.setColumns
email: { name: "Email", visible: true }

View File

@@ -29,12 +29,12 @@
%div.menu_item{ :class => "three columns alpha", 'ng-repeat' => "column in columns", 'ofn-toggle-column' => true }
%span{ :class => 'one column alpha', :style => 'text-align: center'} {{ column.visible && "✓" || !column.visible && " " }}
%span{ :class => 'two columns omega' } {{column.name }}
.row
.sixteen.columns.alpha#loading{ 'ng-if' => 'shop_id && !loaded()' }
%img.spinner{ src: "/assets/spinning-circles.svg" }
%h1 LOADING CUSTOMERS
.row{ :class => "sixteen columns alpha", 'ng-show' => 'loaded() && filteredCustomers.length == 0'}
%h1#no_results No customers found.
.row{ 'ng-if' => 'shop_id && !loaded()' }
.sixteen.columns.alpha#loading
%img.spinner{ src: "/assets/spinning-circles.svg" }
%h1 LOADING CUSTOMERS
.row{ :class => "sixteen columns alpha", 'ng-show' => 'loaded() && filteredCustomers.length == 0'}
%h1#no_results No customers found.
.row{ ng: { show: "loaded()" } }
@@ -55,7 +55,8 @@
%td.bulk
%input{ :type => "checkbox", :name => 'bulk', 'ng-model' => 'customer.checked' }
%td.email{ 'ng-show' => 'columns.email.visible' } {{ customer.email }}
%td.code{ 'ng-show' => 'columns.code.visible' } {{ customer.code }}
%td.code{ 'ng-show' => 'columns.code.visible' }
%input{ :type => 'text', :name => 'code', :id => 'code', 'ng-model' => 'customer.code', 'obj-for-update' => "customer", "attr-for-update" => "code" }
%td.actions
%a{ 'ng-click' => "deleteCustomer(customer)", :class => "delete-customer icon-trash no-text" }
-# %input{ :type => "button", 'value' => 'Update', 'ng-click' => 'pendingChanges.submitAll()' }
%input{ :type => "button", 'value' => 'Update', 'ng-click' => 'submitAll()' }

View File

@@ -19,7 +19,7 @@ feature 'Customers' do
visit admin_customers_path
end
it "lists my customers", js: true do
it "passes the smoke test", js: true do
# Prompts for a hub
expect(page).to have_select2 "shop_id", with_options: [managed_distributor.name], without_options: [unmanaged_distributor.name]
@@ -44,6 +44,15 @@ feature 'Customers' do
first("div#columns_dropdown div.menu div.menu_item", text: "Email").click
expect(page).to_not have_selector "th.email"
expect(page).to_not have_content customer1.email
# Updating attributes
within "tr#c_#{customer1.id}" do
fill_in "code", with: "new-customer-code"
expect(page).to have_css "input#code.update-pending"
end
click_button "Update"
expect(page).to have_css "input#code.update-success"
expect(customer1.reload.code).to eq "new-customer-code"
end
end
end