diff --git a/app/assets/javascripts/admin/customers/controllers/customers_controller.js.coffee b/app/assets/javascripts/admin/customers/controllers/customers_controller.js.coffee index 6bee8f993e..5f078525d9 100644 --- a/app/assets/javascripts/admin/customers/controllers/customers_controller.js.coffee +++ b/app/assets/javascripts/admin/customers/controllers/customers_controller.js.coffee @@ -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 } diff --git a/app/views/admin/customers/index.html.haml b/app/views/admin/customers/index.html.haml index aef398c991..a8e6141796 100644 --- a/app/views/admin/customers/index.html.haml +++ b/app/views/admin/customers/index.html.haml @@ -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()' } diff --git a/spec/features/admin/customers_spec.rb b/spec/features/admin/customers_spec.rb index 38af3145f3..75088bf395 100644 --- a/spec/features/admin/customers_spec.rb +++ b/spec/features/admin/customers_spec.rb @@ -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