From af9376b60c7cd6742dfb4acd77361cadb91b0fbe Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 7 Oct 2016 15:20:53 +1100 Subject: [PATCH] SO Index: Adding column dropdown --- .../admin/standing_orders/standing_orders.js.coffee | 2 +- app/views/admin/standing_orders/_controls.html.haml | 6 ++++++ app/views/admin/standing_orders/_table.html.haml | 2 +- app/views/admin/standing_orders/index.html.haml | 1 + spec/features/admin/standing_orders_spec.rb | 10 +++++++++- 5 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 app/views/admin/standing_orders/_controls.html.haml diff --git a/app/assets/javascripts/admin/standing_orders/standing_orders.js.coffee b/app/assets/javascripts/admin/standing_orders/standing_orders.js.coffee index 3c5f864dca..196191e39e 100644 --- a/app/assets/javascripts/admin/standing_orders/standing_orders.js.coffee +++ b/app/assets/javascripts/admin/standing_orders/standing_orders.js.coffee @@ -1 +1 @@ -angular.module("admin.standingOrders", ['ngResource','admin.indexUtils']) +angular.module("admin.standingOrders", ['ngResource','admin.indexUtils','admin.dropdown']) diff --git a/app/views/admin/standing_orders/_controls.html.haml b/app/views/admin/standing_orders/_controls.html.haml new file mode 100644 index 0000000000..86ec22c6e1 --- /dev/null +++ b/app/views/admin/standing_orders/_controls.html.haml @@ -0,0 +1,6 @@ +%hr.divider.sixteen.columns.alpha.omega{ ng: { show: 'shop_id && standingOrders.length > 0' } } +.controls.sixteen.columns.alpha.omega{ ng: { show: 'shop_id && standingOrders.length > 0' } } + .twelve.columns.alpha +   + .four.columns.omega + %columns-dropdown{ action: "#{controller_name}_#{action_name}" } diff --git a/app/views/admin/standing_orders/_table.html.haml b/app/views/admin/standing_orders/_table.html.haml index 545ca58505..ea4b6c99a0 100644 --- a/app/views/admin/standing_orders/_table.html.haml +++ b/app/views/admin/standing_orders/_table.html.haml @@ -8,7 +8,7 @@ -# %input{ :type => "checkbox", :name => 'toggle_bulk', 'ng-click' => 'toggleAllCheckboxes()', 'ng-checked' => "allBoxesChecked()" } %th.customer{ ng: { show: 'columns.customer.visible' } } = t('admin.customer') - %th.schedule{ ng: { show: 'columns.customer.visible', } } + %th.schedule{ ng: { show: 'columns.schedule.visible', } } = t('admin.schedule') %th.payment_method{ ng: { show: 'columns.payment_method.visible', } } = t('admin.payment_method') diff --git a/app/views/admin/standing_orders/index.html.haml b/app/views/admin/standing_orders/index.html.haml index a898a5463c..68a86446eb 100644 --- a/app/views/admin/standing_orders/index.html.haml +++ b/app/views/admin/standing_orders/index.html.haml @@ -9,4 +9,5 @@ %div{ ng: { controller: 'StandingOrdersController' } } = render 'filters' + = render 'controls' = render 'table' diff --git a/spec/features/admin/standing_orders_spec.rb b/spec/features/admin/standing_orders_spec.rb index 43cca049b6..68bef7f7f1 100644 --- a/spec/features/admin/standing_orders_spec.rb +++ b/spec/features/admin/standing_orders_spec.rb @@ -43,12 +43,20 @@ feature 'Standing Orders' do expect(page).to have_selector "td.customer", text: standing_order.customer.email end - # Filters standing orders according to query + # Using the Quick Search expect(page).to have_selector "tr#so_#{standing_order.id}" fill_in 'query', with: 'blah blah blah' expect(page).to have_no_selector "tr#so_#{standing_order.id}" fill_in 'query', with: '' expect(page).to have_selector "tr#so_#{standing_order.id}" + + # Toggling columns + expect(page).to have_selector "th.customer" + expect(page).to have_content standing_order.customer.email + first("div#columns-dropdown", :text => "COLUMNS").click + first("div#columns-dropdown div.menu div.menu_item", text: "Customer").click + expect(page).to_not have_selector "th.customer" + expect(page).to_not have_content standing_order.customer.email end end